diff options
author | Loïc Hoguin <[email protected]> | 2018-11-29 09:33:07 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-11-29 09:33:07 +0100 |
commit | f943ca241be408177be5d0cfae9815dc87ecffb9 (patch) | |
tree | ed8e40decbc32844cd1d185fd110b5b82c4c0a1b | |
parent | e3c685e2649a99a87a9be3b7cf6c0fdb0ba49af3 (diff) | |
download | erlang.mk-f943ca241be408177be5d0cfae9815dc87ecffb9.tar.gz erlang.mk-f943ca241be408177be5d0cfae9815dc87ecffb9.tar.bz2 erlang.mk-f943ca241be408177be5d0cfae9815dc87ecffb9.zip |
Rebuild C projects when Makefiles change
-rw-r--r-- | plugins/c_src.mk | 2 | ||||
-rw-r--r-- | test/plugin_c_src.mk | 52 |
2 files changed, 39 insertions, 15 deletions
diff --git a/plugins/c_src.mk b/plugins/c_src.mk index 11aab91..bd46613 100644 --- a/plugins/c_src.mk +++ b/plugins/c_src.mk @@ -103,6 +103,8 @@ $(C_SRC_OUTPUT_FILE): $(OBJECTS) $(LDFLAGS) $(if $(filter $(C_SRC_TYPE),shared),-shared) $(LDLIBS) \ -o $(C_SRC_OUTPUT_FILE) +$(OBJECTS): $(MAKEFILE_LIST) + %.o: %.c $(COMPILE_C) $(OUTPUT_OPTION) $< diff --git a/test/plugin_c_src.mk b/test/plugin_c_src.mk index 2b2b1b8..289f08c 100644 --- a/test/plugin_c_src.mk +++ b/test/plugin_c_src.mk @@ -7,6 +7,40 @@ C_SRC_TARGETS = $(call list_targets,c-src) c-src: $(C_SRC_TARGETS) c_src: c-src +ifeq ($(PLATFORM),msys2) +C_SRC_OUTPUT_EXECUTABLE_EXTENSION = .dll +else +C_SRC_OUTPUT_EXECUTABLE_EXTENSION = .so +endif + +c-src-makefile-change: build clean + + $i "Bootstrap a new OTP library named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v + + $i "Generate a NIF from templates" + $t $(MAKE) -C $(APP) new-nif n=$(APP) $v + + $i "Build the application" + $t $(MAKE) -C $(APP) $v + + $i "Touch the Makefile; check that all files get rebuilt" + $t printf "%s\n" \ + $(APP)/$(APP).d \ + $(APP)/c_src/$(APP).o \ + $(APP)/ebin/$(APP).app \ + $(APP)/ebin/$(APP).beam \ + $(APP)/priv/$(APP)$(C_SRC_OUTPUT_EXECUTABLE_EXTENSION) \ + $(APP)/src/$(APP).erl | sort > $(APP)/EXPECT + $t $(SLEEP) + $t touch $(APP)/Makefile + $t $(SLEEP) + $t $(MAKE) -C $(APP) $v + $t find $(APP) -type f -newer $(APP)/Makefile -not -path "$(APP)/.erlang.mk/*" | sort | diff $(APP)/EXPECT - + $t rm $(APP)/EXPECT + c-src-nif: build clean $i "Bootstrap a new OTP library named $(APP)" @@ -26,11 +60,7 @@ c-src-nif: build clean $t test -f $(APP)/c_src/env.mk $t test -f $(APP)/ebin/$(APP).app $t test -f $(APP)/ebin/$(APP).beam -ifeq ($(PLATFORM),msys2) - $t test -f $(APP)/priv/$(APP).dll -else - $t test -f $(APP)/priv/$(APP).so -endif + $t test -f $(APP)/priv/$(APP)$(C_SRC_OUTPUT_EXECUTABLE_EXTENSION) $i "Check that the application was compiled correctly" $t $(ERL) -pa $(APP)/ebin/ -eval " \ @@ -51,11 +81,7 @@ endif $t test -f $(APP)/c_src/env.mk $t test -f $(APP)/ebin/$(APP).app $t test -f $(APP)/ebin/$(APP).beam -ifeq ($(PLATFORM),msys2) - $t test -f $(APP)/priv/$(APP).dll -else - $t test -f $(APP)/priv/$(APP).so -endif + $t test -f $(APP)/priv/$(APP)$(C_SRC_OUTPUT_EXECUTABLE_EXTENSION) $i "Check that the application was compiled correctly" $t $(ERL) -pa $(APP)/ebin/ -eval " \ @@ -75,11 +101,7 @@ endif $t test ! -e $(APP)/c_src/$(APP).o $t test ! -e $(APP)/ebin/$(APP).app $t test ! -e $(APP)/ebin/$(APP).beam -ifeq ($(PLATFORM),msys2) - $t test ! -e $(APP)/priv/$(APP).dll -else - $t test ! -e $(APP)/priv/$(APP).so -endif + $t test ! -e $(APP)/priv/$(APP)$(C_SRC_OUTPUT_EXECUTABLE_EXTENSION) $i "Distclean the application" $t $(MAKE) -C $(APP) distclean $v |