aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-02-08 16:36:17 +0100
committerLoïc Hoguin <[email protected]>2020-02-08 16:40:37 +0100
commitc201677abf9915ea9194d96a6ec31c80e1e61aee (patch)
tree8cddfb7a399836e71945bb679574c1aaad4d09aa
parent3ed8c2fd9b5d154fa96246bb4e40b9ed46bad18f (diff)
downloaderlang.mk-c201677abf9915ea9194d96a6ec31c80e1e61aee.tar.gz
erlang.mk-c201677abf9915ea9194d96a6ec31c80e1e61aee.tar.bz2
erlang.mk-c201677abf9915ea9194d96a6ec31c80e1e61aee.zip
Disable proto plugin if gpb/protobuffs not in deps
-rw-r--r--plugins/protobuffs.mk2
-rw-r--r--test/plugin_protobuffs.mk31
2 files changed, 33 insertions, 0 deletions
diff --git a/plugins/protobuffs.mk b/plugins/protobuffs.mk
index b4f9ce6..809df42 100644
--- a/plugins/protobuffs.mk
+++ b/plugins/protobuffs.mk
@@ -9,6 +9,7 @@ proto_verbose = $(proto_verbose_$(V))
# Core targets.
ifneq ($(wildcard src/),)
+ifneq ($(filter gpb protobuffs,$(BUILD_DEPS) $(DEPS)),)
PROTO_FILES := $(filter %.proto,$(ALL_SRC_FILES))
ERL_FILES += $(addprefix src/,$(patsubst %.proto,%_pb.erl,$(notdir $(PROTO_FILES))))
@@ -55,3 +56,4 @@ $(PROJECT).d:: $(PROTO_FILES)
$(if $(strip $?),$(proto_verbose) $(call erlang,$(call compile_proto.erl,$?)))
endif
endif
+endif
diff --git a/test/plugin_protobuffs.mk b/test/plugin_protobuffs.mk
index 0d29e4b..f5814e8 100644
--- a/test/plugin_protobuffs.mk
+++ b/test/plugin_protobuffs.mk
@@ -72,6 +72,37 @@ protobuffs-compile-with-gpb: init
{ok, [empty_pb, simple_pb]} = application:get_key($(APP), modules), \
halt()"
+protobuffs-dont-compile: init
+
+ $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 "Do not add gpb/protobuffs to the list of dependencies"
+
+ $i "Download two proto files"
+ $t mkdir $(APP)/src/proto/
+ $t curl -s -o $(APP)/src/proto/empty.proto $(PROTOBUFFS_URL)/proto/empty.proto
+ $t curl -s -o $(APP)/src/proto/simple.proto $(PROTOBUFFS_URL)/proto/simple.proto
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that the proto files were ignored"
+ $t test ! -e $(APP)/src/empty_pb.erl
+ $t test ! -e $(APP)/src/simple_pb.erl
+ $t test ! -e $(APP)/include/empty_pb.hrl
+ $t test ! -e $(APP)/include/simple_pb.hrl
+ $t test ! -e $(APP)/ebin/empty_pb.beam
+ $t test ! -e $(APP)/ebin/simple_pb.beam
+
+ $i "Check that the application itself was otherwise compiled properly"
+ $t $(ERL) -pa $(APP)/ebin/ -eval " \
+ ok = application:load($(APP)), \
+ {ok, []} = application:get_key($(APP), modules), \
+ halt()"
+
protobuffs-makefile-change: init
$i "Bootstrap a new OTP library named $(APP)"