aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-12-10 13:52:59 +0100
committerLoïc Hoguin <[email protected]>2018-12-10 13:52:59 +0100
commita11c6fb7f9ee084fe87bdcba32529358d9fab64e (patch)
tree80c309fc48978fe3293a01e49dd7a7bda958ee0f /core
parent7799804277e6fd38d308ebd581d194c38cd3fbb4 (diff)
downloaderlang.mk-a11c6fb7f9ee084fe87bdcba32529358d9fab64e.tar.gz
erlang.mk-a11c6fb7f9ee084fe87bdcba32529358d9fab64e.tar.bz2
erlang.mk-a11c6fb7f9ee084fe87bdcba32529358d9fab64e.zip
Optimization: reduce the number of shell commands on noops
Diffstat (limited to 'core')
-rw-r--r--core/core.mk3
-rw-r--r--core/deps-tools.mk3
-rw-r--r--core/deps.mk28
-rw-r--r--core/erlc.mk14
-rw-r--r--core/kerl.mk3
5 files changed, 26 insertions, 25 deletions
diff --git a/core/core.mk b/core/core.mk
index 661527e..411f146 100644
--- a/core/core.mk
+++ b/core/core.mk
@@ -115,6 +115,9 @@ endif
distclean:: clean distclean-tmp
+$(ERLANG_MK_TMP):
+ $(verbose) mkdir -p $(ERLANG_MK_TMP)
+
distclean-tmp:
$(gen_verbose) rm -rf $(ERLANG_MK_TMP)
diff --git a/core/deps-tools.mk b/core/deps-tools.mk
index 1ad9274..174e09b 100644
--- a/core/deps-tools.mk
+++ b/core/deps-tools.mk
@@ -59,9 +59,8 @@ $(ERLANG_MK_RECURSIVE_DEPS_LIST) \
$(ERLANG_MK_RECURSIVE_DOC_DEPS_LIST) \
$(ERLANG_MK_RECURSIVE_REL_DEPS_LIST) \
$(ERLANG_MK_RECURSIVE_TEST_DEPS_LIST) \
-$(ERLANG_MK_RECURSIVE_SHELL_DEPS_LIST):
+$(ERLANG_MK_RECURSIVE_SHELL_DEPS_LIST): | $(ERLANG_MK_TMP)
ifeq ($(IS_APP)$(IS_DEP),)
- $(verbose) mkdir -p $(ERLANG_MK_TMP)
$(verbose) rm -f $(ERLANG_MK_RECURSIVE_TMP_LIST)
endif
ifndef IS_APP
diff --git a/core/deps.mk b/core/deps.mk
index bfcae30..f11017c 100644
--- a/core/deps.mk
+++ b/core/deps.mk
@@ -81,28 +81,31 @@ dep_verbose = $(dep_verbose_$(V))
# Optimization: don't recompile deps unless truly necessary.
ifndef IS_DEP
+ifneq ($(MAKELEVEL),0)
$(shell rm -f ebin/dep_built)
endif
+endif
# Core targets.
-apps:: $(ALL_APPS_DIRS) clean-tmp-deps.log
-ifeq ($(IS_APP)$(IS_DEP),)
- $(verbose) rm -f $(ERLANG_MK_TMP)/apps.log
-endif
- $(verbose) mkdir -p $(ERLANG_MK_TMP)
+ALL_APPS_DIRS_TO_BUILD = $(if $(LOCAL_DEPS_DIRS)$(IS_APP),$(LOCAL_DEPS_DIRS),$(ALL_APPS_DIRS))
+
+apps:: $(ALL_APPS_DIRS) clean-tmp-deps.log | $(ERLANG_MK_TMP)
# Create ebin directory for all apps to make sure Erlang recognizes them
# as proper OTP applications when using -include_lib. This is a temporary
# fix, a proper fix would be to compile apps/* in the right order.
ifndef IS_APP
+ifneq ($(ALL_APPS_DIRS),)
$(verbose) set -e; for dep in $(ALL_APPS_DIRS) ; do \
mkdir -p $$dep/ebin; \
done
endif
+endif
# At the toplevel: if LOCAL_DEPS is defined with at least one local app, only
# compile that list of apps. Otherwise, compile everything.
# Within an app: compile all LOCAL_DEPS that are (uncompiled) local apps.
- $(verbose) set -e; for dep in $(if $(LOCAL_DEPS_DIRS)$(IS_APP),$(LOCAL_DEPS_DIRS),$(ALL_APPS_DIRS)) ; do \
+ifneq ($(ALL_APPS_DIRS_TO_BUILD),)
+ $(verbose) set -e; for dep in $(ALL_APPS_DIRS_TO_BUILD); do \
if grep -qs ^$$dep$$ $(ERLANG_MK_TMP)/apps.log; then \
:; \
else \
@@ -110,18 +113,19 @@ endif
$(MAKE) -C $$dep $(if $(IS_TEST),test-build-app) IS_APP=1; \
fi \
done
+endif
clean-tmp-deps.log:
ifeq ($(IS_APP)$(IS_DEP),)
- $(verbose) rm -f $(ERLANG_MK_TMP)/deps.log
+ $(verbose) rm -f $(ERLANG_MK_TMP)/apps.log $(ERLANG_MK_TMP)/deps.log
endif
ifneq ($(SKIP_DEPS),)
deps::
else
-deps:: $(ALL_DEPS_DIRS) apps clean-tmp-deps.log
- $(verbose) mkdir -p $(ERLANG_MK_TMP)
- $(verbose) set -e; for dep in $(ALL_DEPS_DIRS) ; do \
+deps:: $(ALL_DEPS_DIRS) apps clean-tmp-deps.log | $(ERLANG_MK_TMP)
+ifneq ($(ALL_DEPS_DIRS),)
+ $(verbose) set -e; for dep in $(ALL_DEPS_DIRS); do \
if grep -qs ^$$dep$$ $(ERLANG_MK_TMP)/deps.log; then \
:; \
else \
@@ -138,6 +142,7 @@ deps:: $(ALL_DEPS_DIRS) apps clean-tmp-deps.log
fi \
done
endif
+endif
# Deps related targets.
@@ -212,7 +217,6 @@ endef
# We use flock/lockf when available to avoid concurrency issues.
define dep_autopatch_fetch_rebar
- mkdir -p $(ERLANG_MK_TMP); \
if command -v flock >/dev/null; then \
flock $(ERLANG_MK_TMP)/rebar.lock sh -c "$(call dep_autopatch_fetch_rebar2)"; \
elif command -v lockf >/dev/null; then \
@@ -645,7 +649,7 @@ define dep_fetch
endef
define dep_target
-$(DEPS_DIR)/$(call dep_name,$1):
+$(DEPS_DIR)/$(call dep_name,$1): | $(ERLANG_MK_TMP)
$(eval DEP_NAME := $(call dep_name,$1))
$(eval DEP_STR := $(if $(filter $1,$(DEP_NAME)),$1,"$1 ($(DEP_NAME))"))
$(verbose) if test -d $(APPS_DIR)/$(DEP_NAME); then \
diff --git a/core/erlc.mk b/core/erlc.mk
index 872d3f5..9195ece 100644
--- a/core/erlc.mk
+++ b/core/erlc.mk
@@ -53,15 +53,9 @@ ifneq ($(wildcard src/),)
# Targets.
-ifeq ($(wildcard ebin/test),)
-app:: deps
+app:: $(if $(wildcard ebin/test),clean) deps
$(verbose) $(MAKE) --no-print-directory $(PROJECT).d
$(verbose) $(MAKE) --no-print-directory app-build
-else
-app:: clean deps
- $(verbose) $(MAKE) --no-print-directory $(PROJECT).d
- $(verbose) $(MAKE) --no-print-directory app-build
-endif
ifeq ($(wildcard src/$(PROJECT_MOD).erl),)
define app_file
@@ -277,8 +271,7 @@ endif
ifneq ($(words $(ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES)),0)
# Rebuild everything when the Makefile changes.
-$(ERLANG_MK_TMP)/last-makefile-change: $(MAKEFILE_LIST)
- $(verbose) mkdir -p $(ERLANG_MK_TMP)
+$(ERLANG_MK_TMP)/last-makefile-change: $(MAKEFILE_LIST) | $(ERLANG_MK_TMP)
$(verbose) if test -f $@; then \
touch $(ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES); \
touch -c $(PROJECT).d; \
@@ -289,6 +282,9 @@ $(ERL_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES):
ebin/$(PROJECT).app:: $(ERLANG_MK_TMP)/last-makefile-change
endif
+$(PROJECT).d::
+ $(verbose) :
+
include $(wildcard $(PROJECT).d)
ebin/$(PROJECT).app:: ebin/
diff --git a/core/kerl.mk b/core/kerl.mk
index b514052..c8096dd 100644
--- a/core/kerl.mk
+++ b/core/kerl.mk
@@ -39,8 +39,7 @@ endef
$(KERL): $(KERL_DIR)
-$(KERL_DIR):
- $(verbose) mkdir -p $(ERLANG_MK_TMP)
+$(KERL_DIR): | $(ERLANG_MK_TMP)
$(gen_verbose) git clone --depth 1 $(KERL_GIT) $(ERLANG_MK_TMP)/kerl
$(verbose) cd $(ERLANG_MK_TMP)/kerl && git checkout $(KERL_COMMIT)
$(verbose) chmod +x $(KERL)