getProject().setProperty("SDB_FILES", "");\r
getProject().setProperty("BASE_NAME", baseName);\r
if (map.get("MsaHeader") != null) {\r
- flag = GlobalData.MSA_AND_MBD;\r
- MsaHeaderDocument.MsaHeader header = ((MsaHeaderDocument) map.get("MsaHeader")).getMsaHeader();\r
- guid = header.getGuid().getStringValue();\r
- componentType = header.getComponentType().toString();\r
+ guid = SurfaceAreaQuery.getModuleGuid();//header.getGuid().getStringValue();\r
+ componentType = SurfaceAreaQuery.getComponentType();//header.getComponentType().toString();\r
+ if (!componentType.equalsIgnoreCase("LIBRARY")) {\r
+ flag = GlobalData.MSA_AND_MBD;\r
+ } else {\r
+ flag = GlobalData.LIBMSA_AND_LIBMBD;\r
+ }\r
} \r
\r
else if (map.get("MsaLibHeader") != null) {\r
if (componentType != null) {\r
getProject().setProperty("COMPONENT_TYPE", componentType);\r
}\r
- \r
+\r
if (guid != null) {\r
getProject().setProperty("FILE_GUID", guid);\r
}\r
}\r
Map<String, XmlObject> msaMap = GlobalData.getNativeMsa(baseName);\r
Map<String, XmlObject> mbdMap = GlobalData.getNativeMbd(baseName);\r
+ Map<String, XmlObject> fpdMap = new HashMap<String, XmlObject>();\r
Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
//\r
// Whether the Module SA has parsed before or not\r
// Here we can also put platform Build override\r
//\r
map = op.override(mbdMap, msaMap);\r
- Map<String, XmlObject> overrideMap = op.override(\r
- getPlatformOverrideInfo(moduleSAs[i]),\r
- OverrideProcess.deal(map));\r
+ fpdMap = getPlatformOverrideInfo(moduleSAs[i]);\r
+ XmlObject buildOption = (XmlObject)fpdMap.get("BuildOptions");\r
+ buildOption = (XmlObject)fpdMap.get("PackageDependencies");\r
+ buildOption = (XmlObject)fpdMap.get("BuildOptions");\r
+ buildOption = op.override(buildOption, platformBuildOptions);\r
+ fpdMap.put("BuildOptions", ((BuildOptionsDocument)buildOption).getBuildOptions());\r
+ Map<String, XmlObject> overrideMap = op.override(fpdMap, OverrideProcess.deal(map));\r
GlobalData.registerModule(baseName, overrideMap);\r
} else {\r
map = GlobalData.getDoc(baseName);\r
Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
map.put("SourceFiles", sa.getSourceFiles());\r
map.put("Includes", sa.getIncludes());\r
+ map.put("PackageDependencies", null);\r
map.put("Libraries", sa.getLibraries());\r
map.put("Protocols", sa.getProtocols());\r
map.put("Events", sa.getEvents());\r
map.put("Formsets", sa.getFormsets());\r
map.put("Guids", sa.getGuids());\r
map.put("Externs", sa.getExterns());\r
- map.put("BuildOptions", platformBuildOptions);\r
+ map.put("BuildOptions", sa.getBuildOptions());//platformBuildOptions);\r
return map;\r
}\r
\r
package org.tianocore.build.global;\r
\r
import java.io.File;\r
+import java.util.ArrayList;\r
import java.util.HashMap;\r
import java.util.HashSet;\r
import java.util.Iterator;\r
\r
import org.apache.tools.ant.BuildException;\r
import org.apache.xmlbeans.XmlObject;\r
+import org.tianocore.FilenameDocument;\r
+import org.tianocore.FilenameDocument.Filename;\r
import org.tianocore.FrameworkDatabaseDocument;\r
import org.tianocore.MsaFilesDocument;\r
-import org.tianocore.PackageListDocument;\r
-import org.tianocore.PackageSurfaceAreaDocument;\r
+import org.tianocore.MsaFilesDocument.MsaFiles.MsaFile;\r
import org.tianocore.MsaHeaderDocument.MsaHeader;\r
import org.tianocore.MsaLibHeaderDocument.MsaLibHeader;\r
-import org.tianocore.build.pcd.entity.MemoryDatabaseManager;\r
+import org.tianocore.PackageListDocument;\r
+import org.tianocore.PackageSurfaceAreaDocument;\r
import org.tianocore.build.autogen.CommonDefinition;\r
import org.tianocore.build.fpd.FpdParserTask;\r
+import org.tianocore.build.pcd.entity.MemoryDatabaseManager;\r
\r
/**\r
GlobalData provide initializing, instoring, querying and update global data.\r
File packageFile = new File(packageFilename);\r
try {\r
PackageSurfaceAreaDocument spd = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(packageFile);\r
+ List<FilenameDocument.Filename> msaFilenameList;\r
+\r
List<MsaFilesDocument.MsaFiles.MsaFile> msasList = spd.getPackageSurfaceArea().getMsaFiles()\r
.getMsaFileList();\r
- Iterator msasIter = msasList.iterator();\r
- while (msasIter.hasNext()) {\r
- MsaFilesDocument.MsaFiles.MsaFile msas = (MsaFilesDocument.MsaFiles.MsaFile) msasIter.next();\r
- String msaFilename = msas.getFilename().getStringValue();\r
+ if (msasList.size() == 0) {\r
+ msaFilenameList = spd.getPackageSurfaceArea().getMsaFiles().getFilenameList();\r
+ } else {\r
+ msaFilenameList = new ArrayList<FilenameDocument.Filename>(msasList.size());\r
+ Iterator msasIter = msasList.iterator();\r
+ while (msasIter.hasNext()) {\r
+ MsaFilesDocument.MsaFiles.MsaFile msaFile = (MsaFilesDocument.MsaFiles.MsaFile)msasIter.next();\r
+ msaFilenameList.add(msaFile.getFilename());\r
+ }\r
+ }\r
+\r
+ Iterator msaFilenameIter = msaFilenameList.iterator();\r
+ while (msaFilenameIter.hasNext()) {\r
+ FilenameDocument.Filename msaFilename = (FilenameDocument.Filename)msaFilenameIter.next();\r
+ String filename = msaFilename.getStringValue();\r
File msaFile = new File(workspaceDir + File.separatorChar + GlobalData.getPackagePath(packageName)\r
- + File.separatorChar + msaFilename);\r
+ + File.separatorChar + filename);\r
SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();\r
Map<String, XmlObject> map = surfaceAreaParser.parseFile(msaFile);\r
String baseName = "";\r
XmlObject header = null;\r
if ((header = map.get("MsaHeader")) != null) {\r
- baseName = ((MsaHeader) header).getBaseName().getStringValue();\r
+ if (((MsaHeader) header).isSetBaseName()) {\r
+ baseName = ((MsaHeader) header).getBaseName().getStringValue();\r
+ } else {\r
+ baseName = ((MsaHeader) header).getModuleName();\r
+ }\r
} else if ((header = map.get("MsaLibHeader")) != null) {\r
baseName = ((MsaLibHeader) header).getBaseName().getStringValue();\r
} else {\r
continue;\r
}\r
nativeMsa.put(baseName, map);\r
- String[] info = { msaFilename, packageName };\r
+ String[] info = { filename, packageName };\r
moduleInfo.put(baseName, info);\r
}\r
} catch (Exception e) {\r
String mbdFilename = getMbdFilename(moduleName);\r
File mbdFile = new File(mbdFilename);\r
if (!mbdFile.exists()) {\r
- throw new BuildException("Info: Surface Area file [" + mbdFile.getPath() + "] can't found.");\r
+ return null;\r
+ //throw new BuildException("Info: Surface Area file [" + mbdFile.getPath() + "] can't found.");\r
}\r
SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();\r
Map<String, XmlObject> map = surfaceAreaParser.parseFile(mbdFile);\r
import org.tianocore.SourceFilesDocument;\r
import org.tianocore.SystemTablesDocument;\r
import org.tianocore.VariablesDocument;\r
+import org.tianocore.PackageDependenciesDocument;\r
\r
/**\r
This class is used to override surface area information. For example, MBD can\r
/// list of top elements of surface area\r
///\r
public static String[] topElements = { "LibraryClassDefinitions",\r
- "SourceFiles", "Includes", "Libraries", "Protocols",\r
+ "SourceFiles", "Includes", "PackageDependencies", "Libraries", "Protocols",\r
"Events", "Hobs", "PPIs", "Variables", "BootModes",\r
"SystemTables", "DataHubs", "Formsets", "Guids", "Externs",\r
"PcdCoded", "BuildOptions" };\r
newMap.put("Includes", ((IncludesDocument) map.get("Includes"))\r
.getIncludes());\r
}\r
+ if (map.get("PackageDependencies") != null) {\r
+ newMap.put("PackageDependencies", ((PackageDependenciesDocument) map.get("PackageDependencies"))\r
+ .getPackageDependencies());\r
+ }\r
if (map.get("Libraries") != null) {\r
newMap.put("Libraries", ((LibrariesDocument) map.get("Libraries"))\r
.getLibraries());\r
result.put("MsaHeader", override(l.get("MsaHeader"), null));\r
result.put("MsaLibHeader", override(l.get("MsaLibHeader"), null));\r
for (int i = 0; i < topElements.length; i++) {\r
- result.put(topElements[i], override(h.get(topElements[i]), l\r
- .get(topElements[i])));\r
+ if (h != null) {\r
+ result.put(topElements[i], override(h.get(topElements[i]), l.get(topElements[i])));\r
+ } else {\r
+ result.put(topElements[i], override(l.get(topElements[i]), null));\r
+ }\r
}\r
return result;\r
}\r
}\r
XmlCursor hc = h.newCursor();\r
if (h.getClass() != l.getClass()) {\r
- System.out\r
- .println("Error: Two XmlObject does not with compliant format.");\r
+ System.out.println("Error: Two XmlObject does not with compliant format.");\r
return null;\r
}\r
if (!hc.toFirstChild()) {\r
import java.util.List;\r
import java.util.Map;\r
\r
-import org.tianocore.PackageSurfaceAreaDocument;\r
import org.tianocore.GuidDeclarationsDocument.GuidDeclarations;\r
import org.tianocore.IncludeHeaderDocument.IncludeHeader;\r
import org.tianocore.LibraryClassDeclarationDocument.LibraryClassDeclaration;\r
import org.tianocore.LibraryClassDeclarationsDocument.LibraryClassDeclarations;\r
import org.tianocore.PackageHeadersDocument.PackageHeaders;\r
+import org.tianocore.PackageSurfaceAreaDocument;\r
import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;\r
import org.tianocore.PpiDeclarationsDocument.PpiDeclarations;\r
+import org.tianocore.PpiDeclarationsDocument.PpiDeclarations.Entry;\r
import org.tianocore.ProtocolDeclarationsDocument.ProtocolDeclarations;\r
\r
/**\r
\r
if (packageHeader != null) {\r
List<IncludeHeader> headerList = packageHeader.getIncludeHeaderList();\r
+ IncludeHeader header;\r
+\r
for (int i = 0; i < headerList.size(); i++) {\r
+ header = (IncludeHeader)headerList.get(i);\r
try {\r
- this.moduleInfo\r
- .put(headerList.get(i).getModuleType()\r
- .toString(), headerList.get(i)\r
- .getStringValue());\r
+ this.moduleInfo.put(header.getModuleType().toString(), header.getStringValue());\r
} catch (Exception e) {\r
- System.out\r
- .print("can't find ModuleHeaders ModuleType & includeHeader!\n");\r
+ System.out.print("can't find ModuleHeaders ModuleType & includeHeader!\n");\r
}\r
}\r
}\r
**/\r
public void genPpiInfoList(PpiDeclarations ppiInfo) {\r
String[] cNameGuid = new String[2];\r
+ String guidString;\r
\r
if (ppiInfo != null) {\r
List<PpiDeclarations.Entry> ppiEntryList = ppiInfo.getEntryList();\r
+ PpiDeclarations.Entry ppiEntry;\r
+\r
for (int i = 0; i < ppiEntryList.size(); i++) {\r
+ ppiEntry = (PpiDeclarations.Entry)ppiEntryList.get(i);\r
try {\r
- cNameGuid[0] = ppiEntryList.get(i).getCName();\r
- cNameGuid[1] = formatGuidName(ppiEntryList.get(i)\r
- .getGuid().getStringValue());\r
- this.ppiInfo.put(ppiEntryList.get(i).getName(), new String[] {\r
- cNameGuid[0], cNameGuid[1] });\r
+ if (ppiEntry.isSetGuidValue()) {\r
+ guidString = ppiEntry.getGuidValue();\r
+ } else {\r
+ guidString = ppiEntry.getGuid().getStringValue();\r
+ }\r
+\r
+ cNameGuid[0] = ppiEntry.getCName();\r
+ cNameGuid[1] = formatGuidName(guidString);\r
+ this.ppiInfo.put(ppiEntry.getName(), new String[] { cNameGuid[0], cNameGuid[1] });\r
} catch (Exception e) {\r
- System.out\r
- .print("can't find GuidDeclarations C_Name & Guid!\n");\r
+ System.out.print("can't find GuidDeclarations C_Name & Guid!\n");\r
}\r
}\r
}\r
**/\r
public void genProtocolInfoList(ProtocolDeclarations proInfo) {\r
String[] cNameGuid = new String[2];\r
+ String guidString;\r
+\r
if (proInfo != null) {\r
List<ProtocolDeclarations.Entry> protocolEntryList = proInfo.getEntryList();\r
+ ProtocolDeclarations.Entry protocolEntry;\r
for (int i = 0; i < protocolEntryList.size(); i++) {\r
+ protocolEntry = (ProtocolDeclarations.Entry)protocolEntryList.get(i);\r
try {\r
- cNameGuid[0] = protocolEntryList.get(i).getCName();\r
- cNameGuid[1] = formatGuidName(protocolEntryList.get(i)\r
- .getGuid().getStringValue());\r
-\r
- String temp = new String(protocolEntryList.get(i).getName());\r
- this.protocolInfo.put(temp, new String[] { cNameGuid[0],\r
- cNameGuid[1] });\r
+ if (protocolEntry.isSetGuidValue()) {\r
+ guidString = protocolEntry.getGuidValue();\r
+ } else {\r
+ guidString = protocolEntry.getGuid().getStringValue();\r
+ }\r
+ cNameGuid[0] = protocolEntry.getCName();\r
+ cNameGuid[1] = formatGuidName(guidString);\r
+\r
+ String temp = new String(protocolEntry.getName());\r
+ this.protocolInfo.put(temp, new String[] { cNameGuid[0], cNameGuid[1] });\r
} catch (Exception e) {\r
- System.out\r
- .print("can't find ProtocolDeclarations C_Name & Guid!\n");\r
+ System.out.print("can't find ProtocolDeclarations C_Name & Guid!\n");\r
}\r
}\r
}\r
**/\r
public void genGuidInfoList(GuidDeclarations guidInfo) {\r
String[] cNameGuid = new String[2];\r
+ String guidString;\r
+\r
if (guidInfo != null) {\r
\r
- List<GuidDeclarations.Entry> guidEntryList = guidInfo.getEntryList();\r
+ List<GuidDeclarations.Entry> guidEntryList = guidInfo.getEntryList();\r
+ GuidDeclarations.Entry guidEntry;\r
for (int i = 0; i < guidEntryList.size(); i++) {\r
- cNameGuid[0] = guidEntryList.get(i).getCName();\r
- cNameGuid[1] = formatGuidName(guidEntryList.get(i)\r
- .getGuid().getStringValue());\r
- this.guidInfo.put(guidEntryList.get(i).getName(), new String[] {\r
- cNameGuid[0], cNameGuid[1] });\r
+ guidEntry = (GuidDeclarations.Entry)guidEntryList.get(i);\r
+ if (guidEntry.isSetGuidValue()) {\r
+ guidString = guidEntry.getGuidValue();\r
+ } else {\r
+ guidString = guidEntry.getGuid().getStringValue();\r
+ }\r
+ \r
+ cNameGuid[0] = guidEntry.getCName();\r
+ cNameGuid[1] = formatGuidName(guidString);\r
+ this.guidInfo.put(guidEntry.getName(), new String[] {cNameGuid[0], cNameGuid[1] });\r
}\r
}\r
}\r
.getLibraryClassDefinitions());\r
msaMap.put("SourceFiles", doc.getModuleSurfaceArea().getSourceFiles());\r
msaMap.put("Includes", doc.getModuleSurfaceArea().getIncludes());\r
+ msaMap.put("PackageDependencies", doc.getModuleSurfaceArea().getPackageDependencies());\r
msaMap.put("Protocols", doc.getModuleSurfaceArea().getProtocols());\r
\r
msaMap.put("Events", doc.getModuleSurfaceArea().getEvents());\r
import org.tianocore.PackageNameDocument;\r
import org.tianocore.ProtocolsDocument;\r
import org.tianocore.PcdCodedDocument.PcdCoded;\r
+import org.tianocore.MsaHeaderDocument;\r
+import org.tianocore.MsaHeaderDocument.MsaHeader;\r
\r
/**\r
SurfaceAreaQuery class is used to query Surface Area information from msa, mbd,\r
};\r
} else {\r
xPath = new String[] {\r
- "/Filename[not(@ArchType) or @ArchType='ALL' or @ArchType='" + arch + "']",\r
+ "/Filename[not(@SupArchList) and not(@ArchType) or @SupArchList='ALL' or @SupArchList='" + arch + "' or @ArchType='ALL' or @ArchType='" + arch + "']",\r
+ "/Filename[not(@SupArchList) and not(@ArchType) or @ArchType='ALL' or @ArchType='" + arch + "']",\r
"/Arch[@ArchType='ALL' or @ArchType='" + arch + "']/Filename"\r
};\r
}\r
} else {\r
xPath = new String[] {\r
"/Option",\r
+ "/Option[@SupArchList='ALL' or @SupArchList='" + arch + "']",\r
"/Arch[@ArchType='ALL' or @ArchType='" + arch + "']/Option"\r
};\r
}\r
return result;\r
}\r
\r
+ public static String getModuleName() {\r
+ String[] xPath = new String[] { "/ModuleName", "/BaseName" };\r
+\r
+ XmlObject[] returns = get(xPath);\r
+ if (returns != null && returns.length > 0) {\r
+ return returns[0].toString();\r
+ }\r
+\r
+ return null;\r
+ }\r
+\r
/**\r
Retrieve <xxxHeader>/ModuleType\r
\r
} else {\r
xPath = new String[] {\r
"/PackageName",\r
+ "/PackageName[@SupArchList='ALL' or @SupArchList='" + arch + "']",\r
+ "/PackageName[@Arch='ALL' or @Arch='" + arch + "']",\r
"/Arch[@ArchType='ALL' or @ArchType='" + arch + "']/PackageName"\r
};\r
}\r
\r
XmlObject[] returns = get("Includes", xPath);\r
if (returns == null || returns.length == 0) {\r
- return null;\r
+ returns = get("PackageDependencies", xPath);\r
+ if (returns == null || returns.length == 0) {\r
+ return null;\r
+ }\r
}\r
\r
List<String> packageNames = new ArrayList<String>();\r
@returns null if nothing is there\r
**/\r
public static String getModuleGuid() {\r
- String[] xPath = new String[] { "/Guid" };\r
+ String[] xPath = new String[] { "" };\r
\r
- XmlObject[] returns = get(xPath);\r
+ XmlObject[] returns = get("MsaHeader", xPath);\r
if (returns != null && returns.length > 0) {\r
- GuidDocument.Guid guid = (GuidDocument.Guid) returns[0];\r
- return guid.getStringValue();\r
+ MsaHeaderDocument.MsaHeader moduleHeader = (MsaHeaderDocument.MsaHeader) returns[0];\r
+ if (moduleHeader.isSetGuid()) {\r
+ return moduleHeader.getGuid().getStringValue();\r
+ } else if (moduleHeader.isSetGuidValue()) {\r
+ return moduleHeader.getGuidValue();\r
+ }\r
+ }\r
+\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ Retrieve module Guid string\r
+ \r
+ @returns GUILD string if elements are found at the known xpath\r
+ @returns null if nothing is there\r
+ **/\r
+ public static String getModuleGuidValue() {\r
+ String[] xPath = new String[] { "" };\r
+\r
+ XmlObject[] returns = get("MsaHeader", xPath);\r
+ if (returns != null && returns.length > 0) { \r
+ MsaHeaderDocument.MsaHeader moduleHeader = (MsaHeaderDocument.MsaHeader) returns[0];\r
+ return moduleHeader.getGuidValue();\r
}\r
\r
return null;\r
}\r
\r
xPath = new String[] {\r
- "/Library" + usageAttribute,\r
+ "/Library" + archAttribute, //usageAttribute,\r
+ "/Library[not(@SupArchList) or @SupArchList='" + arch + "']",\r
"/Arch" + archAttribute + "/Library" + usageAttribute\r
};\r
\r
\r
XmlObject[] result = get("FrameworkPlatformDescription", xPath);\r
if (result == null) {\r
+ xPath = new String[] { "/FrameworkModules/*/ModuleSA" };\r
+ result = get("FrameworkPlatformDescription", xPath);\r
+ if (result != null) {\r
+ return (ModuleSADocument.ModuleSA[]) result;\r
+ }\r
return new ModuleSADocument.ModuleSA[0];\r
}\r
\r