diff options
author | wuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-10-18 08:22:09 +0000 |
---|---|---|
committer | wuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-10-18 08:22:09 +0000 |
commit | b69bb9ba72ebb7341bce97eec1a499d8258a3272 (patch) | |
tree | 082b1e1b1e4c3cafc90649de85349180a1114943 /Tools | |
parent | 01022d98b31e5e6906d80dfe2b7795e1e1758082 (diff) | |
download | edk2-b69bb9ba72ebb7341bce97eec1a499d8258a3272.zip edk2-b69bb9ba72ebb7341bce97eec1a499d8258a3272.tar.gz edk2-b69bb9ba72ebb7341bce97eec1a499d8258a3272.tar.bz2 |
Support MSA build options. Now the build options from four places: 1. tools_def.txt
2. MSA <ModuleBuildOptions>/<Options> 3. FPD <BuildOptions>/<Options> 4. FPD <FrameworkModules>/<ModuleSaBuildOptions>/<Options>. And we do not support "ABC", "XYZ" such format from now on, please only use the simple format like ABC XYZ.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1790 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
7 files changed, 94 insertions, 77 deletions
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java index 9a84717..389b8f1 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java @@ -23,8 +23,6 @@ import java.util.List; import java.util.Map;
import java.util.Set;
import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener;
@@ -490,10 +488,6 @@ public class GenBuildTask extends Ant { String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId);
if (cmdFlags != null)
{
-// Set<String> addset = new LinkedHashSet<String>();
-// Set<String> subset = new LinkedHashSet<String>();
-// putFlagsToSet(addset, cmdFlags);
-// getProject().setProperty(cmd[m] + "_FLAGS", getProject().replaceProperties(getFlags(addset, subset)));
getProject().setProperty(cmd[m] + "_FLAGS", cmdFlags);
}
else
@@ -501,7 +495,6 @@ public class GenBuildTask extends Ant { getProject().setProperty(cmd[m] + "_FLAGS", "");
}
-
//
// Set CC_EXT
//
@@ -718,54 +711,6 @@ public class GenBuildTask extends Ant { ant.execute();
}
-
- /**
- Separate the string and instore in set.
-
- <p> String is separated by Java Regulation Expression
- "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+". </p>
-
- <p>For example: </p>
-
- <pre>
- "/nologo", "/W3", "/WX"
- "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
- </pre>
-
- @param set store the separated string
- @param str string to separate
- **/
- private void putFlagsToSet(Set<String> set, String str) {
- if (str == null || str.length() == 0) {
- return;
- }
-
- Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
- Matcher matcher = myPattern.matcher(str + " ");
- while (matcher.find()) {
- String item = str.substring(matcher.start(1), matcher.end(1));
- set.add(item);
- }
- }
-
- /**
- Generate the final flags string will be used by compile command.
-
- @param add the add flags set
- @param sub the sub flags set
- @return final flags after add set substract sub set
- **/
- private String getFlags(Set<String> add, Set<String> sub) {
- String result = "";
- add.removeAll(sub);
- Iterator iter = add.iterator();
- while (iter.hasNext()) {
- String str = (String) iter.next();
- result += str.substring(1, str.length() - 1) + " ";
- }
- return result;
- }
-
public void setSingleModuleBuild(boolean isSingleModuleBuild) {
this.isSingleModuleBuild = isSingleModuleBuild;
}
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java index 93510a7..a2f22c1 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java @@ -368,6 +368,13 @@ public class FpdParserForThread extends FpdParserTask { //
GlobalData.addModuleToolChainOption(fpdModuleId, parseModuleBuildOptions(false));
GlobalData.addModuleToolChainFamilyOption(fpdModuleId, parseModuleBuildOptions(true));
+
+ //
+ // parse MSA build options
+ //
+ GlobalData.addMsaBuildOption(moduleId, parseMsaBuildOptions(false));
+ GlobalData.addMsaFamilyBuildOption(moduleId, parseMsaBuildOptions(true));
+
saq.pop();
}
}
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java index d45abcd..2837979 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java @@ -516,6 +516,13 @@ public class FpdParserTask extends Task { //
GlobalData.addModuleToolChainOption(fpdModuleId, parseModuleBuildOptions(false));
GlobalData.addModuleToolChainFamilyOption(fpdModuleId, parseModuleBuildOptions(true));
+
+ //
+ // parse MSA build options
+ //
+ GlobalData.addMsaBuildOption(moduleId, parseMsaBuildOptions(false));
+ GlobalData.addMsaFamilyBuildOption(moduleId, parseMsaBuildOptions(true));
+
saq.pop();
}
}
@@ -536,6 +543,14 @@ public class FpdParserTask extends Task { return parseOptions(options);
}
+ ToolChainMap parseMsaBuildOptions(boolean toolChainFamilyFlag) throws EdkException {
+ String[][] options = saq.getMsaBuildOptions(toolChainFamilyFlag);
+ if (options == null || options.length == 0) {
+ return new ToolChainMap();
+ }
+ return parseOptions(options);
+ }
+
private ToolChainMap parseOptions(String[][] options) throws EdkException {
ToolChainMap map = new ToolChainMap();
int flagIndex = ToolChainElement.ATTRIBUTE.value;
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java index 18ef849..b1e119a 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java @@ -46,11 +46,6 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod { Project project = null;
///
- /// Time of the start of the build
- ///
- private long startTime = System.currentTimeMillis();
-
- ///
/// flag to present whether cache all msg or not
/// true means to cache.
///
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/GlobalData.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/GlobalData.java index 310381b..bf4cd43 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/GlobalData.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/global/GlobalData.java @@ -24,8 +24,6 @@ import java.util.Iterator; import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
@@ -132,7 +130,10 @@ public class GlobalData { private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainOption = new HashMap<FpdModuleIdentification, ToolChainMap>();
private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainFamilyOption = new HashMap<FpdModuleIdentification, ToolChainMap>();
- private static Pattern flagPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
+ private static Map<ModuleIdentification, ToolChainMap> msaBuildOption = new HashMap<ModuleIdentification, ToolChainMap>();
+ private static Map<ModuleIdentification, ToolChainMap> msaFamilyBuildOption = new HashMap<ModuleIdentification, ToolChainMap>();
+
+// private static Pattern flagPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
/**
Parse framework database (DB) and all SPD files listed in DB to initialize
the environment for next build. This method will only be executed only once
@@ -437,6 +438,7 @@ public class GlobalData { msaMap.put("Guids", cloneXmlObject(msa.getGuids(), true));
msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true));
msaMap.put("PcdCoded", cloneXmlObject(msa.getPcdCoded(), true));
+ msaMap.put("ModuleBuildOptions", cloneXmlObject(msa.getModuleBuildOptions(), true));
return msaMap;
} catch(IOException ex) {
EdkException edkException = new EdkException("Parsing MSA file [" + msaFile.getPath() + "] error. \n" + ex.getMessage());
@@ -715,7 +717,17 @@ public class GlobalData { ToolChainMap toolChainOption) {
moduleToolChainFamilyOption.put(fpdModuleId, toolChainOption);
}
-
+
+ public static void addMsaBuildOption(ModuleIdentification moduleId,
+ ToolChainMap toolChainOption) {
+ msaBuildOption.put(moduleId, toolChainOption);
+ }
+
+ public static void addMsaFamilyBuildOption(ModuleIdentification moduleId,
+ ToolChainMap toolChainOption) {
+ msaFamilyBuildOption.put(moduleId, toolChainOption);
+ }
+
public static boolean isCommandSet(String target, String toolchain, String arch) {
String[] commands = getToolChainInfo().getCommands();
@@ -729,6 +741,22 @@ public class GlobalData { return false;
}
+ /**
+ Except FLAGS, all attribute are from TOOLS_DEF file.
+
+ For FLAGS, information from four places, they are:
+ <pre>
+ 1. tools_def.txt
+ 2. MSA <BuildOptions>/<Options>
+ 3. FPD <BuildOptions>/<Options>
+ 4. FPD <FrameworkModules>/<ModuleSaBuildOptions>/<Options>
+ </pre>
+
+ @param commandDescription Key: TARGET, TAGNAME, ARCH, COMMANDTYPE, ATTRIBUTE
+ @param fpdModuleId Module Identification with Arch
+ @return The corresponding String
+ @throws EdkException If build option definition error
+ **/
public synchronized static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException {
ToolChainKey toolChainKey = new ToolChainKey(commandDescription);
ToolChainMap toolChainConfig = toolsDef.getConfig();
@@ -746,7 +774,7 @@ public class GlobalData { }
//
- // tool's option can be in .fpd and/or .msa file
+ // Tool's option can be in .fpd and/or .msa file
//
String optionString;
ToolChainMap option = null;
@@ -758,6 +786,22 @@ public class GlobalData { toolChainFamilyKey.setKey(ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS, ToolChainElement.ATTRIBUTE.value);
//
+ // MSA's tool chain family option
+ //
+ option = msaFamilyBuildOption.get(fpdModuleId.getModule());
+ if (option != null && (optionString = option.get(toolChainFamilyKey)) != null) {
+ setting += (" " + optionString);
+ }
+
+ //
+ // MSA's tool chain option
+ //
+ option = msaBuildOption.get(fpdModuleId.getModule());
+ if (option != null && (optionString = option.get(toolChainKey)) != null) {
+ setting += (" " + optionString);
+ }
+
+ //
// Platform's tool chain family option
//
optionString = platformToolChainFamilyOption.get(toolChainFamilyKey);
@@ -770,10 +814,7 @@ public class GlobalData { //
optionString = platformToolChainOption.get(toolChainKey);
if (optionString != null) {
- Matcher matcher = flagPattern.matcher(optionString + " ");
- while (matcher.find()) {
- setting += (" " + optionString.substring(matcher.start(1), matcher.end(1)));
- }
+ setting += (" " + optionString);
}
//
@@ -781,10 +822,7 @@ public class GlobalData { //
option = moduleToolChainFamilyOption.get(fpdModuleId);
if (option != null && (optionString = option.get(toolChainFamilyKey)) != null) {
- Matcher matcher = flagPattern.matcher(optionString + " ");
- while (matcher.find()) {
- setting += (" " + optionString.substring(matcher.start(1), matcher.end(1)));
- }
+ setting += (" " + optionString);
}
//
@@ -792,10 +830,7 @@ public class GlobalData { //
option = moduleToolChainOption.get(fpdModuleId);
if (option != null && (optionString = option.get(toolChainKey)) != null) {
- Matcher matcher = flagPattern.matcher(optionString + " ");
- while (matcher.find()) {
- setting += (" " + optionString.substring(matcher.start(1), matcher.end(1)));
- }
+ setting += (" " + optionString);
}
return setting;
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java index 6afeb30..b927560 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java @@ -492,6 +492,22 @@ public class SurfaceAreaQuery { return getOptions("PlatformSurfaceArea", xPath, toolChainFamilyFlag);
}
+
+ public String[][] getMsaBuildOptions(boolean toolChainFamilyFlag) {
+ String[] xPath;
+
+ if (toolChainFamilyFlag == true) {
+ xPath = new String[] {
+ "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
+ "/Options/Option[@ToolChainFamily]", };
+ } else {
+ xPath = new String[] {
+ "/Options/Option[not(@ToolChainFamily) and not(@TagName)]",
+ "/Options/Option[@TagName]", };
+ }
+
+ return getOptions("ModuleBuildOptions", xPath, toolChainFamilyFlag);
+ }
public ToolChainInfo getFpdToolChainInfo() {
String[] xPath = new String[] { "/PlatformDefinitions" };
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java b/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java index f3f0779..18e664c 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java @@ -320,5 +320,9 @@ public class ToolChainMap { public Set<ToolChainKey> keySet() {
return (Set<ToolChainKey>)map.keySet();
}
+
+ public String toString() {
+ return map + "";
+ }
}
|