Add thread control classes. (2)

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1433 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
wuyizhong 2006-09-04 03:49:31 +00:00
parent 534089527b
commit 19bf6b15d0
7 changed files with 70 additions and 26 deletions

View File

@ -84,12 +84,6 @@ public class FfsProcess {
/// ///
public static final String[][] sectionExt = EdkDefinitions.SectionTypeExtensions; public static final String[][] sectionExt = EdkDefinitions.SectionTypeExtensions;
private SurfaceAreaQuery saq = null;
public FfsProcess(SurfaceAreaQuery saq) {
this.saq = saq;
}
/** /**
search in the type, if componentType is listed in type, return true; search in the type, if componentType is listed in type, return true;
otherwise return false. otherwise return false.
@ -121,9 +115,8 @@ public class FfsProcess {
// //
// Try to find Ffs layout from FPD file // Try to find Ffs layout from FPD file
// //
saq.push(GlobalData.getFpdBuildOptions()); SurfaceAreaQuery saq = new SurfaceAreaQuery(GlobalData.getFpdBuildOptionsMap());
BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = saq.getFpdFfs(); BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = saq.getFpdFfs();
saq.pop();
for (int i = 0; i < ffsArray.length; i++) { for (int i = 0; i < ffsArray.length; i++) {
if (isMatch(ffsArray[i].getFfsKey(), buildType)) { if (isMatch(ffsArray[i].getFfsKey(), buildType)) {
ffsXmlObject = ffsArray[i]; ffsXmlObject = ffsArray[i];

View File

@ -23,6 +23,7 @@ import java.util.Set;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.tianocore.build.fpd.FpdParserForThread;
import org.tianocore.build.fpd.FpdParserTask; import org.tianocore.build.fpd.FpdParserTask;
import org.tianocore.build.global.GlobalData; import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.PropertyManager; import org.tianocore.build.global.PropertyManager;
@ -81,6 +82,16 @@ public class FrameworkBuildTask extends Task{
String activePlatform = null; String activePlatform = null;
///
/// The flag to present current is multi-thread enabled
///
public static boolean multithread = false;
///
/// The concurrent thread number
///
public static int MAX_CONCURRENT_THREAD_NUMBER = 1;
/// ///
/// there are three type: all (build), clean and cleanall /// there are three type: all (build), clean and cleanall
/// ///
@ -175,6 +186,19 @@ public class FrameworkBuildTask extends Task{
// //
if (buildFile.getName().endsWith(ToolDefinitions.FPD_EXTENSION)) { if (buildFile.getName().endsWith(ToolDefinitions.FPD_EXTENSION)) {
System.out.println("Processing the FPD file [" + buildFile.getPath() + "] ..>> "); System.out.println("Processing the FPD file [" + buildFile.getPath() + "] ..>> ");
//
// Iff for platform build will enable the multi-thread if set in target.txt
//
if (multithread && type.equalsIgnoreCase("all")) {
System.out.println("Multi-thread build is enabled. ");
FpdParserForThread fpdParserForThread = new FpdParserForThread();
fpdParserForThread.setType(type);
fpdParserForThread.setProject(getProject());
fpdParserForThread.setFpdFile(buildFile);
fpdParserForThread.execute();
return ;
}
FpdParserTask fpdParserTask = new FpdParserTask(); FpdParserTask fpdParserTask = new FpdParserTask();
fpdParserTask.setType(type); fpdParserTask.setType(type);
fpdParserTask.setProject(getProject()); fpdParserTask.setProject(getProject());
@ -330,6 +354,23 @@ public class FrameworkBuildTask extends Task{
} }
activePlatform = str; activePlatform = str;
} }
str = getValue("MULTIPLE_THREAD", targetFileInfo);
if (str != null && str.trim().equalsIgnoreCase("Enable")) {
multithread = true;
}
str = getValue("MAX_CONCURRENT_THREAD_NUMBER", targetFileInfo);
if (str != null ) {
try {
int threadNum = Integer.parseInt(str);
if (threadNum > 0) {
MAX_CONCURRENT_THREAD_NUMBER = threadNum;
}
} catch (Exception enuma) {
}
}
} }
catch (Exception ex) { catch (Exception ex) {
throw new BuildException(ex.getMessage()); throw new BuildException(ex.getMessage());

View File

@ -97,7 +97,9 @@ public class GenBuildTask extends Ant {
/// Module surface area file. /// Module surface area file.
/// ///
File msaFile; File msaFile;
public ModuleIdentification parentId;
private String type = "all"; private String type = "all";
/// ///
@ -783,5 +785,10 @@ public class GenBuildTask extends Ant {
.replaceFirst("IA32", "Ia32") .replaceFirst("IA32", "Ia32")
.replaceFirst("ARM", "Arm") .replaceFirst("ARM", "Arm")
.replaceFirst("EBC", "Ebc"); .replaceFirst("EBC", "Ebc");
} }
public void setExternalProperties(Vector<Property> v) {
this.properties = v;
}
} }

View File

@ -91,7 +91,7 @@ public class ModuleBuildFileGenerator {
Error throws during BaseName_build.xml generating. Error throws during BaseName_build.xml generating.
**/ **/
public void genBuildFile(String buildFilename) throws BuildException { public void genBuildFile(String buildFilename) throws BuildException {
FfsProcess fp = new FfsProcess(saq); FfsProcess fp = new FfsProcess();
DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
try { try {
DocumentBuilder dombuilder = domfac.newDocumentBuilder(); DocumentBuilder dombuilder = domfac.newDocumentBuilder();
@ -143,7 +143,9 @@ public class ModuleBuildFileGenerator {
// //
// Parse all sourfiles but files specified in sections // Parse all sourfiles but files specified in sections
// //
applyLibraryInstance(document, ele); if (!FrameworkBuildTask.multithread) {
applyLibraryInstance(document, ele);
}
root.appendChild(ele); root.appendChild(ele);
// //

View File

@ -77,19 +77,19 @@ public class FpdParserTask extends Task {
private File fpdFile = null; private File fpdFile = null;
private PlatformIdentification platformId; PlatformIdentification platformId;
private String type; private String type;
/// ///
/// Mapping from modules identification to out put file name /// Mapping from modules identification to out put file name
/// ///
private Map<FpdModuleIdentification, String> outfiles = new LinkedHashMap<FpdModuleIdentification, String>(); Map<FpdModuleIdentification, String> outfiles = new LinkedHashMap<FpdModuleIdentification, String>();
/// ///
/// Mapping from FV name to its modules /// Mapping from FV name to its modules
/// ///
private Map<String, Set<FpdModuleIdentification>> fvs = new HashMap<String, Set<FpdModuleIdentification>>(); Map<String, Set<FpdModuleIdentification>> fvs = new HashMap<String, Set<FpdModuleIdentification>>();
/// ///
/// FpdParserTask can specify some ANT properties. /// FpdParserTask can specify some ANT properties.
@ -98,7 +98,7 @@ public class FpdParserTask extends Task {
SurfaceAreaQuery saq = null; SurfaceAreaQuery saq = null;
private boolean isUnified = true; boolean isUnified = true;
/** /**
Public construct method. It is necessary for ANT task. Public construct method. It is necessary for ANT task.
@ -195,7 +195,7 @@ public class FpdParserTask extends Task {
@throws BuildException @throws BuildException
File write FV.inf files error. File write FV.inf files error.
**/ **/
private void genFvInfFiles(String ffsCommonDir) throws BuildException { void genFvInfFiles(String ffsCommonDir) throws BuildException {
String[] validFv = saq.getFpdValidImageNames(); String[] validFv = saq.getFpdValidImageNames();
for (int i = 0; i < validFv.length; i++) { for (int i = 0; i < validFv.length; i++) {
// //
@ -318,7 +318,7 @@ public class FpdParserTask extends Task {
@throws BuildException @throws BuildException
FPD file is not valid. FPD file is not valid.
**/ **/
private void parseFpdFile() throws BuildException { void parseFpdFile() throws BuildException {
try { try {
XmlObject doc = XmlObject.Factory.parse(fpdFile); XmlObject doc = XmlObject.Factory.parse(fpdFile);
@ -381,7 +381,7 @@ public class FpdParserTask extends Task {
/** /**
Parse all modules listed in FPD file. Parse all modules listed in FPD file.
**/ **/
private void parseModuleSAFiles() throws EdkException{ void parseModuleSAFiles() throws EdkException{
Map<FpdModuleIdentification, Map<String, XmlObject>> moduleSAs = saq.getFpdModules(); Map<FpdModuleIdentification, Map<String, XmlObject>> moduleSAs = saq.getFpdModules();
// //
@ -429,7 +429,7 @@ public class FpdParserTask extends Task {
} }
} }
private ToolChainMap parseModuleBuildOptions(boolean toolChainFamilyFlag) throws EdkException { ToolChainMap parseModuleBuildOptions(boolean toolChainFamilyFlag) throws EdkException {
String[][] options = saq.getModuleBuildOptions(toolChainFamilyFlag); String[][] options = saq.getModuleBuildOptions(toolChainFamilyFlag);
if (options == null || options.length == 0) { if (options == null || options.length == 0) {
return new ToolChainMap(); return new ToolChainMap();
@ -475,7 +475,7 @@ public class FpdParserTask extends Task {
@param fvName current FV name @param fvName current FV name
@param moduleName current module identification @param moduleName current module identification
**/ **/
private void updateFvs(String fvName, FpdModuleIdentification fpdModuleId) { void updateFvs(String fvName, FpdModuleIdentification fpdModuleId) {
if (fvName == null || fvName.trim().length() == 0) { if (fvName == null || fvName.trim().length() == 0) {
fvName = "NULL"; fvName = "NULL";
} }

View File

@ -87,6 +87,8 @@ public class GlobalData {
private static Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleSA= new HashMap<FpdModuleIdentification, Map<String, XmlObject>>(); private static Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleSA= new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();
private static Map<String, XmlObject> fpdBuildOptionsMap = new HashMap<String, XmlObject>();
private static XmlObject fpdBuildOptions; private static XmlObject fpdBuildOptions;
private static XmlObject fpdDynamicPcds; private static XmlObject fpdDynamicPcds;
@ -416,14 +418,13 @@ public class GlobalData {
} }
} }
public static Map<String, XmlObject> getFpdBuildOptions() { public static Map<String, XmlObject> getFpdBuildOptionsMap() {
Map<String, XmlObject> map = new HashMap<String, XmlObject>(); return fpdBuildOptionsMap;
map.put("BuildOptions", fpdBuildOptions);
return map;
} }
public static void setFpdBuildOptions(XmlObject fpdBuildOptions) { public static void setFpdBuildOptions(XmlObject fpdBuildOptions) {
GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true); GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);
fpdBuildOptionsMap.put("BuildOptions", GlobalData.fpdBuildOptions);
} }
public static XmlObject getFpdDynamicPcds() { public static XmlObject getFpdDynamicPcds() {

View File

@ -31,7 +31,7 @@ public class OnDependency extends Task {
/// ///
/// cache the modified timestamp of files accessed, to speed up the depencey check /// cache the modified timestamp of files accessed, to speed up the depencey check
/// ///
private static Map<String, Long> timeStampCache = new HashMap<String, Long>(); private Map<String, Long> timeStampCache = new HashMap<String, Long>();
/// ///
/// source files list /// source files list
/// ///