From 7edc30ad40cd5dc033bc8f0e914b951abf6d0527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Tue, 25 Feb 2020 15:51:34 +0100 Subject: Add the query-deps family of targets The query-deps, query-doc-deps, query-rel-deps, query-test-deps and query-shell-deps targets go through dependencies and print some information about them: $ make query-deps ... cowboy: cowlib git https://github.com/ninenines/cowlib 2.7.3 cowboy: ranch git https://github.com/ninenines/ranch 1.7.1 $ make query-deps QUERY="name repo version absolute_path" ... cowboy: cowlib https://github.com/ninenines/cowlib 2.7.3 /path/to/deps/cowlib cowboy: ranch https://github.com/ninenines/ranch 1.7.1 /path/to/deps/ranch The query-deps target is recursive; the others aren't. This mirrors the behavior when fetching and building dependencies. The full list of options is: QUERY="fetch_method name repo version extra absolute_path" When an option has no corresponding value, "-" will be printed. For example most fetch methods do not have extra information to print. When there is extra information, the value will be prefixed with a descriptive name. For example: package-name=uuid_erl This commit also introduces changes to deps handling: some of the functions for querying will now be used directly. In the future the goal is to remove the old dep_name, dep_commit, etc. functions and replace their usage with the new query functions. Custom fetch methods should implement query functions in order to have information about the relevant dependencies printed properly. --- core/deps-tools.mk | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'core/deps-tools.mk') diff --git a/core/deps-tools.mk b/core/deps-tools.mk index e3eb913..2a632e4 100644 --- a/core/deps-tools.mk +++ b/core/deps-tools.mk @@ -97,3 +97,43 @@ list-shell-deps: $(ERLANG_MK_RECURSIVE_SHELL_DEPS_LIST) list-deps list-doc-deps list-rel-deps list-test-deps list-shell-deps: $(verbose) cat $^ + +# Query dependencies recursively. + +.PHONY: query-deps query-doc-deps query-rel-deps query-test-deps \ + query-shell-deps + +QUERY ?= name fetch_method repo version + +define query_target +$(1): $(2) clean-tmp-query.log +ifeq ($(IS_APP)$(IS_DEP),) + $(verbose) rm -f $(4) +endif + $(verbose) $(foreach dep,$(3),\ + echo $(PROJECT): $(foreach q,$(QUERY),$(call query_$(q),$(dep))) >> $(4) ;) + $(if $(filter-out query-deps,$(1)),,\ + $(verbose) set -e; for dep in $(3) ; do \ + if grep -qs ^$$$$dep$$$$ $(ERLANG_MK_TMP)/query.log; then \ + :; \ + else \ + echo $$$$dep >> $(ERLANG_MK_TMP)/query.log; \ + $(MAKE) -C $(DEPS_DIR)/$$$$dep $$@ QUERY="$(QUERY)" IS_DEP=1 || true; \ + fi \ + done) +ifeq ($(IS_APP)$(IS_DEP),) + $(verbose) touch $(4) + $(verbose) cat $(4) +endif +endef + +clean-tmp-query.log: +ifeq ($(IS_DEP),) + $(verbose) rm -f $(ERLANG_MK_TMP)/query.log +endif + +$(eval $(call query_target,query-deps,$(ERLANG_MK_RECURSIVE_DEPS_LIST),$(BUILD_DEPS) $(DEPS),$(ERLANG_MK_QUERY_DEPS_FILE))) +$(eval $(call query_target,query-doc-deps,$(ERLANG_MK_RECURSIVE_DOC_DEPS_LIST),$(DOC_DEPS),$(ERLANG_MK_QUERY_DOC_DEPS_FILE))) +$(eval $(call query_target,query-rel-deps,$(ERLANG_MK_RECURSIVE_REL_DEPS_LIST),$(REL_DEPS),$(ERLANG_MK_QUERY_REL_DEPS_FILE))) +$(eval $(call query_target,query-test-deps,$(ERLANG_MK_RECURSIVE_TEST_DEPS_LIST),$(TEST_DEPS),$(ERLANG_MK_QUERY_TEST_DEPS_FILE))) +$(eval $(call query_target,query-shell-deps,$(ERLANG_MK_RECURSIVE_SHELL_DEPS_LIST),$(SHELL_DEPS),$(ERLANG_MK_QUERY_SHELL_DEPS_FILE))) -- cgit v1.2.3