Move VarType out of its respective outer classes.
It's used more than I originally thought it would be and it's unnecessarily nested. Test: rm -rf out/config/ && m product-config-test product-config && java -jar out/host/linux-x86/testcases/product-config-test/product-config-test.jar && time ( product-config --ckati_bin /source/kati/ckati > ~/Desktop/out.txt ) Change-Id: Id5a075863151e37ec60e5d9dbeb817c2df245bc7
This commit is contained in:
@@ -46,15 +46,6 @@ public class ConfigBase {
|
|||||||
*/
|
*/
|
||||||
protected final TreeMap<String, VarType> mProductVars = new TreeMap();
|
protected final TreeMap<String, VarType> mProductVars = new TreeMap();
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether a product config variable is a list or single-value variable.
|
|
||||||
*/
|
|
||||||
public enum VarType {
|
|
||||||
LIST,
|
|
||||||
SINGLE,
|
|
||||||
UNKNOWN // For non-product vars
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPhase(String phase) {
|
public void setPhase(String phase) {
|
||||||
mPhase = phase;
|
mPhase = phase;
|
||||||
}
|
}
|
||||||
@@ -112,7 +103,7 @@ public class ConfigBase {
|
|||||||
public void copyFrom(ConfigBase that) {
|
public void copyFrom(ConfigBase that) {
|
||||||
setPhase(that.getPhase());
|
setPhase(that.getPhase());
|
||||||
setRootNodes(that.getRootNodes());
|
setRootNodes(that.getRootNodes());
|
||||||
for (Map.Entry<String, ConfigBase.VarType> entry: that.getProductVars().entrySet()) {
|
for (Map.Entry<String, VarType> entry: that.getProductVars().entrySet()) {
|
||||||
addProductVar(entry.getKey(), entry.getValue());
|
addProductVar(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
mInitialVariables = new HashMap(that.getInitialVariables());
|
mInitialVariables = new HashMap(that.getInitialVariables());
|
||||||
|
@@ -107,7 +107,7 @@ public class ConvertMakeToGenericConfig {
|
|||||||
* Converts one variable from a MakeConfig Block into a GenericConfig Assignment.
|
* Converts one variable from a MakeConfig Block into a GenericConfig Assignment.
|
||||||
*/
|
*/
|
||||||
GenericConfig.Assign convertAssignment(MakeConfig.BlockType blockType, Str inheritedFile,
|
GenericConfig.Assign convertAssignment(MakeConfig.BlockType blockType, Str inheritedFile,
|
||||||
ConfigBase.VarType varType, String varName, Str varVal, Str prevVal) {
|
VarType varType, String varName, Str varVal, Str prevVal) {
|
||||||
if (prevVal == null) {
|
if (prevVal == null) {
|
||||||
// New variable.
|
// New variable.
|
||||||
return new GenericConfig.Assign(varName, varVal);
|
return new GenericConfig.Assign(varName, varVal);
|
||||||
@@ -120,7 +120,7 @@ public class ConvertMakeToGenericConfig {
|
|||||||
// Product vars have the @inherit processing. Other vars we
|
// Product vars have the @inherit processing. Other vars we
|
||||||
// will just ignore and put in one section at the end, based
|
// will just ignore and put in one section at the end, based
|
||||||
// on the difference between the BEFORE and AFTER blocks.
|
// on the difference between the BEFORE and AFTER blocks.
|
||||||
if (varType == ConfigBase.VarType.UNKNOWN) {
|
if (varType == VarType.UNKNOWN) {
|
||||||
if (blockType == MakeConfig.BlockType.AFTER) {
|
if (blockType == MakeConfig.BlockType.AFTER) {
|
||||||
// For UNKNOWN variables, we don't worry about the
|
// For UNKNOWN variables, we don't worry about the
|
||||||
// intermediate steps, just take the final value.
|
// intermediate steps, just take the final value.
|
||||||
|
@@ -140,8 +140,7 @@ public class DumpConfigParser {
|
|||||||
System.out.println(" " + makeConfig.getRootNodes());
|
System.out.println(" " + makeConfig.getRootNodes());
|
||||||
}
|
}
|
||||||
} else if (matchLineType(line, "var", 2)) {
|
} else if (matchLineType(line, "var", 2)) {
|
||||||
final MakeConfig.VarType type = "list".equals(fields.get(1))
|
final VarType type = "list".equals(fields.get(1)) ? VarType.LIST : VarType.SINGLE;
|
||||||
? MakeConfig.VarType.LIST : MakeConfig.VarType.SINGLE;
|
|
||||||
makeConfig.addProductVar(fields.get(2), type);
|
makeConfig.addProductVar(fields.get(2), type);
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.build.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a product config variable is a list or single-value variable.
|
||||||
|
*/
|
||||||
|
public enum VarType {
|
||||||
|
/**
|
||||||
|
* A product config variable that is a list of space separated strings.
|
||||||
|
* These are defined by _product_single_value_vars in product.mk.
|
||||||
|
*/
|
||||||
|
LIST,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A product config varaible that is a single string.
|
||||||
|
* These are defined by _product_list_vars in product.mk.
|
||||||
|
*/
|
||||||
|
SINGLE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A variable that is given the special product config handling but is
|
||||||
|
* nonetheless defined by product config makefiles.
|
||||||
|
*/
|
||||||
|
UNKNOWN
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user