+++ /dev/null
-/** @file\r
- OutputManager class.\r
- \r
- OutputManager class set output directories for every module by BUILD_MODE.\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.global;\r
-\r
-import org.apache.tools.ant.Project;\r
-import java.io.File;\r
-\r
-/**\r
- OutputManager class is used to setup output directories (BIN_DIR, DEST_DIR_OUTPUT, \r
- DEST_DIR_DEBUG). \r
- \r
- @since GenBuild 1.0\r
-**/\r
-public class OutputManager {\r
-\r
- ///\r
- /// means intermediate files will put under Module's dir\r
- ///\r
- private String MODULE = "MODULE";\r
- \r
- ///\r
- /// mean intermediate files will put under a unify dir\r
- ///\r
- private String UNIFIED = "UNIFIED";\r
- \r
- \r
- private String userdir;\r
- \r
- private String type;\r
- ///\r
- /// Singleton Design Pattern\r
- ///\r
- private static OutputManager object;\r
- \r
- public synchronized static OutputManager getInstance() {\r
- if ( object == null ) {\r
- object = new OutputManager();\r
- }\r
- return object;\r
- }\r
- \r
- public void setup(String userdir, String type) {\r
- this.userdir = userdir;\r
- this.type = type;\r
- }\r
- \r
- /**\r
- Setup BIN_DIR, DEST_DIR_OUTPUT and DEST_DIR_OUTPUT, following are the rules:\r
- \r
- <p>Divide all output files into two types: one is final files, such as FFS \r
- file for driver module while LIB file for library module; another is \r
- intermediate files, such AutoGen.c, OBJ files, Section files and so on. \r
- \r
- <p>In FPD, OutputDirectory element is used to specify where to put the output \r
- files to. There are two mode (MODULE | UNIFIED). MODULE mode means that all \r
- output files will put to the module directory while UNIFIED mode means that \r
- all output files will put together. Default is UNIFIED mode. \r
- \r
- <p>BUILD_DIR is the base directory for current module build. By default, \r
- BUILD_DIR is PLATFORM_DIR/Build in UNIFIED mode while is MODULE_DIR/Build \r
- in MODULE mode. Of course, user can customize BUILD_DIR. If user-defined \r
- BUILD_DIR is relative path, then look as related to WORKSPACE_DIR. \r
- \r
- <p>Then, BIN_DIR is BUILD_DIR/TARGET/TOOLCHAIN/ARCH;\r
- \r
- <p>FV_DIR is BUILD_DIR/TARGET/TOOLCHAIN/FV;\r
- \r
- <p>DEST_DIR_DEBUG | DEST_DIR_OUTPUT is: \r
- BIN_DIR/PACKAGE_RELATIVE_DIR/MODULE_RELATIVE_DIR/DEBUG | OUTPUT\r
-\r
- \r
- @param project current ANT build Project\r
- @param userdir user-defined directory\r
- @param type the module build type (MODULE or UNIFIED)\r
- **/\r
- public void update(Project project) {\r
- //\r
- // Default mode is UNIFIED. \r
- //\r
- if (type != null && type.equalsIgnoreCase(MODULE)) {\r
- type = MODULE;\r
- }\r
- else {\r
- type = UNIFIED;\r
- }\r
- \r
- //\r
- // default BUILD_DIR value\r
- //\r
- String buildDir;\r
- if(type.equals(MODULE)){\r
- buildDir = project.getProperty("MODULE_DIR") + File.separatorChar + "Build";\r
- }\r
- else {\r
- buildDir = project.getProperty("PLATFORM_DIR") + File.separatorChar + "Build";\r
- }\r
- \r
- //\r
- // If user define BUILD_DIR\r
- //\r
- if (userdir != null && ! userdir.equals("")) {\r
- File buildFile = new File(userdir);\r
- if (buildFile.isAbsolute()){\r
- buildDir = userdir;\r
- }\r
- //\r
- // If path is not absolute, then look as related to WORKSPACE_DIR\r
- //\r
- else {\r
- buildDir = GlobalData.getWorkspacePath() + File.separatorChar + userdir;\r
- }\r
- }\r
- \r
- //\r
- // Define TARGET_DIR\r
- //\r
- String targetDir = buildDir + File.separatorChar + project.getProperty("TARGET")\r
- + "_" + project.getProperty("TOOLCHAIN");\r
- \r
- //\r
- // Define BIN_DIR and FV_DIR\r
- //\r
- String binDir = targetDir + File.separatorChar + project.getProperty("ARCH") ;\r
- \r
- String fvDir = targetDir + File.separatorChar + "FV";\r
- \r
- //\r
- // Define DEST_DIR_OUTPUT and DEST_DIR_DEBUG\r
- //\r
- String destDir = binDir + File.separatorChar + project.getProperty("PACKAGE_RELATIVE_DIR")\r
- + File.separatorChar + project.getProperty("MODULE_RELATIVE_DIR");\r
- \r
- //\r
- // Set properties\r
- //\r
- project.setProperty("BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));\r
- project.setProperty("TARGET_DIR", targetDir.replaceAll("(\\\\)", "/"));\r
- project.setProperty("FV_DIR", fvDir.replaceAll("(\\\\)", "/"));\r
- project.setProperty("BIN_DIR", binDir.replaceAll("(\\\\)", "/"));\r
- project.setProperty("DEST_DIR_DEBUG", (destDir + File.separatorChar + "DEBUG").replaceAll("(\\\\)", "/"));\r
- project.setProperty("DEST_DIR_OUTPUT", (destDir + File.separatorChar + "OUTPUT").replaceAll("(\\\\)", "/"));\r
- \r
- //\r
- // Create all directory if necessary\r
- //\r
- (new File(buildDir)).mkdirs();\r
- (new File(fvDir)).mkdirs();\r
- (new File(binDir)).mkdirs();\r
- (new File(destDir + File.separatorChar + "DEBUG")).mkdirs();\r
- (new File(destDir + File.separatorChar + "OUTPUT")).mkdirs();\r
- }\r
- \r
- public boolean prepareBuildDir(Project project){\r
- boolean isUnified = true;\r
- \r
- if (type.equalsIgnoreCase("MODULE")) {\r
- isUnified = false;\r
- }\r
- \r
- String buildDir = project.getProperty("PLATFORM_DIR") + File.separatorChar + "Build";\r
- //\r
- // If user define BUILD_DIR\r
- //\r
- if (userdir != null && ! userdir.equals("")) {\r
- File buildFile = new File(userdir);\r
- if (buildFile.isAbsolute()){\r
- buildDir = userdir;\r
- }\r
- //\r
- // If path is not absolute, then look as related to WORKSPACE_DIR\r
- //\r
- else {\r
- buildDir = GlobalData.getWorkspacePath() + File.separatorChar + userdir;\r
- }\r
- }\r
- \r
- //\r
- // Set to property\r
- //\r
- project.setProperty("BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));\r
- \r
- //\r
- // Create all directory if necessary\r
- //\r
- (new File(buildDir)).mkdirs();\r
- return isUnified;\r
- }\r
-\r
-}
\ No newline at end of file