diff options
author | Loïc Hoguin <[email protected]> | 2015-05-16 12:34:08 +0300 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-05-16 12:34:08 +0300 |
commit | 245fa2c0b8eff5cbd1fbf07cec78d3005eeded0f (patch) | |
tree | 17055d15d39767fa6c2a6032c6d8d3b02829f31d /plugins | |
parent | 7f9f7ff3ada0259534d31e57bd791ff87923906a (diff) | |
download | erlang.mk-245fa2c0b8eff5cbd1fbf07cec78d3005eeded0f.tar.gz erlang.mk-245fa2c0b8eff5cbd1fbf07cec78d3005eeded0f.tar.bz2 erlang.mk-245fa2c0b8eff5cbd1fbf07cec78d3005eeded0f.zip |
Add protobuffs plugin to compile *.proto files
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/protobuffs.mk | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/plugins/protobuffs.mk b/plugins/protobuffs.mk new file mode 100644 index 0000000..e3e58f5 --- /dev/null +++ b/plugins/protobuffs.mk @@ -0,0 +1,31 @@ +# Copyright (c) 2015, Loïc Hoguin <[email protected]> +# This file is part of erlang.mk and subject to the terms of the ISC License. + +# Verbosity. + +proto_verbose_0 = @echo " PROTO " $(filter %.proto,$(?F)); +proto_verbose = $(proto_verbose_$(V)) + +# Core targets. + +define compile_proto + @mkdir -p ebin/ include/ + $(proto_verbose) $(call erlang,$(call compile_proto.erl,$(1))) + $(proto_verbose) erlc $(ERLC_OPTS) -o ebin/ ebin/*.erl + @rm ebin/*.erl +endef + +define compile_proto.erl + [begin + Dir = filename:dirname(filename:dirname(F)), + protobuffs_compile:generate_source(F, + [{output_include_dir, Dir ++ "/include"}, + {output_src_dir, Dir ++ "/ebin"}]) + end || F <- string:tokens("$(1)", " ")], + halt(). +endef + +ifneq ($(wildcard src/),) +ebin/$(PROJECT).app:: $(shell find src -type f -name \*.proto 2>/dev/null) + $(if $(strip $?),$(call compile_proto,$?)) +endif |