Loading core/product.mk +56 −7 Original line number Original line Diff line number Diff line Loading @@ -123,24 +123,66 @@ define dump-products $(foreach p,$(PRODUCTS),$(call dump-product,$(p))) $(foreach p,$(PRODUCTS),$(call dump-product,$(p))) endef endef # # Internal function. Appends inherited product variables to an existing one. # # $(1): Product variable to operate on # $(2): Value to append # define inherit-product_append-var $(eval $(1) := $($(1)) $(INHERIT_TAG)$(strip $(2))) endef # # Internal function. Prepends inherited product variables to an existing one. # # $(1): Product variable to operate on # $(2): Value to prepend # define inherit-product_prepend-var $(eval $(1) := $(INHERIT_TAG)$(strip $(2)) $($(1))) endef # # Internal function. Tracks visited notes during inheritance resolution. # # $(1): Product being inherited # define inherit-product_track-node $(eval inherit_var := \ PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \ $(eval $(inherit_var) := $(sort $($(inherit_var)) $(strip $(1)))) \ $(eval inherit_var:=) \ $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack)))) endef # # # $(1): product to inherit # $(1): product to inherit # # # Does three things: # Does three things: # 1. Inherits all of the variables from $1. # 1. Inherits all of the variables from $1, prioritizing existing settings. # 2. Records the inheritance in the .INHERITS_FROM variable # 2. Records the inheritance in the .INHERITS_FROM variable # 3. Records that we've visited this node, in ALL_PRODUCTS # 3. Records that we've visited this node, in ALL_PRODUCTS # # define inherit-product define inherit-product $(foreach v,$(_product_var_list), \ $(foreach v,$(_product_var_list), \ $(eval $(v) := $($(v)) $(INHERIT_TAG)$(strip $(1)))) \ $(call inherit-product_append-var,$(v),$(1))) \ $(eval inherit_var := \ $(call inherit-product_track-node,$(1)) PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \ $(eval $(inherit_var) := $(sort $($(inherit_var)) $(strip $(1)))) \ $(eval inherit_var:=) \ $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack)))) endef endef # # $(1): product to inherit # # Does three things: # 1. Inherits all of the variables from $1, prioritizing inherited settings. # 2. Records the inheritance in the .INHERITS_FROM variable # 3. Records that we've visited this node, in ALL_PRODUCTS # define prepend-product $(foreach v,$(_product_var_list), \ $(call inherit-product_prepend-var,$(v),$(1))) \ $(call inherit-product_track-node,$(1)) endef # # # Do inherit-product only if $(1) exists # Do inherit-product only if $(1) exists Loading @@ -149,6 +191,13 @@ define inherit-product-if-exists $(if $(wildcard $(1)),$(call inherit-product,$(1)),) $(if $(wildcard $(1)),$(call inherit-product,$(1)),) endef endef # # Do inherit-product-prepend only if $(1) exists # define prepend-product-if-exists $(if $(wildcard $(1)),$(call prepend-product,$(1)),) endef # # # $(1): product makefile list # $(1): product makefile list # # Loading Loading
core/product.mk +56 −7 Original line number Original line Diff line number Diff line Loading @@ -123,24 +123,66 @@ define dump-products $(foreach p,$(PRODUCTS),$(call dump-product,$(p))) $(foreach p,$(PRODUCTS),$(call dump-product,$(p))) endef endef # # Internal function. Appends inherited product variables to an existing one. # # $(1): Product variable to operate on # $(2): Value to append # define inherit-product_append-var $(eval $(1) := $($(1)) $(INHERIT_TAG)$(strip $(2))) endef # # Internal function. Prepends inherited product variables to an existing one. # # $(1): Product variable to operate on # $(2): Value to prepend # define inherit-product_prepend-var $(eval $(1) := $(INHERIT_TAG)$(strip $(2)) $($(1))) endef # # Internal function. Tracks visited notes during inheritance resolution. # # $(1): Product being inherited # define inherit-product_track-node $(eval inherit_var := \ PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \ $(eval $(inherit_var) := $(sort $($(inherit_var)) $(strip $(1)))) \ $(eval inherit_var:=) \ $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack)))) endef # # # $(1): product to inherit # $(1): product to inherit # # # Does three things: # Does three things: # 1. Inherits all of the variables from $1. # 1. Inherits all of the variables from $1, prioritizing existing settings. # 2. Records the inheritance in the .INHERITS_FROM variable # 2. Records the inheritance in the .INHERITS_FROM variable # 3. Records that we've visited this node, in ALL_PRODUCTS # 3. Records that we've visited this node, in ALL_PRODUCTS # # define inherit-product define inherit-product $(foreach v,$(_product_var_list), \ $(foreach v,$(_product_var_list), \ $(eval $(v) := $($(v)) $(INHERIT_TAG)$(strip $(1)))) \ $(call inherit-product_append-var,$(v),$(1))) \ $(eval inherit_var := \ $(call inherit-product_track-node,$(1)) PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \ $(eval $(inherit_var) := $(sort $($(inherit_var)) $(strip $(1)))) \ $(eval inherit_var:=) \ $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack)))) endef endef # # $(1): product to inherit # # Does three things: # 1. Inherits all of the variables from $1, prioritizing inherited settings. # 2. Records the inheritance in the .INHERITS_FROM variable # 3. Records that we've visited this node, in ALL_PRODUCTS # define prepend-product $(foreach v,$(_product_var_list), \ $(call inherit-product_prepend-var,$(v),$(1))) \ $(call inherit-product_track-node,$(1)) endef # # # Do inherit-product only if $(1) exists # Do inherit-product only if $(1) exists Loading @@ -149,6 +191,13 @@ define inherit-product-if-exists $(if $(wildcard $(1)),$(call inherit-product,$(1)),) $(if $(wildcard $(1)),$(call inherit-product,$(1)),) endef endef # # Do inherit-product-prepend only if $(1) exists # define prepend-product-if-exists $(if $(wildcard $(1)),$(call prepend-product,$(1)),) endef # # # $(1): product makefile list # $(1): product makefile list # # Loading