]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java
1. Update to just keep several line JAVA related msg; 2. Remove file PropertyManager...
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / FrameworkBuildTask.java
index 440510b522dbb106969ba8a1550e57d7a73f3c73..53d5cea8bb1e11c89dea571673207025290cea1f 100644 (file)
  **/\r
 package org.tianocore.build;\r
 \r
  **/\r
 package org.tianocore.build;\r
 \r
-import java.io.BufferedReader;\r
 import java.io.File;\r
 import java.io.IOException;\r
 import java.io.File;\r
 import java.io.IOException;\r
-import java.io.InputStreamReader;\r
 import java.util.Hashtable;\r
 import java.util.Iterator;\r
 import java.util.LinkedHashSet;\r
 import java.util.Hashtable;\r
 import java.util.Iterator;\r
 import java.util.LinkedHashSet;\r
@@ -57,8 +55,7 @@ import org.tianocore.common.logger.EdkLog;
   4. No MSA file, and ACTIVE_PLATFORM is specified, build the active platform;\r
   5. No MSA file, no ACTIVE_PLATFORM, and no FPD file, report error;\r
   6. No MSA file, no ACTIVE_PLATFORM, and only one FPD file, build the platform;\r
   4. No MSA file, and ACTIVE_PLATFORM is specified, build the active platform;\r
   5. No MSA file, no ACTIVE_PLATFORM, and no FPD file, report error;\r
   6. No MSA file, no ACTIVE_PLATFORM, and only one FPD file, build the platform;\r
-  7. No MSA file, no ACTIVE_PLATFORM, and more than one FPD files, list all platform\r
-  and let user choose one. \r
+  7. No MSA file, no ACTIVE_PLATFORM, and more than one FPD files, Report Error!\r
   </pre>\r
   \r
   <p>\r
   </pre>\r
   \r
   <p>\r
