plugin_c_src.mk 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # C source plugin.
  2. C_SRC_CASES = cpp custom dir env nif port
  3. C_SRC_TARGETS = $(addprefix c-src-,$(C_SRC_CASES))
  4. C_SRC_CLEAN_TARGETS = $(addprefix clean-,$(C_SRC_TARGETS))
  5. .PHONY: c-src $(C_SRC_TARGETS) clean-c-src $(C_SRC_CLEAN_TARGETS)
  6. clean-c-src: $(C_SRC_CLEAN_TARGETS)
  7. $(C_SRC_CLEAN_TARGETS):
  8. $t rm -rf $(APP_TO_CLEAN)/
  9. c-src: $(C_SRC_TARGETS)
  10. c-src-nif: build clean-c-src-nif
  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 "Generate a NIF from templates"
  16. $t $(MAKE) -C $(APP) new-nif n=$(APP) $v
  17. $i "Build the application"
  18. $t $(MAKE) -C $(APP) $v
  19. $i "Check that all compiled files exist"
  20. $t test -f $(APP)/$(APP).d
  21. $t test -f $(APP)/c_src/$(APP).o
  22. $t test -f $(APP)/c_src/env.mk
  23. $t test -f $(APP)/ebin/$(APP).app
  24. $t test -f $(APP)/ebin/$(APP).beam
  25. $t test -f $(APP)/priv/$(APP).so
  26. $i "Check that the application was compiled correctly"
  27. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  28. ok = application:start($(APP)), \
  29. {ok, [$(APP)]} = application:get_key($(APP), modules), \
  30. {module, $(APP)} = code:load_file($(APP)), \
  31. {hello, joe} = $(APP):hello(joe), \
  32. {hello, mike} = $(APP):hello(mike), \
  33. {hello, robert} = $(APP):hello(robert), \
  34. halt()"
  35. $i "Re-build the application"
  36. $t $(MAKE) -C $(APP) $v
  37. $i "Check that all compiled files exist"
  38. $t test -f $(APP)/$(APP).d
  39. $t test -f $(APP)/c_src/$(APP).o
  40. $t test -f $(APP)/c_src/env.mk
  41. $t test -f $(APP)/ebin/$(APP).app
  42. $t test -f $(APP)/ebin/$(APP).beam
  43. $t test -f $(APP)/priv/$(APP).so
  44. $i "Check that the application was compiled correctly"
  45. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  46. ok = application:start($(APP)), \
  47. {ok, [$(APP)]} = application:get_key($(APP), modules), \
  48. {module, $(APP)} = code:load_file($(APP)), \
  49. {hello, joe} = $(APP):hello(joe), \
  50. {hello, mike} = $(APP):hello(mike), \
  51. {hello, robert} = $(APP):hello(robert), \
  52. halt()"
  53. $i "Clean the application"
  54. $t $(MAKE) -C $(APP) clean $v
  55. $i "Check that all intermediate files were removed"
  56. $t test ! -e $(APP)/$(APP).d
  57. $t test ! -e $(APP)/c_src/$(APP).o
  58. $t test ! -e $(APP)/ebin/$(APP).app
  59. $t test ! -e $(APP)/ebin/$(APP).beam
  60. $t test ! -e $(APP)/priv/$(APP).so
  61. $i "Distclean the application"
  62. $t $(MAKE) -C $(APP) distclean $v
  63. $i "Check that all files were removed"
  64. $t test ! -e $(APP)/c_src/env.mk