**/\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.InputStreamReader;\r
import java.util.Hashtable;\r
import java.util.Iterator;\r
import java.util.LinkedHashSet;\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
**/\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
\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
}\r
\r
private void processFrameworkBuild() throws EdkException, GenBuildException, AutoGenException, PcdAutogenException, PlatformPcdPreprocessBuildException {\r
- //\r
- // Seach build.xml -> .FPD -> .MSA file\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
+ //\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
- 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
- // 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
- // Third, search MSA file, if found, build it\r
+ // Found MSA file\r
//\r
msaFiles.add(files[i]);\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
- backupSystemProperties();\r
+ importSystemEnvVariables();\r
\r
//\r
// Read target.txt file\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
- 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 (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
// If there is no build files or FPD files or MSA files, stop build\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
- 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
}\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
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