]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
Update GlobalData, SPD, SurfaceAreaQuery to using EdkException.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / GenBuildTask.java
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