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 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
String setting = null;\r
\r
+ //\r
+ // Default in tools_def.txt\r
+ // \r
setting = toolChainConfig.get(toolChainKey);\r
if (setting == null) {\r
- setting = "";\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
- // get module specific options, if any\r
- //\r
- // tool tag first\r
- ToolChainMap option = moduleToolChainOption.get(fpdModuleId);\r
- ToolChainKey toolChainFamilyKey = null;\r
-\r
- if (option != null && option.get(toolChainKey) != null) \r
- {\r
- String str = option.get(toolChainKey);\r
-\r
- Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");\r
- Matcher matcher = myPattern.matcher(str + " ");\r
- while (matcher.find()) \r
- {\r
- setting = setting + " " + str.substring(matcher.start(1), matcher.end(1));\r
- }\r
- } \r
-// else \r
-// {\r
- if (toolChainFamilyKey == null) \r
- {\r
- toolChainFamilyKey = new ToolChainKey(commandDescription);\r
- toolChainFamilyKey.setKey(ToolChainAttribute.FAMILY.toString(), 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
- }\r
-\r
- option = moduleToolChainFamilyOption.get(fpdModuleId);\r
- if (option != null && option.get(toolChainFamilyKey) != null) \r
- {\r
- String str = option.get(toolChainFamilyKey);\r
-\r
- Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");\r
- Matcher matcher = myPattern.matcher(str + " ");\r
- while (matcher.find()) \r
- {\r
- setting = setting + " " + str.substring(matcher.start(1), matcher.end(1));\r
- }\r
- }\r
-// }\r
-\r
- //\r
- // get platform options, if any\r
- //\r
- // tool tag first\r
-// if (platformToolChainOption != null && platformToolChainOption.get(toolChainKey) != null) \r
- if (platformToolChainOption.get(toolChainKey) != null) \r
- {\r
- String str = platformToolChainOption.get(toolChainKey);\r
-\r
- Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");\r
- Matcher matcher = myPattern.matcher(str + " ");\r
- while (matcher.find()) \r
- {\r
- setting = setting + " " + str.substring(matcher.start(1), matcher.end(1));\r
- }\r
- } \r
-// else \r
-// {\r
- // then tool chain family\r
- if (toolChainFamilyKey == null) \r
- {\r
- toolChainFamilyKey = new ToolChainKey(commandDescription);\r
- toolChainFamilyKey.setKey(ToolChainAttribute.FAMILY.toString(), 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
- }\r
-\r
-// if (platformToolChainFamilyOption != null && platformToolChainFamilyOption.get(toolChainFamilyKey) != null) \r
- if (platformToolChainFamilyOption.get(toolChainFamilyKey) != null) \r
- {\r
- String str = platformToolChainFamilyOption.get(toolChainFamilyKey);\r
-\r
- setting = setting + " " + str;\r
-\r
-// Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");\r
-// Matcher matcher = myPattern.matcher(str + " ");\r
-// while (matcher.find()) \r
-// {\r
-// setting = setting + " " + str.substring(matcher.start(1), matcher.end(1));\r
-// }\r
- }\r
-// }\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
- return setting;\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(ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS, ToolChainElement.ATTRIBUTE.value);\r
\r
-/*\r
//\r
- // get module specific options, if any\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
- // tool tag first\r
- ToolChainMap option = moduleToolChainOption.get(fpdModuleId);\r
- ToolChainKey toolChainFamilyKey = null;\r
+ option = msaBuildOption.get(fpdModuleId.getModule());\r
+ if (option != null && (optionString = option.get(toolChainKey)) != null) {\r
+ setting += (" " + optionString);\r
+ }\r
\r
- if ((option == null) || (option != null && (setting = option.get(toolChainKey)) == null)) \r
- {\r
- //\r
- // then tool chain family\r
- //\r
- toolChainFamilyKey = new ToolChainKey(commandDescription);\r
- toolChainFamilyKey.setKey(ToolChainAttribute.FAMILY.toString(), 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
-\r
- option = moduleToolChainFamilyOption.get(fpdModuleId);\r
- if (option != null) {\r
- setting = option.get(toolChainFamilyKey);\r
- }\r
+ //\r
+ // Platform's tool chain family option\r
+ //\r
+ optionString = platformToolChainFamilyOption.get(toolChainFamilyKey);\r
+ if (optionString != null) {\r
+ setting += (" " + optionString);\r
}\r
\r
//\r
- // get platform options, if any\r
+ // Platform's tool chain tag option\r
//\r
- if (setting == null) {\r
- // tool tag first\r
- if (platformToolChainOption == null || (setting = platformToolChainOption.get(toolChainKey)) == null) {\r
- // then tool chain family\r
- if (toolChainFamilyKey == null) {\r
- toolChainFamilyKey = new ToolChainKey(commandDescription);\r
- toolChainFamilyKey.setKey(ToolChainAttribute.FAMILY.toString(), 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
- }\r
+ optionString = platformToolChainOption.get(toolChainKey);\r
+ if (optionString != null) {\r
+ setting += (" " + optionString);\r
+ }\r
\r
- setting = platformToolChainFamilyOption.get(toolChainFamilyKey);\r
- }\r
+ //\r
+ // Module's tool chain family option\r
+ //\r
+ option = moduleToolChainFamilyOption.get(fpdModuleId);\r
+ if (option != null && (optionString = option.get(toolChainFamilyKey)) != null) {\r
+ setting += (" " + optionString);\r
}\r
\r
- if (setting == null) {\r
- setting = "";\r
+ //\r
+ // Module's tool chain tag option\r
+ //\r
+ option = moduleToolChainOption.get(fpdModuleId);\r
+ if (option != null && (optionString = option.get(toolChainKey)) != null) {\r
+ setting += (" " + optionString);\r
}\r
\r
return setting;\r
-*/\r
}\r
\r
public static void setToolChainEnvInfo(ToolChainInfo envInfo) {\r