From: wuyizhong Date: Mon, 4 Sep 2006 03:49:31 +0000 (+0000) Subject: Add thread control classes. (2) X-Git-Tag: edk2-stable201903~24441 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=19bf6b15d0dd0a61a0835714c09a4e707e7cd518 Add thread control classes. (2) git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1433 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java b/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java index 66ad11ab55..ed94da38ed 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java +++ b/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java @@ -84,12 +84,6 @@ public class FfsProcess { /// 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; otherwise return false. @@ -121,9 +115,8 @@ public class FfsProcess { // // Try to find Ffs layout from FPD file // - saq.push(GlobalData.getFpdBuildOptions()); + SurfaceAreaQuery saq = new SurfaceAreaQuery(GlobalData.getFpdBuildOptionsMap()); BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = saq.getFpdFfs(); - saq.pop(); for (int i = 0; i < ffsArray.length; i++) { if (isMatch(ffsArray[i].getFfsKey(), buildType)) { ffsXmlObject = ffsArray[i]; diff --git a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java index dc12f6e23e..07da77c2bc 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java @@ -23,6 +23,7 @@ import java.util.Set; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; +import org.tianocore.build.fpd.FpdParserForThread; import org.tianocore.build.fpd.FpdParserTask; import org.tianocore.build.global.GlobalData; import org.tianocore.build.global.PropertyManager; @@ -81,6 +82,16 @@ public class FrameworkBuildTask extends Task{ 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 /// @@ -175,6 +186,19 @@ public class FrameworkBuildTask extends Task{ // if (buildFile.getName().endsWith(ToolDefinitions.FPD_EXTENSION)) { 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.setType(type); fpdParserTask.setProject(getProject()); @@ -330,6 +354,23 @@ public class FrameworkBuildTask extends Task{ } 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) { throw new BuildException(ex.getMessage()); diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java index c5fb00b3e0..6230477445 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java @@ -97,7 +97,9 @@ public class GenBuildTask extends Ant { /// Module surface area file. /// File msaFile; - + + public ModuleIdentification parentId; + private String type = "all"; /// @@ -783,5 +785,10 @@ public class GenBuildTask extends Ant { .replaceFirst("IA32", "Ia32") .replaceFirst("ARM", "Arm") .replaceFirst("EBC", "Ebc"); - } + } + + + public void setExternalProperties(Vector v) { + this.properties = v; + } } diff --git a/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java index 1bdae21245..122f04f3d3 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java +++ b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java @@ -91,7 +91,7 @@ public class ModuleBuildFileGenerator { Error throws during BaseName_build.xml generating. **/ public void genBuildFile(String buildFilename) throws BuildException { - FfsProcess fp = new FfsProcess(saq); + FfsProcess fp = new FfsProcess(); DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance(); try { DocumentBuilder dombuilder = domfac.newDocumentBuilder(); @@ -143,7 +143,9 @@ public class ModuleBuildFileGenerator { // // Parse all sourfiles but files specified in sections // - applyLibraryInstance(document, ele); + if (!FrameworkBuildTask.multithread) { + applyLibraryInstance(document, ele); + } root.appendChild(ele); // diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java index 8a90ea563d..c044856de3 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java @@ -77,19 +77,19 @@ public class FpdParserTask extends Task { private File fpdFile = null; - private PlatformIdentification platformId; + PlatformIdentification platformId; private String type; /// /// Mapping from modules identification to out put file name /// - private Map outfiles = new LinkedHashMap(); + Map outfiles = new LinkedHashMap(); /// /// Mapping from FV name to its modules /// - private Map> fvs = new HashMap>(); + Map> fvs = new HashMap>(); /// /// FpdParserTask can specify some ANT properties. @@ -98,7 +98,7 @@ public class FpdParserTask extends Task { SurfaceAreaQuery saq = null; - private boolean isUnified = true; + boolean isUnified = true; /** Public construct method. It is necessary for ANT task. @@ -195,7 +195,7 @@ public class FpdParserTask extends Task { @throws BuildException File write FV.inf files error. **/ - private void genFvInfFiles(String ffsCommonDir) throws BuildException { + void genFvInfFiles(String ffsCommonDir) throws BuildException { String[] validFv = saq.getFpdValidImageNames(); for (int i = 0; i < validFv.length; i++) { // @@ -318,7 +318,7 @@ public class FpdParserTask extends Task { @throws BuildException FPD file is not valid. **/ - private void parseFpdFile() throws BuildException { + void parseFpdFile() throws BuildException { try { XmlObject doc = XmlObject.Factory.parse(fpdFile); @@ -381,7 +381,7 @@ public class FpdParserTask extends Task { /** Parse all modules listed in FPD file. **/ - private void parseModuleSAFiles() throws EdkException{ + void parseModuleSAFiles() throws EdkException{ Map> 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); if (options == null || options.length == 0) { return new ToolChainMap(); @@ -475,7 +475,7 @@ public class FpdParserTask extends Task { @param fvName current FV name @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) { fvName = "NULL"; } diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java index 7e1e2c6852..45f36ee1fa 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java @@ -87,6 +87,8 @@ public class GlobalData { private static Map> fpdModuleSA= new HashMap>(); + private static Map fpdBuildOptionsMap = new HashMap(); + private static XmlObject fpdBuildOptions; private static XmlObject fpdDynamicPcds; @@ -416,14 +418,13 @@ public class GlobalData { } } - public static Map getFpdBuildOptions() { - Map map = new HashMap(); - map.put("BuildOptions", fpdBuildOptions); - return map; + public static Map getFpdBuildOptionsMap() { + return fpdBuildOptionsMap; } public static void setFpdBuildOptions(XmlObject fpdBuildOptions) { GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true); + fpdBuildOptionsMap.put("BuildOptions", GlobalData.fpdBuildOptions); } public static XmlObject getFpdDynamicPcds() { diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java b/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java index 4177b50466..6f845ea371 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java @@ -31,7 +31,7 @@ public class OnDependency extends Task { /// /// cache the modified timestamp of files accessed, to speed up the depencey check /// - private static Map timeStampCache = new HashMap(); + private Map timeStampCache = new HashMap(); /// /// source files list ///