From: klu2 Date: Tue, 13 Jun 2006 05:46:05 +0000 (+0000) Subject: 1) Fix a bug for PCD autogen tools, see track#115 in PVCS: Module's PCD informtion... X-Git-Tag: edk2-stable201903~25266 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=ad82307c753df478012953df517006c58cd7b8a4 1) Fix a bug for PCD autogen tools, see track#115 in PVCS: Module's PCD informtion is generated into autogen.h/autogen.c of library 2) Remove PcdEmulatedDriver from PcdAutogen class. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@495 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java index 62bb4c6b59..53f5fa908f 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java +++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java @@ -414,11 +414,11 @@ public class AutoGen { null, this.arch, null, - baseName.equalsIgnoreCase("PcdEmulatorPeim"), - false); + false, + SurfaceAreaQuery.getModulePcdEntryNameArray()); this.myPcdAutogen.execute(); } catch (Exception e) { - throw new BuildException("PCD Autogen failed:" + e.getMessage()); + throw new BuildException("PCD Autogen for module failed:" + e.getMessage()); } if (this.myPcdAutogen != null) { @@ -555,11 +555,11 @@ public class AutoGen { null, this.arch, null, - baseName.equalsIgnoreCase("PcdEmulatorPeim"), - true); + true, + SurfaceAreaQuery.getModulePcdEntryNameArray()); this.myPcdAutogen.execute(); } catch (Exception e) { - throw new BuildException(e.getMessage()); + throw new BuildException("Pcd Autogen for library failed! " + e.getMessage()); } if (this.myPcdAutogen != null) { @@ -2015,4 +2015,4 @@ public class AutoGen { } -} \ No newline at end of file +} diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java b/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java index dae2ca29aa..9354def6ba 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java @@ -36,7 +36,7 @@ import org.tianocore.LibrariesDocument; import org.tianocore.LibraryClassDefinitionsDocument; import org.tianocore.MsaHeaderDocument; import org.tianocore.MsaLibHeaderDocument; -import org.tianocore.PCDsDocument; +import org.tianocore.PcdCodedDocument; import org.tianocore.PPIsDocument; import org.tianocore.ProtocolsDocument; import org.tianocore.SourceFilesDocument; @@ -113,7 +113,7 @@ public class OverrideProcess { "SourceFiles", "Includes", "Libraries", "Protocols", "Events", "Hobs", "PPIs", "Variables", "BootModes", "SystemTables", "DataHubs", "Formsets", "Guids", "Externs", - "PCDs", "BuildOptions" }; + "PcdCoded", "BuildOptions" }; /// /// list of exclusive elements @@ -223,8 +223,8 @@ public class OverrideProcess { newMap.put("Externs", ((ExternsDocument) map.get("Externs")) .getExterns()); } - if (map.get("PCDs") != null) { - newMap.put("PCDs", ((PCDsDocument) map.get("PCDs")).getPCDs()); + if (map.get("PcdCoded") != null) { + newMap.put("PcdCoded", ((PcdCodedDocument) map.get("PcdCoded")).getPcdCoded()); } if (map.get("BuildOptions") != null) { newMap.put("BuildOptions", ((BuildOptionsDocument) map diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaParser.java b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaParser.java index 96003c2e71..a2780e626c 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaParser.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaParser.java @@ -91,18 +91,14 @@ public class SurfaceAreaParser { msaMap.put("Variables", doc.getModuleSurfaceArea().getVariables()); msaMap.put("BootModes", doc.getModuleSurfaceArea().getBootModes()); - msaMap - .put("SystemTables", doc.getModuleSurfaceArea() - .getSystemTables()); + msaMap.put("SystemTables", doc.getModuleSurfaceArea().getSystemTables()); msaMap.put("DataHubs", doc.getModuleSurfaceArea().getDataHubs()); msaMap.put("Formsets", doc.getModuleSurfaceArea().getFormsets()); msaMap.put("Guids", doc.getModuleSurfaceArea().getGuids()); msaMap.put("Externs", doc.getModuleSurfaceArea().getExterns()); - msaMap.put("PCDs", doc.getModuleSurfaceArea().getPCDs()); - msaMap - .put("BuildOptions", doc.getModuleSurfaceArea() - .getBuildOptions()); + msaMap.put("PcdCoded", doc.getModuleSurfaceArea().getPcdCoded()); + msaMap.put("BuildOptions", doc.getModuleSurfaceArea().getBuildOptions()); } /** @@ -132,7 +128,6 @@ public class SurfaceAreaParser { mbdMap.put("Guids", doc.getModuleBuildDescription().getGuids()); mbdMap.put("Externs", doc.getModuleBuildDescription().getExterns()); - mbdMap.put("PCDs", doc.getModuleBuildDescription().getPCDs()); mbdMap.put("BuildOptions", doc.getModuleBuildDescription() .getBuildOptions()); } @@ -168,7 +163,7 @@ public class SurfaceAreaParser { msaMap.put("Guids", doc.getLibraryModuleSurfaceArea().getGuids()); msaMap.put("Externs", doc.getLibraryModuleSurfaceArea().getExterns()); - msaMap.put("PCDs", doc.getLibraryModuleSurfaceArea().getPCDs()); + msaMap.put("PcdCoded", doc.getLibraryModuleSurfaceArea().getPcdCoded()); msaMap.put("BuildOptions", doc.getLibraryModuleSurfaceArea() .getBuildOptions()); } @@ -211,7 +206,6 @@ public class SurfaceAreaParser { mbdMap.put("Externs", doc.getLibraryModuleBuildDescription() .getExterns()); - mbdMap.put("PCDs", doc.getLibraryModuleBuildDescription().getPCDs()); mbdMap.put("BuildOptions", doc.getLibraryModuleBuildDescription() .getBuildOptions()); } diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java index 03c8d4328d..ed6d0a2f18 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java @@ -43,7 +43,7 @@ import org.tianocore.OutputDirectoryDocument; import org.tianocore.PPIsDocument; import org.tianocore.PackageNameDocument; import org.tianocore.ProtocolsDocument; -import org.tianocore.PCDsDocument.PCDs; +import org.tianocore.PcdCodedDocument.PcdCoded; /** SurfaceAreaQuery class is used to query Surface Area information from msa, mbd, @@ -1029,81 +1029,27 @@ public class SurfaceAreaQuery { } /** - Retrieve PCD tokens - - @returns CName/ItemType pairs list if elements are found at the known xpath - @returns null if nothing is there - **/ - public static String[][] getPcdTokenArray() { - String[] xPath = new String[] {"/PcdData"}; - - XmlObject[] returns = get("PCDs", xPath); - if (returns == null || returns.length == 0) { + Get name array of PCD in a module. In one module, token space + is same, and token name should not be conflicted. + + @return String[] + **/ + public static String[] getModulePcdEntryNameArray() { + PcdCoded.PcdEntry[] pcdEntries = null; + String[] results; + int index; + String[] xPath = new String[] {"/PcdEntry"}; + XmlObject[] returns = get ("PcdCoded", xPath); + if (returns == null) { return null; } - - PCDs.PcdData[] pcds = (PCDs.PcdData[]) returns; - String[][] result = new String[pcds.length][2]; - for (int i = 0; i < returns.length; ++i) { - if (pcds[i].getItemType() != null) { - result[i][1] = pcds[i].getItemType().toString(); - } else { - result[i][1] = null; - } - result[i][0] = pcds[i].getCName(); - } - - return result; - } - /** - Get the PcdToken array from module's surface area document. - The array should contains following data: -

