aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.config15
-rw-r--r--plugins/protobuffs.mk31
2 files changed, 41 insertions, 5 deletions
diff --git a/build.config b/build.config
index d68eaff..c1bf936 100644
--- a/build.config
+++ b/build.config
@@ -1,16 +1,21 @@
-# Core modules.
+# Do *not* comment or remove core modules
+# unless you know what you are doing.
#
-# Do *not* comment or remove them
-# unless you know what you are doing!
+# Feel free to comment plugins out however.
+
+# Core modules.
core/core
core/deps
+
+# Plugins that must run before Erlang code gets compiled.
+plugins/protobuffs
+
+# Core modules, continued.
core/erlc
core/docs
core/test
# Plugins.
-#
-# Comment to disable, uncomment to enable.
plugins/asciidoc
plugins/bootstrap
plugins/c_src
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