+++ /dev/null
-/** @file\r
- \r
- This file is an ANT task OutputDirSetupTask. \r
- \r
- This task main purpose is to setup some necessary properties for Package,\r
- Platform or Module clean. \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
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-**/\r
-package org.tianocore.build;\r
-\r
-import java.io.File;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.tools.ant.Task;\r
-import org.apache.xmlbeans.XmlObject;\r
-\r
-import org.tianocore.build.global.GlobalData;\r
-import org.tianocore.build.global.OutputManager;\r
-import org.tianocore.build.global.SurfaceAreaQuery;\r
-import org.tianocore.build.toolchain.ToolChainFactory;\r
-\r
-/**\r
- <code>OutputDirSetupTask</code> is an ANT task that can be used in ANT build\r
- system. The main function of this task is to initialize some basic information\r
- for Package|Platform|Module clean or cleanall usage. \r
- \r
- <p>Here is an example: </p> \r
- <pre>\r
- <OutputDirSetup baseName="HelloWorld" \r
- mbdFilename="${MODULE_DIR}\HelloWorld.mbd" \r
- msaFilename="${MODULE_DIR}\HelloWorld.msa" />\r
- </pre>\r
- \r
- <p>Note that all this task doing is part of GenBuildTask. </p>\r
- \r
- @since GenBuild 1.0\r
- @see org.tianocore.build.GenBuildTask\r
-**/\r
-public class OutputDirSetupTask extends Task {\r
- \r
- ///\r
- /// Module surface area file.\r
- ///\r
- File msaFilename;\r
-\r
- ///\r
- /// Module build description file.\r
- ///\r
- File mbdFilename;\r
- \r
- ///\r
- /// Module surface area information after overrided.\r
- ///\r
- public Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
- \r
- ///\r
- /// Module's base name.\r
- ///\r
- private String baseName;\r
- \r
- /**\r
- Public construct method. It is necessary for ANT task.\r
- **/\r
- public OutputDirSetupTask () {\r
- }\r
- \r
- /**\r
- ANT task's entry point, will be called after init(). The main steps is described\r
- as following: \r
- <ul>\r
- <li> Judge current build mode (MODULE | PACKAGE | PLATFORM). This step will execute\r
- only once in whole build process; </li>\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> Restore some important ANT property. If current build is single module \r
- build, here will set many default values; </li>\r
- <li> Get the current module's overridded surface area information from \r
- global data; </li> \r
- <li> Set up the output directories, including BIN_DIR, DEST_DIR_OUTPUT and\r
- DEST_DIR_DEBUG; </li>\r
- </ul>\r
- \r
- @throws BuildException\r
- From module build, exception from module surface area invalid.\r
- **/\r
- public void execute() throws BuildException {\r
- System.out.println("Deleting module [" + baseName + "] start.");\r
- OutputManager.update(getProject());\r
- GlobalData.initInfo("Tools" + File.separatorChar + "Conf" + File.separatorChar + "FrameworkDatabase.db", getProject()\r
- .getProperty("WORKSPACE_DIR"));\r
- recallFixedProperties();\r
- map = GlobalData.getDoc(baseName);\r
- //\r
- // Initialize SurfaceAreaQuery\r
- //\r
- SurfaceAreaQuery.setDoc(map);\r
- //\r
- // Setup Output Management\r
- //\r
- String[] outdir = SurfaceAreaQuery.getOutputDirectory();\r
- OutputManager.update(getProject(), outdir[1], outdir[0]);\r
- }\r
- \r
- /**\r
- Get current module's base name. \r
- \r
- @return base name\r
- **/\r
- public String getBaseName() {\r
- return baseName;\r
- }\r
-\r
- /**\r
- Set base name. For ANT use.\r
- \r
- @param baseName Base name\r
- **/\r
- public void setBaseName(String baseName) {\r
- this.baseName = baseName;\r
- }\r
-\r
- /**\r
- Set MBD surface area file. For ANT use.\r
- \r
- @param mbdFilename Surface Area file\r
- **/\r
- public void setMbdFilename(File mbdFilename) {\r
- this.mbdFilename = mbdFilename;\r
- }\r
-\r
- /**\r
- Set MSA surface area file. For ANT use.\r
- \r
- @param msaFilename Surface Area file\r
- **/\r
- public void setMsaFilename(File msaFilename) {\r
- this.msaFilename = msaFilename;\r
- }\r
- \r
- /**\r
- Restore some important ANT property. If current build is single module \r
- build, here will set many default values.\r
- \r
- <p> If current build is single module build, then the default <code>ARCH</code>\r
- is <code>IA32</code>. Also set up the properties <code>PACKAGE</code>, \r
- <code>PACKAGE_DIR</code>, <code>TARGET</code> and <code>MODULE_DIR</code></p>\r
- \r
- <p> Note that for package build, package name is stored in <code>PLATFORM</code>\r
- and package directory is stored in <code>PLATFORM_DIR</code>. </p> \r
- \r
- @see org.tianocore.build.global.OutputManager\r
- **/\r
- private void recallFixedProperties(){\r
- //\r
- // If build is for module build\r
- //\r
- if (getProject().getProperty("PACKAGE_DIR") == null) {\r
- ToolChainFactory toolChainFactory = new ToolChainFactory(getProject());\r
- toolChainFactory.setupToolChain();\r
- //\r
- // PACKAGE PACKAGE_DIR ARCH (Default) COMMON_FILE BUILD_MACRO\r
- //\r
- if (getProject().getProperty("ARCH") == null){\r
- getProject().setProperty("ARCH", "IA32");\r
- }\r
- String packageName = GlobalData.getPackageNameForModule(baseName);\r
- getProject().setProperty("PACKAGE", packageName);\r
- String packageDir = GlobalData.getPackagePath(packageName);\r
- getProject().setProperty("PACKAGE_DIR", getProject().getProperty("WORKSPACE_DIR") + File.separatorChar + packageDir);\r
- getProject().setProperty("TARGET", toolChainFactory.getCurrentTarget());\r
- getProject().setProperty("MODULE_DIR", getProject().replaceProperties(getProject().getProperty("MODULE_DIR")));\r
- }\r
- if (OutputManager.PLATFORM != null) {\r
- getProject().setProperty("PLATFORM", OutputManager.PLATFORM);\r
- }\r
- if (OutputManager.PLATFORM_DIR != null) {\r
- getProject().setProperty("PLATFORM_DIR", OutputManager.PLATFORM_DIR);\r
- }\r
- }\r
-}\r