]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java
4 OutputManager class set output directories for every module by BUILD_MODE.
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 package org
.tianocore
.build
.global
;
17 import org
.apache
.tools
.ant
.Project
;
21 OutputManager class is used to setup output directories (BIN_DIR, DEST_DIR_OUTPUT,
22 DEST_DIR_DEBUG) according to BUILD_MODE.
26 public class OutputManager
{
29 /// Single Module build
31 public static final String MODULE_BUILD
= "MODULE";
36 public static final String PACKAGE_BUILD
= "PACKAGE";
41 public static final String PLATFORM_BUILD
= "PLATFORM";
43 public static String buildMode
= MODULE_BUILD
;
46 /// For Package build, PLATFORM represent PACKAGE
48 public static String PLATFORM
;
51 /// For Platform build, PLATFORM_DIR represent PACKAGE_DIR
53 public static String PLATFORM_DIR
;
56 /// means intermediate files will put under Module's dir
58 public static final String MODULE
= "MODULE";
61 /// mean intermediate files will put under a unify dir
63 public static final String UNIFIED
= "UNIFIED";
66 /// Flag to ensure the function <code>update</code> will be called only one in the whole build.
68 private static boolean flag
= true;
71 If BUILD_MODE is PLATFORM or PACKAGE, record PLATFORM and PLARFORM_DIR.
72 Reminder that for PACKAGE build, here set value PACKAGE to PLATFORM and
73 PACKAGE_DIR to PLARFORM_DIR, and also update the ant properties.
75 <p>Note that this function will be called only once in the whole build.</p>
77 @param project current ANT build Project
79 public synchronized static void update(Project project
) {
82 String str
= project
.getProperty("BUILD_MODE");
84 if (str
.equals(PLATFORM_BUILD
)) {
85 buildMode
= PLATFORM_BUILD
;
86 PLATFORM
= project
.getProperty("PLATFORM");
87 PLATFORM_DIR
= project
.getProperty("PLATFORM_DIR");
89 else if (str
.equals(PACKAGE_BUILD
)) {
90 buildMode
= PACKAGE_BUILD
;
91 PLATFORM
= project
.getProperty("PACKAGE");
92 PLATFORM_DIR
= project
.getProperty("PACKAGE_DIR");
93 project
.setProperty("PLATFORM", PLATFORM
);
94 project
.setProperty("PLATFORM_DIR", PLATFORM_DIR
);
101 Setup BIN_DIR, DEST_DIR_OUTPUT and DEST_DIR_OUTPUT, following are the rules:
104 Those three variables are defined as following
105 DEST_DIR_OUTPUT (intermediate files)
106 DEST_DIR_DEBUG (intermediate debug files)
107 BIN_DIR (final files)
109 Output Dir (MODULE or UNIFIED):
110 For <b>Module</b> build:
111 All intermediate files are at ${MODULE_DIR}/Build/${TARGET}/${ARCH}/DEBUG|OUTPUT
112 All final files are at ${MODULE_DIR}/Build/${TARGET}/${ARCH}
114 For <b>Platform</b> build:
115 If specified with MODULE
116 Intermediate files->${MODULE_DIR}/Build/${PLATFORM}/${TARGET}/${ARCH}/DEBUG|OUTPUT
117 Final files -> ${PLARFORM_DIR}/Build/${TARGET}/${ARCH}
119 Else if specified with UNIFIED
120 Intermediate files->${PLARFORM_DIR}/Build/${TARGET}/${ARCH}/${PACKAGE}/${SOURCE_RELATIVE_PATH}/DEBUG|OUTPUT
121 Final files -> ${PLARFORM_DIR}/Build/${TARGET}/${ARCH}
123 For <b>Package</b> build:
124 If specified with MODULE
125 Intermediate files->${MODULE_DIR}/Build/${PACKAGE}/${TARGET}/${ARCH}/DEBUG|OUTPUT
126 Final files -> ${PACKAGE_DIR}/Build/${TARGET}/${ARCH}
128 Else if specified with UNIFIED
129 Intermediate files->${PACKAGE_DIR}/Build/${TARGET}/${ARCH}/${PACKAGE}/${SOURCE_RELATIVE_PATH}/DEBUG|OUTPUT
130 Final files -> ${PACKAGE_DIR}/Build/${TARGET}/${ARCH}
133 @param project current ANT build Project
134 @param userdir user-defined directory
135 @param type the module build type (MODULE or UNIFIED)
137 public synchronized static void update(Project project
, String userdir
, String type
) {
141 if( type
== null || ! type
.equals(MODULE
)){
144 if (buildMode
.equals(MODULE_BUILD
)){
145 project
.setProperty("DEST_DIR_OUTPUT", project
.replaceProperties("${MODULE_DIR}"
146 + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${TARGET}"
147 + File
.separatorChar
+ "${ARCH}" + File
.separatorChar
+ "OUTPUT"));
148 project
.setProperty("DEST_DIR_DEBUG", project
.replaceProperties("${MODULE_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}" + File
.separatorChar
+ "DEBUG"));
149 project
.setProperty("BIN_DIR", project
.replaceProperties("${MODULE_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}"));
151 else if (buildMode
.equals(PLATFORM_BUILD
)) {
152 if (type
.equals(MODULE
)) {
153 project
.setProperty("DEST_DIR_OUTPUT", project
.replaceProperties("${MODULE_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${PLATFORM}" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}" + File
.separatorChar
+ "OUTPUT"));
154 project
.setProperty("DEST_DIR_DEBUG", project
.replaceProperties("${MODULE_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${PLATFORM}" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}" + File
.separatorChar
+ "DEBUG"));
155 project
.setProperty("BIN_DIR", project
.replaceProperties("${PLATFORM_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}"));
157 else if (type
.equals(UNIFIED
)){
158 project
.setProperty("DEST_DIR_OUTPUT", project
.replaceProperties("${PLATFORM_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}" + File
.separatorChar
+ "${PACKAGE}" + File
.separatorChar
+ "${MODULE_RELATIVE_PATH}" + File
.separatorChar
+ "OUTPUT"));
159 project
.setProperty("DEST_DIR_DEBUG", project
.replaceProperties("${PLATFORM_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}" + File
.separatorChar
+ "${PACKAGE}" + File
.separatorChar
+ "${MODULE_RELATIVE_PATH}" + File
.separatorChar
+ "DEBUG"));
160 project
.setProperty("BIN_DIR", project
.replaceProperties("${PLATFORM_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}"));
163 else if (buildMode
.equals(PACKAGE_BUILD
)) {
164 if (type
.equals(MODULE
)) {
165 project
.setProperty("DEST_DIR_OUTPUT", project
.replaceProperties("${MODULE_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${PLATFORM}" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}" + File
.separatorChar
+ "OUTPUT"));
166 project
.setProperty("DEST_DIR_DEBUG", project
.replaceProperties("${MODULE_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${PLATFORM}" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}" + File
.separatorChar
+ "DEBUG"));
167 project
.setProperty("BIN_DIR", project
.replaceProperties("${PLATFORM_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}"));
169 else if (type
.equals(UNIFIED
)){
170 project
.setProperty("DEST_DIR_OUTPUT", project
.replaceProperties("${PLATFORM_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}" + File
.separatorChar
+ "${PACKAGE}" + File
.separatorChar
+ "${MODULE_RELATIVE_PATH}" + File
.separatorChar
+ "OUTPUT"));
171 project
.setProperty("DEST_DIR_DEBUG", project
.replaceProperties("${PLATFORM_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}" + File
.separatorChar
+ "${PACKAGE}" + File
.separatorChar
+ "${MODULE_RELATIVE_PATH}" + File
.separatorChar
+ "DEBUG"));
172 project
.setProperty("BIN_DIR", project
.replaceProperties("${PLATFORM_DIR}" + File
.separatorChar
+ "Build" + File
.separatorChar
+ "${TARGET}" + File
.separatorChar
+ "${ARCH}"));