[08/11] nmk: Add obj and lib deps gathering via helpers

Submitted by Cyrill Gorcunov on July 12, 2018, 12:51 p.m.

Details

Message ID 20180712125142.8737-9-gorcunov@gmail.com
State New
Series "build: Fix issue on simultaneous build"
Headers show

Commit Message

Cyrill Gorcunov July 12, 2018, 12:51 p.m.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 scripts/nmk/scripts/build.mk | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/scripts/nmk/scripts/build.mk b/scripts/nmk/scripts/build.mk
index e55fd5726fe1..bf5048fcaab1 100644
--- a/scripts/nmk/scripts/build.mk
+++ b/scripts/nmk/scripts/build.mk
@@ -255,6 +255,16 @@  $(foreach t,$(libso-y),$(eval $(call gen-so-link-rules,$(t))))
 
 #
 # Figure out if the target we're building needs deps to include.
+define collect-builtin-deps
+        ifeq ($(1),$(2))
+                deps-y += $(obj-y:.o=.d)
+        endif
+endef
+define collect-lib-deps
+        ifeq ($(1),$(2))
+                deps-y += $(lib-y:.o=.d)
+        endif
+endef
 define collect-hostprogs-deps
         ifeq ($(1),$(2))
                 deps-y += $(addprefix $(obj)/,$($(1)-objs:.o=.d))
@@ -272,12 +282,8 @@  define collect-deps
                         deps-y += $(addsuffix .d,$(basename $(1)))
                 endif
         endif
-        ifeq ($(builtin-target),$(1))
-                deps-y += $(obj-y:.o=.d)
-        endif
-        ifeq ($(lib-target),$(1))
-                deps-y += $(lib-y:.o=.d)
-        endif
+        $(eval $(call collect-builtin-deps,$(builtin-target),$(1)))
+        $(eval $(call collect-lib-deps,$(lib-target),$(1)))
         $(foreach t,$(hostprogs-y),$(eval $(call collect-hostprogs-deps,$(t),$(1))))
         $(foreach t,$(target),$(eval $(call collect-target-deps,$(t),$(1))))
         ifneq ($(filter all $(filter-out $(builtin-target) $(lib-target), $(all-y)) $(hostprogs-y),$(1)),)