]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/GenBuild/org/tianocore/build/GenBuildTask.java
Changed the way of determining how to call customized build file. Now we check if...
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / GenBuildTask.java
index 79eeb2757fcc4b5962df7e7e7e1debc4701a1398..2265d6ba05cbf2135505727ab0ff75a92b7f62e1 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,7 +201,7 @@ 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
@@ -226,9 +230,9 @@ public class GenBuildTask extends Ant {
         }\r
 \r
         Set<String> archSet = new LinkedHashSet<String>();\r
-\r
-        if ( getProject().getProperty("ARCH") != null) {\r
-            String[] fpdArchList = getProject().getProperty("ARCH").split(" ");\r
+        String archString = getProject().getProperty("ARCH");\r
+        if (archString != null) {\r
+            String[] fpdArchList = archString.split(" ");\r
 \r
             for (int i = 0; i < fpdArchList.length; i++) {\r
                 if (archListSupByToolChain.contains(fpdArchList[i])) {\r
@@ -254,7 +258,7 @@ public class GenBuildTask extends Ant {
         }\r
 \r
         if (archList.length == 0) {\r
-            EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: " + moduleId + " was not found in current platform FPD file!\n");\r
+            EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: " + "[" + archString + "] is not supported for " + moduleId + " in this build!\n");\r
         }\r
 \r
         for (int k = 0; k < archList.length; k++) {\r
@@ -429,7 +433,7 @@ public class GenBuildTask extends Ant {
         String msaFileName = msaFile.getName();\r
         getProject().setProperty("MODULE_DIR", msaFile.getParent().replaceAll("(\\\\)", "/"));\r
         getProject().setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/") \r
-            + File.separatorChar + msaFileName.substring(0, msaFileName.length() - 3));\r
+            + File.separatorChar + msaFileName.substring(0, msaFileName.lastIndexOf('.')));\r
 \r
         //\r
         // SUBSYSTEM\r
@@ -645,10 +649,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 +665,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
@@ -811,4 +816,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