Skip to content

Commit 9d6dc96

Browse files
committed
Progress
1 parent 92a8f5e commit 9d6dc96

File tree

2 files changed

+58
-23
lines changed

2 files changed

+58
-23
lines changed

deps/rabbitmq_cli/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,20 @@ endif
4343

4444
export MAKE
4545

46-
.DEFAULT_GOAL = escript
47-
4846
ESCRIPT_NAME = Elixir.RabbitMQCtl
4947
ESCRIPT_FILE = escript/rabbitmqctl
5048

49+
.DEFAULT_GOAL = $(ESCRIPT_FILE)
50+
5151
escript::
5252
$(verbose) mkdir -p escript/
5353

5454
include ../../rabbitmq-components.mk
5555
include ../../erlang.mk
5656

57+
$(ESCRIPT_FILE): $(EX_FILES)
58+
$(verbose) $(MAKE) escript
59+
5760
ESCRIPT_EMU_ARGS += -hidden
5861

5962
escript-zip::

erlang.mk

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST)))
1818
export ERLANG_MK_FILENAME
1919

20-
ERLANG_MK_VERSION = 2022.05.31-145-g12f1987-dirty
20+
ERLANG_MK_VERSION = 2022.05.31-150-g91e552d-dirty
2121
ERLANG_MK_WITHOUT =
2222

2323
# Make 3.81 and 3.82 are deprecated.
@@ -537,7 +537,7 @@ dep_name = $(call query_name,$(1))
537537
LOCAL_DEPS_DIRS = $(foreach a,$(LOCAL_DEPS),$(if $(wildcard $(APPS_DIR)/$a),$(APPS_DIR)/$a))
538538
# Elixir is handled specially as it must be built before all other deps
539539
# 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))))
541541

542542
# When we are calling an app directly we don't want to include it here
543543
# otherwise it'll be treated both as an apps and a top-level project.
@@ -629,9 +629,11 @@ endif
629629
ifneq ($(SKIP_DEPS),)
630630
deps::
631631
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 \
635637
if grep -qs ^$$dep$$ $(ERLANG_MK_TMP)/deps.log; then \
636638
:; \
637639
else \
@@ -1527,6 +1529,10 @@ ALL_SRC_FILES := $(sort $(call core_find,src/,*))
15271529
ERL_FILES := $(filter %.erl,$(ALL_SRC_FILES))
15281530
CORE_FILES := $(filter %.core,$(ALL_SRC_FILES))
15291531

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+
15301536
# ASN.1 files.
15311537

15321538
ifneq ($(wildcard asn1/),)
@@ -1707,11 +1713,11 @@ $(PROJECT).d:: $(ERL_FILES) $(EX_FILES) $(call core_find,include/,*.hrl) $(MAKEF
17071713
endif
17081714

17091715
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)
17111717
# Rebuild everything when the Makefile changes.
17121718
$(ERLANG_MK_TMP)/last-makefile-change: $(MAKEFILE_LIST) | $(ERLANG_MK_TMP)
17131719
$(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); \
17151721
touch -c $(PROJECT).d; \
17161722
fi
17171723
$(verbose) touch $@
@@ -1744,9 +1750,9 @@ define validate_app_file
17441750
endef
17451751

17461752
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,$?))
17481754
$(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))))))
17501756
# Older git versions do not have the --first-parent flag. Do without in that case.
17511757
$(eval GITDESCRIBE := $(shell git describe --dirty --abbrev=7 --tags --always --first-parent 2>/dev/null \
17521758
|| git describe --dirty --abbrev=7 --tags --always 2>/dev/null || true))
@@ -1788,21 +1794,21 @@ endif
17881794
# Copyright (c) 2024, Loïc Hoguin <[email protected]>
17891795
# This file is part of erlang.mk and subject to the terms of the ISC License.
17901796

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-
17941797
ELIXIR ?= $(if $(filter elixir,$(BUILD_DEPS) $(DEPS)),dep,system)
17951798
export ELIXIR
17961799

17971800
ifeq ($(ELIXIR),system)
17981801
# 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
18001806
ERL_LIBS := $(ERL_LIBS):$(ELIXIR_LIBS)
18011807
else
18021808
ERL_LIBS := $(ERL_LIBS):$(DEPS_DIR)/elixir/lib/
18031809
endif
18041810

1805-
elixirc_verbose_0 = @echo " ELIXIRC " $(EX_FILES)
1811+
elixirc_verbose_0 = @echo " EXC $(words $(EX_FILES)) files"
18061812
elixirc_verbose_2 = set -x;
18071813
elixirc_verbose = $(elixirc_verbose_$(V))
18081814

@@ -3402,17 +3408,45 @@ help::
34023408

34033409
# Plugin-specific targets.
34043410

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
34073440
$(verbose) mkdir -p $(dir $(abspath $(ESCRIPT_ZIP_FILE)))
34083441
$(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/*
34103443
ifneq ($(DEPS),)
34113444
$(verbose) cd $(DEPS_DIR) && $(ESCRIPT_ZIP) $(abspath $(ESCRIPT_ZIP_FILE)) \
34123445
$(subst $(DEPS_DIR)/,,$(addsuffix /*,$(wildcard \
3413-
$(addsuffix /ebin,$(shell cat $(ERLANG_MK_TMP)/deps.log)))))
3446+
$(addsuffix /ebin,$(shell cat $(ESCRIPT_RUNTIME_DEPS_FILE))))))
34143447
endif
34153448

3449+
# @todo Only generate the zip file if there were changes.
34163450
escript:: escript-zip
34173451
$(gen_verbose) printf "%s\n" \
34183452
"#!$(ESCRIPT_SHEBANG)" \
@@ -4798,9 +4832,7 @@ endif
47984832
ifeq ($(IS_APP)$(IS_DEP),)
47994833
$(verbose) sort < $(ERLANG_MK_RECURSIVE_TMP_LIST) | \
48004834
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 $@
48044836
$(verbose) rm $(ERLANG_MK_RECURSIVE_TMP_LIST)
48054837
endif
48064838
endif # ifneq ($(SKIP_DEPS),)

0 commit comments

Comments
 (0)