aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-07-08 18:50:02 +0200
committerLoïc Hoguin <[email protected]>2013-07-08 18:51:44 +0200
commit90cba7b8c57dd87e222dfec64e0120fbb27d29a3 (patch)
tree8e9c9e40e392efd4677205279c52182f8544d62d
parentc62cedbb530a629f9be7ff84630035eede9506b6 (diff)
downloaderlang.mk-90cba7b8c57dd87e222dfec64e0120fbb27d29a3.tar.gz
erlang.mk-90cba7b8c57dd87e222dfec64e0120fbb27d29a3.tar.bz2
erlang.mk-90cba7b8c57dd87e222dfec64e0120fbb27d29a3.zip
Add support for .xrl and .yrl files
Leex and Yecc files for generating lexers and parsers.
-rw-r--r--README.md2
-rw-r--r--erlang.mk21
2 files changed, 19 insertions, 4 deletions
diff --git a/README.md b/README.md
index 53c4180..98fc96b 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,8 @@ The following files will be automatically compiled:
| `src/$(PROJECT).app.src` | OTP application resource file |
| `src/*.erl` | Erlang source files |
| `src/*.core` | Core Erlang source files |
+| `src/*.xrl` | Leex source files |
+| `src/*.yrl` | Yecc source files |
| `templates/*.dtl` | ErlyDTL template files |
Only the `.app.src` file and at least one `.erl` file are required.
diff --git a/erlang.mk b/erlang.mk
index 960318e..3ddcf21 100644
--- a/erlang.mk
+++ b/erlang.mk
@@ -19,9 +19,12 @@ V ?= 0
appsrc_verbose_0 = @echo " APP " $(PROJECT).app.src;
appsrc_verbose = $(appsrc_verbose_$(V))
-erlc_verbose_0 = @echo " ERLC " $(filter-out %.dtl,$(?F));
+erlc_verbose_0 = @echo " ERLC " $(filter %.erl %.core,$(?F));
erlc_verbose = $(erlc_verbose_$(V))
+xyrl_verbose_0 = @echo " XYRL " $(filter %.xrl %.yrl,$(?F));
+xyrl_verbose = $(xyrl_verbose_$(V))
+
dtl_verbose_0 = @echo " DTL " $(filter %.dtl,$(?F));
dtl_verbose = $(dtl_verbose_$(V))
@@ -66,6 +69,12 @@ define compile_erl
-I include/ $(COMPILE_FIRST_PATHS) $(1)
endef
+define compile_xyrl
+ $(xyrl_verbose) erlc -v -o ebin/ $(1)
+ $(xyrl_verbose) erlc $(ERLC_OPTS) -o ebin/ ebin/*.erl
+ @rm ebin/*.erl
+endef
+
define compile_dtl
$(dtl_verbose) erl -noshell -pa ebin/ deps/erlydtl/ebin/ -eval ' \
Compile = fun(F) -> \
@@ -77,10 +86,14 @@ define compile_dtl
init:stop()'
endef
-ebin/$(PROJECT).app: src/*.erl $(wildcard src/*.core) $(wildcard templates/*.dtl)
+ebin/$(PROJECT).app: src/*.erl $(wildcard src/*.core) \
+ $(wildcard src/*.xrl) $(wildcard src/*.yrl) \
+ $(wildcard templates/*.dtl)
@mkdir -p ebin/
- $(if $(strip $(filter-out %.dtl,$?)), \
- $(call compile_erl,$(filter-out %.dtl,$?)))
+ $(if $(strip $(filter %.erl %.core,$?)), \
+ $(call compile_erl,$(filter %.erl %.core,$?)))
+ $(if $(strip $(filter %.xrl %.yrl,$?)), \
+ $(call compile_xyrl,$(filter %.xrl %.yrl,$?)))
$(if $(strip $(filter %.dtl,$?)), \
$(call compile_dtl,$(filter %.dtl,$?)))