|
17 | 17 | ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST))) |
18 | 18 | export ERLANG_MK_FILENAME |
19 | 19 |
|
20 | | -ERLANG_MK_VERSION = 2022.05.31-145-g12f1987-dirty |
| 20 | +ERLANG_MK_VERSION = 2022.05.31-150-g91e552d-dirty |
21 | 21 | ERLANG_MK_WITHOUT = |
22 | 22 |
|
23 | 23 | # Make 3.81 and 3.82 are deprecated. |
@@ -537,7 +537,7 @@ dep_name = $(call query_name,$(1)) |
537 | 537 | LOCAL_DEPS_DIRS = $(foreach a,$(LOCAL_DEPS),$(if $(wildcard $(APPS_DIR)/$a),$(APPS_DIR)/$a)) |
538 | 538 | # Elixir is handled specially as it must be built before all other deps |
539 | 539 | # when Mix autopatching is necessary. |
540 | | -ALL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(foreach dep,$(filter-out $(if $(filter-out elixir,$(BUILD_DEPS) $(DEPS)),elixir) $(IGNORE_DEPS),$(BUILD_DEPS) $(DEPS)),$(call query_name,$(dep)))) |
| 540 | +ALL_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(foreach dep,$(filter-out $(IGNORE_DEPS),$(BUILD_DEPS) $(DEPS)),$(call query_name,$(dep)))) |
541 | 541 |
|
542 | 542 | # When we are calling an app directly we don't want to include it here |
543 | 543 | # otherwise it'll be treated both as an apps and a top-level project. |
@@ -629,9 +629,11 @@ endif |
629 | 629 | ifneq ($(SKIP_DEPS),) |
630 | 630 | deps:: |
631 | 631 | else |
632 | | -deps:: $(ALL_DEPS_DIRS) apps clean-tmp-deps.log | $(ERLANG_MK_TMP) |
633 | | -ifneq ($(ALL_DEPS_DIRS),) |
634 | | - $(verbose) set -e; for dep in $(ALL_DEPS_DIRS); do \ |
| 632 | +ALL_DEPS_DIRS_TO_BUILD = $(if $(filter-out $(DEPS_DIR)/elixir,$(ALL_DEPS_DIRS)),$(filter-out $(DEPS_DIR)/elixir,$(ALL_DEPS_DIRS)),$(ALL_DEPS_DIRS)) |
| 633 | + |
| 634 | +deps:: $(ALL_DEPS_DIRS_TO_BUILD) apps clean-tmp-deps.log | $(ERLANG_MK_TMP) |
| 635 | +ifneq ($(ALL_DEPS_DIRS_TO_BUILD),) |
| 636 | + $(verbose) set -e; for dep in $(ALL_DEPS_DIRS_TO_BUILD); do \ |
635 | 637 | if grep -qs ^$$dep$$ $(ERLANG_MK_TMP)/deps.log; then \ |
636 | 638 | :; \ |
637 | 639 | else \ |
@@ -1527,6 +1529,10 @@ ALL_SRC_FILES := $(sort $(call core_find,src/,*)) |
1527 | 1529 | ERL_FILES := $(filter %.erl,$(ALL_SRC_FILES)) |
1528 | 1530 | CORE_FILES := $(filter %.core,$(ALL_SRC_FILES)) |
1529 | 1531 |
|
| 1532 | +# @todo Must be defined first. |
| 1533 | +ALL_LIB_FILES := $(sort $(call core_find,lib/,*)) |
| 1534 | +EX_FILES := $(filter-out lib/mix/%,$(filter %.ex,$(ALL_SRC_FILES) $(ALL_LIB_FILES))) |
| 1535 | + |
1530 | 1536 | # ASN.1 files. |
1531 | 1537 |
|
1532 | 1538 | ifneq ($(wildcard asn1/),) |
@@ -1707,11 +1713,11 @@ $(PROJECT).d:: $(ERL_FILES) $(EX_FILES) $(call core_find,include/,*.hrl) $(MAKEF |
1707 | 1713 | endif |
1708 | 1714 |
|
1709 | 1715 | ifeq ($(IS_APP)$(IS_DEP),) |
1710 | | -ifneq ($(words $(ERL_FILES) $(EX_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES)),0) |
| 1716 | +ifneq ($(words $(ERL_FILES) $(EX_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES) $(EX_FILES)),0) |
1711 | 1717 | # Rebuild everything when the Makefile changes. |
1712 | 1718 | $(ERLANG_MK_TMP)/last-makefile-change: $(MAKEFILE_LIST) | $(ERLANG_MK_TMP) |
1713 | 1719 | $(verbose) if test -f $@; then \ |
1714 | | - touch $(ERL_FILES) $(EX_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES); \ |
| 1720 | + touch $(ERL_FILES) $(EX_FILES) $(CORE_FILES) $(ASN1_FILES) $(MIB_FILES) $(XRL_FILES) $(YRL_FILES) $(EX_FILES); \ |
1715 | 1721 | touch -c $(PROJECT).d; \ |
1716 | 1722 | fi |
1717 | 1723 | $(verbose) touch $@ |
@@ -1744,9 +1750,9 @@ define validate_app_file |
1744 | 1750 | endef |
1745 | 1751 |
|
1746 | 1752 | ebin/$(PROJECT).app:: $(ERL_FILES) $(CORE_FILES) $(wildcard src/$(PROJECT).app.src) $(EX_FILES) |
1747 | | - $(eval FILES_TO_COMPILE := $(filter-out src/$(PROJECT).app.src,$?)) |
| 1753 | + $(eval FILES_TO_COMPILE := $(filter-out $(EX_FILES) src/$(PROJECT).app.src,$?)) |
1748 | 1754 | $(if $(strip $(FILES_TO_COMPILE)),$(call compile_erl,$(FILES_TO_COMPILE))) |
1749 | | - $(if $(strip $(EX_FILES)),$(elixirc_verbose) $(eval MODULES := $(shell $(call erlang,$(call compile_ex.erl,$(EX_FILES)))))) |
| 1755 | + $(if $(filter $?,$(EX_FILES)),$(elixirc_verbose) $(eval MODULES := $(shell $(call erlang,$(call compile_ex.erl,$(EX_FILES)))))) |
1750 | 1756 | # Older git versions do not have the --first-parent flag. Do without in that case. |
1751 | 1757 | $(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null \ |
1752 | 1758 | || git describe --dirty --abbrev=7 --tags --always 2>/dev/null || true)) |
@@ -1788,21 +1794,21 @@ endif |
1788 | 1794 | # Copyright (c) 2024, Loïc Hoguin <[email protected]> |
1789 | 1795 | # This file is part of erlang.mk and subject to the terms of the ISC License. |
1790 | 1796 |
|
1791 | | -ALL_LIB_FILES := $(sort $(call core_find,lib/,*)) |
1792 | | -EX_FILES := $(filter-out lib/mix/%,$(filter %.ex,$(ALL_SRC_FILES) $(ALL_LIB_FILES))) |
1793 | | - |
1794 | 1797 | ELIXIR ?= $(if $(filter elixir,$(BUILD_DEPS) $(DEPS)),dep,system) |
1795 | 1798 | export ELIXIR |
1796 | 1799 |
|
1797 | 1800 | ifeq ($(ELIXIR),system) |
1798 | 1801 | # We expect 'elixir' to be on the path. |
1799 | | -ELIXIR_LIBS := $(dir $(shell elixir -e 'IO.puts(:code.lib_dir(:elixir))')) |
| 1802 | +# @todo Only if there are EX_FILES |
| 1803 | +ELIXIR_LIBS ?= $(dir $(shell elixir -e 'IO.puts(:code.lib_dir(:elixir))')) |
| 1804 | +ELIXIR_LIBS := $(ELIXIR_LIBS) |
| 1805 | +export ELIXIR_LIBS |
1800 | 1806 | ERL_LIBS := $(ERL_LIBS):$(ELIXIR_LIBS) |
1801 | 1807 | else |
1802 | 1808 | ERL_LIBS := $(ERL_LIBS):$(DEPS_DIR)/elixir/lib/ |
1803 | 1809 | endif |
1804 | 1810 |
|
1805 | | -elixirc_verbose_0 = @echo " ELIXIRC " $(EX_FILES) |
| 1811 | +elixirc_verbose_0 = @echo " EXC $(words $(EX_FILES)) files" |
1806 | 1812 | elixirc_verbose_2 = set -x; |
1807 | 1813 | elixirc_verbose = $(elixirc_verbose_$(V)) |
1808 | 1814 |
|
@@ -3402,17 +3408,45 @@ help:: |
3402 | 3408 |
|
3403 | 3409 | # Plugin-specific targets. |
3404 | 3410 |
|
3405 | | -escript-zip:: FULL=1 |
3406 | | -escript-zip:: deps app |
| 3411 | +ALL_ESCRIPT_DEPS_DIRS = $(LOCAL_DEPS_DIRS) $(addprefix $(DEPS_DIR)/,$(foreach dep,$(filter-out $(IGNORE_DEPS),$(DEPS)),$(call query_name,$(dep)))) |
| 3412 | + |
| 3413 | +ESCRIPT_RUNTIME_DEPS_FILE ?= $(ERLANG_MK_TMP)/escript-deps.log |
| 3414 | + |
| 3415 | +escript-list-runtime-deps: |
| 3416 | +ifeq ($(IS_DEP),) |
| 3417 | + $(verbose) rm -f $(ESCRIPT_RUNTIME_DEPS_FILE) |
| 3418 | +endif |
| 3419 | + $(verbose) touch $(ESCRIPT_RUNTIME_DEPS_FILE) |
| 3420 | + $(verbose) set -e; for dep in $(ALL_ESCRIPT_DEPS_DIRS) ; do \ |
| 3421 | + if ! grep -qs ^$$dep$$ $(ESCRIPT_RUNTIME_DEPS_FILE); then \ |
| 3422 | + echo $$dep >> $(ESCRIPT_RUNTIME_DEPS_FILE); \ |
| 3423 | + if grep -qs -E "^[[:blank:]]*include[[:blank:]]+(erlang\.mk|.*/erlang\.mk|.*ERLANG_MK_FILENAME.*)$$" \ |
| 3424 | + $$dep/GNUmakefile $$dep/makefile $$dep/Makefile; then \ |
| 3425 | + $(MAKE) -C $$dep escript-list-runtime-deps \ |
| 3426 | + IS_DEP=1 \ |
| 3427 | + ESCRIPT_RUNTIME_DEPS_FILE=$(ESCRIPT_RUNTIME_DEPS_FILE); \ |
| 3428 | + fi \ |
| 3429 | + fi \ |
| 3430 | + done |
| 3431 | +ifeq ($(IS_DEP),) |
| 3432 | + $(verbose) sort < $(ESCRIPT_RUNTIME_DEPS_FILE) | uniq > $(ESCRIPT_RUNTIME_DEPS_FILE).sorted |
| 3433 | + $(verbose) mv $(ESCRIPT_RUNTIME_DEPS_FILE).sorted $(ESCRIPT_RUNTIME_DEPS_FILE) |
| 3434 | +endif |
| 3435 | + |
| 3436 | +escript-prepare: deps app |
| 3437 | + $(MAKE) escript-list-runtime-deps |
| 3438 | + |
| 3439 | +escript-zip:: escript-prepare |
3407 | 3440 | $(verbose) mkdir -p $(dir $(abspath $(ESCRIPT_ZIP_FILE))) |
3408 | 3441 | $(verbose) rm -f $(abspath $(ESCRIPT_ZIP_FILE)) |
3409 | | - $(gen_verbose) cd .. && $(ESCRIPT_ZIP) $(abspath $(ESCRIPT_ZIP_FILE)) rabbitmq_cli/ebin/* |
| 3442 | + $(gen_verbose) cd .. && $(ESCRIPT_ZIP) $(abspath $(ESCRIPT_ZIP_FILE)) $(notdir $(CURDIR))/ebin/* |
3410 | 3443 | ifneq ($(DEPS),) |
3411 | 3444 | $(verbose) cd $(DEPS_DIR) && $(ESCRIPT_ZIP) $(abspath $(ESCRIPT_ZIP_FILE)) \ |
3412 | 3445 | $(subst $(DEPS_DIR)/,,$(addsuffix /*,$(wildcard \ |
3413 | | - $(addsuffix /ebin,$(shell cat $(ERLANG_MK_TMP)/deps.log))))) |
| 3446 | + $(addsuffix /ebin,$(shell cat $(ESCRIPT_RUNTIME_DEPS_FILE)))))) |
3414 | 3447 | endif |
3415 | 3448 |
|
| 3449 | +# @todo Only generate the zip file if there were changes. |
3416 | 3450 | escript:: escript-zip |
3417 | 3451 | $(gen_verbose) printf "%s\n" \ |
3418 | 3452 | "#!$(ESCRIPT_SHEBANG)" \ |
@@ -4798,9 +4832,7 @@ endif |
4798 | 4832 | ifeq ($(IS_APP)$(IS_DEP),) |
4799 | 4833 | $(verbose) sort < $(ERLANG_MK_RECURSIVE_TMP_LIST) | \ |
4800 | 4834 | uniq > $(ERLANG_MK_RECURSIVE_TMP_LIST).sorted |
4801 | | - $(verbose) cmp -s $(ERLANG_MK_RECURSIVE_TMP_LIST).sorted $@ \ |
4802 | | - || mv $(ERLANG_MK_RECURSIVE_TMP_LIST).sorted $@ |
4803 | | - $(verbose) rm -f $(ERLANG_MK_RECURSIVE_TMP_LIST).sorted |
| 4835 | + $(verbose) mv $(ERLANG_MK_RECURSIVE_TMP_LIST).sorted $@ |
4804 | 4836 | $(verbose) rm $(ERLANG_MK_RECURSIVE_TMP_LIST) |
4805 | 4837 | endif |
4806 | 4838 | endif # ifneq ($(SKIP_DEPS),) |
|
0 commit comments