X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fglobal%2FGlobalData.java;h=51f198571a9241a11999f017d2697e3a75cdb242;hp=99cccc364cc3211317f79f2894155cffa89a2d40;hb=4748b24d77d65a13dd2bcb0f9fa9ed83f24f9bf4;hpb=a29c47e01d9689fad735bbeccfaef67676a425d1 diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java index 99cccc364c..51f198571a 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java @@ -21,20 +21,21 @@ import org.apache.xmlbeans.XmlObject; import org.tianocore.DbPathAndFilename; import org.tianocore.FrameworkDatabaseDocument; import org.tianocore.ModuleSurfaceAreaDocument; +import org.tianocore.PcdBuildDefinitionDocument; import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; -import org.tianocore.build.exception.EdkException; import org.tianocore.build.id.FpdModuleIdentification; import org.tianocore.build.id.ModuleIdentification; import org.tianocore.build.id.PackageIdentification; import org.tianocore.build.id.PlatformIdentification; +import org.tianocore.build.pcd.entity.MemoryDatabaseManager; import org.tianocore.build.toolchain.ToolChainAttribute; import org.tianocore.build.toolchain.ToolChainConfig; import org.tianocore.build.toolchain.ToolChainElement; import org.tianocore.build.toolchain.ToolChainInfo; import org.tianocore.build.toolchain.ToolChainKey; import org.tianocore.build.toolchain.ToolChainMap; -//import org.tianocore.build.pcd.entity.MemoryDatabaseManager; -//import org.tianocore.logger.EdkLog; +import org.tianocore.exception.EdkException; +import org.tianocore.logger.EdkLog; import java.io.File; import java.util.HashMap; @@ -130,7 +131,7 @@ public class GlobalData { private static Map moduleToolChainOption = new HashMap(); private static Map moduleToolChainFamilyOption = new HashMap(); -// private static final MemoryDatabasseManager pcdDbManager = new MemoryDatabaseManager(); + private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager(); @@ -165,8 +166,7 @@ public class GlobalData { // If ToolChain has been set up before, do nothing. // CONF dir + tools definition file name // - String confDir = GlobalData.workspaceDir + File.separatorChar + "Tools" + File.separatorChar + "Conf"; - File toolsDefFile = new File(confDir + File.separatorChar + toolsDefFilename); + File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename); System.out.println("Using file [" + toolsDefFile.getPath() + "] as tools definition file. "); toolsDef = new ToolChainConfig(toolsDefFile); @@ -230,7 +230,6 @@ public class GlobalData { } } } catch (Exception e) { - e.printStackTrace(); throw new BuildException("Parse workspace Database [" + dbFile.getPath() + "] Error.\n" + e.getMessage()); } } @@ -341,7 +340,7 @@ public class GlobalData { // // First part: get the MSA files info // - doc = getNativeMsa(moduleId); + doc.putAll(getNativeMsa(moduleId)); // // Second part: put build options @@ -413,6 +412,7 @@ public class GlobalData { msaMap.put("PPIs", cloneXmlObject(msa.getPPIs(), true)); msaMap.put("Guids", cloneXmlObject(msa.getGuids(), true)); msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true)); + msaMap.put("PcdCoded", cloneXmlObject(msa.getPcdCoded(), true)); return msaMap; } catch (Exception ex){ @@ -507,15 +507,16 @@ public class GlobalData { /** * return two values: {cName, GuidValue} */ - public static String[] getGuid(PackageIdentification[] packages, String name) + public static String[] getGuid(List packages, String name) throws BuildException { if (packages == null) { // throw Exception or not???? return new String[0]; } String[] result = null; - for (int i = 0; i < packages.length; i++) { - Spd spd = spdTable.get(packages[i]); + Iterator item = packages.iterator(); + while (item.hasNext()){ + Spd spd = spdTable.get(item.next()); // // If find one package defined the GUID // @@ -523,20 +524,22 @@ public class GlobalData { return result; } } + return null; } /** * return two values: {cName, GuidValue} */ - public static String[] getPpiGuid(PackageIdentification[] packages, + public static String[] getPpiGuid(List packages, String name) throws BuildException { if (packages == null) { return new String[0]; } String[] result = null; - for (int i = 0; i < packages.length; i++) { - Spd spd = spdTable.get(packages[i]); + Iterator item = packages.iterator(); + while (item.hasNext()){ + Spd spd = spdTable.get(item.next()); // // If find one package defined the Ppi GUID // @@ -551,18 +554,19 @@ public class GlobalData { /** * return two values: {cName, GuidValue} */ - public static String[] getProtocolGuid(PackageIdentification[] packages, + public static String[] getProtocolGuid(List packages, String name) throws BuildException { if (packages == null) { return new String[0]; } String[] result = null; - for (int i = 0; i < packages.length; i++) { - Spd spd = spdTable.get(packages[i]); + Iterator item = packages.iterator(); + while (item.hasNext()){ + Spd spd = spdTable.get(item.next()); // // If find one package defined the protocol GUID // - if ((result = spd.getProtocol(name)) != null) { + if ((result = spd.getProtocol(name))!= null){ return result; } } @@ -570,21 +574,27 @@ public class GlobalData { } - /////////////////////////// Update!! Update!! Update!! -// public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() { -// return pcdDbManager; -// } - /////////////////////////// - public synchronized static PlatformIdentification getPlatform(String name) throws BuildException { + public synchronized static PlatformIdentification getPlatformByName(String name) throws BuildException { Iterator iter = platformList.iterator(); while(iter.hasNext()){ PlatformIdentification platformId = (PlatformIdentification)iter.next(); if (platformId.getName().equalsIgnoreCase(name)) { -// GlobalData.log.info("Platform: " + platformId + platformId.getFpdFile()); return platformId; } } - throw new BuildException("Can't find platform [" + name + "] in current workspace. "); + throw new BuildException("Can't find platform [" + name + "] in current workspace database. "); + } + + public synchronized static PlatformIdentification getPlatform(String filename) throws BuildException { + File file = new File(workspaceDir + File.separatorChar + filename); + Iterator iter = platformList.iterator(); + while(iter.hasNext()){ + PlatformIdentification platformId = (PlatformIdentification)iter.next(); + if (platformId.getFpdFile().getPath().equalsIgnoreCase(file.getPath())) { + return platformId; + } + } + throw new BuildException("Can't find platform file [" + filename + "] in current workspace database. "); } public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws BuildException { @@ -678,6 +688,19 @@ public class GlobalData { moduleToolChainFamilyOption.put(fpdModuleId, toolChainOption); } + public static boolean isCommandSet(String target, String toolchain, String arch) { + String[] commands = getToolChainInfo().getCommands(); + + for (int i = 0; i < commands.length; ++i) { + String cmdName = toolsDef.getConfig().get(new String[] {target, toolchain, arch, commands[i], ToolChainAttribute.NAME.toString()}); + if (cmdName != null && cmdName.length() != 0) { + return true; + } + } + + return false; + } + public static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException { ToolChainKey toolChainKey = new ToolChainKey(commandDescription); ToolChainMap toolChainConfig = toolsDef.getConfig(); @@ -750,52 +773,66 @@ public class GlobalData { // // for PCD // -// public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() { -// return pcdDbManager; -// } + public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() { + return pcdDbManager; + } // - // For PCD + // For PCD get tokenSpaceGUid // - /** - * - * @param guidName - * @return - */ -// public synchronized static String[] getGuidInfoGuid(String guidName) { -// String[] cNameGuid = null; -// Set set = spdTable.keySet(); -// Iterator iter = set.iterator(); -// -// while (iter.hasNext()) { -// Spd spd = (Spd) spdTable.get(iter.next()); -// cNameGuid = spd.getGuidNameArray(guidName); -// if (cNameGuid != null) { -// break; -// } -// } -// return cNameGuid; -// } + public synchronized static String[] getGuidInfoFromCname(String cName){ + String cNameGuid[] = null; + String guid = null; + Set set = spdTable.keySet(); + Iterator iter = set.iterator(); + + if (iter == null) { + return null; + } + + while (iter.hasNext()){ + Spd spd = (Spd) spdTable.get(iter.next()); + guid = spd.getGuidFromCname(cName); + if (guid != null){ + cNameGuid = new String[2]; + cNameGuid[0] = cName; + cNameGuid[1] = guid; + break; + } + } + return cNameGuid; + } // // For PCD // -// public synchronized static Map getFpdModuleSaXmlObject( -// String xmlObjectName) { -// Set fpdModuleSASet = fpdModuleSA.keySet(); -// Iterator item = fpdModuleSASet.iterator(); -// -// Map SAPcdBuildDef = new HashMap(); -// Map SANode = new HashMap(); -// FpdModuleIdentification moduleId; -// while (item.hasNext()) { -// moduleId = (FpdModuleIdentification) item.next(); -// SANode = fpdModuleSA.get(item.next()); -// SAPcdBuildDef.put(moduleId, -// (PcdBuildDefinitionDocument.PcdBuildDefinition) SANode -// .get(xmlObjectName)); -// } -// return SAPcdBuildDef; -// } + public synchronized static Map getFpdModuleSaXmlObject( + String xmlObjectName) { + Set fpdModuleSASet = fpdModuleSA.keySet(); + Iterator item = fpdModuleSASet.iterator(); + + + Map SAPcdBuildDef = new HashMap(); + Map SANode = new HashMap(); + FpdModuleIdentification moduleId; + while (item.hasNext()) { + + moduleId = (FpdModuleIdentification) item.next(); + SANode = fpdModuleSA.get(moduleId); + try{ + if (SANode.get(xmlObjectName)!= null){ + SAPcdBuildDef.put(moduleId, + (XmlObject) SANode + .get(xmlObjectName)); + + } + + + } catch (Exception e){ + EdkLog.log(EdkLog.EDK_INFO, e.getMessage()); + } + } + return SAPcdBuildDef; + } }