plugin_erlydtl.mk 2.2 KB

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