From 250258de0d6ed07201db565101d45f4d92729bce Mon Sep 17 00:00:00 2001 From: jwang36 Date: Wed, 14 Jun 2006 10:44:45 +0000 Subject: [PATCH] added the support for new schema and old schema at the same time git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@510 6f19259b-4bc3-4df7-8a09-765794883524 --- .../org/tianocore/build/GenBuildTask.java | 13 +-- .../tianocore/build/fpd/FpdParserTask.java | 14 +++- .../tianocore/build/global/GlobalData.java | 44 ++++++++--- .../build/global/OverrideProcess.java | 17 ++-- .../org/tianocore/build/global/Spd.java | 79 ++++++++++++------- .../build/global/SurfaceAreaParser.java | 1 + .../build/global/SurfaceAreaQuery.java | 62 +++++++++++++-- 7 files changed, 169 insertions(+), 61 deletions(-) diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java index 2d3318d551..5ee07fb34e 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java @@ -1063,10 +1063,13 @@ public class GenBuildTask extends Task { getProject().setProperty("SDB_FILES", ""); getProject().setProperty("BASE_NAME", baseName); if (map.get("MsaHeader") != null) { - flag = GlobalData.MSA_AND_MBD; - MsaHeaderDocument.MsaHeader header = ((MsaHeaderDocument) map.get("MsaHeader")).getMsaHeader(); - guid = header.getGuid().getStringValue(); - componentType = header.getComponentType().toString(); + guid = SurfaceAreaQuery.getModuleGuid();//header.getGuid().getStringValue(); + componentType = SurfaceAreaQuery.getComponentType();//header.getComponentType().toString(); + if (!componentType.equalsIgnoreCase("LIBRARY")) { + flag = GlobalData.MSA_AND_MBD; + } else { + flag = GlobalData.LIBMSA_AND_LIBMBD; + } } else if (map.get("MsaLibHeader") != null) { @@ -1080,7 +1083,7 @@ public class GenBuildTask extends Task { if (componentType != null) { getProject().setProperty("COMPONENT_TYPE", componentType); } - + if (guid != null) { getProject().setProperty("FILE_GUID", guid); } diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java index 011e13de52..21197b5c62 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java @@ -352,6 +352,7 @@ public class FpdParserTask extends Task { } Map msaMap = GlobalData.getNativeMsa(baseName); Map mbdMap = GlobalData.getNativeMbd(baseName); + Map fpdMap = new HashMap(); Map map = new HashMap(); // // Whether the Module SA has parsed before or not @@ -363,9 +364,13 @@ public class FpdParserTask extends Task { // Here we can also put platform Build override // map = op.override(mbdMap, msaMap); - Map overrideMap = op.override( - getPlatformOverrideInfo(moduleSAs[i]), - OverrideProcess.deal(map)); + fpdMap = getPlatformOverrideInfo(moduleSAs[i]); + XmlObject buildOption = (XmlObject)fpdMap.get("BuildOptions"); + buildOption = (XmlObject)fpdMap.get("PackageDependencies"); + buildOption = (XmlObject)fpdMap.get("BuildOptions"); + buildOption = op.override(buildOption, platformBuildOptions); + fpdMap.put("BuildOptions", ((BuildOptionsDocument)buildOption).getBuildOptions()); + Map overrideMap = op.override(fpdMap, OverrideProcess.deal(map)); GlobalData.registerModule(baseName, overrideMap); } else { map = GlobalData.getDoc(baseName); @@ -460,6 +465,7 @@ public class FpdParserTask extends Task { Map map = new HashMap(); map.put("SourceFiles", sa.getSourceFiles()); map.put("Includes", sa.getIncludes()); + map.put("PackageDependencies", null); map.put("Libraries", sa.getLibraries()); map.put("Protocols", sa.getProtocols()); map.put("Events", sa.getEvents()); @@ -472,7 +478,7 @@ public class FpdParserTask extends Task { map.put("Formsets", sa.getFormsets()); map.put("Guids", sa.getGuids()); map.put("Externs", sa.getExterns()); - map.put("BuildOptions", platformBuildOptions); + map.put("BuildOptions", sa.getBuildOptions());//platformBuildOptions); return map; } diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java index e457d6dbe9..bc2e359b07 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java @@ -17,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. package org.tianocore.build.global; import java.io.File; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -26,15 +27,18 @@ import java.util.Set; import org.apache.tools.ant.BuildException; import org.apache.xmlbeans.XmlObject; +import org.tianocore.FilenameDocument; +import org.tianocore.FilenameDocument.Filename; import org.tianocore.FrameworkDatabaseDocument; import org.tianocore.MsaFilesDocument; -import org.tianocore.PackageListDocument; -import org.tianocore.PackageSurfaceAreaDocument; +import org.tianocore.MsaFilesDocument.MsaFiles.MsaFile; import org.tianocore.MsaHeaderDocument.MsaHeader; import org.tianocore.MsaLibHeaderDocument.MsaLibHeader; -import org.tianocore.build.pcd.entity.MemoryDatabaseManager; +import org.tianocore.PackageListDocument; +import org.tianocore.PackageSurfaceAreaDocument; import org.tianocore.build.autogen.CommonDefinition; import org.tianocore.build.fpd.FpdParserTask; +import org.tianocore.build.pcd.entity.MemoryDatabaseManager; /** GlobalData provide initializing, instoring, querying and update global data. @@ -291,27 +295,44 @@ public class GlobalData { File packageFile = new File(packageFilename); try { PackageSurfaceAreaDocument spd = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(packageFile); + List msaFilenameList; + List msasList = spd.getPackageSurfaceArea().getMsaFiles() .getMsaFileList(); - Iterator msasIter = msasList.iterator(); - while (msasIter.hasNext()) { - MsaFilesDocument.MsaFiles.MsaFile msas = (MsaFilesDocument.MsaFiles.MsaFile) msasIter.next(); - String msaFilename = msas.getFilename().getStringValue(); + if (msasList.size() == 0) { + msaFilenameList = spd.getPackageSurfaceArea().getMsaFiles().getFilenameList(); + } else { + msaFilenameList = new ArrayList(msasList.size()); + Iterator msasIter = msasList.iterator(); + while (msasIter.hasNext()) { + MsaFilesDocument.MsaFiles.MsaFile msaFile = (MsaFilesDocument.MsaFiles.MsaFile)msasIter.next(); + msaFilenameList.add(msaFile.getFilename()); + } + } + + Iterator msaFilenameIter = msaFilenameList.iterator(); + while (msaFilenameIter.hasNext()) { + FilenameDocument.Filename msaFilename = (FilenameDocument.Filename)msaFilenameIter.next(); + String filename = msaFilename.getStringValue(); File msaFile = new File(workspaceDir + File.separatorChar + GlobalData.getPackagePath(packageName) - + File.separatorChar + msaFilename); + + File.separatorChar + filename); SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser(); Map map = surfaceAreaParser.parseFile(msaFile); String baseName = ""; XmlObject header = null; if ((header = map.get("MsaHeader")) != null) { - baseName = ((MsaHeader) header).getBaseName().getStringValue(); + if (((MsaHeader) header).isSetBaseName()) { + baseName = ((MsaHeader) header).getBaseName().getStringValue(); + } else { + baseName = ((MsaHeader) header).getModuleName(); + } } else if ((header = map.get("MsaLibHeader")) != null) { baseName = ((MsaLibHeader) header).getBaseName().getStringValue(); } else { continue; } nativeMsa.put(baseName, map); - String[] info = { msaFilename, packageName }; + String[] info = { filename, packageName }; moduleInfo.put(baseName, info); } } catch (Exception e) { @@ -472,7 +493,8 @@ public class GlobalData { String mbdFilename = getMbdFilename(moduleName); File mbdFile = new File(mbdFilename); if (!mbdFile.exists()) { - throw new BuildException("Info: Surface Area file [" + mbdFile.getPath() + "] can't found."); + return null; + //throw new BuildException("Info: Surface Area file [" + mbdFile.getPath() + "] can't found."); } SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser(); Map map = surfaceAreaParser.parseFile(mbdFile); diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java b/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java index 9354def6ba..60f430f458 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java @@ -42,6 +42,7 @@ import org.tianocore.ProtocolsDocument; import org.tianocore.SourceFilesDocument; import org.tianocore.SystemTablesDocument; import org.tianocore.VariablesDocument; +import org.tianocore.PackageDependenciesDocument; /** This class is used to override surface area information. For example, MBD can @@ -110,7 +111,7 @@ public class OverrideProcess { /// list of top elements of surface area /// public static String[] topElements = { "LibraryClassDefinitions", - "SourceFiles", "Includes", "Libraries", "Protocols", + "SourceFiles", "Includes", "PackageDependencies", "Libraries", "Protocols", "Events", "Hobs", "PPIs", "Variables", "BootModes", "SystemTables", "DataHubs", "Formsets", "Guids", "Externs", "PcdCoded", "BuildOptions" }; @@ -178,6 +179,10 @@ public class OverrideProcess { newMap.put("Includes", ((IncludesDocument) map.get("Includes")) .getIncludes()); } + if (map.get("PackageDependencies") != null) { + newMap.put("PackageDependencies", ((PackageDependenciesDocument) map.get("PackageDependencies")) + .getPackageDependencies()); + } if (map.get("Libraries") != null) { newMap.put("Libraries", ((LibrariesDocument) map.get("Libraries")) .getLibraries()); @@ -285,8 +290,11 @@ public class OverrideProcess { result.put("MsaHeader", override(l.get("MsaHeader"), null)); result.put("MsaLibHeader", override(l.get("MsaLibHeader"), null)); for (int i = 0; i < topElements.length; i++) { - result.put(topElements[i], override(h.get(topElements[i]), l - .get(topElements[i]))); + if (h != null) { + result.put(topElements[i], override(h.get(topElements[i]), l.get(topElements[i]))); + } else { + result.put(topElements[i], override(l.get(topElements[i]), null)); + } } return result; } @@ -310,8 +318,7 @@ public class OverrideProcess { } XmlCursor hc = h.newCursor(); if (h.getClass() != l.getClass()) { - System.out - .println("Error: Two XmlObject does not with compliant format."); + System.out.println("Error: Two XmlObject does not with compliant format."); return null; } if (!hc.toFirstChild()) { diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/Spd.java b/Tools/Source/GenBuild/org/tianocore/build/global/Spd.java index 54c1391094..72efa7eba7 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/Spd.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/Spd.java @@ -18,14 +18,15 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.tianocore.PackageSurfaceAreaDocument; import org.tianocore.GuidDeclarationsDocument.GuidDeclarations; import org.tianocore.IncludeHeaderDocument.IncludeHeader; import org.tianocore.LibraryClassDeclarationDocument.LibraryClassDeclaration; import org.tianocore.LibraryClassDeclarationsDocument.LibraryClassDeclarations; import org.tianocore.PackageHeadersDocument.PackageHeaders; +import org.tianocore.PackageSurfaceAreaDocument; import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea; import org.tianocore.PpiDeclarationsDocument.PpiDeclarations; +import org.tianocore.PpiDeclarationsDocument.PpiDeclarations.Entry; import org.tianocore.ProtocolDeclarationsDocument.ProtocolDeclarations; /** @@ -125,15 +126,14 @@ public class Spd { if (packageHeader != null) { List headerList = packageHeader.getIncludeHeaderList(); + IncludeHeader header; + for (int i = 0; i < headerList.size(); i++) { + header = (IncludeHeader)headerList.get(i); try { - this.moduleInfo - .put(headerList.get(i).getModuleType() - .toString(), headerList.get(i) - .getStringValue()); + this.moduleInfo.put(header.getModuleType().toString(), header.getStringValue()); } catch (Exception e) { - System.out - .print("can't find ModuleHeaders ModuleType & includeHeader!\n"); + System.out.print("can't find ModuleHeaders ModuleType & includeHeader!\n"); } } } @@ -149,19 +149,26 @@ public class Spd { **/ public void genPpiInfoList(PpiDeclarations ppiInfo) { String[] cNameGuid = new String[2]; + String guidString; if (ppiInfo != null) { List ppiEntryList = ppiInfo.getEntryList(); + PpiDeclarations.Entry ppiEntry; + for (int i = 0; i < ppiEntryList.size(); i++) { + ppiEntry = (PpiDeclarations.Entry)ppiEntryList.get(i); try { - cNameGuid[0] = ppiEntryList.get(i).getCName(); - cNameGuid[1] = formatGuidName(ppiEntryList.get(i) - .getGuid().getStringValue()); - this.ppiInfo.put(ppiEntryList.get(i).getName(), new String[] { - cNameGuid[0], cNameGuid[1] }); + if (ppiEntry.isSetGuidValue()) { + guidString = ppiEntry.getGuidValue(); + } else { + guidString = ppiEntry.getGuid().getStringValue(); + } + + cNameGuid[0] = ppiEntry.getCName(); + cNameGuid[1] = formatGuidName(guidString); + this.ppiInfo.put(ppiEntry.getName(), new String[] { cNameGuid[0], cNameGuid[1] }); } catch (Exception e) { - System.out - .print("can't find GuidDeclarations C_Name & Guid!\n"); + System.out.print("can't find GuidDeclarations C_Name & Guid!\n"); } } } @@ -177,20 +184,26 @@ public class Spd { **/ public void genProtocolInfoList(ProtocolDeclarations proInfo) { String[] cNameGuid = new String[2]; + String guidString; + if (proInfo != null) { List protocolEntryList = proInfo.getEntryList(); + ProtocolDeclarations.Entry protocolEntry; for (int i = 0; i < protocolEntryList.size(); i++) { + protocolEntry = (ProtocolDeclarations.Entry)protocolEntryList.get(i); try { - cNameGuid[0] = protocolEntryList.get(i).getCName(); - cNameGuid[1] = formatGuidName(protocolEntryList.get(i) - .getGuid().getStringValue()); - - String temp = new String(protocolEntryList.get(i).getName()); - this.protocolInfo.put(temp, new String[] { cNameGuid[0], - cNameGuid[1] }); + if (protocolEntry.isSetGuidValue()) { + guidString = protocolEntry.getGuidValue(); + } else { + guidString = protocolEntry.getGuid().getStringValue(); + } + cNameGuid[0] = protocolEntry.getCName(); + cNameGuid[1] = formatGuidName(guidString); + + String temp = new String(protocolEntry.getName()); + this.protocolInfo.put(temp, new String[] { cNameGuid[0], cNameGuid[1] }); } catch (Exception e) { - System.out - .print("can't find ProtocolDeclarations C_Name & Guid!\n"); + System.out.print("can't find ProtocolDeclarations C_Name & Guid!\n"); } } } @@ -207,15 +220,23 @@ public class Spd { **/ public void genGuidInfoList(GuidDeclarations guidInfo) { String[] cNameGuid = new String[2]; + String guidString; + if (guidInfo != null) { - List guidEntryList = guidInfo.getEntryList(); + List guidEntryList = guidInfo.getEntryList(); + GuidDeclarations.Entry guidEntry; for (int i = 0; i < guidEntryList.size(); i++) { - cNameGuid[0] = guidEntryList.get(i).getCName(); - cNameGuid[1] = formatGuidName(guidEntryList.get(i) - .getGuid().getStringValue()); - this.guidInfo.put(guidEntryList.get(i).getName(), new String[] { - cNameGuid[0], cNameGuid[1] }); + guidEntry = (GuidDeclarations.Entry)guidEntryList.get(i); + if (guidEntry.isSetGuidValue()) { + guidString = guidEntry.getGuidValue(); + } else { + guidString = guidEntry.getGuid().getStringValue(); + } + + cNameGuid[0] = guidEntry.getCName(); + cNameGuid[1] = formatGuidName(guidString); + this.guidInfo.put(guidEntry.getName(), new String[] {cNameGuid[0], cNameGuid[1] }); } } } diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaParser.java b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaParser.java index a2780e626c..229e16976d 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaParser.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaParser.java @@ -83,6 +83,7 @@ public class SurfaceAreaParser { .getLibraryClassDefinitions()); msaMap.put("SourceFiles", doc.getModuleSurfaceArea().getSourceFiles()); msaMap.put("Includes", doc.getModuleSurfaceArea().getIncludes()); + msaMap.put("PackageDependencies", doc.getModuleSurfaceArea().getPackageDependencies()); msaMap.put("Protocols", doc.getModuleSurfaceArea().getProtocols()); msaMap.put("Events", doc.getModuleSurfaceArea().getEvents()); diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java index ed6d0a2f18..50345c8a68 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java @@ -44,6 +44,8 @@ import org.tianocore.PPIsDocument; import org.tianocore.PackageNameDocument; import org.tianocore.ProtocolsDocument; import org.tianocore.PcdCodedDocument.PcdCoded; +import org.tianocore.MsaHeaderDocument; +import org.tianocore.MsaHeaderDocument.MsaHeader; /** SurfaceAreaQuery class is used to query Surface Area information from msa, mbd, @@ -233,7 +235,8 @@ public class SurfaceAreaQuery { }; } else { xPath = new String[] { - "/Filename[not(@ArchType) or @ArchType='ALL' or @ArchType='" + arch + "']", + "/Filename[not(@SupArchList) and not(@ArchType) or @SupArchList='ALL' or @SupArchList='" + arch + "' or @ArchType='ALL' or @ArchType='" + arch + "']", + "/Filename[not(@SupArchList) and not(@ArchType) or @ArchType='ALL' or @ArchType='" + arch + "']", "/Arch[@ArchType='ALL' or @ArchType='" + arch + "']/Filename" }; } @@ -300,6 +303,7 @@ public class SurfaceAreaQuery { } else { xPath = new String[] { "/Option", + "/Option[@SupArchList='ALL' or @SupArchList='" + arch + "']", "/Arch[@ArchType='ALL' or @ArchType='" + arch + "']/Option" }; } @@ -341,6 +345,17 @@ public class SurfaceAreaQuery { return result; } + public static String getModuleName() { + String[] xPath = new String[] { "/ModuleName", "/BaseName" }; + + XmlObject[] returns = get(xPath); + if (returns != null && returns.length > 0) { + return returns[0].toString(); + } + + return null; + } + /** Retrieve /ModuleType @@ -396,13 +411,18 @@ public class SurfaceAreaQuery { } else { xPath = new String[] { "/PackageName", + "/PackageName[@SupArchList='ALL' or @SupArchList='" + arch + "']", + "/PackageName[@Arch='ALL' or @Arch='" + arch + "']", "/Arch[@ArchType='ALL' or @ArchType='" + arch + "']/PackageName" }; } XmlObject[] returns = get("Includes", xPath); if (returns == null || returns.length == 0) { - return null; + returns = get("PackageDependencies", xPath); + if (returns == null || returns.length == 0) { + return null; + } } List packageNames = new ArrayList(); @@ -471,12 +491,34 @@ public class SurfaceAreaQuery { @returns null if nothing is there **/ public static String getModuleGuid() { - String[] xPath = new String[] { "/Guid" }; + String[] xPath = new String[] { "" }; - XmlObject[] returns = get(xPath); + XmlObject[] returns = get("MsaHeader", xPath); if (returns != null && returns.length > 0) { - GuidDocument.Guid guid = (GuidDocument.Guid) returns[0]; - return guid.getStringValue(); + MsaHeaderDocument.MsaHeader moduleHeader = (MsaHeaderDocument.MsaHeader) returns[0]; + if (moduleHeader.isSetGuid()) { + return moduleHeader.getGuid().getStringValue(); + } else if (moduleHeader.isSetGuidValue()) { + return moduleHeader.getGuidValue(); + } + } + + return null; + } + + /** + Retrieve module Guid string + + @returns GUILD string if elements are found at the known xpath + @returns null if nothing is there + **/ + public static String getModuleGuidValue() { + String[] xPath = new String[] { "" }; + + XmlObject[] returns = get("MsaHeader", xPath); + if (returns != null && returns.length > 0) { + MsaHeaderDocument.MsaHeader moduleHeader = (MsaHeaderDocument.MsaHeader) returns[0]; + return moduleHeader.getGuidValue(); } return null; @@ -676,7 +718,8 @@ public class SurfaceAreaQuery { } xPath = new String[] { - "/Library" + usageAttribute, + "/Library" + archAttribute, //usageAttribute, + "/Library[not(@SupArchList) or @SupArchList='" + arch + "']", "/Arch" + archAttribute + "/Library" + usageAttribute }; @@ -832,6 +875,11 @@ public class SurfaceAreaQuery { XmlObject[] result = get("FrameworkPlatformDescription", xPath); if (result == null) { + xPath = new String[] { "/FrameworkModules/*/ModuleSA" }; + result = get("FrameworkPlatformDescription", xPath); + if (result != null) { + return (ModuleSADocument.ModuleSA[]) result; + } return new ModuleSADocument.ModuleSA[0]; } -- 2.39.2