]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
moved exception and logger classes to org.tianocore.common package
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / GlobalData.java
index 1e7568757af2ef77e978d26a8e0c2a0193134334..89c85ed8c26d54d28b1eec37975c4bb37321e756 100644 (file)
@@ -1,10 +1,10 @@
 /** @file\r
-  GlobalData class. \r
-  \r
+  GlobalData class.\r
+\r
   GlobalData provide initializing, instoring, querying and update global data.\r
   It is a bridge to intercommunicate between multiple component, such as AutoGen,\r
-  PCD and so on.   \r
\r
+  PCD and so on.\r
+\r
 Copyright (c) 2006, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -27,6 +27,10 @@ import java.util.logging.Logger;
 \r
 import org.apache.tools.ant.BuildException;\r
 import org.apache.xmlbeans.XmlObject;\r
+\r
+import org.tianocore.common.exception.EdkException;\r
+import org.tianocore.common.logger.EdkLog;\r
+import org.tianocore.pcd.entity.MemoryDatabaseManager;\r
 import org.tianocore.DbPathAndFilename;\r
 import org.tianocore.FrameworkDatabaseDocument;\r
 import org.tianocore.ModuleSurfaceAreaDocument;\r
@@ -35,44 +39,41 @@ import org.tianocore.build.id.FpdModuleIdentification;
 import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.id.PackageIdentification;\r
 import org.tianocore.build.id.PlatformIdentification;\r
-import org.tianocore.pcd.entity.MemoryDatabaseManager;\r
 import org.tianocore.build.toolchain.ToolChainAttribute;\r
 import org.tianocore.build.toolchain.ToolChainConfig;\r
 import org.tianocore.build.toolchain.ToolChainElement;\r
 import org.tianocore.build.toolchain.ToolChainInfo;\r
 import org.tianocore.build.toolchain.ToolChainKey;\r
 import org.tianocore.build.toolchain.ToolChainMap;\r
-import org.tianocore.exception.EdkException;\r
-import org.tianocore.logger.EdkLog;\r
 \r
 /**\r
   GlobalData provide initializing, instoring, querying and update global data.\r
   It is a bridge to intercommunicate between multiple component, such as AutoGen,\r
-  PCD and so on. \r
-  \r
-  <p>Note that all global information are initialized incrementally. All data will \r
+  PCD and so on.\r
+\r
+  <p>Note that all global information are initialized incrementally. All data will\r
   parse and record only of necessary during build time. </p>\r
-  \r
+\r
   @since GenBuild 1.0\r
 **/\r
 public class GlobalData {\r
 \r
     public static Logger log = Logger.getAnonymousLogger();\r
-    \r
+\r
     ///\r
     /// Record current WORKSPACE Directory\r
     ///\r
     private static String workspaceDir = "";\r
-    \r
+\r
     ///\r
     /// Be used to ensure Global data will be initialized only once.\r
     ///\r
     private static boolean globalFlag = false;\r
-    \r
+\r
     ///\r
     /// Framework Database information: package list and platform list\r
     ///\r
-    private static Set<PackageIdentification> packageList = new HashSet<PackageIdentification>();  \r
+    private static Set<PackageIdentification> packageList = new HashSet<PackageIdentification>();\r
 \r
     private static Set<PlatformIdentification> platformList = new HashSet<PlatformIdentification>();\r
 \r
@@ -93,17 +94,17 @@ public class GlobalData {
     private static XmlObject fpdBuildOptions;\r
 \r
     private static XmlObject fpdDynamicPcds;\r
-    \r
+\r
     ///\r
     /// Parsed modules list\r
     ///\r
     private static Map<FpdModuleIdentification, Map<String, XmlObject>> parsedModules = new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r
-    \r
+\r
     ///\r
     /// built modules list with ARCH, TARGET, TOOLCHAIN\r
     ///\r
     private static Set<FpdModuleIdentification> builtModules = new HashSet<FpdModuleIdentification>();\r
-    \r
+\r
     ///\r
     /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.\r
     ///\r
@@ -117,7 +118,7 @@ public class GlobalData {
     /// toolsDef - build tool program information\r
     /// fpdBuildOption - all modules's build options for tool tag or tool chain families\r
     /// moduleSaBuildOption - build options for a specific module\r
-    /// \r
+    ///\r
     private static ToolChainConfig toolsDef;\r
 \r
     private static ToolChainInfo toolChainInfo;\r
@@ -133,8 +134,8 @@ public class GlobalData {
     /**\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
-      in the whole build process.  \r
-    \r
+      in the whole build process.\r
+\r
       @param workspaceDatabaseFile the file name of framework database\r
       @param workspaceDir current workspace directory path\r
       @throws BuildException\r
@@ -149,11 +150,11 @@ public class GlobalData {
         }\r
         globalFlag = true;\r
 \r
-               // \r
+               //\r
         // Backup workspace directory. It will be used by other method\r
         //\r
         GlobalData.workspaceDir = workspaceDir.replaceAll("(\\\\)", "/");\r
-        \r
+\r
         //\r
         // Parse tools definition file\r
         //\r
@@ -164,7 +165,7 @@ public class GlobalData {
         File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);\r
         System.out.println("Using tool definiton file [" + toolsDefFile.getPath() + "].");\r
         toolsDef = new ToolChainConfig(toolsDefFile);\r
-        \r
+\r
         //\r
         // Parse Framework Database\r
         //\r
@@ -228,10 +229,10 @@ public class GlobalData {
             throw new BuildException("Parse WORKSPACE Database file [" + dbFile.getPath() + "] Error.\n" + e.getMessage());\r
         }\r
     }\r
-    \r
+\r
     /**\r
-      Get the current WORKSPACE Directory. \r
-      \r
+      Get the current WORKSPACE Directory.\r
+\r
       @return current workspace directory\r
     **/\r
     public synchronized static String getWorkspacePath() {\r
@@ -245,7 +246,7 @@ public class GlobalData {
     public synchronized static File getMsaFile(ModuleIdentification moduleId) throws BuildException {\r
         File msaFile = null;\r
         //\r
-        // TBD. Do only when package is null. \r
+        // TBD. Do only when package is null.\r
         //\r
         Iterator iter = packageList.iterator();\r
         while (iter.hasNext()) {\r
@@ -271,7 +272,7 @@ public class GlobalData {
         if (moduleId.getPackage() != null) {\r
             return moduleId.getPackage();\r
         }\r
-        \r
+\r
         PackageIdentification packageId = null;\r
         Iterator iter = packageList.iterator();\r
         while (iter.hasNext()) {\r
@@ -289,19 +290,19 @@ public class GlobalData {
             return packageId;\r
         }\r
     }\r
-    \r
+\r
     /**\r
       Difference between build and parse: ToolChain and Target\r
     **/\r
     public synchronized static boolean isModuleBuilt(FpdModuleIdentification moduleId) {\r
         return builtModules.contains(moduleId);\r
     }\r
-    \r
+\r
     public synchronized static void registerBuiltModule(FpdModuleIdentification fpdModuleId) {\r
         builtModules.add(fpdModuleId);\r
     }\r
 \r
-    \r
+\r
     public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map<String, XmlObject> doc) {\r
         Map<String, XmlObject> result = new HashMap<String, XmlObject>();\r
         Set keySet = doc.keySet();\r
@@ -320,11 +321,11 @@ public class GlobalData {
 \r
     /**\r
       Query overrided module surface area information. If current is Package\r
-      or Platform build, also include the information from FPD file. \r
-      \r
-      <p>Note that surface area parsing is incremental. That means the method will \r
+      or Platform build, also include the information from FPD file.\r
+\r
+      <p>Note that surface area parsing is incremental. That means the method will\r
       only parse the MSA and MBD files if necessary. </p>\r
-    \r
+\r
       @param moduleName the base name of the module\r
       @return the overrided module surface area information\r
       @throws BuildException\r
@@ -340,12 +341,12 @@ public class GlobalData {
         // First part: get the MSA files info\r
         //\r
         doc.putAll(getNativeMsa(moduleId));\r
-        \r
+\r
         //\r
         // Second part: put build options\r
         //\r
         doc.put("BuildOptions", fpdBuildOptions);\r
-        \r
+\r
         //\r
         // Third part: get Module info from FPD, such as Library instances, PCDs\r
         //\r
@@ -365,11 +366,11 @@ public class GlobalData {
         return getDoc(fpdModuleId);\r
     }\r
     /**\r
-      Query the native MSA information with module base name. \r
-      \r
-      <p>Note that MSA parsing is incremental. That means the method will \r
+      Query the native MSA information with module base name.\r
+\r
+      <p>Note that MSA parsing is incremental. That means the method will\r
       only to parse the MSA files when never parsed before. </p>\r
-      \r
+\r
       @param moduleName the base name of the module\r
       @return the native MSA information\r
       @throws BuildException\r
@@ -384,7 +385,7 @@ public class GlobalData {
         nativeMsa.put(moduleId, msaMap);\r
         return msaMap;\r
     }\r
-    \r
+\r
     public synchronized static Map<String, XmlObject> getNativeMsa(File msaFile) throws BuildException {\r
         if (! msaFile.exists()) {\r
             throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] can't be found!");\r
@@ -418,13 +419,13 @@ public class GlobalData {
             throw new BuildException(ex.getMessage());\r
         }\r
     }\r
-    \r
+\r
     public static Map<String, XmlObject> getFpdBuildOptions() {\r
         Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
         map.put("BuildOptions", fpdBuildOptions);\r
         return map;\r
     }\r
-    \r
+\r
     public static void setFpdBuildOptions(XmlObject fpdBuildOptions) {\r
         GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);\r
     }\r
@@ -439,7 +440,7 @@ public class GlobalData {
 \r
     //////////////////////////////////////////////\r
     //////////////////////////////////////////////\r
-    \r
+\r
     public static Set<ModuleIdentification> getModules(PackageIdentification packageId){\r
         Spd spd = spdTable.get(packageId);\r
         if (spd == null ) {\r
@@ -572,7 +573,7 @@ public class GlobalData {
         return null;\r
 \r
     }\r
-    \r
+\r
     public synchronized static PlatformIdentification getPlatformByName(String name) throws BuildException {\r
         Iterator iter = platformList.iterator();\r
         while(iter.hasNext()){\r
@@ -583,7 +584,7 @@ public class GlobalData {
         }\r
         throw new BuildException("Can't find platform [" + name + "] in the current WORKSPACE database!");\r
     }\r
-    \r
+\r
     public synchronized static PlatformIdentification getPlatform(String filename) throws BuildException {\r
         File file = new File(workspaceDir + File.separatorChar + filename);\r
         Iterator iter = platformList.iterator();\r
@@ -595,7 +596,7 @@ public class GlobalData {
         }\r
         throw new BuildException("Can't find platform file [" + filename + "] in the current WORKSPACE database!");\r
     }\r
-    \r
+\r
     public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws BuildException {\r
         Iterator iter = packageList.iterator();\r
         while(iter.hasNext()){\r
@@ -608,7 +609,7 @@ public class GlobalData {
         }\r
         throw new BuildException("Can't find package GUID value " + packageId.getGuid() + " in the current workspace!");\r
     }\r
-    \r
+\r
     public synchronized static ModuleIdentification refreshModuleIdentification(ModuleIdentification moduleId) throws BuildException {\r
 //        System.out.println("1");\r
 //        System.out.println("##" + moduleId.getGuid());\r
@@ -632,7 +633,7 @@ public class GlobalData {
         }\r
         throw new BuildException("Can't find module GUID value " + moduleId.getGuid() + " in package, " + packageId + ", in the current workspace!");\r
     }\r
-    \r
+\r
     public synchronized static Set<PackageIdentification> getPackageList(){\r
         return packageList;\r
     }\r
@@ -702,7 +703,7 @@ public class GlobalData {
 \r
     public static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException {\r
         ToolChainKey toolChainKey = new ToolChainKey(commandDescription);\r
-        ToolChainMap toolChainConfig = toolsDef.getConfig(); \r
+        ToolChainMap toolChainConfig = toolsDef.getConfig();\r
         String setting = null;\r
 \r
         if (!commandDescription[ToolChainElement.ATTRIBUTE.value].equals(ToolChainAttribute.FLAGS.toString())) {\r
@@ -731,7 +732,7 @@ public class GlobalData {
             toolChainFamilyKey.setKey(ToolChainAttribute.FLAGS.toString(), ToolChainElement.ATTRIBUTE.value);\r
 \r
             option = moduleToolChainFamilyOption.get(fpdModuleId);\r
-            if (option != null) {                \r
+            if (option != null) {\r
                 setting = option.get(toolChainFamilyKey);\r
             }\r
         }\r
@@ -761,7 +762,7 @@ public class GlobalData {
 \r
         return setting;\r
     }\r
-    \r
+\r
     public static void setToolChainEnvInfo(ToolChainInfo envInfo) {\r
         toolChainEnvInfo = envInfo;\r
     }\r
@@ -803,17 +804,17 @@ public class GlobalData {
     //\r
     // For PCD\r
     //\r
-    public synchronized static Map<FpdModuleIdentification, XmlObject> \r
+    public synchronized static Map<FpdModuleIdentification, XmlObject>\r
                                getFpdModuleSaXmlObject(String xmlObjectName) {\r
         Set<FpdModuleIdentification> fpdModuleSASet = fpdModuleSA.keySet();\r
         Iterator item = fpdModuleSASet.iterator();\r
-        \r
+\r
 \r
         Map<FpdModuleIdentification, XmlObject> SAPcdBuildDef = new HashMap<FpdModuleIdentification, XmlObject>();\r
         Map<String, XmlObject> SANode = new HashMap<String, XmlObject>();\r
         FpdModuleIdentification moduleId;\r
         while (item.hasNext()) {\r
-            \r
+\r
             moduleId = (FpdModuleIdentification) item.next();\r
             SANode = fpdModuleSA.get(moduleId);\r
             try{\r