Browse Source

Fix asn1 compilation with the +maps option

When this option is used no include file is generated.
Therefore don't error out if no include file can be found.
Loïc Hoguin 6 years ago
parent
commit
c0e062aafa
2 changed files with 39 additions and 1 deletions
  1. 1 1
      core/erlc.mk
  2. 38 0
      test/core_app.mk

+ 1 - 1
core/erlc.mk

@@ -110,7 +110,7 @@ define compile_asn1
 	$(verbose) mkdir -p include/
 	$(asn1_verbose) erlc -v -I include/ -o asn1/ +noobj $(ERLC_ASN1_OPTS) $(1)
 	$(verbose) mv asn1/*.erl src/
-	$(verbose) mv asn1/*.hrl include/
+	-$(verbose) mv asn1/*.hrl include/
 	$(verbose) mv asn1/*.asn1db include/
 endef
 

+ 38 - 0
test/core_app.mk

@@ -163,6 +163,44 @@ endif
 		true = lists:member({record_name_prefix, \"FOO-\"}, Opts), \
 		halt()"
 
+core-app-asn1-maps: 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 "Set ERLC_ASN1_OPTS = +maps in the Makefile"
+	$t perl -ni.bak -e 'print;if ($$.==1) {print "ERLC_ASN1_OPTS = +maps\n"}' $(APP)/Makefile
+
+	$i "Download .asn1 files from Erlang/OTP"
+	$t mkdir $(APP)/asn1/
+	$t curl -s -o $(APP)/asn1/CAP.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/CAP.asn1
+	$t curl -s -o $(APP)/asn1/Def.asn1 $(OTP_MASTER)/lib/asn1/test/asn1_SUITE_data/Def.asn1
+
+	$i "Build the application"
+	$t $(MAKE) -C $(APP) $v
+
+	$i "Check that all compiled files exist"
+	$t test -f $(APP)/$(APP).d
+	$t test -f $(APP)/ebin/$(APP).app
+	$t test -f $(APP)/ebin/CAP.beam
+	$t test -f $(APP)/ebin/Def.beam
+	$t test -f $(APP)/include/CAP.asn1db
+	$t ! test -e $(APP)/include/CAP.hrl
+	$t test -f $(APP)/include/Def.asn1db
+	$t ! test -e $(APP)/include/Def.hrl
+	$t test -f $(APP)/src/CAP.erl
+	$t test -f $(APP)/src/Def.erl
+
+	$i "Check that the application was compiled correctly"
+	$t $(ERL) -pa $(APP)/ebin/ -eval " \
+		ok = application:start($(APP)), \
+		{ok, Mods = ['CAP', 'Def']} \
+			= application:get_key($(APP), modules), \
+		[{module, M} = code:load_file(M) || M <- Mods], \
+		halt()"
+
 core-app-auto-git-id: build clean
 
 	$i "Bootstrap a new OTP library named $(APP)"