import java.util.HashSet;\r
import java.util.Iterator;\r
import java.util.List;\r
+import java.util.ListIterator;\r
import java.util.Map;\r
import java.util.Set;\r
+import java.util.Vector;\r
import java.util.logging.Logger;\r
\r
/**\r
///\r
/// Be used to ensure Global data will be initialized only once.\r
///\r
- private static boolean globalFlag = false;\r
+// private static boolean globalFlag = false;\r
\r
///\r
/// Framework Database information: package list and platform list\r
///\r
private static Set<FpdModuleIdentification> builtModules = new HashSet<FpdModuleIdentification>();\r
\r
- ///\r
- /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.\r
- ///\r
-// private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();\r
-\r
- ///\r
- /// build target + tool chain family/tag name + arch + command types + command options\r
- ///\r
- private static Map<String, Object> toolChainOptions;\r
- private static Map<String, Object> toolChainFamilyOptions;\r
- private static Map<String, String> toolChainDefinitions;\r
- ///\r
- ///\r
- ///\r
- private static Set<String> targets;\r
- ///\r
- ///\r
- ///\r
- private static Set<String> toolChainFamilies;\r
- ///\r
- ///\r
- ///\r
- private static Set<String> toolChains;\r
- ///\r
- /// keep track which toolchain family a toolchain tag belongs to\r
- ///\r
- private static Map<String, Set<String>> toolChainFamilyMap;\r
- private static Map<String, Set<String>> toolChainCommandMap;\r
- \r
- ///\r
- /// list of Arch: EBC, ARM, IA32, X64, IPF, PPC\r
- ///\r
- private static Set<String> archs;\r
-\r
- ///\r
- /// list of Command Type: CC, LIB, LINK, ASL, ASM, ASMLINK, PP\r
- ///\r
- private static Set<String> commandTypes;\r
- \r
/**\r
Parse framework database (DB) and all SPD files listed in DB to initialize\r
the environment for next build. This method will only be executed only once\r
Framework Dababase or SPD or MSA file is not valid\r
**/\r
public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir) throws Exception {\r
- //\r
- // ensure this method will be revoked only once\r
- //\r
- if (globalFlag) {\r
- return;\r
- }\r
- globalFlag = true;\r
\r
//\r
// Backup workspace directory. It will be used by other method\r
DbPathAndFilename dbPath = (DbPathAndFilename)iter.next();\r
String fileName = dbPath.getStringValue();\r
Spd spd = new Spd(new File(workspaceDir + File.separatorChar + fileName));\r
- packageList.add(spd.getPackageId());\r
+ if (!packageList.contains(spd.getPackageId())) {\r
+ packageList.add(spd.getPackageId());\r
+ }\r
spdTable.put(spd.getPackageId(), spd);\r
}\r
\r
}\r
\r
public synchronized static Map<String, XmlObject> getNativeMsa(File msaFile) throws Exception {\r
- if (! msaFile.exists()) {\r
- throw new Exception("Surface Area file [" + msaFile.getPath() + "] can't found.");\r
- }\r
+ \r
try {\r
ModuleSurfaceAreaDocument doc = (ModuleSurfaceAreaDocument)XmlObject.Factory.parse(msaFile);\r
//\r
}\r
}\r
\r
- /**\r
- The header file path is relative to workspace dir\r
- **/\r
- public static String[] getLibraryClassHeaderFiles(PackageIdentification[] packages, String name) {\r
- if (packages == null ){\r
- // throw Exception or not????\r
- return new String[0];\r
- }\r
- String[] result = null;\r
- for (int i = 0; i < packages.length; i++){\r
- Spd spd = spdTable.get(packages[i]);\r
- //\r
- // If find one package defined the library class\r
- //\r
- if( (result = spd.getLibClassIncluder(name)) != null){\r
- return result;\r
- } \r
- }\r
- return null;\r
- \r
- }\r
- \r
- /**\r
- The header file path is relative to workspace dir\r
- **/ \r
- public static String getPackageHeaderFiles(PackageIdentification packages, String moduleType) throws Exception {\r
- if (packages == null ){\r
- return new String("");\r
- }\r
- Spd spd = spdTable.get(packages);\r
- //\r
- // If can't find package header file, skip it\r
- //\r
- String temp = null;\r
- if (spd != null){\r
- if( (temp = spd.getPackageIncluder(moduleType)) != null){\r
- return temp;\r
- }else {\r
- temp = "";\r
- return temp;\r
- }\r
- }else {\r
- return null;\r
- }\r
- } \r
- \r
- /**\r
- return two values: {cName, GuidValue}\r
- **/\r
- public static String[] getGuid(PackageIdentification[] packages, String name) throws Exception {\r
- if (packages == null ){\r
- // throw Exception or not????\r
- return new String[0];\r
- }\r
- String[] result = null;\r
- for (int i = 0; i < packages.length; i++){\r
- Spd spd = spdTable.get(packages[i]);\r
- //\r
- // If find one package defined the GUID\r
- //\r
- if( (result = spd.getGuid(name)) != null){\r
- return result;\r
- }\r
- }\r
- return null;\r
- }\r
- \r
- /**\r
- return two values: {cName, GuidValue}\r
- **/ \r
- public static String[] getPpiGuid(PackageIdentification[] packages, String name) throws Exception {\r
- if (packages == null ){\r
- return new String[0];\r
- }\r
- String[] result = null;\r
- for (int i = 0; i < packages.length; i++){\r
- Spd spd = spdTable.get(packages[i]);\r
- //\r
- // If find one package defined the Ppi GUID\r
- //\r
- if( (result = spd.getPpi(name)) != null){\r
- return result;\r
- }\r
- }\r
- return null;\r
- \r
- }\r
- \r
- /**\r
- return two values: {cName, GuidValue}\r
- **/ \r
- public static String[] getProtocolGuid(PackageIdentification[] packages, String name) throws Exception {\r
- if (packages == null ){\r
- return new String[0];\r
- }\r
- String[] result = null;\r
- for (int i = 0; i < packages.length; i++){\r
- Spd spd = spdTable.get(packages[i]);\r
- //\r
- // If find one package defined the protocol GUID\r
- //\r
- if( (result = spd.getProtocol(name)) != null){\r
- return result;\r
- }\r
- }\r
- return null;\r
- \r
- }\r
- \r
- /////////////////////////// Update!! Update!! Update!!\r
-// public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {\r
-// return pcdDbManager;\r
-// }\r
- ///////////////////////////\r
public synchronized static PlatformIdentification getPlatform(String name) throws Exception {\r
Iterator iter = platformList.iterator();\r
while(iter.hasNext()){\r
return result;\r
}\r
\r
- ////// Tool Chain Related, try to refine and put some logic process to ToolChainFactory\r
- public static void setBuildToolChainFamilyOptions(Map<String, Object> map) {\r
- toolChainFamilyOptions = map;\r
- }\r
-\r
- public static Map<String, Object> getToolChainFamilyOptions() {\r
- return toolChainFamilyOptions;\r
- }\r
-\r
- public static void setBuildToolChainOptions(Map<String, Object> map) {\r
- toolChainOptions = map;\r
- }\r
-\r
- public static Map<String, Object> getToolChainOptions() {\r
- return toolChainOptions;\r
- }\r
-\r
- public static void setTargets(Set<String> targetSet) {\r
- GlobalData.log.info("TargetSet: " + targetSet);\r
- targets = targetSet;\r
- }\r
-\r
- public static String[] getTargets() {\r
- return (String[])targets.toArray(new String[targets.size()]);\r
- }\r
-\r
- public static void setToolChains(Set<String> toolChainSet) {\r
- toolChains = toolChainSet;\r
- }\r
-\r
- public static String[] getToolChains() {\r
- String[] toolChainList = new String[toolChains.size()];\r
- return (String[])toolChains.toArray(toolChainList);\r
- }\r
-\r
- public static void setToolChainFamilies(Set<String> toolChainFamilySet) {\r
- toolChainFamilies = toolChainFamilySet;\r
- }\r
-\r
- public static void setToolChainFamiliyMap(Map<String, Set<String>> map) {\r
- /*\r
- Set<String> keys = map.keySet();\r
- Iterator it = keys.iterator();\r
- while (it.hasNext()) {\r
- String toolchain = (String)it.next();\r
- Set<String> familyMap = (Set<String>)map.get(toolchain);\r
- Iterator fit = familyMap.iterator();\r
- System.out.print(toolchain + ": ");\r
- while (fit.hasNext()) {\r
- System.out.print((String)fit.next() + " ");\r
+ \r
+ public static Vector<String> getModuleSupArchs(ModuleIdentification mi) throws Exception{\r
+ Vector<String> vArchs = null;\r
+ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)getModuleXmlObject(mi);\r
+ if (msa.getModuleDefinitions() == null || msa.getModuleDefinitions().getSupportedArchitectures() == null) {\r
+ return vArchs;\r
+ }\r
+ ListIterator li = msa.getModuleDefinitions().getSupportedArchitectures().listIterator();\r
+ while (li.hasNext()) {\r
+ if (vArchs == null) {\r
+ vArchs = new Vector<String>();\r
}\r
- System.out.println("");\r
+ vArchs.add((String)li.next());\r
}\r
- */\r
- toolChainFamilyMap = map;\r
- }\r
-\r
- public static String[] getToolChainFamilies() {\r
- String[] toolChainFamilyList = new String[toolChainFamilies.size()];\r
- return (String[])toolChainFamilies.toArray(toolChainFamilyList);\r
- }\r
-\r
- public static String[] getToolChainFamilies(String toolChain) {\r
- Set<String> familySet = (Set<String>)toolChainFamilyMap.get(toolChain);\r
- String[] toolChainFamilyList = new String[familySet.size()];\r
- return (String[])familySet.toArray(toolChainFamilyList);\r
- }\r
-\r
- public static Set<String> getToolChainFamilySet(String toolChain) {\r
- return (Set<String>)toolChainFamilyMap.get(toolChain);\r
- }\r
-\r
- public static void setArchs(Set<String> archSet) {\r
- archs = archSet;\r
- }\r
-\r
- public static String[] getArchs() {\r
- String[] archList = new String[archs.size()];\r
- return (String[])archs.toArray(archList);\r
- }\r
- /*\r
-\r
- */\r
- public static void SetCommandTypes(Set<String> commandTypeSet) {\r
- commandTypes = commandTypeSet;\r
- }\r
- /*\r
-\r
- */\r
- public static void SetCommandTypes(Map<String, Set<String>> commandTypeMap) {\r
- toolChainCommandMap = commandTypeMap;\r
- }\r
- /*\r
-\r
- */\r
- public static String[] getCommandTypes() {\r
- String[] commandList = new String[commandTypes.size()];\r
- return (String[])commandTypes.toArray(commandList);\r
- }\r
- /*\r
-\r
- */\r
- public static String[] getCommandTypes(String toolChain) {\r
- Set<String> commands = (Set<String>)toolChainCommandMap.get(toolChain);\r
- if (commands == null) {\r
- return new String[0];\r
- }\r
-\r
- String[] commandList = new String[commands.size()];\r
- return (String[])commands.toArray(commandList);\r
- }\r
- /*\r
-\r
- */\r
- public static String getCommandSetting(String commandDescString) {\r
- return (String)toolChainDefinitions.get(commandDescString);\r
- }\r
- /*\r
-\r
- */\r
- public static void setToolChainDefinitions(Map<String, String> def) {\r
- toolChainDefinitions = def;\r
- }\r
-\r
- public static Map<String, String> getToolChainDefinitions() {\r
- return toolChainDefinitions;\r
+ \r
+ return vArchs;\r
}\r
-\r
+ \r
}\r
\r
final class KeyComparator implements Comparator<String> {\r