aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-04-10 15:43:32 +0200
committerLoïc Hoguin <[email protected]>2017-04-10 15:43:32 +0200
commit7a200f54a9c0a41be4bad93e3ad0b19bbde5267f (patch)
treed69963d0d2abf03acd5faa576d0030599d201c1d
parente0ebd0a1f395dc8b9813b490fc7b0104942f0927 (diff)
downloaderlang.mk-7a200f54a9c0a41be4bad93e3ad0b19bbde5267f.tar.gz
erlang.mk-7a200f54a9c0a41be4bad93e3ad0b19bbde5267f.tar.bz2
erlang.mk-7a200f54a9c0a41be4bad93e3ad0b19bbde5267f.zip
Only makedep and build asn1/xrl/mib files when necessary
Because we were unconditionally including the makedep file, it would be built even if the target was unrelated (like "make help"), and it would also trigger building of xrl and other files that produce Erlang code. Instead the makedep file is now included as a wildcard: if it exists it gets included, if it doesn't it's not, and if it's created in the middle of execution it gets included only then. More details on the technique can be found at http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/ A test has been added to make sure the behavior does not come back at a later time.
-rw-r--r--core/erlc.mk2
-rw-r--r--test/core_app.mk24
2 files changed, 24 insertions, 2 deletions
diff --git a/core/erlc.mk b/core/erlc.mk
index 65ef71b..8a8aea0 100644
--- a/core/erlc.mk
+++ b/core/erlc.mk
@@ -238,7 +238,7 @@ $(ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES):
ebin/$(PROJECT).app:: $(ERLANG_MK_TMP)/last-makefile-change
endif
--include $(PROJECT).d
+include $(wildcard $(PROJECT).d)
ebin/$(PROJECT).app:: ebin/
diff --git a/test/core_app.mk b/test/core_app.mk
index da15782..f496bbd 100644
--- a/test/core_app.mk
+++ b/test/core_app.mk
@@ -1,6 +1,6 @@
# Core: Building applications.
-CORE_APP_CASES = appsrc-change asn1 auto-git-id env erlc-exclude erlc-opts erlc-opts-filter error extra-keys generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive makefile-change mib name-special-char no-app no-makedep project-mod pt pt-erlc-opts xrl xrl-include yrl yrl-header yrl-include
+CORE_APP_CASES = appsrc-change asn1 auto-git-id env erlc-exclude erlc-opts erlc-opts-filter error extra-keys generate-erl generate-erl-include generate-erl-prepend hrl hrl-recursive makefile-change mib name-special-char no-app no-makedep project-mod pt pt-erlc-opts xrl xrl-help xrl-include yrl yrl-header yrl-include
CORE_APP_TARGETS = $(addprefix core-app-,$(CORE_APP_CASES))
.PHONY: core-app $(CORE_APP_TARGETS)
@@ -1315,6 +1315,28 @@ endif
[{module, M} = code:load_file(M) || M <- Mods], \
halt()"
+core-app-xrl-help: 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 "Download an .xrl file from Robert"
+ $t curl -s -o $(APP)/src/erlang_scan.xrl https://raw.githubusercontent.com/rvirding/leex/master/examples/erlang_scan.xrl
+
+ $i "Disable warnings; our test .xrl files aren't perfect"
+ $t echo "ERLC_OPTS=+debug_info" >> $(APP)/Makefile
+
+ $i "Run 'make help'"
+ $t $(MAKE) -C $(APP) help $v
+
+ $i "Check that no files were compiled"
+ $t test ! -e $(APP)/$(APP).d
+ $t test ! -e $(APP)/ebin/$(APP).app
+ $t test ! -e $(APP)/ebin/erlang_scan.beam
+ $t test ! -e $(APP)/src/erlang_scan.erl
+
core-app-xrl-include: build clean
$i "Bootstrap a new OTP library named $(APP)"