import org.apache.xmlbeans.XmlException;\r
import org.tianocore.DbPathAndFilename;\r
import org.tianocore.IndustryStdIncludesDocument.IndustryStdIncludes;\r
+import org.tianocore.LibraryClassDeclarationsDocument.LibraryClassDeclarations;\r
+import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;\r
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
import org.tianocore.MsaFilesDocument.MsaFiles;\r
import org.tianocore.PackageDependenciesDocument.PackageDependencies;\r
import org.tianocore.frameworkwizard.common.Sort;\r
import org.tianocore.frameworkwizard.common.Tools;\r
import org.tianocore.frameworkwizard.common.Identifications.Identification;\r
+import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;\r
import org.tianocore.frameworkwizard.far.FarHeader;\r
import org.tianocore.frameworkwizard.far.FarIdentification;\r
import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
return GlobalData.vPackageList;\r
}\r
\r
+ /**\r
+ Get all package which match parameter isRepackagable\r
+ \r
+ @param isRepackagable\r
+ @return\r
+ \r
+ **/\r
+ public Vector<PackageIdentification> getAllRepackagbalePackages() {\r
+ Vector<PackageIdentification> v = new Vector<PackageIdentification>();\r
+ for (int index = 0; index < GlobalData.openingPackageList.size(); index++) {\r
+ OpeningPackageType opt = GlobalData.openingPackageList.getOpeningPackageByIndex(index);\r
+ if (opt.getXmlSpd() != null) {\r
+ if (opt.getXmlSpd().getPackageDefinitions() != null) {\r
+ if (opt.getXmlSpd().getPackageDefinitions().getRePackage()) {\r
+ v.addElement(opt.getId());\r
+ }\r
+ } else {\r
+ v.addElement(opt.getId());\r
+ }\r
+ } else {\r
+ v.addElement(opt.getId());\r
+ }\r
+ }\r
+ return v;\r
+ }\r
+\r
public Vector<FarIdentification> getAllFars() {\r
\r
Vector<FarIdentification> v = new Vector<FarIdentification>();\r
String help = spd.getPcdDeclarations().getPcdEntryList().get(index).getHelpText();\r
Vector<String> type = Tools.convertListToVector(spd.getPcdDeclarations().getPcdEntryList()\r
.get(index).getValidUsage());\r
-\r
+ //\r
+ // The algorithm for PCD of msa should be:\r
+ // 1. If the type of PCD from Spd is FEATURE_FLAG, \r
+ // the type of Msa only can be FEATURE_FLAG.\r
+ // 2. If the type of PCD from Spd is not FEATURE_FLAG, \r
+ // the type of Msa could be selected from the PCD's all types and "DYNAMIC" type.\r
+ //\r
+ boolean hasFEATURE_FLAG = false;\r
+ boolean hasDYNAMIC = false;\r
+ for (int indexOfType = 0; indexOfType < type.size(); indexOfType++) {\r
+ if (type.elementAt(indexOfType).equals(DataType.PCD_ITEM_TYPE_DYNAMIC)) {\r
+ hasDYNAMIC = true;\r
+ }\r
+ if (type.elementAt(indexOfType).equals(DataType.PCD_ITEM_TYPE_FEATURE_FLAG)) {\r
+ hasFEATURE_FLAG = true;\r
+ }\r
+ }\r
+ if (hasFEATURE_FLAG) {\r
+ type.removeAllElements();\r
+ type.addElement(DataType.PCD_ITEM_TYPE_FEATURE_FLAG);\r
+ } else {\r
+ if (!hasDYNAMIC) {\r
+ type.addElement(DataType.PCD_ITEM_TYPE_DYNAMIC);\r
+ }\r
+ }\r
vector.addPcd(new PcdIdentification(name, guidCName, help, type));\r
}\r
}\r
//\r
// Check id\r
//\r
- if (mid.equals(id)) {\r
- return GlobalData.vPackageList.elementAt(indexI);\r
+ if (mid != null) {\r
+ if (mid.equals(id)) {\r
+ return GlobalData.vPackageList.elementAt(indexI);\r
+ }\r
}\r
-\r
}\r
}\r
\r
msaFile.setFilenameArray(msaFile.getFilenameList().size() - 1, fn);\r
spd.setMsaFiles(msaFile);\r
SaveFile.saveSpdFile(mid.getPackageId().getPath(), spd);\r
+ //\r
+ // Update GlobalData\r
+ //\r
+ GlobalData.openingPackageList.getPackageSurfaceAreaFromId(mid.getPackageId()).setMsaFiles(msaFile);\r
}\r
\r
/**\r
public Vector<String> getAllFilesPathOfModule(String path) {\r
Vector<String> v = new Vector<String>();\r
path = Tools.convertPathToCurrentOsType(path);\r
+\r
+ //\r
+ // First add msa file's path\r
+ //\r
v.addElement(path);\r
+\r
ModuleSurfaceArea msa = GlobalData.openingModuleList\r
.getModuleSurfaceAreaFromId(GlobalData.openingModuleList\r
.getIdByPath(path));\r
+ //\r
+ // Get common defined files of module\r
+ //\r
if (msa != null) {\r
//\r
// Get all files' path of a module\r
}\r
}\r
\r
+ //\r
+ // Get include header files for this module\r
+ //\r
+ if (msa.getLibraryClassDefinitions() != null) {\r
+ LibraryClassDefinitions lcd = msa.getLibraryClassDefinitions();\r
+ for (int index = 0; index < lcd.sizeOfLibraryClassArray(); index++) {\r
+ if (lcd.getLibraryClassList().get(index).getUsage().toString()\r
+ .equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)\r
+ || lcd.getLibraryClassList().get(index).getUsage().toString()\r
+ .equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {\r
+ //\r
+ // Get library class name\r
+ //\r
+ String name = lcd.getLibraryClassList().get(index).getKeyword();\r
+\r
+ //\r
+ // Find file path for this class\r
+ //\r
+ PackageIdentification pid = GlobalData.openingModuleList.getIdByPath(path).getPackageId();\r
+ PackageSurfaceArea spd = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(pid);\r
+ String headerFile = getHeaderFileFromPackageByLibraryClassName(spd, name);\r
+ if (!Tools.isEmpty(headerFile)) {\r
+ v.addElement(Tools.convertPathToCurrentOsType(Tools.getFilePathOnly(pid.getPath())\r
+ + DataType.FILE_SEPARATOR + headerFile));\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
return v;\r
}\r
\r
}\r
return v;\r
}\r
+\r
+ public String getHeaderFileFromPackageByLibraryClassName(PackageSurfaceArea spd, String name) {\r
+ String headerFile = "";\r
+ if (spd != null) {\r
+ if (spd.getLibraryClassDeclarations() != null) {\r
+ LibraryClassDeclarations lcdl = spd.getLibraryClassDeclarations();\r
+ for (int indexOfLibOfSpd = 0; indexOfLibOfSpd < lcdl.sizeOfLibraryClassArray(); indexOfLibOfSpd++) {\r
+ if (lcdl.getLibraryClassList().get(indexOfLibOfSpd).getName().equals(name)) {\r
+ return lcdl.getLibraryClassList().get(indexOfLibOfSpd).getIncludeHeader();\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ return headerFile;\r
+ }\r
}\r