]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update GlobalData, SPD, SurfaceAreaQuery to using EdkException.
authorwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 6 Sep 2006 09:37:36 +0000 (09:37 +0000)
committerwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 6 Sep 2006 09:37:36 +0000 (09:37 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1485 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java
Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
Tools/Source/GenBuild/org/tianocore/build/GenBuildThread.java
Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java
Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
Tools/Source/GenBuild/org/tianocore/build/global/Spd.java
Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
Tools/Source/GenBuild/org/tianocore/build/id/ModuleIdentification.java
Tools/Source/GenBuild/org/tianocore/build/id/PackageIdentification.java

index 9d68419aa8bc24365f7a037d55bca59a6a3286ad..14103d7b22f3f076d7abd77c3003973c3c437a15 100644 (file)
@@ -111,6 +111,13 @@ public class FrameworkBuildTask extends Task{
     private String type = "all";\r
     \r
     public void execute() throws BuildException {\r
+        //\r
+        // set Logger\r
+        //\r
+        GenBuildLogger logger = new GenBuildLogger(getProject());\r
+        EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));\r
+        EdkLog.setLogger(logger);\r
+        \r
         try {\r
             processFrameworkBuild();\r
         } catch (PcdAutogenException e) {\r
@@ -142,13 +149,6 @@ public class FrameworkBuildTask extends Task{
     }\r
     \r
     private void processFrameworkBuild() throws EdkException, GenBuildException, AutoGenException, PcdAutogenException, PlatformPcdPreprocessBuildException {\r
-        //\r
-        // set Logger\r
-        //\r
-        GenBuildLogger logger = new GenBuildLogger(getProject());\r
-        EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));\r
-        EdkLog.setLogger(logger);\r
-\r
         //\r
         // Seach build.xml -> .FPD -> .MSA file\r
         //\r
@@ -180,8 +180,10 @@ public class FrameworkBuildTask extends Task{
                     }\r
                 }\r
             }\r
-        } catch (IOException e) {\r
-            throw new BuildException(e.getMessage());\r
+        } catch (IOException ex) {\r
+            BuildException buildException = new BuildException("Scanning current directory error. \n" + ex.getMessage());\r
+            buildException.setStackTrace(ex.getStackTrace());\r
+            throw buildException;\r
         }\r
         \r
         //\r
@@ -426,7 +428,7 @@ public class FrameworkBuildTask extends Task{
                 if (threadNum > 0) {\r
                     MAX_CONCURRENT_THREAD_NUMBER = threadNum;\r
                 }\r
-            } catch (Exception enuma) {\r
+            } catch (Exception ex) {\r
             }\r
         }\r
     }\r
index 9b6251a0a26ae57a368f3ec9c88d096bd261da6e..da866aaa6eabb65a44351837a80209311859ed3f 100644 (file)
@@ -37,6 +37,10 @@ import org.tianocore.common.definitions.ToolDefinitions;
 import org.tianocore.common.exception.EdkException;\r
 import org.tianocore.common.logger.EdkLog;\r
 import org.tianocore.build.autogen.AutoGen;\r
+import org.tianocore.build.exception.AutoGenException;\r
+import org.tianocore.build.exception.GenBuildException;\r
+import org.tianocore.build.exception.PcdAutogenException;\r
+import org.tianocore.build.exception.PlatformPcdPreprocessBuildException;\r
 import org.tianocore.build.fpd.FpdParserTask;\r
 import org.tianocore.build.global.GlobalData;\r
 import org.tianocore.build.global.OutputManager;\r
