plugin_erlydtl.mk 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # ErlyDTL plugin.
  2. ERLYDTL_CASES = compile full-path
  3. ERLYDTL_TARGETS = $(addprefix erlydtl-,$(ERLYDTL_CASES))
  4. .PHONY: erlydtl $(ERLYDTL_TARGETS)
  5. erlydtl: $(ERLYDTL_TARGETS)
  6. erlydtl-compile: build clean
  7. $i "Bootstrap a new OTP library named $(APP)"
  8. $t mkdir $(APP)/
  9. $t cp ../erlang.mk $(APP)/
  10. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  11. $i "Add ErlyDTL to the list of dependencies"
  12. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = erlydtl\n"}' $(APP)/Makefile
  13. $i "Generate ErlyDTL templates"
  14. $t mkdir $(APP)/templates/
  15. $t touch $(APP)/templates/$(APP)_one.dtl
  16. $t touch $(APP)/templates/$(APP)_two.dtl
  17. $i "Build the application"
  18. $t $(MAKE) -C $(APP) $v
  19. $i "Check that ErlyDTL templates are compiled"
  20. $t test -f $(APP)/ebin/$(APP)_one_dtl.beam
  21. $t test -f $(APP)/ebin/$(APP)_two_dtl.beam
  22. $i "Check that ErlyDTL generated modules are included in .app file"
  23. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  24. ok = application:load($(APP)), \
  25. {ok, [$(APP_)_one_dtl, $(APP)_two_dtl]} = application:get_key($(APP), modules), \
  26. halt()"
  27. erlydtl-full-path: build clean
  28. $i "Bootstrap a new OTP library named $(APP)"
  29. $t mkdir $(APP)/
  30. $t cp ../erlang.mk $(APP)/
  31. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  32. $i "Add ErlyDTL to the list of dependencies; set DTL_FULL_PATH"
  33. $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = erlydtl\nDTL_FULL_PATH = 1\n"}' $(APP)/Makefile
  34. $i "Generate ErlyDTL templates"
  35. $t mkdir -p $(APP)/templates/deep/
  36. $t touch $(APP)/templates/$(APP)_one.dtl
  37. $t touch $(APP)/templates/deep/$(APP)_two.dtl
  38. $i "Build the application"
  39. $t $(MAKE) -C $(APP) $v
  40. $i "Check that ErlyDTL templates are compiled"
  41. $t test -f $(APP)/ebin/$(APP)_one_dtl.beam
  42. $t test -f $(APP)/ebin/deep_$(APP)_two_dtl.beam
  43. $i "Check that ErlyDTL generated modules are included in .app file"
  44. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  45. ok = application:load($(APP)), \
  46. {ok, [deep_$(APP)_two_dtl, $(APP_)_one_dtl]} = application:get_key($(APP), modules), \
  47. halt()"