]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java
(Fixed EDKT523) Added more check on "archString" to see if it's empty or not.
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / GenBuildTask.java
index 9d7eb6d09403842ee19d66794b1ba8ec08b9eb51..28bfb9efb51b3f5aeaf0c19facf339ba4f11d7ff 100644 (file)
@@ -26,14 +26,11 @@ import java.util.Vector;
 \r
 import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.BuildListener;\r
+import org.apache.tools.ant.Location;\r
 import org.apache.tools.ant.Project;\r
 import org.apache.tools.ant.taskdefs.Ant;\r
 import org.apache.tools.ant.taskdefs.Property;\r
 import org.apache.xmlbeans.XmlObject;\r
-\r
-import org.tianocore.common.definitions.ToolDefinitions;\r
-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
@@ -48,6 +45,9 @@ import org.tianocore.build.id.ModuleIdentification;
 import org.tianocore.build.id.PackageIdentification;\r
 import org.tianocore.build.id.PlatformIdentification;\r
 import org.tianocore.build.tools.ModuleItem;\r
+import org.tianocore.common.definitions.ToolDefinitions;\r
+import org.tianocore.common.exception.EdkException;\r
+import org.tianocore.common.logger.EdkLog;\r
 \r
 /**\r
   <p>\r
@@ -151,6 +151,10 @@ public class GenBuildTask extends Ant {
             BuildException buildException = new BuildException(e.getMessage());\r
             buildException.setStackTrace(e.getStackTrace());\r
             throw buildException;\r
+        } catch (Exception e) {\r
+            BuildException buildException = new BuildException(e.getMessage());\r
+            buildException.setStackTrace(e.getStackTrace());\r
+            throw buildException;\r
         }\r
     }\r
 \r
@@ -197,12 +201,13 @@ public class GenBuildTask extends Ant {
             moduleId.setMsaFile(msaFile);\r
         }\r
         \r
-        String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED",null);\r
+        String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED", null, null);\r
         if (producedLibraryClasses.length == 0) {\r
             moduleId.setLibrary(false);\r
         } else {\r
             moduleId.setLibrary(true);\r
         }\r
+        moduleId.setBinary(saq.getBinaryModule());\r
 \r
         //\r
         // Judge whether it is single module build or not\r
@@ -227,7 +232,7 @@ public class GenBuildTask extends Ant {
 \r
         Set<String> archSet = new LinkedHashSet<String>();\r
         String archString = getProject().getProperty("ARCH");\r
-        if (archString != null) {\r
+        if (archString != null && archString.length() > 0) {\r
             String[] fpdArchList = archString.split(" ");\r
 \r
             for (int i = 0; i < fpdArchList.length; i++) {\r
@@ -323,10 +328,8 @@ public class GenBuildTask extends Ant {
 \r
                     if (type.equalsIgnoreCase("all") || type.equalsIgnoreCase("build")) {\r
                         applyBuild(targetList[i], toolchainList[j], fpdModuleId);\r
-                    } else if (type.equalsIgnoreCase("clean")) {\r
-                        applyClean(fpdModuleId);\r
-                    } else if (type.equalsIgnoreCase("cleanall")) {\r
-                        applyCleanall(fpdModuleId);\r
+                    } else {\r
+                        applyNonBuildTarget(fpdModuleId);\r
                     }\r
                 }\r
             }\r
@@ -645,10 +648,11 @@ public class GenBuildTask extends Ant {
         // if it is CUSTOM_BUILD\r
         // then call the exist BaseName_build.xml directly.\r
         //\r
-        if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {\r
-            EdkLog.log(this, "Call user-defined " + moduleId.getName() + "_build.xml");\r
+        String buildFilename = "";\r
+        if ((buildFilename = GetCustomizedBuildFile(fpdModuleId.getArch())) != "") {\r
+            EdkLog.log(this, "Call user-defined " + buildFilename);\r
             \r
-            String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";\r
+            String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + buildFilename;\r
             antCall(antFilename, null);\r
             \r
             return ;\r
@@ -660,7 +664,7 @@ public class GenBuildTask extends Ant {
         //\r
         String ffsKeyword = saq.getModuleFfsKeyword();\r
         ModuleBuildFileGenerator fileGenerator = new ModuleBuildFileGenerator(getProject(), ffsKeyword, fpdModuleId, includes, saq);\r
-        String buildFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";\r
+        buildFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";\r
         fileGenerator.genBuildFile(buildFilename);\r
 \r
         //\r
@@ -670,6 +674,24 @@ public class GenBuildTask extends Ant {
         antCall(antFilename, null);\r
     }\r
 \r
+    private void applyNonBuildTarget(FpdModuleIdentification fpdModuleId){\r
+        //\r
+        // if it is CUSTOM_BUILD\r
+        // then call the exist BaseName_build.xml directly.\r
+        //\r
+        if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {\r
+            EdkLog.log(this, "Calling user-defined " + moduleId.getName() + "_build.xml");\r
+            \r
+            String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";\r
+            antCall(antFilename, this.type);\r
+            \r
+            return ;\r
+        }\r
+\r
+        String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";\r
+        antCall(antFilename, this.type);\r
+    }\r
+\r
     private void applyClean(FpdModuleIdentification fpdModuleId){\r
         //\r
         // if it is CUSTOM_BUILD\r
@@ -811,4 +833,15 @@ public class GenBuildTask extends Ant {
    public void setExternalProperties(Vector<Property> v) {\r
        this.properties = v;\r
    }\r
+\r
+   private String GetCustomizedBuildFile(String arch) {\r
+       String[][] files = saq.getSourceFiles(arch);\r
+       for (int i = 0; i < files.length; ++i) {\r
+           if (files[i][1].endsWith("build.xml")) {\r
+               return files[i][1];\r
+           }\r
+       }\r
+\r
+       return "";\r
+   }\r
 }\r