Browse Source

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.
Loïc Hoguin 8 years ago
parent
commit
7a200f54a9
2 changed files with 24 additions and 2 deletions
  1. 1 1
      core/erlc.mk
  2. 23 1
      test/core_app.mk

+ 1 - 1
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/
 

+ 23 - 1
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)"