/** @file\r
This file is ANT task FpdParserTask. \r
\r
- FpdParserTask is used to parse FPD (Framework Platform Description) and generate\r
- build.out.xml. It is for Package or Platform build use. \r
- \r
Copyright (c) 2006, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
import org.apache.tools.ant.taskdefs.Ant;\r
import org.apache.xmlbeans.XmlObject;\r
\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.id.FpdModuleIdentification;\r
import org.tianocore.build.FrameworkBuildTask;\r
import org.tianocore.build.GenBuildThread;\r
import org.tianocore.common.exception.EdkException;\r
+import org.tianocore.common.logger.EdkLog;\r
\r
/**\r
- <code>FpdParserTask</code> is an ANT task. The main function is parsing Framework\r
- Platform Descritpion (FPD) XML file and generating its ANT build script for \r
- corresponding platform. \r
-\r
- <p>The task sets global properties PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR\r
- and BUILD_DIR. </p>\r
- \r
- <p>The task generates ${PLATFORM}_build.xml file which will be called by top level\r
- build.xml. The task also generate Fv.inf files (File is for Tool GenFvImage) \r
- and flash definition file (File is for Tool FlashMap) if necessary. </p>\r
- \r
- <p>FpdParserTask task stores all FPD information to GlobalData. And parse\r
- tools definition file to set up compiler options for different Target and\r
- different ToolChainTag. </p>\r
- \r
- <p>The method parseFpdFile is also prepared for single module build. </p>\r
- \r
- <p>The usage is (take NT32 Platform for example):</p>\r
-\r
- <pre>\r
- <FPDParser platformName="Nt32" />\r
- </pre>\r
-\r
- <p>The task will initialize all information through parsing Framework Database, \r
- SPD, Tool chain configuration files. </p>\r
\r
@since GenBuild 1.0\r
**/\r
\r
public static int currentRunNumber = 0;\r
\r
+ public static int totalNumber = 0;\r
+ \r
+ public static int remainNumber = 0;\r
+ \r
/**\r
Public construct method. It is necessary for ANT task.\r
**/\r
}\r
\r
/**\r
- ANT task's entry method. The main steps is described as following: \r
- \r
- <ul>\r
- <li>Initialize global information (Framework DB, SPD files and all MSA files \r
- listed in SPD). This step will execute only once in whole build process;</li>\r
- <li>Parse specified FPD file; </li>\r
- <li>Generate FV.inf files; </li>\r
- <li>Generate PlatformName_build.xml file for Flatform build; </li>\r
- <li>Collect PCD information. </li>\r
- </ul>\r
\r
- @throws BuildException\r
- Surface area is not valid. \r
+\r
**/\r
public void execute() throws BuildException {\r
+ \r
+ this.setTaskName(".........");\r
//\r
// Parse FPD file\r
//\r
// Prepare BUILD_DIR\r
//\r
isUnified = OutputManager.getInstance().prepareBuildDir(getProject());\r
-\r
+ String buildDir = getProject().getProperty("BUILD_DIR");\r
+ \r
//\r
// For every Target and ToolChain\r
//\r
//\r
// Prepare FV_DIR\r
//\r
- String ffsCommonDir = getProject().getProperty("BUILD_DIR") + File.separatorChar\r
- + targetList[i] + File.separatorChar\r
+ String ffsCommonDir = buildDir + File.separatorChar\r
+ + targetList[i] + "_"\r
+ toolchainList[j];\r
File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");\r
fvDir.mkdirs();\r
//\r
// Gen build.xml\r
//\r
- PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq);\r
+ String platformBuildFile = buildDir + File.separatorChar + platformId.getName() + "_build.xml";\r
+ PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile);\r
fileGenerator.genBuildFile();\r
\r
//\r
//\r
Ant ant = new Ant();\r
ant.setProject(getProject());\r
- ant.setAntfile(platformId.getFpdFile().getParent() + File.separatorChar + platformId.getName() + "_build.xml");\r
+ ant.setAntfile(platformBuildFile);\r
ant.setTarget("prebuild");\r
ant.setInheritAll(true);\r
ant.init();\r
ant.execute();\r
\r
- System.out.println("Task number is " + allThreads.size());\r
+ remainNumber = totalNumber = allThreads.size();\r
\r
+ EdkLog.log(this, EdkLog.EDK_ALWAYS, "Total thread number is " + totalNumber);\r
+ GenBuildLogger.setCacheEnable(true);\r
//\r
// Waiting for all thread over, or time out\r
//\r
if (currentQueueCode >= queueList.size()) {\r
break ;\r
}\r
+ \r
+ int percentage = (totalNumber - remainNumber) * 100 / totalNumber;\r
+ EdkLog.log(this, EdkLog.EDK_ALWAYS, percentage + "% finished. Has built " + (totalNumber - remainNumber) + " modules of " + totalNumber + " total. ");\r
\r
Set<FpdModuleIdentification> currentQueueModules = fvs.get(queueList.get(currentQueueCode));\r
\r
//\r
// Exist ready thread\r
//\r
- System.out.println("## Exist ready thread");\r
+// EdkLog.log(this, EdkLog.EDK_ALWAYS, "Exist ready thread");\r
\r
} else if (existNoneReady && currentRunNumber == 0) {\r
//\r
// No active thread, but still have dependency not read thread\r
//\r
- throw new BuildException("Found can't resolve dependencies. ");\r
+ throw new BuildException("Existing some modules can't resolve depedencies. ");\r
} else if (!existNoneReady && currentRunNumber == 0) {\r
//\r
// Current queue build finish, move to next\r
//\r
- System.out.println("## Current queue build finish, move to next");\r
+ EdkLog.log(this, EdkLog.EDK_ALWAYS, "Current queue build finish, move to next");\r
++currentQueueCode;\r
continue ;\r
} else {\r
//\r
// active thread exist, but no ready thread\r
//\r
- System.out.println("## active thread exist, but no ready thread" + currentRunNumber);\r
+ EdkLog.log(this, EdkLog.EDK_ALWAYS, "Active thread exist, but no ready thread. Current running number is " + currentRunNumber);\r
}\r
\r
try {\r
deamonSemaphore.wait();\r
- } catch (InterruptedException e) {\r
- e.printStackTrace();\r
+ } catch (InterruptedException ex) {\r
+ BuildException e = new BuildException("Thread wait Error. \n" + ex.getMessage());\r
+ e.setStackTrace(ex.getStackTrace());\r
+ throw e;\r
}\r
}\r
}\r
- \r
+ GenBuildLogger.setCacheEnable(false);\r
//\r
// call fvs, postbuild\r
//\r
ant = new Ant();\r
ant.setProject(getProject());\r
- ant.setAntfile(platformId.getFpdFile().getParent() + File.separatorChar + platformId.getName() + "_build.xml");\r
+ ant.setAntfile(platformBuildFile);\r
ant.setTarget("fvs");\r
ant.setInheritAll(true);\r
ant.init();\r
\r
ant = new Ant();\r
ant.setProject(getProject());\r
- ant.setAntfile(platformId.getFpdFile().getParent() + File.separatorChar + platformId.getName() + "_build.xml");\r
+ ant.setAntfile(platformBuildFile);\r
ant.setTarget("postbuild");\r
ant.setInheritAll(true);\r
ant.init();\r
ant.execute();\r
\r
+ EdkLog.flushLogToFile(new File(buildDir + File.separatorChar + "build.log"));\r
+ \r
}\r
\r
\r
public synchronized static void subCount() {\r
synchronized (countSemaphore) {\r
--currentRunNumber;\r
+ --remainNumber;\r
}\r
}\r
}\r