Skip to content
Snippets Groups Projects
Commit be1d267a authored by Simon Rose's avatar Simon Rose
Browse files

Fetch dependencies recursively

This uses some general make tools, most notably "while" and "select" which come from
https://github.com/markpiffer/gmtt.git and which allow us to recursively parse the
.dep files in the given e3 installation. Broadly speaking, we start with all variables
of the form `%_DEP_VERSION` to determine the first line of dependent modules, and then
we ask them (using `fetch_deps`) what they depend on.
parent e39534f6
No related branches found
No related tags found
No related merge requests found
...@@ -423,6 +423,46 @@ ifeq ($(filter O.%,$(notdir ${CURDIR})),) ...@@ -423,6 +423,46 @@ ifeq ($(filter O.%,$(notdir ${CURDIR})),)
## RUN 3 ## RUN 3
# Target architecture defined. # Target architecture defined.
# Still in source directory, third run. # Still in source directory, third run.
# First, sort out all of the dependencies. This is done recursively using tools from https://github.com/markpiffer/gmtt.git
space := $(strip) $(strip)#
comma := ,#
list2param = $(subst $(space),$(comma),$(strip $1))
exec = $(eval -exec=$1)$(eval -exec:=$$(call -exec,$(call list2param,$2)))$(-exec)
while = $(if $(call exec,$1),$(eval $2)$(call while,$1,$2,$3),$(eval $3))
pick = $(foreach elem,$1,$(word $(elem),$2))
select = $(strip $(call -select,$1,$(strip $2),$3))
-select = $(call --select,$(wordlist 2,2147483647,$2),$(firstword $2),3,$1,$3)
--select = $(if $1,$(if $(call exec,$5,$(call list2param,$(wordlist 1,$2,$1))), $(call pick,$4,$1))$(call --select,$(wordlist $3,2147483647,$1),$2,$3,$4,$5))
str-eq = $(if $(subst x$1,,x$2),,t)
define fetch_deps
2 $(shell cat $(E3_SITEMODS_PATH)/$1/$($1_VERSION)/lib/$(T_A)/$1.dep | sed '1d')
endef
define update_dep_versions
m := $$(firstword $$(_MODULES))
REQUIRED += $$m
$$m_TBL := $$(call fetch_deps,$$m)
$$m_DEPS := $$(call select,1,$$($$m_TBL),1)
_MODULES := $$(filter-out $$(REQUIRED),$$(_MODULES) $$($$m_DEPS))
$$(foreach mm,$$($$m_DEPS),$$(eval export $$(mm)_VERSION := $$(call select,2,$$($$m_TBL),$$$$(call str-eq,$$$$1,$$(mm)))))
endef
# Convert (for example) ASYN_DEP_VERSION to asyn_VERSION and add asyn to the list of modules
_MODULES :=
REQUIRED :=
$(foreach m,$(patsubst %_DEP_VERSION,%,$(filter %_DEP_VERSION,$(.VARIABLES))),\
$(eval _lm := $(shell echo $m | tr '[:upper:]' '[:lower:]'))\
$(eval export $(_lm)_VERSION := $($m_DEP_VERSION))\
$(eval _MODULES += $(_lm)))
$(call while,$$(_MODULES),$(update_dep_versions))
debug:: debug::
@echo "===================== Pass 3: T_A = $(T_A) =====================" @echo "===================== Pass 3: T_A = $(T_A) ====================="
@echo "BINS = $(BINS)" @echo "BINS = $(BINS)"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment