Loading core/dumpconfig.mk +16 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,10 @@ ifeq (,$(DUMPCONFIG_FILE)) $(error stopping) endif # Skip the second inclusion of all of the product config files, because # we will do these checks in the product_config tool. SKIP_ARTIFACT_PATH_REQUIREMENT_PRODUCTS_CHECK := true # Before we do anything else output the format version. $(file > $(DUMPCONFIG_FILE),dumpconfig_version,1) $(file >> $(DUMPCONFIG_FILE),dumpconfig_file,$(DUMPCONFIG_FILE)) Loading Loading @@ -75,7 +79,7 @@ $(eval $(file >> $(DUMPCONFIG_FILE),inherit,$(strip $(1)),$(strip $(2)))) endef # Args: # $(1): Config phase (PRODUCT or DEVICE) # $(1): Config phase (PRODUCT, EXPAND, or DEVICE) # $(2): Root nodes to import # $(3): All variable names # $(4): Single-value variables Loading Loading @@ -104,10 +108,21 @@ DUMPCONFIG_SKIP_VARS := \ .KATI_SYMBOLS \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7 \ 8 \ 9 \ LOCAL_PATH \ MAKEFILE_LIST \ PARENT_PRODUCT_FILES \ current_mk \ _eiv_ev \ _eiv_i \ _eiv_sv \ _eiv_tv \ inherit_var \ np \ _node_import_context \ Loading core/product.mk +4 −1 Original line number Diff line number Diff line Loading @@ -606,6 +606,8 @@ get-product-var = $(PRODUCTS.$(strip $(1)).$(2)) # to a shorthand that is more convenient to read from elsewhere. # define strip-product-vars $(call dump-phase-start,PRODUCT-EXPAND,,$(_product_var_list),$(_product_single_value_vars), \ build/make/core/product.mk) \ $(foreach v,\ $(_product_var_list) \ PRODUCT_ENFORCE_PACKAGES_EXIST \ Loading @@ -613,7 +615,8 @@ $(foreach v,\ $(eval $(v) := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).$(v)))) \ $(eval get-product-var = $$(if $$(filter $$(1),$$(INTERNAL_PRODUCT)),$$($$(2)),$$(PRODUCTS.$$(strip $$(1)).$$(2)))) \ $(KATI_obsolete_var PRODUCTS.$(INTERNAL_PRODUCT).$(v),Use $(v) instead) \ ) ) \ $(call dump-phase-end,build/make/core/product.mk) endef define add-to-product-copy-files-if-exists Loading core/product_config.mk +7 −3 Original line number Diff line number Diff line Loading @@ -163,12 +163,14 @@ endif # Import all or just the current product makefile # Quick check $(check-all-products) ifeq ($(SKIP_ARTIFACT_PATH_REQUIREMENT_PRODUCTS_CHECK),) # Import all the products that have made artifact path requirements, so that we can verify # the artifacts they produce. # These are imported after check-all-products because some of them might not be real products. $(foreach makefile,$(ARTIFACT_PATH_REQUIREMENT_PRODUCTS),\ $(if $(filter-out $(makefile),$(PRODUCTS)),$(eval $(call import-products,$(makefile))))\ ) endif ifneq ($(filter dump-products, $(MAKECMDGOALS)),) $(dump-products) Loading @@ -181,14 +183,16 @@ INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT)) ifneq ($(current_product_makefile),$(INTERNAL_PRODUCT)) $(error PRODUCT_NAME inconsistent in $(current_product_makefile) and $(INTERNAL_PRODUCT)) endif current_product_makefile := all_product_makefiles := all_product_configs := ############################################################################ # Strip and assign the PRODUCT_ variables. $(call strip-product-vars) current_product_makefile := all_product_makefiles := all_product_configs := ############################################################################# # Quick check and assign default values Loading tools/product_config/inherit_tree.py 0 → 100755 +49 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 # # Run from the root of the tree, after product-config has been run to see # the product inheritance hierarchy for the current lunch target. # import csv import sys def PrintNodes(graph, node, prefix): sys.stdout.write("%s%s" % (prefix, node)) children = graph.get(node, []) if children: sys.stdout.write(" {\n") for child in sorted(graph.get(node, [])): PrintNodes(graph, child, prefix + " ") sys.stdout.write("%s}\n" % prefix); else: sys.stdout.write("\n") def main(argv): if len(argv) != 2: print("usage: inherit_tree.py out/$TARGET_PRODUCT-$TARGET_BUILD_VARIANT/dumpconfig.csv") sys.exit(1) root = None graph = {} with open(argv[1], newline='') as csvfile: for line in csv.reader(csvfile): if not root: # Look for PRODUCTS if len(line) < 3 or line[0] != "phase" or line[1] != "PRODUCTS": continue root = line[2] else: # Everything else if len(line) < 3 or line[0] != "inherit": continue graph.setdefault(line[1], list()).append(line[2]) PrintNodes(graph, root, "") if __name__ == "__main__": main(sys.argv) # vim: set expandtab ts=2 sw=2 sts=2: tools/product_config/src/com/android/build/config/ConvertMakeToGenericConfig.java +34 −5 Original line number Diff line number Diff line Loading @@ -31,14 +31,20 @@ public class ConvertMakeToGenericConfig { mErrors = errors; } public GenericConfig convert(MakeConfig make) { public GenericConfig convert(Map<String, MakeConfig> make) { final GenericConfig result = new GenericConfig(); final MakeConfig products = make.get("PRODUCTS"); if (products == null) { mErrors.ERROR_DUMPCONFIG.add("Could not find PRODUCTS phase in dumpconfig output."); return null; } // Base class fields result.copyFrom(make); result.copyFrom(products); // Each file for (MakeConfig.ConfigFile f: make.getConfigFiles()) { for (MakeConfig.ConfigFile f: products.getConfigFiles()) { final GenericConfig.ConfigFile genericFile = new GenericConfig.ConfigFile(f.getFilename()); result.addConfigFile(genericFile); Loading Loading @@ -77,7 +83,7 @@ public class ConvertMakeToGenericConfig { for (final Map.Entry<String, Str> entry: block.getVars().entrySet()) { final String varName = entry.getKey(); final GenericConfig.Assign assign = convertAssignment(block.getBlockType(), block.getInheritedFile(), make.getVarType(varName), varName, block.getInheritedFile(), products.getVarType(varName), varName, entry.getValue(), prevBlock.getVar(varName)); if (assign != null) { genericFile.addStatement(assign); Loading @@ -100,6 +106,29 @@ public class ConvertMakeToGenericConfig { prevBlock = block; } } // Overwrite the final variables with the ones that come from the PRODUCTS-EXPAND phase. // Drop the ones that were newly defined between the two phases, but leave values // that were modified between. We do need to reproduce that logic in this tool. final MakeConfig expand = make.get("PRODUCT-EXPAND"); if (expand == null) { mErrors.ERROR_DUMPCONFIG.add("Could not find PRODUCT-EXPAND phase in dumpconfig" + " output."); return null; } final Map<String, Str> productsFinal = products.getFinalVariables(); final Map<String, Str> expandInitial = expand.getInitialVariables(); final Map<String, Str> expandFinal = expand.getFinalVariables(); final Map<String, Str> finalFinal = result.getFinalVariables(); finalFinal.clear(); for (Map.Entry<String, Str> var: expandFinal.entrySet()) { final String varName = var.getKey(); if (expandInitial.containsKey(varName) && !productsFinal.containsKey(varName)) { continue; } finalFinal.put(varName, var.getValue()); } return result; } Loading @@ -113,7 +142,7 @@ public class ConvertMakeToGenericConfig { return new GenericConfig.Assign(varName, varVal); } else if (!varVal.equals(prevVal)) { // The value changed from the last block. if (varVal.equals("")) { if (varVal.length() == 0) { // It was set to empty return new GenericConfig.Assign(varName, varVal); } else { Loading Loading
core/dumpconfig.mk +16 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,10 @@ ifeq (,$(DUMPCONFIG_FILE)) $(error stopping) endif # Skip the second inclusion of all of the product config files, because # we will do these checks in the product_config tool. SKIP_ARTIFACT_PATH_REQUIREMENT_PRODUCTS_CHECK := true # Before we do anything else output the format version. $(file > $(DUMPCONFIG_FILE),dumpconfig_version,1) $(file >> $(DUMPCONFIG_FILE),dumpconfig_file,$(DUMPCONFIG_FILE)) Loading Loading @@ -75,7 +79,7 @@ $(eval $(file >> $(DUMPCONFIG_FILE),inherit,$(strip $(1)),$(strip $(2)))) endef # Args: # $(1): Config phase (PRODUCT or DEVICE) # $(1): Config phase (PRODUCT, EXPAND, or DEVICE) # $(2): Root nodes to import # $(3): All variable names # $(4): Single-value variables Loading Loading @@ -104,10 +108,21 @@ DUMPCONFIG_SKIP_VARS := \ .KATI_SYMBOLS \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7 \ 8 \ 9 \ LOCAL_PATH \ MAKEFILE_LIST \ PARENT_PRODUCT_FILES \ current_mk \ _eiv_ev \ _eiv_i \ _eiv_sv \ _eiv_tv \ inherit_var \ np \ _node_import_context \ Loading
core/product.mk +4 −1 Original line number Diff line number Diff line Loading @@ -606,6 +606,8 @@ get-product-var = $(PRODUCTS.$(strip $(1)).$(2)) # to a shorthand that is more convenient to read from elsewhere. # define strip-product-vars $(call dump-phase-start,PRODUCT-EXPAND,,$(_product_var_list),$(_product_single_value_vars), \ build/make/core/product.mk) \ $(foreach v,\ $(_product_var_list) \ PRODUCT_ENFORCE_PACKAGES_EXIST \ Loading @@ -613,7 +615,8 @@ $(foreach v,\ $(eval $(v) := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).$(v)))) \ $(eval get-product-var = $$(if $$(filter $$(1),$$(INTERNAL_PRODUCT)),$$($$(2)),$$(PRODUCTS.$$(strip $$(1)).$$(2)))) \ $(KATI_obsolete_var PRODUCTS.$(INTERNAL_PRODUCT).$(v),Use $(v) instead) \ ) ) \ $(call dump-phase-end,build/make/core/product.mk) endef define add-to-product-copy-files-if-exists Loading
core/product_config.mk +7 −3 Original line number Diff line number Diff line Loading @@ -163,12 +163,14 @@ endif # Import all or just the current product makefile # Quick check $(check-all-products) ifeq ($(SKIP_ARTIFACT_PATH_REQUIREMENT_PRODUCTS_CHECK),) # Import all the products that have made artifact path requirements, so that we can verify # the artifacts they produce. # These are imported after check-all-products because some of them might not be real products. $(foreach makefile,$(ARTIFACT_PATH_REQUIREMENT_PRODUCTS),\ $(if $(filter-out $(makefile),$(PRODUCTS)),$(eval $(call import-products,$(makefile))))\ ) endif ifneq ($(filter dump-products, $(MAKECMDGOALS)),) $(dump-products) Loading @@ -181,14 +183,16 @@ INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT)) ifneq ($(current_product_makefile),$(INTERNAL_PRODUCT)) $(error PRODUCT_NAME inconsistent in $(current_product_makefile) and $(INTERNAL_PRODUCT)) endif current_product_makefile := all_product_makefiles := all_product_configs := ############################################################################ # Strip and assign the PRODUCT_ variables. $(call strip-product-vars) current_product_makefile := all_product_makefiles := all_product_configs := ############################################################################# # Quick check and assign default values Loading
tools/product_config/inherit_tree.py 0 → 100755 +49 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 # # Run from the root of the tree, after product-config has been run to see # the product inheritance hierarchy for the current lunch target. # import csv import sys def PrintNodes(graph, node, prefix): sys.stdout.write("%s%s" % (prefix, node)) children = graph.get(node, []) if children: sys.stdout.write(" {\n") for child in sorted(graph.get(node, [])): PrintNodes(graph, child, prefix + " ") sys.stdout.write("%s}\n" % prefix); else: sys.stdout.write("\n") def main(argv): if len(argv) != 2: print("usage: inherit_tree.py out/$TARGET_PRODUCT-$TARGET_BUILD_VARIANT/dumpconfig.csv") sys.exit(1) root = None graph = {} with open(argv[1], newline='') as csvfile: for line in csv.reader(csvfile): if not root: # Look for PRODUCTS if len(line) < 3 or line[0] != "phase" or line[1] != "PRODUCTS": continue root = line[2] else: # Everything else if len(line) < 3 or line[0] != "inherit": continue graph.setdefault(line[1], list()).append(line[2]) PrintNodes(graph, root, "") if __name__ == "__main__": main(sys.argv) # vim: set expandtab ts=2 sw=2 sts=2:
tools/product_config/src/com/android/build/config/ConvertMakeToGenericConfig.java +34 −5 Original line number Diff line number Diff line Loading @@ -31,14 +31,20 @@ public class ConvertMakeToGenericConfig { mErrors = errors; } public GenericConfig convert(MakeConfig make) { public GenericConfig convert(Map<String, MakeConfig> make) { final GenericConfig result = new GenericConfig(); final MakeConfig products = make.get("PRODUCTS"); if (products == null) { mErrors.ERROR_DUMPCONFIG.add("Could not find PRODUCTS phase in dumpconfig output."); return null; } // Base class fields result.copyFrom(make); result.copyFrom(products); // Each file for (MakeConfig.ConfigFile f: make.getConfigFiles()) { for (MakeConfig.ConfigFile f: products.getConfigFiles()) { final GenericConfig.ConfigFile genericFile = new GenericConfig.ConfigFile(f.getFilename()); result.addConfigFile(genericFile); Loading Loading @@ -77,7 +83,7 @@ public class ConvertMakeToGenericConfig { for (final Map.Entry<String, Str> entry: block.getVars().entrySet()) { final String varName = entry.getKey(); final GenericConfig.Assign assign = convertAssignment(block.getBlockType(), block.getInheritedFile(), make.getVarType(varName), varName, block.getInheritedFile(), products.getVarType(varName), varName, entry.getValue(), prevBlock.getVar(varName)); if (assign != null) { genericFile.addStatement(assign); Loading @@ -100,6 +106,29 @@ public class ConvertMakeToGenericConfig { prevBlock = block; } } // Overwrite the final variables with the ones that come from the PRODUCTS-EXPAND phase. // Drop the ones that were newly defined between the two phases, but leave values // that were modified between. We do need to reproduce that logic in this tool. final MakeConfig expand = make.get("PRODUCT-EXPAND"); if (expand == null) { mErrors.ERROR_DUMPCONFIG.add("Could not find PRODUCT-EXPAND phase in dumpconfig" + " output."); return null; } final Map<String, Str> productsFinal = products.getFinalVariables(); final Map<String, Str> expandInitial = expand.getInitialVariables(); final Map<String, Str> expandFinal = expand.getFinalVariables(); final Map<String, Str> finalFinal = result.getFinalVariables(); finalFinal.clear(); for (Map.Entry<String, Str> var: expandFinal.entrySet()) { final String varName = var.getKey(); if (expandInitial.containsKey(varName) && !productsFinal.containsKey(varName)) { continue; } finalFinal.put(varName, var.getValue()); } return result; } Loading @@ -113,7 +142,7 @@ public class ConvertMakeToGenericConfig { return new GenericConfig.Assign(varName, varVal); } else if (!varVal.equals(prevVal)) { // The value changed from the last block. if (varVal.equals("")) { if (varVal.length() == 0) { // It was set to empty return new GenericConfig.Assign(varName, varVal); } else { Loading