diff options
author | Loïc Hoguin <[email protected]> | 2018-11-28 13:33:57 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-11-28 13:33:57 +0100 |
commit | 7a514c6a372219fee528e0bc2ed0b2f2ba9c758d (patch) | |
tree | a0f4ef115bf87479c319d4392e25825a1da9b18c /plugins/protobuffs.mk | |
parent | 31c93f4ad6b55b90ccb07a047acb941af645c059 (diff) | |
download | erlang.mk-7a514c6a372219fee528e0bc2ed0b2f2ba9c758d.tar.gz erlang.mk-7a514c6a372219fee528e0bc2ed0b2f2ba9c758d.tar.bz2 erlang.mk-7a514c6a372219fee528e0bc2ed0b2f2ba9c758d.zip |
Modernize the protobuffs plugin
Diffstat (limited to 'plugins/protobuffs.mk')
-rw-r--r-- | plugins/protobuffs.mk | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/plugins/protobuffs.mk b/plugins/protobuffs.mk index dea271d..8eac4d8 100644 --- a/plugins/protobuffs.mk +++ b/plugins/protobuffs.mk @@ -8,23 +8,36 @@ proto_verbose = $(proto_verbose_$(V)) # Core targets. -define compile_proto - $(verbose) mkdir -p ebin/ include/ - $(proto_verbose) $(call erlang,$(call compile_proto.erl,$(1))) - $(proto_verbose) erlc +debug_info -o ebin/ ebin/*.erl - $(verbose) rm ebin/*.erl -endef +ifneq ($(wildcard src/),) +PROTO_FILES := $(filter %.proto,$(ALL_SRC_FILES)) +ERL_FILES += $(addprefix src/,$(patsubst %.proto,%_pb.erl,$(notdir $(PROTO_FILES)))) + +ifeq ($(words $(PROTO_FILES)),0) +$(ERLANG_MK_TMP)/last-makefile-change-protobuffs: + $(verbose) : +else +# Rebuild proto files when the Makefile changes. +# We exclude $(PROJECT).d to avoid a circular dependency. +$(ERLANG_MK_TMP)/last-makefile-change-protobuffs: $(filter-out $(PROJECT).d,$(MAKEFILE_LIST)) + $(verbose) mkdir -p $(ERLANG_MK_TMP) + $(verbose) if test -f $@; then \ + touch $(PROTO_FILES); \ + fi + $(verbose) touch $@ + +$(PROJECT).d:: $(ERLANG_MK_TMP)/last-makefile-change-protobuffs +endif define compile_proto.erl [begin protobuffs_compile:generate_source(F, [{output_include_dir, "./include"}, - {output_src_dir, "./ebin"}]) - end || F <- string:tokens("$(1)", " ")], + {output_src_dir, "./src"}]) + end || F <- string:tokens("$1", " ")], halt(). endef -ifneq ($(wildcard src/),) -ebin/$(PROJECT).app:: $(sort $(call core_find,src/,*.proto)) - $(if $(strip $?),$(call compile_proto,$?)) +$(PROJECT).d:: $(PROTO_FILES) + $(verbose) mkdir -p ebin/ include/ + $(if $(strip $?),$(proto_verbose) $(call erlang,$(call compile_proto.erl,$?))) endif |