]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
Enhance Arch check.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / GenBuildTask.java
index 0e807f8abbe07fc6c3bcc9671f24186413858bcd..ec2fd1ad2f167f17156bc8920d6fbba7876077a4 100644 (file)
@@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 package org.tianocore.build;\r
 \r
 import java.io.File;\r
+import java.util.ArrayList;\r
 import java.util.Hashtable;\r
 import java.util.Iterator;\r
 import java.util.LinkedHashSet;\r
@@ -32,8 +33,9 @@ import org.apache.tools.ant.taskdefs.Ant;
 import org.apache.tools.ant.taskdefs.Property;\r
 import org.apache.xmlbeans.XmlObject;\r
 \r
-import org.tianocore.build.exception.EdkException;\r
+import org.tianocore.build.autogen.AutoGen;\r
 import org.tianocore.build.fpd.FpdParserTask;\r
+import org.tianocore.build.global.GenBuildLogger;\r
 import org.tianocore.build.global.GlobalData;\r
 import org.tianocore.build.global.OutputManager;\r
 import org.tianocore.build.global.SurfaceAreaQuery;\r
@@ -42,6 +44,8 @@ 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.exception.EdkException;\r
+import org.tianocore.logger.EdkLog;\r
 \r
 /**\r
   <p>\r
@@ -97,11 +101,10 @@ public class GenBuildTask extends Ant {
     private ModuleIdentification moduleId;\r
 \r
     private Vector<Property> properties = new Vector<Property>();\r
-    \r
+\r
     private static Stack<Hashtable> backupPropertiesStack = new Stack<Hashtable>();\r
     \r
-    \r
-    private static Hashtable backupProperties;\r
+    private boolean isSingleModuleBuild = false;\r
     \r
     /**\r
       Public construct method. It is necessary for ANT task.\r
@@ -115,7 +118,14 @@ public class GenBuildTask extends Ant {
               From module build, exception from module surface area invalid.\r
     **/\r
     public void execute() throws BuildException {\r
-        try{\r
+       //\r
+        // set Logger\r
+        //\r
+        GenBuildLogger logger = new GenBuildLogger(getProject());\r
+        EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));\r
+        EdkLog.setLogger(logger);\r
+        // remove !!\r
+        try {\r
         pushProperties();\r
         //\r
         // Enable all specified properties\r
@@ -149,7 +159,7 @@ public class GenBuildTask extends Ant {
             SurfaceAreaQuery.setDoc(doc);\r
             moduleId = SurfaceAreaQuery.getMsaHeader();\r
         }\r
-        String[] producedLibraryClasses = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");\r
+        String[] producedLibraryClasses = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED",null);\r
         if (producedLibraryClasses.length == 0) {\r
             moduleId.setLibrary(false);\r
         }\r
@@ -160,7 +170,7 @@ public class GenBuildTask extends Ant {
         //\r
         // Judge whether it is single module build or not\r
         //\r
-        if (getProject().getProperty("PLATFORM") == null) {\r
+        if (isSingleModuleBuild) {\r
             //\r
             // Single Module build\r
             //\r
@@ -170,8 +180,8 @@ public class GenBuildTask extends Ant {
             //\r
             // Platform build. Restore the platform related info\r
             //\r
-            String platformName = getProject().getProperty("PLATFORM");\r
-            PlatformIdentification platformId = GlobalData.getPlatform(platformName);\r
+            String filename = getProject().getProperty("PLATFORM_FILE");\r
+            PlatformIdentification platformId = GlobalData.getPlatform(filename);\r
             getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));\r
             getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));\r
             \r
@@ -185,14 +195,29 @@ public class GenBuildTask extends Ant {
         // If single module : intersection MSA supported ARCHs and tools def!!\r
         // else, get arch from pass down\r
         //\r
-        String[] archList = new String[0];\r
-        if ( getProject().getProperty("ARCH") != null ) {\r
-            archList = getProject().getProperty("ARCH").split(" ");\r
+        Set<String> archListSupByToolChain = new LinkedHashSet<String>(); \r
+        String[] archs = GlobalData.getToolChainInfo().getArchs(); \r
+        \r
+        for (int i = 0; i < archs.length; i ++) {\r
+            archListSupByToolChain.add(archs[i]);\r
+        }\r
+        \r
+        Set<String> archSet = new LinkedHashSet<String>();\r
+        \r
+        if ( getProject().getProperty("ARCH") != null) {\r
+            String[] fpdArchList = getProject().getProperty("ARCH").split(" ");\r
+            \r
+            for (int i = 0; i < fpdArchList.length; i++) {\r
+                if (archListSupByToolChain.contains(fpdArchList[i])) {\r
+                    archSet.add(fpdArchList[i]);\r
+                }\r
+            }\r
         }\r
         else {\r
-            archList = GlobalData.getToolChainInfo().getArchs();\r
+            archSet = archListSupByToolChain; \r
         }\r
-        \r
+  \r
+        String[] archList = archSet.toArray(new String[archSet.size()]);\r
         \r
         //\r
         // Judge if arch is all supported by current module. If not, throw Exception.\r
@@ -207,6 +232,7 @@ public class GenBuildTask extends Ant {
         }\r
         \r
         for (int k = 0; k < archList.length; k++) {\r
+            \r
             getProject().setProperty("ARCH", archList[k]);\r
             \r
             FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, archList[k]);\r
@@ -233,6 +259,15 @@ public class GenBuildTask extends Ant {
                 getProject().setProperty("TARGET", targetList[i]);\r
                 String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();\r
                 for(int j = 0; j < toolchainList.length; j ++){\r
+                    //\r
+                    // check if any tool is defined for current target + toolchain + arch\r
+                    // don't do anything if no tools found\r
+                    // \r
+                    if (GlobalData.isCommandSet(targetList[i], toolchainList[j], archList[k]) == false) {\r
+                        System.out.println("Warning: No build issued. No tools found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");\r
+                        continue;\r
+                    }\r
+\r
                     //\r
                     // Prepare for toolchain related common properties\r
                     // TOOLCHAIN\r
@@ -273,7 +308,6 @@ public class GenBuildTask extends Ant {
         }\r
         popProperties();\r
         }catch (Exception e){\r
-            e.printStackTrace();\r
             throw new BuildException(e.getMessage());\r
         }\r
     }\r
@@ -299,13 +333,13 @@ public class GenBuildTask extends Ant {
         //\r
         // Read ACTIVE_PLATFORM's FPD file (Call FpdParserTask's method)\r
         //\r
-        String activePlatformName = getProject().getProperty("ACTIVE_PLATFORM");\r
+        String filename = getProject().getProperty("PLATFORM_FILE");\r
         \r
-        if (activePlatformName == null){\r
+        if (filename == null){\r
             throw new BuildException("Plese set ACTIVE_PLATFORM if you want to build a single module. ");\r
         }\r
         \r
-        PlatformIdentification platformId = GlobalData.getPlatform(activePlatformName);\r
+        PlatformIdentification platformId = GlobalData.getPlatform(filename);\r
         \r
         //\r
         // Read FPD file\r
@@ -318,7 +352,7 @@ public class GenBuildTask extends Ant {
         // Prepare for Platform related common properties\r
         // PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR\r
         //\r
-        getProject().setProperty("PLATFORM", activePlatformName);\r
+        getProject().setProperty("PLATFORM", platformId.getName());\r
         getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));\r
         getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));\r
     }\r
@@ -414,7 +448,6 @@ public class GenBuildTask extends Ant {
             key[4] = "NAME";\r
             String cmdName = GlobalData.getCommandSetting(key, fpdModuleId);\r
             File cmdFile = new File(cmdPath + File.separatorChar + cmdName);\r
-//            GlobalData.log.info("PATH: " + cmdFile.getPath());\r
             getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));\r
             \r
             //\r
