core_plugins.mk 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Core: External plugins.
  2. CORE_PLUGINS_CASES = all one
  3. CORE_PLUGINS_TARGETS = $(addprefix core-plugins-,$(CORE_PLUGINS_CASES))
  4. CORE_PLUGINS_CLEAN_TARGETS = $(addprefix clean-,$(CORE_PLUGINS_TARGETS))
  5. .PHONY: core-plugins $(CORE_PLUGINS_TARGETS) clean-core-plugins $(CORE_PLUGINS_CLEAN_TARGETS)
  6. clean-core-plugins: $(CORE_PLUGINS_CLEAN_TARGETS)
  7. $(CORE_PLUGINS_CLEAN_TARGETS):
  8. $t rm -rf $(APP_TO_CLEAN)/
  9. core-plugins: $(CORE_PLUGINS_TARGETS)
  10. core-plugins-all: build clean-core-plugins-all
  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 "Create a local git repository with two plugins"
  16. $t mkdir -p $(APP)/plugin_dep/mk
  17. $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
  18. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
  19. $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
  20. $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
  21. $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
  22. # We check that overriding THIS doesn't cause an error.
  23. $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
  24. $t cd $(APP)/plugin_dep && git init && git add . && git commit -m "Tests"
  25. $i "Add dependency and plugins to the Makefile"
  26. $t sed -i.bak '2i\
  27. DEPS = plugin_dep\
  28. dep_plugin_dep = git file://$(abspath $(APP)/plugin_dep) master\
  29. DEP_PLUGINS = plugin_dep\
  30. ' $(APP)/Makefile
  31. $i "Run 'make plugin1' and check that it prints plugin1"
  32. $t test -n "`$(MAKE) -C $(APP) plugin1 | grep plugin1`"
  33. $i "Run 'make plugin2' and check that it prints plugin2"
  34. $t test -n "`$(MAKE) -C $(APP) plugin2 | grep plugin2`"
  35. core-plugins-one: build clean-core-plugins-one
  36. $i "Bootstrap a new OTP library named $(APP)"
  37. $t mkdir $(APP)/
  38. $t cp ../erlang.mk $(APP)/
  39. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  40. $i "Create a local git repository with two plugins"
  41. $t mkdir -p $(APP)/plugin_dep/mk
  42. $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
  43. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
  44. $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
  45. $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
  46. $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
  47. # We check that overriding THIS doesn't cause an error.
  48. $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
  49. $t cd $(APP)/plugin_dep && git init && git add . && git commit -m "Tests"
  50. $i "Add dependency and plugins to the Makefile"
  51. $t sed -i.bak '2i\
  52. DEPS = plugin_dep\
  53. dep_plugin_dep = git file://$(abspath $(APP)/plugin_dep) master\
  54. DEP_PLUGINS = plugin_dep/mk/plugin1.mk\
  55. ' $(APP)/Makefile
  56. $i "Run 'make plugin1' and check that it prints plugin1"
  57. $t test -n "`$(MAKE) -C $(APP) plugin1 | grep plugin1`"
  58. $i "Run 'make plugin2' and confirm the target doesn't exist"
  59. $t if `$(MAKE) -C $(APP) plugin2`; then false; fi