plugin_c_src.mk 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # C source plugin.
  2. C_SRC_TARGETS = $(call list_targets,c-src)
  3. .PHONY: c-src $(C_SRC_TARGETS)
  4. c-src: $(C_SRC_TARGETS)
  5. c_src: c-src
  6. c-src-nif: 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 "Generate a NIF from templates"
  12. $t $(MAKE) -C $(APP) new-nif n=$(APP) $v
  13. $i "Build the application"
  14. $t $(MAKE) -C $(APP) $v
  15. $i "Check that all compiled files exist"
  16. $t test -f $(APP)/$(APP).d
  17. $t test -f $(APP)/c_src/$(APP).o
  18. $t test -f $(APP)/c_src/env.mk
  19. $t test -f $(APP)/ebin/$(APP).app
  20. $t test -f $(APP)/ebin/$(APP).beam
  21. ifeq ($(PLATFORM),msys2)
  22. $t test -f $(APP)/priv/$(APP).dll
  23. else
  24. $t test -f $(APP)/priv/$(APP).so
  25. endif
  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. ifeq ($(PLATFORM),msys2)
  44. $t test -f $(APP)/priv/$(APP).dll
  45. else
  46. $t test -f $(APP)/priv/$(APP).so
  47. endif
  48. $i "Check that the application was compiled correctly"
  49. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  50. ok = application:start($(APP)), \
  51. {ok, [$(APP)]} = application:get_key($(APP), modules), \
  52. {module, $(APP)} = code:load_file($(APP)), \
  53. {hello, joe} = $(APP):hello(joe), \
  54. {hello, mike} = $(APP):hello(mike), \
  55. {hello, robert} = $(APP):hello(robert), \
  56. halt()"
  57. $i "Clean the application"
  58. $t $(MAKE) -C $(APP) clean $v
  59. $i "Check that all intermediate files were removed"
  60. $t test ! -e $(APP)/$(APP).d
  61. $t test ! -e $(APP)/c_src/$(APP).o
  62. $t test ! -e $(APP)/ebin/$(APP).app
  63. $t test ! -e $(APP)/ebin/$(APP).beam
  64. ifeq ($(PLATFORM),msys2)
  65. $t test ! -e $(APP)/priv/$(APP).dll
  66. else
  67. $t test ! -e $(APP)/priv/$(APP).so
  68. endif
  69. $i "Distclean the application"
  70. $t $(MAKE) -C $(APP) distclean $v
  71. $i "Check that all files were removed"
  72. $t test ! -e $(APP)/c_src/env.mk