@@ -422,7 +455,6 @@ public class GenBuildTask extends Ant {
             //\r
             key[4] = "FLAGS";\r
             String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId);\r
-//            GlobalData.log.info("Flags: " + cmdFlags);\r
             Set<String> addset = new LinkedHashSet<String>();\r
             Set<String> subset = new LinkedHashSet<String>();\r
             putFlagsToSet(addset, cmdFlags);\r
@@ -433,7 +465,6 @@ public class GenBuildTask extends Ant {
             //\r
             key[4] = "EXT";\r
             String extName = GlobalData.getCommandSetting(key, fpdModuleId);\r
-//            GlobalData.log.info("Ext: " + extName);\r
             if ( extName != null && ! extName.equalsIgnoreCase("")) {\r
                 getProject().setProperty(cmd[m] + "_EXT", extName);\r
             }\r
@@ -446,7 +477,6 @@ public class GenBuildTask extends Ant {
             //\r
             key[4] = "FAMILY";\r
             String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId);\r
-//            GlobalData.log.info("FAMILY: " + toolChainFamily);\r
             if (toolChainFamily != null) {\r
                 getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily);\r
             }\r
@@ -456,7 +486,6 @@ public class GenBuildTask extends Ant {
             //\r
             key[4] = "SPATH";\r
             String spath = GlobalData.getCommandSetting(key, fpdModuleId);\r
-//            GlobalData.log.info("SPATH: " + spath);\r
             if (spath != null) {\r
                 getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));\r
             }\r
@@ -469,7 +498,6 @@ public class GenBuildTask extends Ant {
             //\r
             key[4] = "DPATH";\r
             String dpath = GlobalData.getCommandSetting(key, fpdModuleId);\r
-//            GlobalData.log.info("DPATH: " + dpath);\r
             if (dpath != null) {\r
                 getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));\r
             }\r
@@ -524,8 +552,9 @@ public class GenBuildTask extends Ant {
         //\r
         // AutoGen\r
         //\r
-//        AutoGen autogen = new AutoGen(getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId);\r
-//        autogen.genAutogen();\r
+        \r
+        AutoGen autogen = new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId.getModule(),fpdModuleId.getArch());\r
+        autogen.genAutogen();\r
         \r
         \r
         //\r
@@ -755,4 +784,8 @@ public class GenBuildTask extends Ant {
             getProject().setProperty(item, (String)backupProperties.get(item));\r
         }\r
     }\r
+\r
+    public void setSingleModuleBuild(boolean isSingleModuleBuild) {\r
+        this.isSingleModuleBuild = isSingleModuleBuild;\r
+    }\r
 }\r