-------------------------------------------------------------------

-

CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText

-

-------------------------------------------------------------------

-

Note: Until new schema applying, now we can only get CName, ItemType,

- - @return 2-array table contains all information of PCD token retrieved from MSA. - **/ - public static Object[][] getModulePCDTokenArray () { - int index; - Object[][] result; - PCDs.PcdData[] pcds; - String[] xPath = new String[] {"/PcdData"}; - XmlObject[] returns = get ("PCDs", xPath); - - if ((returns == null) || (returns.length == 0)) { - return null; - } - - pcds = (PCDs.PcdData[]) returns; - result = new Object[pcds.length][6]; - for (index = 0; index < pcds.length; index ++) { - // - // Get CName - // - result [index][0] = pcds[index].getCName(); - // - // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE, DYNAMIC, DYNAMIC_EX - // - if (pcds[index].getItemType() != null) { - result [index][1] = pcds[index].getItemType().toString(); - } else { - result [index][1] = null; - } + pcdEntries = (PcdCoded.PcdEntry[])returns; + results = new String[pcdEntries.length]; - // - // BUGBUG: following field can *not* be got from current MSA until schema changed. - // - //result [index][2] = pcds[index].getTokenSpaceName(); - result [index][2] = null; - result [index][3] = pcds[index].getDefaultValue(); - //result [index][4] = pcds[index].getUsage (); - result [index][4] = null; - //result [index][5] = pcds[index].getHelpText (); - result [index][5] = null; - } - return result; + for (index = 0; index < pcdEntries.length; index ++) { + results[index] = pcdEntries[index].getCName(); + } + return results; } } diff --git a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java index 278e58ceae..796aff62c3 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java +++ b/Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java @@ -18,9 +18,14 @@ package org.tianocore.build.pcd.action; import java.io.File; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.UUID; +import java.util.ArrayList; +import org.apache.xmlbeans.XmlObject; import org.tianocore.build.global.GlobalData; +import org.tianocore.build.global.SurfaceAreaQuery; import org.tianocore.build.pcd.entity.MemoryDatabaseManager; import org.tianocore.build.pcd.entity.Token; import org.tianocore.build.pcd.entity.UsageInstance; @@ -60,11 +65,6 @@ public class PCDAutoGenAction extends BuildAction { /// private String version; /// - /// Wheter current module is PCD emulated driver. It is only for - /// emulated PCD driver and will be kept until PCD IMAGE tool ready. - /// - private boolean isEmulatedPCDDriver; - /// /// Whether current autogen is for building library used by current module. /// private boolean isBuildUsedLibrary; @@ -75,8 +75,11 @@ public class PCDAutoGenAction extends BuildAction { /// /// The generated string for C code file. /// - private String cAutoGenString; - + private String cAutoGenString; + /// + /// The name array of in a module. + /// + private String[] pcdNameArray; /** Set parameter ModuleName @@ -86,38 +89,67 @@ public class PCDAutoGenAction extends BuildAction { this.moduleName = moduleName; } + /** + set the moduleGuid parameter. + + @param moduleGuid + **/ public void setModuleGuid(UUID moduleGuid) { this.moduleGuid = moduleGuid; } + /** + set packageName parameter. + + @param packageName + **/ public void setPackageName(String packageName) { this.packageName = packageName; } + /** + set packageGuid parameter. + + @param packageGuid + **/ public void setPackageGuid(UUID packageGuid) { this.packageGuid = packageGuid; } + /** + set Arch parameter. + + @param arch + **/ public void setArch(String arch) { this.arch = arch; } + /** + set version parameter + + @param version + */ public void setVersion(String version) { this.version = version; } /** - Set parameter isEmulatedPCDDriver - - @param isEmulatedPCDDriver whether this module is PeiEmulatedPCD driver - **/ - public void setIsEmulatedPCDDriver(boolean isEmulatedPCDDriver) { - this.isEmulatedPCDDriver = isEmulatedPCDDriver; - } - + set isBuildUsedLibrary parameter. + + @param isBuildUsedLibrary + */ public void setIsBuildUsedLibrary(boolean isBuildUsedLibrary) { this.isBuildUsedLibrary = isBuildUsedLibrary; } + /** + set pcdNameArray parameter. + + @param pcdNameArray + */ + public void setPcdNameArray(String[] pcdNameArray) { + this.pcdNameArray = pcdNameArray; + } /** Get the output of generated string for header file. @@ -145,23 +177,23 @@ public class PCDAutoGenAction extends BuildAction { @param moduleName Parameter of this action class. @param isEmulatedPCDDriver Parameter of this action class. **/ - public PCDAutoGenAction(String moduleName, - UUID moduleGuid, - String packageName, - UUID packageGuid, - String arch, - String version, - boolean isEmulatedPCDDriver, - boolean isBuildUsedLibrary) { + public PCDAutoGenAction(String moduleName, + UUID moduleGuid, + String packageName, + UUID packageGuid, + String arch, + String version, + boolean isBuildUsedLibrary, + String[] pcdNameArray) { dbManager = null; hAutoGenString = ""; cAutoGenString = ""; - setIsEmulatedPCDDriver(isEmulatedPCDDriver); setModuleName(moduleName); setModuleGuid(moduleGuid); setPackageName(packageName); setPackageGuid(packageGuid); + setPcdNameArray(pcdNameArray); setArch(arch); setVersion(version); setIsBuildUsedLibrary(isBuildUsedLibrary); @@ -173,13 +205,7 @@ public class PCDAutoGenAction extends BuildAction { @throws BuildActionException Bad parameter. **/ void checkParameter() throws BuildActionException { - if(!isEmulatedPCDDriver &&(moduleName == null)) { - throw new BuildActionException("Wrong module name parameter for PCDAutoGenAction tool!"); - } - - if(!isEmulatedPCDDriver && moduleName.length() == 0) { - throw new BuildActionException("Wrong module name parameter for PCDAutoGenAction tool!"); - } + } /** @@ -224,8 +250,8 @@ public class PCDAutoGenAction extends BuildAction { **/ private void generateAutogenForModule() { - int index; - List usageInstanceArray; + int index, index2; + List usageInstanceArray, usageContext; if (!isBuildUsedLibrary) { usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleName, @@ -237,21 +263,39 @@ public class PCDAutoGenAction extends BuildAction { dbManager.UsageInstanceContext = usageInstanceArray; dbManager.CurrentModuleName = moduleName; } else { - usageInstanceArray = dbManager.UsageInstanceContext; + usageContext = dbManager.UsageInstanceContext; // // For building MDE package, although all module are library, but PCD entries of // these library should be used to autogen. // - if (usageInstanceArray == null) { + if (usageContext == null) { usageInstanceArray = dbManager.getUsageInstanceArrayByModuleName(moduleName, moduleGuid, packageName, packageGuid, arch, version); + } else { + usageInstanceArray = new ArrayList(); + // + // Remove PCD entries which are not belong to this library. + // + for (index = 0; index < usageContext.size(); index++) { + if ((pcdNameArray == null) || (pcdNameArray.length == 0)){ + break; + } + + for (index2 = 0; index2 < pcdNameArray.length; index2 ++) { + if (pcdNameArray[index2].equalsIgnoreCase(usageContext.get(index).parentToken.cName)) { + usageInstanceArray.add(usageContext.get(index)); + break; + } + } + } } } + if(usageInstanceArray.size() != 0) { // // Add "#include 'PcdLib.h'" for Header file @@ -301,6 +345,7 @@ public class PCDAutoGenAction extends BuildAction { String WorkSpace = "M:/ForPcd/edk2"; String logFilePath = WorkSpace + "/MdePkg/MdePkg.fpd"; + String[] nameArray = null; // // At first, CollectPCDAction should be invoked to collect @@ -328,8 +373,7 @@ public class PCDAutoGenAction extends BuildAction { null, null, false, - false - ); + nameArray); autogenAction.execute(); System.out.println(autogenAction.OutputH());