plugin_c_src.mk 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. .PHONY: c-src $(C_SRC_TARGETS)
  5. c-src: $(C_SRC_TARGETS)
  6. c_src: c-src
  7. c-src-nif: build clean
  8. $i "Bootstrap a new OTP library named $(APP)"
  9. $t mkdir $(APP)/
  10. $t cp ../erlang.mk $(APP)/
  11. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  12. $i "Generate a NIF from templates"
  13. $t $(MAKE) -C $(APP) new-nif n=$(APP) $v
  14. $i "Build the application"
  15. $t $(MAKE) -C $(APP) $v
  16. $i "Check that all compiled files exist"
  17. $t test -f $(APP)/$(APP).d
  18. $t test -f $(APP)/c_src/$(APP).o
  19. $t test -f $(APP)/c_src/env.mk
  20. $t test -f $(APP)/ebin/$(APP).app
  21. $t test -f $(APP)/ebin/$(APP).beam
  22. ifeq ($(PLATFORM),msys2)
  23. $t test -f $(APP)/priv/$(APP).dll
  24. else
  25. $t test -f $(APP)/priv/$(APP).so
  26. endif
  27. $i "Check that the application was compiled correctly"
  28. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  29. ok = application:start($(APP)), \
  30. {ok, [$(APP)]} = application:get_key($(APP), modules), \
  31. {module, $(APP)} = code:load_file($(APP)), \
  32. {hello, joe} = $(APP):hello(joe), \
  33. {hello, mike} = $(APP):hello(mike), \
  34. {hello, robert} = $(APP):hello(robert), \
  35. halt()"
  36. $i "Re-build the application"
  37. $t $(MAKE) -C $(APP) $v
  38. $i "Check that all compiled files exist"
  39. $t test -f $(APP)/$(APP).d
  40. $t test -f $(APP)/c_src/$(APP).o
  41. $t test -f $(APP)/c_src/env.mk
  42. $t test -f $(APP)/ebin/$(APP).app
  43. $t test -f $(APP)/ebin/$(APP).beam
  44. ifeq ($(PLATFORM),msys2)
  45. $t test -f $(APP)/priv/$(APP).dll
  46. else
  47. $t test -f $(APP)/priv/$(APP).so
  48. endif
  49. $i "Check that the application was compiled correctly"
  50. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  51. ok = application:start($(APP)), \
  52. {ok, [$(APP)]} = application:get_key($(APP), modules), \
  53. {module, $(APP)} = code:load_file($(APP)), \
  54. {hello, joe} = $(APP):hello(joe), \
  55. {hello, mike} = $(APP):hello(mike), \
  56. {hello, robert} = $(APP):hello(robert), \
  57. halt()"
  58. $i "Clean the application"
  59. $t $(MAKE) -C $(APP) clean $v
  60. $i "Check that all intermediate files were removed"
  61. $t test ! -e $(APP)/$(APP).d
  62. $t test ! -e $(APP)/c_src/$(APP).o
  63. $t test ! -e $(APP)/ebin/$(APP).app
  64. $t test ! -e $(APP)/ebin/$(APP).beam
  65. ifeq ($(PLATFORM),msys2)
  66. $t test ! -e $(APP)/priv/$(APP).dll
  67. else
  68. $t test ! -e $(APP)/priv/$(APP).so
  69. endif
  70. $i "Distclean the application"
  71. $t $(MAKE) -C $(APP) distclean $v
  72. $i "Check that all files were removed"
  73. $t test ! -e $(APP)/c_src/env.mk