X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2FGenBuildTask.java;h=9b6251a0a26ae57a368f3ec9c88d096bd261da6e;hb=91f7d582299ddc08babbff1624df3fd136a37ee9;hp=7ec12b042721d9f6c1403c7c65d443e882e8d4e3;hpb=0719317158cadc33959fdce23537456bc6de66eb;p=mirror_edk2.git diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java index 7ec12b0427..9b6251a0a2 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java @@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. package org.tianocore.build; import java.io.File; +import java.util.Hashtable; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; @@ -26,6 +27,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildListener; +import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Ant; import org.apache.tools.ant.taskdefs.Property; import org.apache.xmlbeans.XmlObject; @@ -35,10 +38,8 @@ import org.tianocore.common.exception.EdkException; import org.tianocore.common.logger.EdkLog; import org.tianocore.build.autogen.AutoGen; import org.tianocore.build.fpd.FpdParserTask; -import org.tianocore.build.global.GenBuildLogger; import org.tianocore.build.global.GlobalData; import org.tianocore.build.global.OutputManager; -import org.tianocore.build.global.PropertyManager; import org.tianocore.build.global.SurfaceAreaQuery; import org.tianocore.build.id.FpdModuleIdentification; import org.tianocore.build.id.ModuleIdentification; @@ -97,7 +98,9 @@ public class GenBuildTask extends Ant { /// Module surface area file. /// File msaFile; - + + public ModuleIdentification parentId; + private String type = "all"; /// @@ -108,6 +111,8 @@ public class GenBuildTask extends Ant { private Vector properties = new Vector(); private boolean isSingleModuleBuild = false; + + private SurfaceAreaQuery saq = null; /** Public construct method. It is necessary for ANT task. @@ -121,22 +126,17 @@ public class GenBuildTask extends Ant { From module build, exception from module surface area invalid. **/ public void execute() throws BuildException { - // - // set Logger - // - GenBuildLogger logger = new GenBuildLogger(getProject()); - EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL")); - EdkLog.setLogger(logger); + if (!FrameworkBuildTask.multithread) { + cleanupProperties(); + } - PropertyManager.setProject(getProject()); - PropertyManager.save(); // // Enable all specified properties // Iterator iter = properties.iterator(); while (iter.hasNext()) { Property item = iter.next(); - PropertyManager.setProperty(item.getName(), item.getValue()); + getProject().setProperty(item.getName(), item.getValue()); } // @@ -154,14 +154,14 @@ public class GenBuildTask extends Ant { moduleId = new ModuleIdentification(moduleGuid, moduleVersion); moduleId.setPackage(packageId); Map doc = GlobalData.getNativeMsa(moduleId); - SurfaceAreaQuery.setDoc(doc); - moduleId = SurfaceAreaQuery.getMsaHeader(); + saq = new SurfaceAreaQuery(doc); + moduleId = saq.getMsaHeader(); } else { Map doc = GlobalData.getNativeMsa(msaFile); - SurfaceAreaQuery.setDoc(doc); - moduleId = SurfaceAreaQuery.getMsaHeader(); + saq = new SurfaceAreaQuery(doc); + moduleId = saq.getMsaHeader(); } - String[] producedLibraryClasses = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED",null); + String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED",null); if (producedLibraryClasses.length == 0) { moduleId.setLibrary(false); } else { @@ -177,14 +177,6 @@ public class GenBuildTask extends Ant { // prepareSingleModuleBuild(); } else { - // - // Platform build. Restore the platform related info - // - String filename = getProject().getProperty("PLATFORM_FILE"); - PlatformIdentification platformId = GlobalData.getPlatform(filename); - PropertyManager.setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/")); - PropertyManager.setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/")); - String packageGuid = getProject().getProperty("PACKAGE_GUID"); String packageVersion = getProject().getProperty("PACKAGE_VERSION"); PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion); @@ -221,7 +213,7 @@ public class GenBuildTask extends Ant { // // Judge if arch is all supported by current module. If not, throw Exception. // - List moduleSupportedArchs = SurfaceAreaQuery.getModuleSupportedArchs(); + List moduleSupportedArchs = saq.getModuleSupportedArchs(); if (moduleSupportedArchs != null) { for (int k = 0; k < archList.length; k++) { if ( ! moduleSupportedArchs.contains(archList[k])) { @@ -232,7 +224,7 @@ public class GenBuildTask extends Ant { for (int k = 0; k < archList.length; k++) { - PropertyManager.setProperty("ARCH", archList[k]); + getProject().setProperty("ARCH", archList[k]); FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, archList[k]); @@ -240,7 +232,7 @@ public class GenBuildTask extends Ant { // Whether the module is built before // if (moduleId.isLibrary() == false && GlobalData.hasFpdModuleSA(fpdModuleId) == false) { - System.out.println("\nWARNING: " + moduleId + " for " + archList[k] + " was not found in current platform FPD file!\n"); + EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: " + moduleId + " for " + archList[k] + " was not found in current platform FPD file!\n"); continue; } else if (GlobalData.isModuleBuilt(fpdModuleId)) { break; @@ -257,7 +249,7 @@ public class GenBuildTask extends Ant { // Prepare for target related common properties // TARGET // - PropertyManager.setProperty("TARGET", targetList[i]); + getProject().setProperty("TARGET", targetList[i]); String[] toolchainList = GlobalData.getToolChainInfo().getTagnames(); for(int j = 0; j < toolchainList.length; j ++){ // @@ -265,7 +257,7 @@ public class GenBuildTask extends Ant { // don't do anything if no tools found // if (GlobalData.isCommandSet(targetList[i], toolchainList[j], archList[k]) == false) { - System.out.println("Warning: No build issued. No tools were found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n"); + EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: No build issued. No tools were found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n"); continue; } @@ -273,11 +265,11 @@ public class GenBuildTask extends Ant { // Prepare for toolchain related common properties // TOOLCHAIN // - PropertyManager.setProperty("TOOLCHAIN", toolchainList[j]); + getProject().setProperty("TOOLCHAIN", toolchainList[j]); - System.out.println("Build " + moduleId + " start >>>"); - System.out.println("Target: " + targetList[i] + " Tagname: " + toolchainList[j] + " Arch: " + archList[k]); - SurfaceAreaQuery.setDoc(GlobalData.getDoc(fpdModuleId)); + EdkLog.log(this, "Build " + moduleId + " start >>>"); + EdkLog.log(this, "Target: " + targetList[i] + " Tagname: " + toolchainList[j] + " Arch: " + archList[k]); + saq.push(GlobalData.getDoc(fpdModuleId)); // // Prepare for all other common properties @@ -304,8 +296,6 @@ public class GenBuildTask extends Ant { } } } - - PropertyManager.restore(); } /** @@ -343,17 +333,30 @@ public class GenBuildTask extends Ant { FpdParserTask fpdParser = new FpdParserTask(); fpdParser.setProject(getProject()); fpdParser.parseFpdFile(platformId.getFpdFile()); - PropertyManager.setProperty("ARCH", fpdParser.getAllArchForModule(moduleId)); - - // - // Prepare for Platform related common properties - // PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR - // - PropertyManager.setProperty("PLATFORM", platformId.getName()); - PropertyManager.setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/")); - PropertyManager.setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/")); + getProject().setProperty("ARCH", fpdParser.getAllArchForModule(moduleId)); } + private void cleanupProperties() { + Project newProject = new Project(); + + Hashtable passdownProperties = FrameworkBuildTask.originalProperties; + Iterator iter = passdownProperties.keySet().iterator(); + while (iter.hasNext()) { + String item = iter.next(); + newProject.setProperty(item, passdownProperties.get(item)); + } + + newProject.setInputHandler(getProject().getInputHandler()); + + Iterator listenerIter = getProject().getBuildListeners().iterator(); + while (listenerIter.hasNext()) { + newProject.addBuildListener((BuildListener) listenerIter.next()); + } + + getProject().initSubProject(newProject); + + setProject(newProject); + } /** Set Module-Related information to properties. @@ -366,29 +369,29 @@ public class GenBuildTask extends Ant { // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR // PackageIdentification packageId = moduleId.getPackage(); - PropertyManager.setProperty("PACKAGE", packageId.getName()); - PropertyManager.setProperty("PACKAGE_GUID", packageId.getGuid()); - PropertyManager.setProperty("PACKAGE_VERSION", packageId.getVersion()); - PropertyManager.setProperty("PACKAGE_DIR", packageId.getPackageDir().replaceAll("(\\\\)", "/")); - PropertyManager.setProperty("PACKAGE_RELATIVE_DIR", packageId.getPackageRelativeDir().replaceAll("(\\\\)", "/")); + getProject().setProperty("PACKAGE", packageId.getName()); + getProject().setProperty("PACKAGE_GUID", packageId.getGuid()); + getProject().setProperty("PACKAGE_VERSION", packageId.getVersion()); + getProject().setProperty("PACKAGE_DIR", packageId.getPackageDir().replaceAll("(\\\\)", "/")); + getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId.getPackageRelativeDir().replaceAll("(\\\\)", "/")); // // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE // MODULE_DIR, MODULE_RELATIVE_DIR // - PropertyManager.setProperty("MODULE", moduleId.getName()); - String baseName = SurfaceAreaQuery.getModuleOutputFileBasename(); + getProject().setProperty("MODULE", moduleId.getName()); + String baseName = saq.getModuleOutputFileBasename(); if (baseName == null) { - PropertyManager.setProperty("BASE_NAME", moduleId.getName()); + getProject().setProperty("BASE_NAME", moduleId.getName()); } else { - PropertyManager.setProperty("BASE_NAME", baseName); + getProject().setProperty("BASE_NAME", baseName); } - PropertyManager.setProperty("GUID", moduleId.getGuid()); - PropertyManager.setProperty("FILE_GUID", moduleId.getGuid()); - PropertyManager.setProperty("VERSION", moduleId.getVersion()); - PropertyManager.setProperty("MODULE_TYPE", moduleId.getModuleType()); - PropertyManager.setProperty("MODULE_DIR", moduleId.getMsaFile().getParent().replaceAll("(\\\\)", "/")); - PropertyManager.setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/")); + getProject().setProperty("GUID", moduleId.getGuid()); + getProject().setProperty("FILE_GUID", moduleId.getGuid()); + getProject().setProperty("VERSION", moduleId.getVersion()); + getProject().setProperty("MODULE_TYPE", moduleId.getModuleType()); + getProject().setProperty("MODULE_DIR", moduleId.getMsaFile().getParent().replaceAll("(\\\\)", "/")); + getProject().setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/")); // // SUBSYSTEM @@ -414,18 +417,18 @@ public class GenBuildTask extends Ant { break ; } } - PropertyManager.setProperty("SUBSYSTEM", subsystem); + getProject().setProperty("SUBSYSTEM", subsystem); // // ENTRYPOINT // if (arch.equalsIgnoreCase("EBC")) { - PropertyManager.setProperty("ENTRYPOINT", "EfiStart"); + getProject().setProperty("ENTRYPOINT", "EfiStart"); } else { - PropertyManager.setProperty("ENTRYPOINT", "_ModuleEntryPoint"); + getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint"); } - PropertyManager.setProperty("OBJECTS", ""); + getProject().setProperty("OBJECTS", ""); } private void getCompilerFlags(String target, String toolchain, FpdModuleIdentification fpdModuleId) throws EdkException { @@ -440,7 +443,7 @@ public class GenBuildTask extends Ant { key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_NAME; String cmdName = GlobalData.getCommandSetting(key, fpdModuleId); File cmdFile = new File(cmdPath + File.separatorChar + cmdName); - PropertyManager.setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/")); + getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/")); // // set CC_FLAGS @@ -450,7 +453,7 @@ public class GenBuildTask extends Ant { Set addset = new LinkedHashSet(); Set subset = new LinkedHashSet(); putFlagsToSet(addset, cmdFlags); - PropertyManager.setProperty(cmd[m] + "_FLAGS", getProject().replaceProperties(getFlags(addset, subset))); + getProject().setProperty(cmd[m] + "_FLAGS", getProject().replaceProperties(getFlags(addset, subset))); // // Set CC_EXT @@ -458,9 +461,9 @@ public class GenBuildTask extends Ant { key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_EXT; String extName = GlobalData.getCommandSetting(key, fpdModuleId); if ( extName != null && ! extName.equalsIgnoreCase("")) { - PropertyManager.setProperty(cmd[m] + "_EXT", extName); + getProject().setProperty(cmd[m] + "_EXT", extName); } else { - PropertyManager.setProperty(cmd[m] + "_EXT", ""); + getProject().setProperty(cmd[m] + "_EXT", ""); } // @@ -469,7 +472,7 @@ public class GenBuildTask extends Ant { key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FAMILY; String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId); if (toolChainFamily != null) { - PropertyManager.setProperty(cmd[m] + "_FAMILY", toolChainFamily); + getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily); } // @@ -478,9 +481,9 @@ public class GenBuildTask extends Ant { key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_SPATH; String spath = GlobalData.getCommandSetting(key, fpdModuleId); if (spath != null) { - PropertyManager.setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/")); + getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/")); } else { - PropertyManager.setProperty(cmd[m] + "_SPATH", ""); + getProject().setProperty(cmd[m] + "_SPATH", ""); } // @@ -489,9 +492,9 @@ public class GenBuildTask extends Ant { key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_DPATH; String dpath = GlobalData.getCommandSetting(key, fpdModuleId); if (dpath != null) { - PropertyManager.setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/")); + getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/")); } else { - PropertyManager.setProperty(cmd[m] + "_DPATH", ""); + getProject().setProperty(cmd[m] + "_DPATH", ""); } } } @@ -539,13 +542,11 @@ public class GenBuildTask extends Ant { private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws BuildException{ // - // AutoGen + // Call AutoGen to generate AutoGen.c and AutoGen.h // - - AutoGen autogen = new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId.getModule(),fpdModuleId.getArch()); + AutoGen autogen = new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId.getModule(),fpdModuleId.getArch(), saq); autogen.genAutogen(); - // // Get compiler flags // @@ -559,12 +560,12 @@ public class GenBuildTask extends Ant { // // Prepare LIBS // - ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch()); + ModuleIdentification[] libinstances = saq.getLibraryInstance(fpdModuleId.getArch()); String propertyLibs = ""; for (int i = 0; i < libinstances.length; i++) { propertyLibs += " " + getProject().getProperty("BIN_DIR") + File.separatorChar + libinstances[i].getName() + ".lib"; } - PropertyManager.setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/")); + getProject().setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/")); // // Get all includepath and set to INCLUDE_PATHS @@ -576,7 +577,7 @@ public class GenBuildTask extends Ant { // then call the exist BaseName_build.xml directly. // if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) { - System.out.println("Call user-defined " + moduleId.getName() + "_build.xml"); + EdkLog.log(this, "Call user-defined " + moduleId.getName() + "_build.xml"); String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"; antCall(antFilename, null); @@ -588,8 +589,8 @@ public class GenBuildTask extends Ant { // Generate ${BASE_NAME}_build.xml // TBD // - String ffsKeyword = SurfaceAreaQuery.getModuleFfsKeyword(); - ModuleBuildFileGenerator fileGenerator = new ModuleBuildFileGenerator(getProject(), ffsKeyword, fpdModuleId, includes); + String ffsKeyword = saq.getModuleFfsKeyword(); + ModuleBuildFileGenerator fileGenerator = new ModuleBuildFileGenerator(getProject(), ffsKeyword, fpdModuleId, includes, saq); String buildFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml"; fileGenerator.genBuildFile(buildFilename); @@ -606,7 +607,7 @@ public class GenBuildTask extends Ant { // then call the exist BaseName_build.xml directly. // if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) { - System.out.println("Calling user-defined " + moduleId.getName() + "_build.xml"); + EdkLog.log(this, "Calling user-defined " + moduleId.getName() + "_build.xml"); String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"; antCall(antFilename, "clean"); @@ -624,7 +625,7 @@ public class GenBuildTask extends Ant { // then call the exist BaseName_build.xml directly. // if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) { - System.out.println("Calling user-defined " + moduleId.getName() + "_build.xml"); + EdkLog.log(this, "Calling user-defined " + moduleId.getName() + "_build.xml"); String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"; antCall(antFilename, "cleanall"); @@ -721,7 +722,7 @@ public class GenBuildTask extends Ant { // // Packages in PackageDenpendencies // - PackageIdentification[] packageDependencies = SurfaceAreaQuery.getDependencePkg(fpdModuleId.getArch()); + PackageIdentification[] packageDependencies = saq.getDependencePkg(fpdModuleId.getArch()); for (int i = 0; i < packageDependencies.length; i++) { GlobalData.refreshPackageIdentification(packageDependencies[i]); File packageFile = packageDependencies[i].getSpdFile(); @@ -732,17 +733,17 @@ public class GenBuildTask extends Ant { // // All Dependency Library Instance's PackageDependencies // - ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch()); + ModuleIdentification[] libinstances = saq.getLibraryInstance(fpdModuleId.getArch()); for (int i = 0; i < libinstances.length; i++) { - SurfaceAreaQuery.push(GlobalData.getDoc(libinstances[i], fpdModuleId.getArch())); - PackageIdentification[] libraryPackageDependencies = SurfaceAreaQuery.getDependencePkg(fpdModuleId.getArch()); + saq.push(GlobalData.getDoc(libinstances[i], fpdModuleId.getArch())); + PackageIdentification[] libraryPackageDependencies = saq.getDependencePkg(fpdModuleId.getArch()); for (int j = 0; j < libraryPackageDependencies.length; j++) { GlobalData.refreshPackageIdentification(libraryPackageDependencies[j]); File packageFile = libraryPackageDependencies[j].getSpdFile(); includes.add(packageFile.getParent() + File.separatorChar + "Include"); includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + archDir(arch)); } - SurfaceAreaQuery.pop(); + saq.pop(); } @@ -766,7 +767,7 @@ public class GenBuildTask extends Ant { includePaths.append(iter.next()); includePaths.append("; "); } - PropertyManager.setProperty("INCLUDE_PATHS", getProject().replaceProperties(includePaths.toString()).replaceAll("(\\\\)", "/")); + getProject().setProperty("INCLUDE_PATHS", getProject().replaceProperties(includePaths.toString()).replaceAll("(\\\\)", "/")); return includes.toArray(new String[includes.size()]); } @@ -783,5 +784,10 @@ public class GenBuildTask extends Ant { .replaceFirst("IA32", "Ia32") .replaceFirst("ARM", "Arm") .replaceFirst("EBC", "Ebc"); - } + } + + + public void setExternalProperties(Vector v) { + this.properties = v; + } }