aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-07-02 18:35:44 +0200
committerLoïc Hoguin <[email protected]>2015-07-02 18:35:44 +0200
commit6a3bf18655384cbd534308104d82b1ae0f66c228 (patch)
tree65a4d3a9c0910774eb664ac5895af18bb623cbf1 /core
parent061d4491da416ad23a8d470a4198a0cd608b7e0f (diff)
downloaderlang.mk-6a3bf18655384cbd534308104d82b1ae0f66c228.tar.gz
erlang.mk-6a3bf18655384cbd534308104d82b1ae0f66c228.tar.bz2
erlang.mk-6a3bf18655384cbd534308104d82b1ae0f66c228.zip
Reduce dependency on external programs
This commit implements a core_find and core_ls function that can be used to list files recursively or not. A few other minute changes are included and a couple hacks removed.
Diffstat (limited to 'core')
-rw-r--r--core/core.mk11
-rw-r--r--core/erlc.mk25
-rw-r--r--core/test.mk4
3 files changed, 22 insertions, 18 deletions
diff --git a/core/core.mk b/core/core.mk
index c9c8256..ad70ee6 100644
--- a/core/core.mk
+++ b/core/core.mk
@@ -126,13 +126,13 @@ define newline
endef
-define erlang_list
-[$(subst $(space),$(comma),$(strip $(1)))]
+define comma_list
+$(subst $(space),$(comma),$(strip $(1)))
endef
# Adding erlang.mk to make Erlang scripts who call init:get_plain_arguments() happy.
define erlang
-$(ERL) -pa $(ERLANG_MK_TMP)/rebar/ebin -eval "$(subst $(newline),,$(subst ",\",$(1)))" -- erlang.mk
+$(ERL) -pz $(ERLANG_MK_TMP)/rebar/ebin -eval "$(subst $(newline),,$(subst ",\",$(1)))" -- erlang.mk
endef
ifeq ($(shell which wget 2>/dev/null | wc -l), 1)
@@ -162,8 +162,13 @@ endif
core_eq = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
+core_find = $(foreach d,$(call core_ls,$1*),$(call core_find,$d/,$2) $(filter $(subst *,%,$2),$d))
+
core_lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$(1)))))))))))))))))))))))))))
+# @todo On Windows: $(shell dir /B $(1)); make sure to handle when no file exists.
+core_ls = $(filter-out $(1),$(shell echo $(1)))
+
# Automated update.
ERLANG_MK_BUILD_CONFIG ?= build.config
diff --git a/core/erlc.mk b/core/erlc.mk
index b1f7c40..20b8fbb 100644
--- a/core/erlc.mk
+++ b/core/erlc.mk
@@ -51,9 +51,9 @@ define app_file
{description, "$(PROJECT_DESCRIPTION)"},
{vsn, "$(PROJECT_VERSION)"},
{id, "$(1)"},
- {modules, [$(2)]},
+ {modules, [$(call comma_list,$(2))]},
{registered, []},
- {applications, $(call erlang_list,kernel stdlib $(OTP_DEPS) $(DEPS))}
+ {applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(DEPS))]}
]}.
endef
else
@@ -62,9 +62,9 @@ define app_file
{description, "$(PROJECT_DESCRIPTION)"},
{vsn, "$(PROJECT_VERSION)"},
{id, "$(1)"},
- {modules, [$(2)]},
- {registered, $(call erlang_list,$(PROJECT)_sup $(PROJECT_REGISTERED))},
- {applications, $(call erlang_list,kernel stdlib $(OTP_DEPS) $(DEPS))},
+ {modules, [$(call comma_list,$(2))]},
+ {registered, [$(call comma_list,$(PROJECT)_sup $(PROJECT_REGISTERED))]},
+ {applications, [$(call comma_list,kernel stdlib $(OTP_DEPS) $(DEPS))]},
{mod, {$(PROJECT)_app, []}}
]}.
endef
@@ -72,8 +72,7 @@ endif
app-build: erlc-include ebin/$(PROJECT).app
$(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null || true))
- $(eval MODULES := $(shell find ebin -type f -name \*.beam \
- | sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//'))
+ $(eval MODULES := $(patsubst %,'%',$(sort $(notdir $(basename $(wildcard ebin/*.beam))))))
ifeq ($(wildcard src/$(PROJECT).app.src),)
$(app_verbose) echo $(subst $(newline),,$(subst ",\",$(call app_file,$(GITDESCRIBE),$(MODULES)))) \
> ebin/$(PROJECT).app
@@ -83,7 +82,7 @@ else
exit 1; \
fi
$(appsrc_verbose) cat src/$(PROJECT).app.src \
- | sed "s/{[[:space:]]*modules[[:space:]]*,[[:space:]]*\[\]}/{modules, \[$(MODULES)\]}/" \
+ | sed "s/{[[:space:]]*modules[[:space:]]*,[[:space:]]*\[\]}/{modules, \[$(call comma_list,$(MODULES))\]}/" \
| sed "s/{id,[[:space:]]*\"git\"}/{id, \"$(GITDESCRIBE)\"}/" \
> ebin/$(PROJECT).app
endif
@@ -123,21 +122,21 @@ ebin/$(PROJECT).app::
@mkdir -p ebin/
ifneq ($(wildcard asn1/),)
-ebin/$(PROJECT).app:: $(shell find asn1 -type f -name \*.asn1)
+ebin/$(PROJECT).app:: $(sort $(call core_find,asn1/,*.asn1))
@mkdir -p include
$(if $(strip $?),$(call compile_asn1,$?))
endif
ifneq ($(wildcard mibs/),)
-ebin/$(PROJECT).app:: $(shell find mibs -type f -name \*.mib)
+ebin/$(PROJECT).app:: $(sort $(call core_find,mibs/,*.mib))
@mkdir -p priv/mibs/ include
$(if $(strip $?),$(call compile_mib,$?))
endif
-ebin/$(PROJECT).app:: $(shell find src -type f -name \*.erl -o -name \*.core)
+ebin/$(PROJECT).app:: $(sort $(call core_find,src/,*.erl *.core))
$(if $(strip $?),$(call compile_erl,$?))
-ebin/$(PROJECT).app:: $(shell find src -type f -name \*.xrl -o -name \*.yrl)
+ebin/$(PROJECT).app:: $(sort $(call core_find,src/,*.xrl *.yrl))
$(if $(strip $?),$(call compile_xyrl,$?))
endif
@@ -145,4 +144,4 @@ clean:: clean-app
clean-app:
$(gen_verbose) rm -rf ebin/ priv/mibs/ \
- $(addprefix include/,$(addsuffix .hrl,$(notdir $(basename $(wildcard mibs/*.mib)))))
+ $(addprefix include/,$(addsuffix .hrl,$(notdir $(basename $(call core_find,mibs/,*.mib)))))
diff --git a/core/test.mk b/core/test.mk
index 7dd5d61..3832996 100644
--- a/core/test.mk
+++ b/core/test.mk
@@ -23,10 +23,10 @@ test-deps: $(ALL_TEST_DEPS_DIRS)
@for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep; done
endif
-ifneq ($(strip $(TEST_DIR)),)
+ifneq ($(wildcard $(TEST_DIR)),)
test-dir:
$(gen_verbose) erlc -v $(TEST_ERLC_OPTS) -I include/ -o $(TEST_DIR) \
- $(wildcard $(TEST_DIR)/*.erl $(TEST_DIR)/*/*.erl) -pa ebin/
+ $(call core_find,$(TEST_DIR)/,*.erl) -pa ebin/
endif
ifeq ($(wildcard ebin/test),)