Makefile 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # MySQL/OTP
  2. #
  3. # This Makefile should be complete enough for this project to be used as an
  4. ## erlang.mk dependency.
  5. #
  6. # We use rebar for eunit with coverage since erlang.mk doesn't have this yet.
  7. # 'make tests' is not usable. Try 'rebar eunit' or 'make eunit-coverage'.
  8. #
  9. # Additional targets:
  10. #
  11. # - eunit-coverage: Creates doc/eunit.html with the coverage and eunit output.
  12. # - gh-pages: Generates docs and eunit reports and commits these in the
  13. # gh-pages which Github publishes automatically when pushed.
  14. PROJECT = mysql
  15. EDOC_OPTS = {stylesheet_file,"priv/edoc-style.css"},{todo,true}
  16. include erlang.mk
  17. .PHONY: gh-pages eunit eunit-report
  18. eunit:
  19. @mkdir -p .eunit
  20. @rm -f .eunit/index.html # make sure we don't get an old one if cover=false
  21. @rebar eunit | tee .eunit/output
  22. # Update the local 'gh-pages' branch with pregenerated output files
  23. # (trick from https://groups.google.com/forum/#!topic/github/XYxkdzxpgCo)
  24. gh-pages: docs eunit-report
  25. @if [ $$(git name-rev --name-only HEAD) != master ] ; then \
  26. echo "Not on master. Aborting." ; \
  27. false ; \
  28. fi
  29. @git update-ref refs/heads/gh-pages origin/gh-pages '' 2>/dev/null || true
  30. @GIT_INDEX_FILE=gitindex.tmp; export GIT_INDEX_FILE; \
  31. rm -f $${GIT_INDEX_FILE} && \
  32. git add -f doc/*.html doc/stylesheet.css doc/erlang.png && \
  33. git update-ref refs/heads/gh-pages \
  34. $$(echo "Autogenerated html pages for $$(git describe --tags)" \
  35. | git commit-tree $$(git write-tree --prefix=doc) \
  36. -p refs/heads/gh-pages)
  37. @rm gitindex.tmp
  38. @echo "Committed $$(git describe --tags) in the gh-pages branch."
  39. # Build eunit.html containing the coverage report and the eunit output in the
  40. # doc directory.
  41. eunit-report: eunit
  42. @(echo '<!DOCTYPE html>' ; \
  43. cat .eunit/index.html | sed 's!</body></html>!!' ; \
  44. echo '<h3>Output of <code>make eunit</code></h3><pre>' ; \
  45. sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g;' .eunit/output ; \
  46. echo '</pre>' ; \
  47. echo '<p><em>Generated using rebar and EUnit,' ; \
  48. date -u '+%d %h %Y %H:%M:%S UTC.' ; \
  49. echo '</em></p>' ; \
  50. echo '</body></html>') > doc/eunit.html
  51. @cp .eunit/*.COVER.html doc/