@@ -126,6 +130,37 @@ public class GenBuildTask extends Ant {
               From module build, exception from module surface area invalid.\r
     **/\r
     public void execute() throws BuildException {\r
+        try {\r
+            processGenBuild();\r
+        } catch (PcdAutogenException e) {\r
+            //\r
+            // Add more logic process here\r
+            //\r
+            throw new BuildException(e.getMessage());\r
+        } catch (AutoGenException e) {\r
+            //\r
+            // Add more logic process here\r
+            //\r
+            throw new BuildException(e.getMessage());\r
+        } catch (PlatformPcdPreprocessBuildException e) {\r
+            //\r
+            // Add more logic process here\r
+            //\r
+            throw new BuildException(e.getMessage());\r
+        } catch (GenBuildException e) {\r
+            //\r
+            // Add more logic process here\r
+            //\r
+            throw new BuildException(e.getMessage());\r
+        } catch (EdkException e) {\r
+            //\r
+            // Add more logic process here\r
+            //\r
+            throw new BuildException(e.getMessage());\r
+        }\r
+    }\r
+\r
+    private void processGenBuild() throws EdkException, BuildException, GenBuildException, AutoGenException, PcdAutogenException, PlatformPcdPreprocessBuildException {\r
        if (!FrameworkBuildTask.multithread) {\r
             cleanupProperties();\r
         }\r
@@ -147,20 +182,26 @@ public class GenBuildTask extends Ant {
             String moduleVersion = getProject().getProperty("MODULE_VERSION");\r
             String packageGuid = getProject().getProperty("PACKAGE_GUID");\r
             String packageVersion = getProject().getProperty("PACKAGE_VERSION");\r
+            //\r
+            // If one of module Guid or package Guid is not specified, report error\r
+            //\r
             if (moduleGuid == null || packageGuid == null) {\r
                 throw new BuildException("GenBuild parameter error.");\r
             }\r
+            \r
             PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);\r
+            GlobalData.refreshPackageIdentification(packageId);\r
             moduleId = new ModuleIdentification(moduleGuid, moduleVersion);\r
             moduleId.setPackage(packageId);\r
+            GlobalData.refreshModuleIdentification(moduleId);\r
             Map<String, XmlObject> doc = GlobalData.getNativeMsa(moduleId);\r
             saq = new SurfaceAreaQuery(doc);\r
-            moduleId = saq.getMsaHeader();\r
         } else {\r
             Map<String, XmlObject> doc = GlobalData.getNativeMsa(msaFile);\r
             saq = new SurfaceAreaQuery(doc);\r
             moduleId = saq.getMsaHeader();\r
         }\r
+        \r
         String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED",null);\r
         if (producedLibraryClasses.length == 0) {\r
             moduleId.setLibrary(false);\r
@@ -176,11 +217,6 @@ public class GenBuildTask extends Ant {
             // Single Module build\r
             //\r
             prepareSingleModuleBuild();\r
-        } else {\r
-            String packageGuid = getProject().getProperty("PACKAGE_GUID");\r
-            String packageVersion = getProject().getProperty("PACKAGE_VERSION");\r
-            PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);\r
-            moduleId.setPackage(packageId);\r
         }\r
 \r
         //\r
@@ -307,14 +343,15 @@ public class GenBuildTask extends Ant {
       Database must be unique. </p>\r
 \r
     **/\r
-    private void prepareSingleModuleBuild(){\r
+    private void prepareSingleModuleBuild() throws EdkException {\r
         //\r
         // Find out the package which the module belongs to\r
         // TBD: Enhance it!!!!\r
         //\r
         PackageIdentification packageId = GlobalData.getPackageForModule(moduleId);\r
-\r
+        GlobalData.refreshPackageIdentification(packageId);\r
         moduleId.setPackage(packageId);\r
+        GlobalData.refreshModuleIdentification(moduleId);\r
 \r
         //\r
         // Read ACTIVE_PLATFORM's FPD file \r
@@ -540,7 +577,7 @@ public class GenBuildTask extends Ant {
         this.type = type;\r
     }\r
 \r
-    private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws BuildException{\r
+    private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws EdkException {\r
         //\r
         // Call AutoGen to generate AutoGen.c and AutoGen.h\r
         //\r
@@ -701,7 +738,7 @@ public class GenBuildTask extends Ant {
         this.isSingleModuleBuild = isSingleModuleBuild;\r
     }\r
     \r
-    private String[] prepareIncludePaths(FpdModuleIdentification fpdModuleId) {\r
+    private String[] prepareIncludePaths(FpdModuleIdentification fpdModuleId) throws EdkException{\r
         //\r
         // Prepare the includes: PackageDependencies and Output debug direactory\r
         //\r
index 416ccd11837fc9f22bbceccaf1b90c34b109e89a..5ab7c0aff79f097e5b9e3e535994cae8276884e9 100644 (file)
@@ -213,5 +213,4 @@ public class GenBuildThread implements Runnable {
     public void setStatus(int status) {\r
         this.status = status;\r
     }\r
-    \r
 }\r
index 548839f135384f710a07eadfca8e7f9016a1a34f..f8c78b848e9be34ac43d1f0c9c3c472eda5960af 100644 (file)
@@ -34,6 +34,7 @@ import org.tianocore.build.global.SurfaceAreaQuery;
 import org.tianocore.build.id.FpdModuleIdentification;\r
 import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.id.PackageIdentification;\r
+import org.tianocore.common.exception.EdkException;\r
 import org.w3c.dom.Comment;\r
 import org.w3c.dom.Document;\r
 import org.w3c.dom.Element;\r
@@ -296,7 +297,7 @@ public class ModuleBuildFileGenerator {
       @param document current BaseName_build.xml XML document\r
       @param root Root element for current\r
     **/\r
-    private void applyLibraryInstance(Document document, Node root) {\r
+    private void applyLibraryInstance(Document document, Node root) throws EdkException {\r
         ModuleIdentification[] libinstances = saq.getLibraryInstance(fpdModuleId.getArch());\r
         for (int i = 0; i < libinstances.length; i++) {\r
             //\r
index 08b44f9eb47a871d398ef64e32972f805e06cc2a..117b6bfe17944810f2348f9d38310d78ab853c29 100644 (file)
@@ -42,6 +42,7 @@ import org.tianocore.build.id.PackageIdentification;
 import org.tianocore.build.pcd.action.PCDAutoGenAction;\r
 import org.tianocore.common.logger.EdkLog;\r
 import org.tianocore.common.definitions.ToolDefinitions;\r
+import org.tianocore.common.exception.EdkException;\r
 \r
 /**\r
   This class is to generate Autogen.h and Autogen.c according to module surface\r
@@ -280,7 +281,7 @@ public class AutoGen {
       @throws BuildException\r
                   Failed to generate AutoGen.h.\r
     **/\r
-    void moduleGenAutogenH() throws AutoGenException {\r
+    void moduleGenAutogenH() throws EdkException, AutoGenException {\r
 \r
         Set<String> libClassIncludeH;\r
         String moduleType;\r
@@ -406,7 +407,7 @@ public class AutoGen {
       @throws BuildException\r
                   Failed to generate AutoGen.c.\r
     **/\r
-    void moduleGenAutogenC() throws AutoGenException {\r
+    void moduleGenAutogenC() throws EdkException, AutoGenException {\r
 \r
         StringBuffer fileBuffer = new StringBuffer(8192);\r
         //\r
@@ -535,7 +536,7 @@ public class AutoGen {
       @throws BuildException\r
                   Failed to generate AutoGen.c.\r
     **/\r
-    void libGenAutogenH() throws AutoGenException {\r
+    void libGenAutogenH() throws EdkException, AutoGenException {\r
 \r
         Set<String> libClassIncludeH;\r
         String moduleType;\r
@@ -699,7 +700,7 @@ public class AutoGen {
       @return includeStrList List of *.h file.\r
     **/\r
     Set<String> LibraryClassToAutogenH(String[] libClassList)\r
-    throws AutoGenException {\r
+    throws EdkException, AutoGenException {\r
         Set<String> includeStrList = new LinkedHashSet<String>();\r
         String includeName[];\r
         String str = "";\r
@@ -1904,7 +1905,7 @@ public class AutoGen {
       @param\r
       @return    \r
     **/\r
-    private void collectLibInstanceInfo(){\r
+    private void collectLibInstanceInfo() throws EdkException{\r
         int index;\r
 \r
         String libConstructName = null;\r
index 99e7cca94441f66bc134e4a29ba30dc479324420..ea14ac350fdee412e4c690919d0bf44e080d285b 100644 (file)
@@ -64,18 +64,10 @@ import org.tianocore.build.toolchain.ToolChainMap;
 \r
   <p>The method parseFpdFile is also prepared for single module build. </p>\r
 \r
-  <p>The usage is (take NT32 Platform for example):</p>\r
-\r
-  <pre>\r
-  &lt;FPDParser platformName="Nt32" /&gt;\r
-  </pre>\r
-\r
   @since GenBuild 1.0\r
 **/\r
 public class FpdParserTask extends Task {\r
 \r
-    private String platformName;\r
-\r
     private File fpdFile = null;\r
 \r
     PlatformIdentification platformId;\r
@@ -123,18 +115,6 @@ public class FpdParserTask extends Task {
      Surface area is not valid.\r
     **/\r
     public void execute() throws BuildException {\r
-        //\r
-        // If fpdFile is not specified, \r
-        // then try to get FPD file by platformName\r
-        //\r
-        if ( fpdFile == null) {\r
-            if (platformName == null) {\r
-                throw new BuildException("FpdParserTask parameter error. Please specify either the platform name or FPD file!");\r
-            }\r
-            platformId = GlobalData.getPlatformByName(platformName);\r
-            fpdFile = platformId.getFpdFile();\r
-        }\r
-\r
         //\r
         // Parse FPD file\r
         //\r
@@ -178,7 +158,6 @@ public class FpdParserTask extends Task {
         //\r
         // Ant call ${PLATFORM}_build.xml\r
         //\r
-\r
         Ant ant = new Ant();\r
         ant.setProject(getProject());\r
         ant.setAntfile(platformId.getFpdFile().getParent() + File.separatorChar + platformId.getName() + "_build.xml");\r
@@ -554,10 +533,6 @@ public class FpdParserTask extends Task {
         properties.addElement(p);\r
     }\r
 \r
-    public void setPlatformName(String platformName) {\r
-        this.platformName = platformName;\r
-    }\r
-\r
     public void setFpdFile(File fpdFile) {\r
         this.fpdFile = fpdFile;\r
     }\r
index 4a7b56fc49eb13b1aad0d046ea96862cf75330cc..52ba681f556365b4a1b22e5cdb6b0062b20be754 100644 (file)
@@ -17,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 package org.tianocore.build.global;\r
 \r
 import java.io.File;\r
+import java.io.IOException;\r
 import java.util.HashMap;\r
 import java.util.HashSet;\r
 import java.util.Iterator;\r
@@ -24,7 +25,7 @@ import java.util.List;
 import java.util.Map;\r
 import java.util.Set;\r
 \r
-import org.apache.tools.ant.BuildException;\r
+import org.apache.xmlbeans.XmlException;\r
 import org.apache.xmlbeans.XmlObject;\r
 \r
 import org.tianocore.common.exception.EdkException;\r
@@ -139,7 +140,7 @@ public class GlobalData {
       @throws BuildException\r
             Framework Dababase or SPD or MSA file is not valid\r
     **/\r
-    public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir, String toolsDefFilename ) throws BuildException {\r
+    public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir, String toolsDefFilename ) throws EdkException {\r
         //\r
         // ensure this method will be revoked only once\r
         //\r
@@ -161,12 +162,9 @@ public class GlobalData {
         // CONF dir + tools definition file name\r
         //\r
         File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);\r
-        EdkLog.log("Init", "Using tool definiton file [" + toolsDefFile.getPath() + "].");\r
-        try {\r
-            toolsDef = new ToolChainConfig(toolsDefFile);\r
-        } catch (Exception e) {\r
-            throw new BuildException(e.getMessage());\r
-        }\r
+        EdkLog.log("Init", "Using tool definition file [" + toolsDefFile.getPath() + "].");\r
+        toolsDef = new ToolChainConfig(toolsDefFile);\r
+\r
 \r
         //\r
         // Parse Framework Database\r
@@ -178,7 +176,7 @@ public class GlobalData {
             // validate FrameworkDatabaseFile\r
             //\r
             if (!db.validate()) {\r
-                throw new BuildException("Framework Database file [" + dbFile.getPath() + "] format is invalid!");\r
+                throw new EdkException("Framework Database file [" + dbFile.getPath() + "] format is invalid!");\r
             }\r
             //\r
             // Get package list\r
@@ -190,6 +188,15 @@ public class GlobalData {
                     String fileName = iter.next().getStringValue().trim();\r
                     Spd spd = new Spd(new File(workspaceDir + File.separatorChar + fileName));\r
                     packageList.add(spd.getPackageId());\r
+                    //\r
+                    // Report warning if existing two packages with same GUID and Version\r
+                    //\r
+                    if (spdTable.containsKey(spd.getPackageId())) {\r
+                        //\r
+                        // BUGBUG\r
+                        //\r
+                        EdkLog.log("Init", EdkLog.EDK_WARNING, "Warning: Existing two packages with same GUID and Version. They are ... " + spd.getPackageId().getSpdFile().getPath());\r
+                    }\r
                     spdTable.put(spd.getPackageId(), spd);\r
                 }\r
             }\r
@@ -204,31 +211,43 @@ public class GlobalData {
                     String fileName = iter.next().getStringValue().trim();\r
                     File fpdFile = new File(workspaceDir + File.separatorChar + fileName);\r
                     if ( !fpdFile.exists() ) {\r
-                        throw new BuildException("Platform file [" + fpdFile.getPath() + "] not exists. ");\r
+                        throw new EdkException("Platform file [" + fpdFile.getPath() + "] not exists. ");\r
                     }\r
                     XmlObject fpdDoc = XmlObject.Factory.parse(fpdFile);\r
                     //\r
                     // Verify FPD file, if is invalid, throw Exception\r
                     //\r
                     if (!fpdDoc.validate()) {\r
-                        throw new BuildException("Framework Platform Surface Area file [" + fpdFile.getPath() + "] format is invalid!");\r
+                        throw new EdkException("Framework Platform Surface Area file [" + fpdFile.getPath() + "] format is invalid!");\r
                     }\r
                     //\r
                     // We can change Map to XmlObject\r
                     //\r
-                    //\r
-                    // TBD check SPD or FPD is existed in FS\r
-                    //\r
                     Map<String, XmlObject> fpdDocMap = new HashMap<String, XmlObject>();\r
                     fpdDocMap.put("PlatformSurfaceArea", fpdDoc);\r
                     SurfaceAreaQuery saq = new SurfaceAreaQuery(fpdDocMap);\r
                     PlatformIdentification platformId = saq.getFpdHeader();\r
                     platformId.setFpdFile(fpdFile);\r
+                    //\r
+                    // Report warning if existing two platfrom with same GUID and Version\r
+                    //\r
+                    if (platformList.contains(platformId)) {\r
+                        //\r
+                        // BUGBUG\r
+                        //\r
+                        EdkLog.log("Init", EdkLog.EDK_WARNING, "Warning: Existing two platforms with same GUID and Version. They are ... " + fpdFile.getPath());\r
+                    }\r
                     platformList.add(platformId);\r
                 }\r
             }\r
-        } catch (Exception e) {\r
-            throw new BuildException("Parse WORKSPACE Database file [" + dbFile.getPath() + "] Error.\n" + e.getMessage());\r
+        } catch(IOException ex) {\r
+            EdkException edkException = new EdkException("Parse WORKSPACE Database file [" + dbFile.getPath() + "] Error.\n" + ex.getMessage());\r
+            edkException.setStackTrace(ex.getStackTrace());\r
+            throw edkException;\r
+        } catch(XmlException ex) {\r
+            EdkException edkException = new EdkException("Parse WORKSPACE Database file [" + dbFile.getPath() + "] Error.\n" + ex.getMessage());\r
+            edkException.setStackTrace(ex.getStackTrace());\r
+            throw edkException;\r
         }\r
     }\r
 \r
@@ -245,7 +264,7 @@ public class GlobalData {
     /**\r
       Get the MSA file name with absolute path\r
      */\r
-    public synchronized static File getMsaFile(ModuleIdentification moduleId) throws BuildException {\r
+    public synchronized static File getMsaFile(ModuleIdentification moduleId) throws EdkException {\r
         File msaFile = null;\r
         //\r
         // TBD. Do only when package is null.\r
@@ -260,13 +279,13 @@ public class GlobalData {
             }\r
         }\r
         if (msaFile == null){\r
-            throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r
+            throw new EdkException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r
         } else {\r
             return msaFile;\r
         }\r
     }\r
 \r
-    public synchronized static PackageIdentification getPackageForModule(ModuleIdentification moduleId) {\r
+    public synchronized static PackageIdentification getPackageForModule(ModuleIdentification moduleId) throws EdkException {\r
         //\r
         // If package already defined in module\r
         //\r
@@ -285,7 +304,7 @@ public class GlobalData {
             }\r
         }\r
         if (packageId == null){\r
-            throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r
+            throw new EdkException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r
         } else {\r
             return packageId;\r
         }\r
@@ -303,7 +322,7 @@ public class GlobalData {
     }\r
 \r
 \r
-    public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map<String, XmlObject> doc) {\r
+    public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map<String, XmlObject> doc) throws EdkException{\r
         Map<String, XmlObject> result = new HashMap<String, XmlObject>();\r
         Set keySet = doc.keySet();\r
         Iterator iter = keySet.iterator();\r
@@ -329,7 +348,7 @@ public class GlobalData {
       @return ModuleSA info and MSA info for fpdModuleId\r
       @throws BuildException Can't find MSA\r
     **/\r
-    public synchronized static Map<String, XmlObject> getDoc(FpdModuleIdentification fpdModuleId) throws BuildException {\r
+    public synchronized static Map<String, XmlObject> getDoc(FpdModuleIdentification fpdModuleId) throws EdkException{\r
         if (parsedModules.containsKey(fpdModuleId)) {\r
             return parsedModules.get(fpdModuleId);\r
         }\r
@@ -359,10 +378,11 @@ public class GlobalData {
         return doc;\r
     }\r
 \r
-    public synchronized static Map<String, XmlObject> getDoc(ModuleIdentification moduleId, String arch) throws BuildException {\r
+    public synchronized static Map<String, XmlObject> getDoc(ModuleIdentification moduleId, String arch) throws EdkException{\r
         FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);\r
         return getDoc(fpdModuleId);\r
     }\r
+    \r
     /**\r
       Query the native MSA information with module base name.\r
 \r
@@ -374,7 +394,7 @@ public class GlobalData {
       @throws BuildException\r
               MSA file is not valid\r
     **/\r
-    public synchronized static Map<String, XmlObject> getNativeMsa(ModuleIdentification moduleId) throws BuildException {\r
+    public synchronized static Map<String, XmlObject> getNativeMsa(ModuleIdentification moduleId) throws EdkException {\r
         if (nativeMsa.containsKey(moduleId)) {\r
             return nativeMsa.get(moduleId);\r
         }\r
@@ -384,9 +404,9 @@ public class GlobalData {
         return msaMap;\r
     }\r
 \r
-    public synchronized static Map<String, XmlObject> getNativeMsa(File msaFile) throws BuildException {\r
+    public synchronized static Map<String, XmlObject> getNativeMsa(File msaFile) throws EdkException {\r
         if (!msaFile.exists()) {\r
-            throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] can't be found!");\r
+            throw new EdkException("Module Surface Area file [" + msaFile.getPath() + "] can't be found!");\r
         }\r
         try {\r
             ModuleSurfaceAreaDocument doc = (ModuleSurfaceAreaDocument)XmlObject.Factory.parse(msaFile);\r
@@ -394,7 +414,7 @@ public class GlobalData {
             // Validate File if they accord with XML Schema\r
             //\r
             if ( !doc.validate()){\r
-                throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] format is invalid!");\r
+                throw new EdkException("Module Surface Area file [" + msaFile.getPath() + "] format is invalid!");\r
             }\r
             //\r
             // parse MSA file\r
@@ -412,9 +432,14 @@ public class GlobalData {
             msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true));\r
             msaMap.put("PcdCoded", cloneXmlObject(msa.getPcdCoded(), true));\r
             return msaMap;\r
-        }\r
-        catch (Exception ex){\r
-            throw new BuildException("Parsing MSA file [" + msaFile.getPath() + "] error. \n" + ex.getMessage() );\r
+        } catch(IOException ex) {\r
+            EdkException edkException = new EdkException("Parsing MSA file [" + msaFile.getPath() + "] error. \n" + ex.getMessage());\r
+            edkException.setStackTrace(ex.getStackTrace());\r
+            throw edkException;\r
+        } catch(XmlException ex) {\r
+            EdkException edkException = new EdkException("Parsing MSA file [" + msaFile.getPath() + "] error. \n" + ex.getMessage());\r
+            edkException.setStackTrace(ex.getStackTrace());\r
+            throw edkException;\r
         }\r
     }\r
 \r
@@ -422,7 +447,7 @@ public class GlobalData {
         return fpdBuildOptionsMap;\r
     }\r
 \r
-    public static void setFpdBuildOptions(XmlObject fpdBuildOptions) {\r
+    public static void setFpdBuildOptions(XmlObject fpdBuildOptions) throws EdkException {\r
         GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);\r
         fpdBuildOptionsMap.put("BuildOptions", GlobalData.fpdBuildOptions);\r
     }\r
@@ -449,8 +474,7 @@ public class GlobalData {
      * The header file path is relative to workspace dir\r
      */\r
     public static String[] getLibraryClassHeaderFiles(\r
-            PackageIdentification[] packages, String name)\r
-            throws BuildException {\r
+            PackageIdentification[] packages, String name) throws EdkException{\r
         if (packages == null) {\r
             // throw Exception or not????\r
             return new String[0];\r
@@ -468,7 +492,7 @@ public class GlobalData {
         //\r
         // If can't find library class declaration in every package\r
         //\r
-        throw new BuildException("Can not find library class [" + name\r
+        throw new EdkException("Can not find library class [" + name\r
                 + "] declaration in any SPD package!");\r
     }\r
 \r
@@ -476,7 +500,7 @@ public class GlobalData {
      * The header file path is relative to workspace dir\r
      */\r
     public static String getPackageHeaderFiles(PackageIdentification packages,\r
-            String moduleType) throws BuildException {\r
+            String moduleType) {\r
         if (packages == null) {\r
             return new String("");\r
         }\r
@@ -500,8 +524,7 @@ public class GlobalData {
     /**\r
      * return two values: {cName, GuidValue}\r
      */\r
-    public static String[] getGuid(List<PackageIdentification> packages, String name)\r
-            throws BuildException {\r
+    public static String[] getGuid(List<PackageIdentification> packages, String name) {\r
         if (packages == null) {\r
             // throw Exception or not????\r
             return new String[0];\r
@@ -525,7 +548,7 @@ public class GlobalData {
      * return two values: {cName, GuidValue}\r
      */\r
     public static String[] getPpiGuid(List<PackageIdentification> packages,\r
-            String name) throws BuildException {\r
+            String name) {\r
         if (packages == null) {\r
             return new String[0];\r
         }\r
@@ -547,7 +570,7 @@ public class GlobalData {
      * return two values: {cName, GuidValue}\r
      */\r
     public static String[] getProtocolGuid(List<PackageIdentification> packages,\r
-            String name) throws BuildException {\r
+            String name) {\r
         if (packages == null) {\r
             return new String[0];\r
         }\r
@@ -566,7 +589,7 @@ public class GlobalData {
 \r
     }\r
 \r
-    public synchronized static PlatformIdentification getPlatformByName(String name) throws BuildException {\r
+    public synchronized static PlatformIdentification getPlatformByName(String name) throws EdkException {\r
         Iterator iter = platformList.iterator();\r
         while(iter.hasNext()){\r
             PlatformIdentification platformId = (PlatformIdentification)iter.next();\r
@@ -574,10 +597,10 @@ public class GlobalData {
                 return platformId;\r
             }\r
         }\r
-        throw new BuildException("Can't find platform [" + name + "] in the current WORKSPACE database!");\r
+        throw new EdkException("Can't find platform [" + name + "] in the current WORKSPACE database!");\r
     }\r
 \r
-    public synchronized static PlatformIdentification getPlatform(String filename) throws BuildException {\r
+    public synchronized static PlatformIdentification getPlatform(String filename) throws EdkException {\r
         File file = new File(workspaceDir + File.separatorChar + filename);\r
         Iterator iter = platformList.iterator();\r
         while(iter.hasNext()){\r
@@ -586,10 +609,10 @@ public class GlobalData {
                 return platformId;\r
             }\r
         }\r
-        throw new BuildException("Can't find platform file [" + filename + "] in the current WORKSPACE database!");\r
+        throw new EdkException("Can't find platform file [" + filename + "] in the current WORKSPACE database!");\r
     }\r
 \r
-    public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws BuildException {\r
+    public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws EdkException {\r
         Iterator iter = packageList.iterator();\r
         while(iter.hasNext()){\r
             PackageIdentification packageItem = (PackageIdentification)iter.next();\r
@@ -599,15 +622,15 @@ public class GlobalData {
                 return packageId;\r
             }\r
         }\r
-        throw new BuildException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");\r
+        throw new EdkException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");\r
     }\r
 \r
-    public synchronized static ModuleIdentification refreshModuleIdentification(ModuleIdentification moduleId) throws BuildException {\r
+    public synchronized static ModuleIdentification refreshModuleIdentification(ModuleIdentification moduleId) throws EdkException {\r
         PackageIdentification packageId = getPackageForModule(moduleId);\r
         moduleId.setPackage(packageId);\r
         Spd spd = spdTable.get(packageId);\r
         if (spd == null) {\r
-            throw new BuildException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");\r
+            throw new EdkException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");\r
         }\r
         Set<ModuleIdentification> modules = spd.getModules();\r
         Iterator<ModuleIdentification> iter = modules.iterator();\r
@@ -620,7 +643,7 @@ public class GlobalData {
                 return moduleId;\r
             }\r
         }\r
-        throw new BuildException("Can't find module GUID value " + moduleId.toGuidString() + " in " + packageId + " under the current workspace!");\r
+        throw new EdkException("Can't find module GUID value " + moduleId.toGuidString() + " in " + packageId + " under the current workspace!");\r
     }\r
 \r
     public synchronized static Set<PackageIdentification> getPackageList(){\r
@@ -636,7 +659,7 @@ public class GlobalData {
       @return XmlObject after clone\r
       @throws BuildException parse original XmlObject error. \r
     **/\r
-    private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws BuildException {\r
+    private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws EdkException {\r
         if ( object == null) {\r
             return null;\r
         }\r
@@ -644,8 +667,10 @@ public class GlobalData {
         try {\r
             result = XmlObject.Factory.parse(object.getDomNode()\r
                             .cloneNode(deep));\r
-        } catch (Exception ex) {\r
-            throw new BuildException(ex.getMessage());\r
+        } catch (XmlException ex) {\r
+            EdkException edkException = new EdkException(ex.getMessage());\r
+            edkException.setStackTrace(ex.getStackTrace());\r
+            throw edkException;\r
         }\r
         return result;\r
     }\r
index cfb5dc1f875e2dc7c18f89fb9b62ba29e8dc4bc8..965e8ef499233ba5c81a41c7051b56d82635af52 100644 (file)
 package org.tianocore.build.global;\r
 \r
 import java.io.File;\r
+import java.io.IOException;\r
 import java.util.HashMap;\r
 import java.util.Iterator;\r
 import java.util.Map;\r
 import java.util.Set;\r
 \r
-import org.apache.tools.ant.BuildException;\r
+import org.apache.xmlbeans.XmlException;\r
 import org.apache.xmlbeans.XmlObject;\r
 import org.tianocore.build.id.ModuleIdentification;\r
 import org.tianocore.build.id.PackageIdentification;\r
+import org.tianocore.common.exception.EdkException;\r
 \r
 /**\r
  \r
  This class is to generate a global table for the content of spd file.\r
  \r
- **/\r
+**/\r
 public class Spd {\r
     ///\r
     ///\r
@@ -88,12 +90,12 @@ public class Spd {
      \r
      This function mainly initialize some member variables. \r
     **/\r
-    Spd(File packageFile) throws BuildException {\r
+    Spd(File packageFile) throws EdkException {\r
         //\r
         // If specified package file not exists\r
         //\r
         if ( ! packageFile.exists()) {\r
-            throw new BuildException("Package file [" + packageFile.getPath() + "] does not exist!");\r
+            throw new EdkException("Package file [" + packageFile.getPath() + "] does not exist!");\r
         }\r
         try {\r
             XmlObject spdDoc = XmlObject.Factory.parse(packageFile);\r
@@ -101,15 +103,15 @@ public class Spd {
             // Verify SPD file, if is invalid, throw Exception\r
             //\r
             if (! spdDoc.validate()) {\r
-                throw new BuildException("Package Surface Area file [" + packageFile.getPath() + "] format is invalid!");\r
+                throw new EdkException("Package Surface Area file [" + packageFile.getPath() + "] format is invalid!");\r
             }\r
+            //\r
             // We can change Map to XmlObject\r
+            //\r
             Map<String, XmlObject> spdDocMap = new HashMap<String, XmlObject>();\r
             spdDocMap.put("PackageSurfaceArea", spdDoc);\r
             SurfaceAreaQuery saq = new SurfaceAreaQuery(spdDocMap);\r
-            //\r
-            //\r
-            //\r
+\r
             packageId = saq.getSpdHeader();\r
             packageId.setSpdFile(packageFile);\r
             \r
@@ -127,7 +129,7 @@ public class Spd {
                 moduleId.setPackage(packageId);\r
                 moduleId.setMsaFile(msaFile);\r
                 if (msaInfo.containsKey(moduleId)) {\r
-                    throw new BuildException("Found two modules with the same GUID and Version in package " + packageId + ".\nThey are  module [" + msaInfo.get(moduleId) + "] and MSA file [" + msaFile + "]!");\r
+                    throw new EdkException("Found two modules with the same GUID and Version in package " + packageId + ".\nThey are  module [" + msaInfo.get(moduleId) + "] and MSA file [" + msaFile + "]!");\r
                 }\r
                 msaInfo.put(moduleId, msaFile);\r
             }\r
@@ -196,10 +198,14 @@ public class Spd {
                 }\r
                 libClassHeaderList.put(libraryClassName, headerFiles);\r
             }\r
-        }\r
-        catch (Exception e) {\r
-            throw new BuildException("Parse of the package description file [" + packageFile.getPath() + "] failed!\n"\r
-                                     + e.getMessage());\r
+        } catch (IOException ex) {\r
+            EdkException edkException = new EdkException("Parse of the package description file [" + packageFile.getPath() + "] failed!\n" + ex.getMessage());\r
+            edkException.setStackTrace(ex.getStackTrace());\r
+            throw edkException;\r
+        } catch (XmlException ex) {\r
+            EdkException edkException = new EdkException("Parse of the package description file [" + packageFile.getPath() + "] failed!\n" + ex.getMessage());\r
+            edkException.setStackTrace(ex.getStackTrace());\r
+            throw edkException;\r
         }\r
     }\r
 \r
index 3eb024463ab84b54806722647ea0b8388f741ee1..daf23092584cfc978e8286a94ba0c3caad957f4c 100644 (file)
@@ -62,6 +62,7 @@ import org.tianocore.ProtocolsDocument.Protocols.Protocol;
 import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
 import org.tianocore.PcdDriverTypes;\r
 \r
+import org.tianocore.common.exception.EdkException;\r
 import org.tianocore.common.logger.EdkLog;\r
 import org.tianocore.build.id.FpdModuleIdentification;\r
 import org.tianocore.build.id.ModuleIdentification;\r
@@ -556,7 +557,7 @@ public class SurfaceAreaQuery {
      * @returns package name list if elements are found at the known xpath\r
      * @returns null if nothing is there\r
      */\r
-    public PackageIdentification[] getDependencePkg(String arch) {\r
+    public PackageIdentification[] getDependencePkg(String arch) throws EdkException {\r
         String[] xPath;\r
         String packageGuid = null;\r
         String packageVersion = null;\r
@@ -579,19 +580,13 @@ public class SurfaceAreaQuery {
             if (arch == null || archList == null || contains(archList, arch)) {\r
                 packageGuid = item.getPackageGuid();\r
                 packageVersion = item.getPackageVersion();\r
-                packageIdList.add(new PackageIdentification(null, packageGuid,\r
-                    packageVersion));\r
+                PackageIdentification pkgId = new PackageIdentification(null, packageGuid, packageVersion);\r
+                GlobalData.refreshPackageIdentification(pkgId);\r
+                packageIdList.add(pkgId);\r
             }\r
         }\r
 \r
-        //\r
-        //  transfer packageIdentification list to array.\r
-        //\r
-        PackageIdentification[] packageIdArray = new PackageIdentification[packageIdList.size()];\r
-        for (int i = 0; i < packageIdList.size(); i++) {\r
-            packageIdArray[i] = new PackageIdentification(null, packageIdList.get(i).getGuid(),packageIdList.get(i).getVersion());\r
-        }\r
-        return packageIdArray;\r
+        return packageIdList.toArray(new PackageIdentification[packageIdList.size()]);\r
     }\r
 \r
     /**\r
@@ -1107,7 +1102,7 @@ public class SurfaceAreaQuery {
      *          xpath\r
      * @returns null if nothing is there\r
      */\r
-    public ModuleIdentification[] getLibraryInstance(String arch) {\r
+    public ModuleIdentification[] getLibraryInstance(String arch) throws EdkException {\r
         String[] xPath;\r
         String saGuid = null;\r
         String saVersion = null;\r
@@ -1144,7 +1139,9 @@ public class SurfaceAreaQuery {
                     saVersion);\r
             PackageIdentification pkgId = new PackageIdentification(null,\r
                     pkgGuid, pkgVersion);\r
+            GlobalData.refreshPackageIdentification(pkgId);\r
             saId.setPackage(pkgId);\r
+            GlobalData.refreshModuleIdentification(saId);\r
 \r
             saIdList[i] = saId;\r
 \r
@@ -1308,7 +1305,7 @@ public class SurfaceAreaQuery {
      * @returns ModuleSA objects list if elements are found at the known xpath\r
      * @returns Empty ModuleSA list if nothing is there\r
      */\r
-    public Map<FpdModuleIdentification, Map<String, XmlObject>> getFpdModules() {\r
+    public Map<FpdModuleIdentification, Map<String, XmlObject>> getFpdModules() throws EdkException {\r
         String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r
         Object[] result = get("PlatformSurfaceArea", xPath);\r
         String arch = null;\r
@@ -1362,8 +1359,10 @@ public class SurfaceAreaQuery {
             // identification.\r
             //\r
             PackageIdentification pkgId = new PackageIdentification(null, pkgGuid, pkgVersion);\r
+            GlobalData.refreshPackageIdentification(pkgId);\r
             ModuleIdentification saId = new ModuleIdentification(null, saGuid, saVersion);\r
-\r
+            GlobalData.refreshModuleIdentification(saId);\r
+            \r
             saId.setPackage(pkgId);\r
 \r
             //\r
index d7c6f62d5e8426db98033a3279b31b01dcbeca72..87024d13a099422121060164fc33ce7f7c9472c1 100644 (file)
@@ -15,7 +15,6 @@ package org.tianocore.build.id;
 \r
 import java.io.File;\r
 \r
-import org.tianocore.build.global.GlobalData;\r
 /**\r
   This class is used to identify a module with Module Guid, Module Version, \r
   Package Guid, Package Version. \r
@@ -88,7 +87,6 @@ public class ModuleIdentification extends Identification {
       @return MSA File\r
     **/\r
     public File getMsaFile() {\r
-        prepareMsaFile();\r
         return msaFile;\r
     }\r
     \r
@@ -96,19 +94,12 @@ public class ModuleIdentification extends Identification {
       @return Module relative path to package\r
     **/\r
     public String getModuleRelativePath() {\r
-        prepareMsaFile();\r
         if (msaFile.getParent().length() == packageId.getPackageDir().length()) {\r
             return ".";\r
         }\r
         return msaFile.getParent().substring(packageId.getPackageDir().length() + 1);\r
     }\r
 \r
-    private void prepareMsaFile(){\r
-        if (msaFile == null) {\r
-            GlobalData.refreshModuleIdentification(this);\r
-        }\r
-    }\r
-\r
     /**\r
       @param msaFile Set Msa File\r
     **/\r
@@ -137,10 +128,7 @@ public class ModuleIdentification extends Identification {
         }\r
     }\r
     \r
-    public String toString(){\r
-        if (name == null) {\r
-            GlobalData.refreshModuleIdentification(this);\r
-        }\r
+    public String toString() {\r
         if (version == null || version.trim().equalsIgnoreCase("")) {\r
             return "Module [" + name + "] in " + packageId;\r
         }\r
@@ -167,9 +155,6 @@ public class ModuleIdentification extends Identification {
       @return get module type\r
     **/\r
     public String getModuleType() {\r
-        if (moduleType == null) {\r
-            GlobalData.refreshModuleIdentification(this);\r
-        }\r
         return moduleType;\r
     }\r
 \r
@@ -181,9 +166,6 @@ public class ModuleIdentification extends Identification {
     }\r
     \r
     public String getName() {\r
-        if (name == null) {\r
-            GlobalData.refreshModuleIdentification(this);\r
-        }\r
         return name;\r
     }\r
 }\r
index cb0b2a09c0572f0b72bed1588e5552cb6e5ce85b..9371f6afda7edd423b157a9160b030333eaffd03 100644 (file)
@@ -84,9 +84,6 @@ public class PackageIdentification extends Identification{
     }\r
 \r
     public String toString(){\r
-        if (name == null) {\r
-            GlobalData.refreshPackageIdentification(this);\r
-        }\r
         if (version == null || version.trim().equalsIgnoreCase("")) {\r
             return "package [" + name + "]";\r
         }\r
@@ -100,7 +97,6 @@ public class PackageIdentification extends Identification{
       @return Package Directory\r
     **/\r
     public String getPackageDir(){\r
-        prepareSpdFile();\r
         return spdFile.getParent();\r
     }\r
     \r
@@ -109,7 +105,6 @@ public class PackageIdentification extends Identification{
       @return package relative directory\r
     **/\r
     public String getPackageRelativeDir(){\r
-        prepareSpdFile();\r
         String relativeDir =spdFile.getParent().substring(GlobalData.getWorkspacePath().length());\r
         if(relativeDir.startsWith("\\") || relativeDir.startsWith("/")) {\r
           relativeDir = relativeDir.substring(1);\r
@@ -117,16 +112,7 @@ public class PackageIdentification extends Identification{
         return relativeDir;\r
     }\r
     \r
-    private void prepareSpdFile(){\r
-        if (spdFile == null) {\r
-            GlobalData.refreshPackageIdentification(this);\r
-        }\r
-    }\r
-    \r
     public String getName() {\r
-        if (name == null) {\r
-            GlobalData.refreshPackageIdentification(this);\r
-        }\r
         return name;\r
     }\r
 }\r