aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-10-19 17:29:04 +0200
committerLoïc Hoguin <[email protected]>2015-10-19 17:29:04 +0200
commit7f1ace7622a5a9e046b8ae10accc8169ab59b047 (patch)
tree78d91b77cd9a07f77faca2742e4cdf1ed4612c9e
parent77afa66836f92a1f1f2052e1a7d9ace9fd4cee57 (diff)
downloaderlang.mk-7f1ace7622a5a9e046b8ae10accc8169ab59b047.tar.gz
erlang.mk-7f1ace7622a5a9e046b8ae10accc8169ab59b047.tar.bz2
erlang.mk-7f1ace7622a5a9e046b8ae10accc8169ab59b047.zip
Force rebuilds on Makefile/.app.src changes
Everything will be rebuilt when the Makefile or any included Makefile (like Erlang.mk or plugins) change. Only the .app will be rebuilt when the .app.src file changes.
-rw-r--r--core/erlc.mk9
-rw-r--r--plugins/erlydtl.mk4
-rw-r--r--test/core_app.mk48
3 files changed, 58 insertions, 3 deletions
diff --git a/core/erlc.mk b/core/erlc.mk
index a8ab8fe..02524b4 100644
--- a/core/erlc.mk
+++ b/core/erlc.mk
@@ -183,6 +183,10 @@ $(PROJECT).d:: $(ERL_FILES) $(call core_find,include/,*.hrl)
$(makedep_verbose) $(call erlang,$(call makedep.erl,$@))
endif
+# Rebuild everything when the Makefile changes.
+$(ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES):: $(MAKEFILE_LIST)
+ @touch $@
+
-include $(PROJECT).d
ebin/$(PROJECT).app:: ebin/
@@ -195,8 +199,9 @@ define compile_erl
-pa ebin/ -I include/ $(filter-out $(ERLC_EXCLUDE_PATHS),$(COMPILE_FIRST_PATHS) $(1))
endef
-ebin/$(PROJECT).app:: $(ERL_FILES) $(CORE_FILES)
- $(if $(strip $?),$(call compile_erl,$?))
+ebin/$(PROJECT).app:: $(ERL_FILES) $(CORE_FILES) $(wildcard src/$(PROJECT).app.src)
+ $(eval FILES_TO_COMPILE := $(filter-out src/$(PROJECT).app.src,$?))
+ $(if $(strip $(FILES_TO_COMPILE)),$(call compile_erl,$(FILES_TO_COMPILE)))
$(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null || true))
$(eval MODULES := $(patsubst %,'%',$(sort $(notdir $(basename \
$(filter-out $(ERLC_EXCLUDE_PATHS),$(ERL_FILES) $(CORE_FILES) $(BEAM_FILES)))))))
diff --git a/plugins/erlydtl.mk b/plugins/erlydtl.mk
index dea6366..072da50 100644
--- a/plugins/erlydtl.mk
+++ b/plugins/erlydtl.mk
@@ -42,6 +42,10 @@ else
BEAM_FILES += $(addprefix ebin/,$(patsubst %.dtl,%_dtl.beam,$(notdir $(DTL_FILES))))
endif
+# Rebuild templates when the Makefile changes.
+$(DTL_FILES): $(MAKEFILE_LIST)
+ @touch $@
+
ebin/$(PROJECT).app:: $(DTL_FILES)
$(if $(strip $?),\
$(dtl_verbose) $(call erlang,$(call erlydtl_compile.erl,$?,-pa ebin/ $(DEPS_DIR)/erlydtl/ebin/)))
diff --git a/test/core_app.mk b/test/core_app.mk
index f95d593..14720df 100644
--- a/test/core_app.mk
+++ b/test/core_app.mk
@@ -1,6 +1,6 @@
# Core: Building applications.
-CORE_APP_CASES = asn1 auto-git-id erlc-exclude erlc-opts erlc-opts-filter error generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive mib no-app no-makedep pt pt-erlc-opts xrl xrl-include yrl yrl-include
+CORE_APP_CASES = appsrc-change asn1 auto-git-id erlc-exclude erlc-opts erlc-opts-filter error generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive makefile-change mib no-app no-makedep pt pt-erlc-opts xrl xrl-include yrl yrl-include
CORE_APP_TARGETS = $(addprefix core-app-,$(CORE_APP_CASES))
CORE_APP_CLEAN_TARGETS = $(addprefix clean-,$(CORE_APP_TARGETS))
@@ -13,6 +13,27 @@ $(CORE_APP_CLEAN_TARGETS):
core-app: $(CORE_APP_TARGETS)
+ifdef LEGACY
+core-app-appsrc-change: build clean-core-app-appsrc-change
+
+ $i "Bootstrap a new OTP application named $(APP)"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Touch the .app.src file; check that only the .app file gets rebuilt"
+ $t printf "%s\n" $(APP)/ebin/$(APP).app > $(APP)/EXPECT
+ $t $(SLEEP)
+ $t touch $(APP)/src/$(APP).app.src
+ $t $(SLEEP)
+ $t $(MAKE) -C $(APP) $v
+ $t find $(APP) -type f -newer $(APP)/src/$(APP).app.src | sort | diff $(APP)/EXPECT -
+ $t rm $(APP)/EXPECT
+endif
+
core-app-asn1: build clean-core-app-asn1
$i "Bootstrap a new OTP library named $(APP)"
@@ -738,6 +759,31 @@ endif
[{module, M} = code:load_file(M) || M <- Mods], \
halt()"
+core-app-makefile-change: build clean-core-app-makefile-change
+
+ $i "Bootstrap a new OTP application named $(APP)"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $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)/ebin/$(APP).app \
+ $(APP)/ebin/$(APP)_app.beam \
+ $(APP)/ebin/$(APP)_sup.beam \
+ $(APP)/src/$(APP)_app.erl \
+ $(APP)/src/$(APP)_sup.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 | sort | diff $(APP)/EXPECT -
+ $t rm $(APP)/EXPECT
+
core-app-mib: build clean-core-app-mib
$i "Bootstrap a new OTP library named $(APP)"