import java.util.List;\r
import java.util.Map;\r
import java.util.Set;\r
-import java.util.regex.Matcher;\r
-import java.util.regex.Pattern;\r
\r
import org.apache.xmlbeans.XmlException;\r
import org.apache.xmlbeans.XmlObject;\r
\r
+import org.tianocore.common.definitions.ToolDefinitions;\r
import org.tianocore.common.exception.EdkException;\r
import org.tianocore.common.logger.EdkLog;\r
import org.tianocore.pcd.entity.MemoryDatabaseManager;\r
import org.tianocore.build.id.ModuleIdentification;\r
import org.tianocore.build.id.PackageIdentification;\r
import org.tianocore.build.id.PlatformIdentification;\r
-import org.tianocore.build.toolchain.ToolChainAttribute;\r
import org.tianocore.build.toolchain.ToolChainConfig;\r
import org.tianocore.build.toolchain.ToolChainElement;\r
import org.tianocore.build.toolchain.ToolChainInfo;\r
private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainOption = new HashMap<FpdModuleIdentification, ToolChainMap>();\r
private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainFamilyOption = new HashMap<FpdModuleIdentification, ToolChainMap>();\r
\r
- private static Pattern flagPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");\r
+ private static Map<ModuleIdentification, ToolChainMap> msaBuildOption = new HashMap<ModuleIdentification, ToolChainMap>();\r
+ private static Map<ModuleIdentification, ToolChainMap> msaFamilyBuildOption = new HashMap<ModuleIdentification, ToolChainMap>();\r
+\r
+// private static Pattern flagPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");\r
/**\r
Parse framework database (DB) and all SPD files listed in DB to initialize\r
the environment for next build. This method will only be executed only once\r
msaMap.put("Guids", cloneXmlObject(msa.getGuids(), true));\r
msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true));\r
msaMap.put("PcdCoded", cloneXmlObject(msa.getPcdCoded(), true));\r
+ msaMap.put("ModuleBuildOptions", cloneXmlObject(msa.getModuleBuildOptions(), true));\r
return msaMap;\r
} catch(IOException ex) {\r
EdkException edkException = new EdkException("Parsing MSA file [" + msaFile.getPath() + "] error. \n" + ex.getMessage());\r
ToolChainMap toolChainOption) {\r
moduleToolChainFamilyOption.put(fpdModuleId, toolChainOption);\r
}\r
-\r
+ \r
+ public static void addMsaBuildOption(ModuleIdentification moduleId,\r
+ ToolChainMap toolChainOption) {\r
+ msaBuildOption.put(moduleId, toolChainOption);\r
+ }\r
+ \r
+ public static void addMsaFamilyBuildOption(ModuleIdentification moduleId,\r
+ ToolChainMap toolChainOption) {\r
+ msaFamilyBuildOption.put(moduleId, toolChainOption);\r
+ }\r
+ \r
public static boolean isCommandSet(String target, String toolchain, String arch) {\r
String[] commands = getToolChainInfo().getCommands();\r
\r
for (int i = 0; i < commands.length; ++i) {\r
- String cmdName = toolsDef.getConfig().get(new String[] {target, toolchain, arch, commands[i], ToolChainAttribute.NAME.toString()});\r
+ String cmdName = toolsDef.getConfig().get(new String[] {target, toolchain, arch, commands[i], ToolDefinitions.TOOLS_DEF_ATTRIBUTE_NAME});\r
if (cmdName != null && cmdName.length() != 0) {\r
return true;\r
}\r
return false;\r
}\r
\r
+ /**\r
+ Except FLAGS, all attribute are from TOOLS_DEF file. \r
+ \r
+ For FLAGS, information from four places, they are: \r
+ <pre>\r
+ 1. tools_def.txt\r
+ 2. MSA <BuildOptions>/<Options>\r
+ 3. FPD <BuildOptions>/<Options>\r
+ 4. FPD <FrameworkModules>/<ModuleSaBuildOptions>/<Options>\r
+ </pre>\r
+ \r
+ @param commandDescription Key: TARGET, TAGNAME, ARCH, COMMANDTYPE, ATTRIBUTE\r
+ @param fpdModuleId Module Identification with Arch\r
+ @return The corresponding String\r
+ @throws EdkException If build option definition error\r
+ **/\r
public synchronized static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException {\r
ToolChainKey toolChainKey = new ToolChainKey(commandDescription);\r
ToolChainMap toolChainConfig = toolsDef.getConfig();\r
if (setting == null) {\r
setting = "";\r
}\r
- if (!commandDescription[ToolChainElement.ATTRIBUTE.value].equals(ToolChainAttribute.FLAGS.toString())) {\r
+ if (!commandDescription[ToolChainElement.ATTRIBUTE.value].equals(ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS)) {\r
return setting;\r
}\r
\r
//\r
- // tool's option can be in .fpd and/or .msa file\r
+ // Tool's option can be in .fpd and/or .msa file\r
//\r
String optionString;\r
ToolChainMap option = null;\r
ToolChainKey toolChainFamilyKey = new ToolChainKey(commandDescription);\r
\r
- toolChainFamilyKey.setKey(ToolChainAttribute.FAMILY.toString(), ToolChainElement.ATTRIBUTE.value);\r
+ toolChainFamilyKey.setKey(ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FAMILY, ToolChainElement.ATTRIBUTE.value);\r
String family = toolChainConfig.get(toolChainFamilyKey);\r
toolChainFamilyKey.setKey(family, ToolChainElement.TOOLCHAIN.value);\r
- toolChainFamilyKey.setKey(ToolChainAttribute.FLAGS.toString(), ToolChainElement.ATTRIBUTE.value);\r
+ toolChainFamilyKey.setKey(ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS, ToolChainElement.ATTRIBUTE.value);\r
\r
+ //\r
+ // MSA's tool chain family option\r
+ //\r
+ option = msaFamilyBuildOption.get(fpdModuleId.getModule());\r
+ if (option != null && (optionString = option.get(toolChainFamilyKey)) != null) {\r
+ setting += (" " + optionString);\r
+ }\r
+ \r
+ //\r
+ // MSA's tool chain option\r
+ //\r
+ option = msaBuildOption.get(fpdModuleId.getModule());\r
+ if (option != null && (optionString = option.get(toolChainKey)) != null) {\r
+ setting += (" " + optionString);\r
+ }\r
+ \r
//\r
// Platform's tool chain family option\r
//\r
//\r
optionString = platformToolChainOption.get(toolChainKey);\r
if (optionString != null) {\r
- Matcher matcher = flagPattern.matcher(optionString + " ");\r
- while (matcher.find()) {\r
- setting += (" " + optionString.substring(matcher.start(1), matcher.end(1)));\r
- }\r
+ setting += (" " + optionString);\r
}\r
\r
//\r
//\r
option = moduleToolChainFamilyOption.get(fpdModuleId);\r
if (option != null && (optionString = option.get(toolChainFamilyKey)) != null) {\r
- Matcher matcher = flagPattern.matcher(optionString + " ");\r
- while (matcher.find()) {\r
- setting += (" " + optionString.substring(matcher.start(1), matcher.end(1)));\r
- }\r
+ setting += (" " + optionString);\r
}\r
\r
//\r
//\r
option = moduleToolChainOption.get(fpdModuleId);\r
if (option != null && (optionString = option.get(toolChainKey)) != null) {\r
- Matcher matcher = flagPattern.matcher(optionString + " ");\r
- while (matcher.find()) {\r
- setting += (" " + optionString.substring(matcher.start(1), matcher.end(1)));\r
- }\r
+ setting += (" " + optionString);\r
}\r
\r
return setting;\r