@@ -76,8 +73,6 @@ import org.tianocore.common.logger.EdkLog;
 **/\r
 public class FrameworkBuildTask extends Task{\r
 \r
 **/\r
 public class FrameworkBuildTask extends Task{\r
 \r
-    private Set<File> buildFiles = new LinkedHashSet<File>();\r
-    \r
     private Set<File> fpdFiles = new LinkedHashSet<File>();\r
     \r
     private Set<File> msaFiles = new LinkedHashSet<File>();\r
     private Set<File> fpdFiles = new LinkedHashSet<File>();\r
     \r
     private Set<File> msaFiles = new LinkedHashSet<File>();\r
@@ -120,6 +115,11 @@ public class FrameworkBuildTask extends Task{
         \r
         try {\r
             processFrameworkBuild();\r
         \r
         try {\r
             processFrameworkBuild();\r
+        }catch (BuildException e) {\r
+            //\r
+            // Add more logic process here\r
+            //\r
+            throw new BuildException(e.getMessage());\r
         } catch (PcdAutogenException e) {\r
             //\r
             // Add more logic process here\r
         } catch (PcdAutogenException e) {\r
             //\r
             // Add more logic process here\r
@@ -149,32 +149,27 @@ public class FrameworkBuildTask extends Task{
     }\r
     \r
     private void processFrameworkBuild() throws EdkException, GenBuildException, AutoGenException, PcdAutogenException, PlatformPcdPreprocessBuildException {\r
     }\r
     \r
     private void processFrameworkBuild() throws EdkException, GenBuildException, AutoGenException, PcdAutogenException, PlatformPcdPreprocessBuildException {\r
-        //\r
-        // Seach build.xml -> .FPD -> .MSA file\r
-        //\r
         try {\r
             //\r
         try {\r
             //\r
-            // Gen Current Working Directory\r
+            // Get current working dir\r
             //\r
             File dummyFile = new File(".");\r
             File cwd = dummyFile.getCanonicalFile();\r
             File[] files = cwd.listFiles();\r
             //\r
             File dummyFile = new File(".");\r
             File cwd = dummyFile.getCanonicalFile();\r
             File[] files = cwd.listFiles();\r
+            \r
+            //\r
+            // Scan current dir, and find out all .FPD and .MSA files\r
+            //\r
             for (int i = 0; i < files.length; i++) {\r
                 if (files[i].isFile()) {\r
             for (int i = 0; i < files.length; i++) {\r
                 if (files[i].isFile()) {\r
-                    if (files[i].getName().equalsIgnoreCase("build.xml")) {\r
-                        //\r
-                        // First, search build.xml, if found, ANT call it\r
-                        //\r
-                        buildFiles.add(files[i]);\r
-\r
-                    } else if (files[i].getName().endsWith(ToolDefinitions.FPD_EXTENSION)) {\r
+                    if (files[i].getName().endsWith(ToolDefinitions.FPD_EXTENSION)) {\r
                         //\r
                         //\r
-                        // Second, search FPD file, if found, build it\r
+                        // Found FPD file\r
                         //\r
                         fpdFiles.add(files[i]);\r
                     } else if (files[i].getName().endsWith(ToolDefinitions.MSA_EXTENSION)) {\r
                         //\r
                         //\r
                         fpdFiles.add(files[i]);\r
                     } else if (files[i].getName().endsWith(ToolDefinitions.MSA_EXTENSION)) {\r
                         //\r
-                        // Third, search MSA file, if found, build it\r
+                        // Found MSA file\r
                         //\r
                         msaFiles.add(files[i]);\r
                     }\r
                         //\r
                         msaFiles.add(files[i]);\r
                     }\r
@@ -187,9 +182,9 @@ public class FrameworkBuildTask extends Task{
         }\r
         \r
         //\r
         }\r
         \r
         //\r
-        // Deal with all environment variable (Add them to properties)\r
+        // Import all system environment variables to ANT properties\r
         //\r
         //\r
-        backupSystemProperties();\r
+        importSystemEnvVariables();\r
         \r
         //\r
         // Read target.txt file\r
         \r
         //\r
         // Read target.txt file\r
@@ -208,11 +203,11 @@ public class FrameworkBuildTask extends Task{
         // else fail build. \r
         // If without MSA file, and ACTIVE_PLATFORM is set, build the ACTIVE_PLATFORM. \r
         // If ACTIVE_PLATFORM is not set, and only find one FPD file, build the platform; \r
         // else fail build. \r
         // If without MSA file, and ACTIVE_PLATFORM is set, build the ACTIVE_PLATFORM. \r
         // If ACTIVE_PLATFORM is not set, and only find one FPD file, build the platform; \r
-        // If find more than one FPD files, let user select one. \r
+        // If find more than one FPD files, report error.  \r
         //\r
         File buildFile = null;\r
         if (msaFiles.size() > 1) {\r
         //\r
         File buildFile = null;\r
         if (msaFiles.size() > 1) {\r
-            throw new BuildException("Having more than one MSA file in a directory is not allowed!");\r
+            throw new BuildException("Found " + msaFiles.size() + " MSA files in current dir. ");\r
         } else if (msaFiles.size() == 1 && activePlatform == null) {\r
             throw new BuildException("If trying to build a single module, please set ACTIVE_PLATFORM in file [" + targetFilename + "]. ");\r
         } else if (msaFiles.size() == 1 && activePlatform != null) {\r
         } else if (msaFiles.size() == 1 && activePlatform == null) {\r
             throw new BuildException("If trying to build a single module, please set ACTIVE_PLATFORM in file [" + targetFilename + "]. ");\r
         } else if (msaFiles.size() == 1 && activePlatform != null) {\r
@@ -225,8 +220,9 @@ public class FrameworkBuildTask extends Task{
         } else if (fpdFiles.size() == 1) {\r
             buildFile = fpdFiles.toArray(new File[1])[0];\r
         } else if (fpdFiles.size() > 1) {\r
         } else if (fpdFiles.size() == 1) {\r
             buildFile = fpdFiles.toArray(new File[1])[0];\r
         } else if (fpdFiles.size() > 1) {\r
-            buildFile = intercommuniteWithUser();\r
+            throw new BuildException("Found " + fpdFiles.size() + " FPD files in current dir. ");\r
         }\r
         }\r
+        \r
         //\r
         // If there is no build files or FPD files or MSA files, stop build\r
         //\r
         //\r
         // If there is no build files or FPD files or MSA files, stop build\r
         //\r
@@ -296,11 +292,11 @@ public class FrameworkBuildTask extends Task{
     }\r
     \r
     /**\r
     }\r
     \r
     /**\r
-      Transfer system environment variables to ANT properties. If system variable \r
+      Import system environment variables to ANT properties. If system variable \r
       already exiests in ANT properties, skip it.\r
       \r
     **/\r
       already exiests in ANT properties, skip it.\r
       \r
     **/\r
-    private void backupSystemProperties() {\r
+    private void importSystemEnvVariables() {\r
         Map<String, String> sysProperties = System.getenv();\r
         Iterator<String> iter = sysProperties.keySet().iterator();\r
         while (iter.hasNext()) {\r
         Map<String, String> sysProperties = System.getenv();\r
         Iterator<String> iter = sysProperties.keySet().iterator();\r
         while (iter.hasNext()) {\r
@@ -322,54 +318,6 @@ public class FrameworkBuildTask extends Task{
         }\r
     }\r
 \r
         }\r
     }\r
 \r
-    private File intercommuniteWithUser(){\r
-        File file = null;\r
-        if (fpdFiles.size() > 1) {\r
-            File[] allFiles = new File[fpdFiles.size()];\r
-            int index = 0;\r
-            Iterator<File> iter = fpdFiles.iterator();\r
-            while (iter.hasNext()) {\r
-                allFiles[index] = iter.next();\r
-                index++;\r
-            }\r
-\r
-            EdkLog.log(this, "Finding " + allFiles.length + " FPD files: ");\r
-            for (int i = 0; i < allFiles.length; i++) {\r
-                System.out.println("[" + (i + 1) + "]: " + allFiles[i].getName());\r
-            }\r
-            \r
-            boolean flag = true;\r
-            EdkLog.log(this, "Please select one of the following FPD files to build:[1] ");\r
-            do{\r
-                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\r
-                try {\r
-                     String str = br.readLine();\r
-                     if (str.trim().length() == 0) {\r
-                         file = allFiles[0];\r
-                         flag = false;\r
-                         continue ;\r
-                     }\r
-                     int indexSelect = Integer.parseInt(str);\r
-                     if (indexSelect <=0 || indexSelect > allFiles.length) {\r
-                         EdkLog.log(this, "Please enter a number between [1.." + allFiles.length + "]:[1] ");\r
-                         continue ;\r
-                     } else {\r
-                         file = allFiles[indexSelect - 1];\r
-                         flag = false;\r
-                         continue ;\r
-                     }\r
-                } catch (Exception e) {\r
-                    EdkLog.log(this, "Please enter a valid number:[1] ");\r
-                    flag = true;\r
-                }\r
-            } while (flag);\r
-        } else if (fpdFiles.size() == 1) {\r
-            file = fpdFiles.toArray(new File[1])[0];\r
-        }\r
-        return file;\r
-    }\r
-    \r
-    \r
     public void setType(String type) {\r
         if (type.equalsIgnoreCase("clean") || type.equalsIgnoreCase("cleanall")) {\r
             this.type = type.toLowerCase();\r
     public void setType(String type) {\r
         if (type.equalsIgnoreCase("clean") || type.equalsIgnoreCase("cleanall")) {\r
             this.type = type.toLowerCase();\r
@@ -433,6 +381,10 @@ public class FrameworkBuildTask extends Task{
                     MAX_CONCURRENT_THREAD_NUMBER = threadNum;\r
                 }\r
             } catch (Exception ex) {\r
                     MAX_CONCURRENT_THREAD_NUMBER = threadNum;\r
                 }\r
             } catch (Exception ex) {\r
+                //\r
+                // Give a warning message, and keep the default value\r
+                //\r
+                EdkLog.log(this, EdkLog.EDK_WARNING, "Incorrent number specified for MAX_CONCURRENT_THREAD_NUMBER in file [" + targetFilename + "]");\r
             }\r
         }\r
     }\r
             }\r
         }\r
     }\r