]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
ff225cbb | 2 | This file is ANT task GenBuild.\r |
3 | \r | |
4 | The file is used to parse a specified Module, and generate its build time\r | |
878ddf1f | 5 | ANT script build.xml, then call the the ANT script to build the module.\r |
ff225cbb | 6 | \r |
878ddf1f | 7 | Copyright (c) 2006, Intel Corporation\r |
8 | All rights reserved. This program and the accompanying materials\r | |
9 | are licensed and made available under the terms and conditions of the BSD License\r | |
10 | which accompanies this distribution. The full text of the license may be found at\r | |
11 | http://opensource.org/licenses/bsd-license.php\r | |
12 | \r | |
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
15 | **/\r | |
16 | package org.tianocore.build;\r | |
17 | \r | |
18 | import java.io.File;\r | |
aca6c736 | 19 | import java.util.Hashtable;\r |
878ddf1f | 20 | import java.util.Iterator;\r |
21 | import java.util.LinkedHashSet;\r | |
22 | import java.util.List;\r | |
23 | import java.util.Map;\r | |
24 | import java.util.Set;\r | |
25 | import java.util.Vector;\r | |
878ddf1f | 26 | \r |
878ddf1f | 27 | import org.apache.tools.ant.BuildException;\r |
aca6c736 | 28 | import org.apache.tools.ant.BuildListener;\r |
700279a9 | 29 | import org.apache.tools.ant.Location;\r |
aca6c736 | 30 | import org.apache.tools.ant.Project;\r |
878ddf1f | 31 | import org.apache.tools.ant.taskdefs.Ant;\r |
a29c47e0 | 32 | import org.apache.tools.ant.taskdefs.Property;\r |
878ddf1f | 33 | import org.apache.xmlbeans.XmlObject;\r |
136adffc | 34 | import org.tianocore.build.autogen.AutoGen;\r |
892b0e7a | 35 | import org.tianocore.build.exception.AutoGenException;\r |
36 | import org.tianocore.build.exception.GenBuildException;\r | |
37 | import org.tianocore.build.exception.PcdAutogenException;\r | |
38 | import org.tianocore.build.exception.PlatformPcdPreprocessBuildException;\r | |
878ddf1f | 39 | import org.tianocore.build.fpd.FpdParserTask;\r |
40 | import org.tianocore.build.global.GlobalData;\r | |
41 | import org.tianocore.build.global.OutputManager;\r | |
42 | import org.tianocore.build.global.SurfaceAreaQuery;\r | |
a29c47e0 | 43 | import org.tianocore.build.id.FpdModuleIdentification;\r |
44 | import org.tianocore.build.id.ModuleIdentification;\r | |
45 | import org.tianocore.build.id.PackageIdentification;\r | |
46 | import org.tianocore.build.id.PlatformIdentification;\r | |
47 | import org.tianocore.build.tools.ModuleItem;\r | |
700279a9 | 48 | import org.tianocore.common.definitions.ToolDefinitions;\r |
49 | import org.tianocore.common.exception.EdkException;\r | |
50 | import org.tianocore.common.logger.EdkLog;\r | |
878ddf1f | 51 | \r |
52 | /**\r | |
53 | <p>\r | |
54 | <code>GenBuildTask</code> is an ANT task that can be used in ANT build\r | |
4a6a5026 | 55 | system. \r |
56 | \r | |
57 | <p>The main function of this task is to parse module's surface area (MSA),\r | |
878ddf1f | 58 | then generate the corresponding <em>BaseName_build.xml</em> (the real ANT\r |
a29c47e0 | 59 | build script) and call this to build the module. The whole process including:\r |
4b5f5549 | 60 | \r |
2d16dcec | 61 | <pre>\r |
4a6a5026 | 62 | 1. generate AutoGen.c and AutoGen.h; \r |
63 | 2. build all dependent library instances;\r | |
64 | 3. build all source files inlcude AutoGen.c; \r | |
65 | 4. generate sections;\r | |
ff225cbb | 66 | 5. generate FFS file if it is driver module while LIB file if it is Library module.\r |
2d16dcec | 67 | </pre>\r |
68 | \r | |
ff225cbb | 69 | \r |
878ddf1f | 70 | <p>\r |
71 | The usage is (take module <em>HelloWorld</em> for example):\r | |
72 | </p>\r | |
ff225cbb | 73 | \r |
878ddf1f | 74 | <pre>\r |
4b5f5549 | 75 | <GenBuild \r |
76 | msaFile="${PACKAGE_DIR}/Application/HelloWorld/HelloWorld.msa"\r | |
77 | type="cleanall" />\r | |
878ddf1f | 78 | </pre>\r |
ff225cbb | 79 | \r |
878ddf1f | 80 | <p>\r |
81 | This task calls <code>AutoGen</code> to generate <em>AutoGen.c</em> and\r | |
4b5f5549 | 82 | <em>AutoGen.h</em>. \r |
878ddf1f | 83 | </p>\r |
ff225cbb | 84 | \r |
4b5f5549 | 85 | <p>\r |
86 | This task will also set properties for current module, such as PACKAGE, \r | |
87 | PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR \r | |
88 | (relative to Workspace), MODULE or BASE_NAME, GUID, VERSION, MODULE_DIR, \r | |
89 | MODULE_RELATIVE_DIR (relative to Package), CONFIG_DIR, BIN_DIR, \r | |
90 | DEST_DIR_DEBUG, DEST_DIR_OUTPUT, TARGET, ARCH, TOOLCHAIN, TOOLCHAIN_FAMILY, \r | |
91 | SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH, all compiler command related \r | |
92 | properties (CC, CC_FLAGS, CC_DPATH, CC_SPATH, CC_FAMILY, CC_EXT). \r | |
93 | </p>\r | |
94 | \r | |
878ddf1f | 95 | @since GenBuild 1.0\r |
96 | **/\r | |
a29c47e0 | 97 | public class GenBuildTask extends Ant {\r |
ff225cbb | 98 | \r |
878ddf1f | 99 | ///\r |
100 | /// Module surface area file.\r | |
101 | ///\r | |
a29c47e0 | 102 | File msaFile;\r |
19bf6b15 | 103 | \r |
104 | public ModuleIdentification parentId;\r | |
105 | \r | |
82516887 | 106 | private String type = "all"; \r |
107 | \r | |
878ddf1f | 108 | ///\r |
a29c47e0 | 109 | /// Module's Identification.\r |
878ddf1f | 110 | ///\r |
a29c47e0 | 111 | private ModuleIdentification moduleId;\r |
878ddf1f | 112 | \r |
a29c47e0 | 113 | private Vector<Property> properties = new Vector<Property>();\r |
de4bb9f6 | 114 | \r |
de4bb9f6 | 115 | private boolean isSingleModuleBuild = false;\r |
83fba802 | 116 | \r |
117 | private SurfaceAreaQuery saq = null;\r | |
ff225cbb | 118 | \r |
878ddf1f | 119 | /**\r |
120 | Public construct method. It is necessary for ANT task.\r | |
121 | **/\r | |
122 | public GenBuildTask() {\r | |
123 | }\r | |
124 | \r | |
125 | /**\r | |
ff225cbb | 126 | \r |
878ddf1f | 127 | @throws BuildException\r |
128 | From module build, exception from module surface area invalid.\r | |
129 | **/\r | |
130 | public void execute() throws BuildException {\r | |
89e1408f | 131 | this.setTaskName("GenBuild");\r |
892b0e7a | 132 | try {\r |
133 | processGenBuild();\r | |
134 | } catch (PcdAutogenException e) {\r | |
47412835 | 135 | BuildException buildException = new BuildException(e.getMessage());\r |
136 | buildException.setStackTrace(e.getStackTrace());\r | |
137 | throw buildException;\r | |
892b0e7a | 138 | } catch (AutoGenException e) {\r |
47412835 | 139 | BuildException buildException = new BuildException(e.getMessage());\r |
140 | buildException.setStackTrace(e.getStackTrace());\r | |
141 | throw buildException;\r | |
892b0e7a | 142 | } catch (PlatformPcdPreprocessBuildException e) {\r |
47412835 | 143 | BuildException buildException = new BuildException(e.getMessage());\r |
144 | buildException.setStackTrace(e.getStackTrace());\r | |
145 | throw buildException;\r | |
892b0e7a | 146 | } catch (GenBuildException e) {\r |
47412835 | 147 | BuildException buildException = new BuildException(e.getMessage());\r |
148 | buildException.setStackTrace(e.getStackTrace());\r | |
149 | throw buildException;\r | |
892b0e7a | 150 | } catch (EdkException e) {\r |
47412835 | 151 | BuildException buildException = new BuildException(e.getMessage());\r |
152 | buildException.setStackTrace(e.getStackTrace());\r | |
153 | throw buildException;\r | |
700279a9 | 154 | } catch (Exception e) {\r |
155 | BuildException buildException = new BuildException(e.getMessage());\r | |
156 | buildException.setStackTrace(e.getStackTrace());\r | |
157 | throw buildException;\r | |
892b0e7a | 158 | }\r |
159 | }\r | |
160 | \r | |
161 | private void processGenBuild() throws EdkException, BuildException, GenBuildException, AutoGenException, PcdAutogenException, PlatformPcdPreprocessBuildException {\r | |
aca6c736 | 162 | if (!FrameworkBuildTask.multithread) {\r |
163 | cleanupProperties();\r | |
164 | }\r | |
82516887 | 165 | \r |
878ddf1f | 166 | //\r |
a29c47e0 | 167 | // Enable all specified properties\r |
878ddf1f | 168 | //\r |
a29c47e0 | 169 | Iterator<Property> iter = properties.iterator();\r |
170 | while (iter.hasNext()) {\r | |
171 | Property item = iter.next();\r | |
aca6c736 | 172 | getProject().setProperty(item.getName(), item.getValue());\r |
878ddf1f | 173 | }\r |
ff225cbb | 174 | \r |
878ddf1f | 175 | //\r |
a29c47e0 | 176 | // GenBuild should specify either msaFile or moduleGuid & packageGuid\r |
878ddf1f | 177 | //\r |
a29c47e0 | 178 | if (msaFile == null ) {\r |
179 | String moduleGuid = getProject().getProperty("MODULE_GUID");\r | |
180 | String moduleVersion = getProject().getProperty("MODULE_VERSION");\r | |
181 | String packageGuid = getProject().getProperty("PACKAGE_GUID");\r | |
182 | String packageVersion = getProject().getProperty("PACKAGE_VERSION");\r | |
892b0e7a | 183 | //\r |
184 | // If one of module Guid or package Guid is not specified, report error\r | |
185 | //\r | |
a29c47e0 | 186 | if (moduleGuid == null || packageGuid == null) {\r |
391dbbb1 | 187 | throw new BuildException("GenBuild parameter error.");\r |
878ddf1f | 188 | }\r |
892b0e7a | 189 | \r |
a29c47e0 | 190 | PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);\r |
892b0e7a | 191 | GlobalData.refreshPackageIdentification(packageId);\r |
a29c47e0 | 192 | moduleId = new ModuleIdentification(moduleGuid, moduleVersion);\r |
193 | moduleId.setPackage(packageId);\r | |
892b0e7a | 194 | GlobalData.refreshModuleIdentification(moduleId);\r |
a29c47e0 | 195 | Map<String, XmlObject> doc = GlobalData.getNativeMsa(moduleId);\r |
83fba802 | 196 | saq = new SurfaceAreaQuery(doc);\r |
82516887 | 197 | } else {\r |
a29c47e0 | 198 | Map<String, XmlObject> doc = GlobalData.getNativeMsa(msaFile);\r |
83fba802 | 199 | saq = new SurfaceAreaQuery(doc);\r |
200 | moduleId = saq.getMsaHeader();\r | |
89e1408f | 201 | moduleId.setMsaFile(msaFile);\r |
878ddf1f | 202 | }\r |
892b0e7a | 203 | \r |
700279a9 | 204 | String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED", null, null);\r |
a29c47e0 | 205 | if (producedLibraryClasses.length == 0) {\r |
206 | moduleId.setLibrary(false);\r | |
82516887 | 207 | } else {\r |
a29c47e0 | 208 | moduleId.setLibrary(true);\r |
878ddf1f | 209 | }\r |
2c9b03f2 | 210 | moduleId.setBinary(saq.getBinaryModule());\r |
ff225cbb | 211 | \r |
878ddf1f | 212 | //\r |
a29c47e0 | 213 | // Judge whether it is single module build or not\r |
878ddf1f | 214 | //\r |
de4bb9f6 | 215 | if (isSingleModuleBuild) {\r |
878ddf1f | 216 | //\r |
a29c47e0 | 217 | // Single Module build\r |
878ddf1f | 218 | //\r |
a29c47e0 | 219 | prepareSingleModuleBuild();\r |
878ddf1f | 220 | }\r |
ff225cbb | 221 | \r |
a29c47e0 | 222 | //\r |
82516887 | 223 | // If single module : get arch from pass down, otherwise intersection MSA \r |
224 | // supported ARCHs and tools def\r | |
a29c47e0 | 225 | //\r |
ff225cbb | 226 | Set<String> archListSupByToolChain = new LinkedHashSet<String>();\r |
227 | String[] archs = GlobalData.getToolChainInfo().getArchs();\r | |
228 | \r | |
3c696250 | 229 | for (int i = 0; i < archs.length; i ++) {\r |
230 | archListSupByToolChain.add(archs[i]);\r | |
231 | }\r | |
ff225cbb | 232 | \r |
3c696250 | 233 | Set<String> archSet = new LinkedHashSet<String>();\r |
bc022470 | 234 | String archString = getProject().getProperty("ARCH");\r |
de093b3c | 235 | if (archString != null && archString.length() > 0) {\r |
bc022470 | 236 | String[] fpdArchList = archString.split(" ");\r |
ff225cbb | 237 | \r |
3c696250 | 238 | for (int i = 0; i < fpdArchList.length; i++) {\r |
239 | if (archListSupByToolChain.contains(fpdArchList[i])) {\r | |
240 | archSet.add(fpdArchList[i]);\r | |
241 | }\r | |
242 | }\r | |
82516887 | 243 | } else {\r |
244 | archSet = archListSupByToolChain; \r | |
3c696250 | 245 | }\r |
ff225cbb | 246 | \r |
3c696250 | 247 | String[] archList = archSet.toArray(new String[archSet.size()]);\r |
ff225cbb | 248 | \r |
a29c47e0 | 249 | //\r |
250 | // Judge if arch is all supported by current module. If not, throw Exception.\r | |
251 | //\r | |
83fba802 | 252 | List moduleSupportedArchs = saq.getModuleSupportedArchs();\r |
a29c47e0 | 253 | if (moduleSupportedArchs != null) {\r |
254 | for (int k = 0; k < archList.length; k++) {\r | |
9821fa9a | 255 | if (!moduleSupportedArchs.contains(archList[k])) {\r |
256 | EdkLog.log(this, EdkLog.EDK_WARNING, "Specified architecture [" + archList[k] + "] is not supported by " + moduleId + ". The module " + moduleId + " only supports [" + moduleSupportedArchs + "] architectures.");\r | |
257 | archList[k] = "";\r | |
a29c47e0 | 258 | }\r |
259 | }\r | |
878ddf1f | 260 | }\r |
ff225cbb | 261 | \r |
c340a28e | 262 | if (archList.length == 0) {\r |
bc022470 | 263 | EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: " + "[" + archString + "] is not supported for " + moduleId + " in this build!\n");\r |
c340a28e | 264 | }\r |
265 | \r | |
a29c47e0 | 266 | for (int k = 0; k < archList.length; k++) {\r |
9821fa9a | 267 | if (archList[k] == "") {\r |
268 | continue;\r | |
269 | }\r | |
ff225cbb | 270 | \r |
aca6c736 | 271 | getProject().setProperty("ARCH", archList[k]);\r |
ff225cbb | 272 | \r |
a29c47e0 | 273 | FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, archList[k]);\r |
ff225cbb | 274 | \r |
878ddf1f | 275 | //\r |
a29c47e0 | 276 | // Whether the module is built before\r |
878ddf1f | 277 | //\r |
1fcc1b79 | 278 | if ((moduleId.isLibrary() == false || isSingleModuleBuild) && GlobalData.hasFpdModuleSA(fpdModuleId) == false) {\r |
279 | if (isSingleModuleBuild) {\r | |
280 | EdkLog.log(this, EdkLog.EDK_ERROR, "Error: " + moduleId + " for " + archList[k] + " was not found in current platform FPD file!\n");\r | |
281 | throw new BuildException("No platform containing this module!");\r | |
282 | } else {\r | |
283 | EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: " + moduleId + " for " + archList[k] + " was not found in current platform FPD file!\n");\r | |
284 | }\r | |
34281092 | 285 | continue;\r |
286 | } else if (GlobalData.isModuleBuilt(fpdModuleId)) {\r | |
1fa1cb75 | 287 | break;\r |
34281092 | 288 | } else {\r |
a29c47e0 | 289 | GlobalData.registerBuiltModule(fpdModuleId);\r |
290 | }\r | |
ff225cbb | 291 | \r |
878ddf1f | 292 | //\r |
a29c47e0 | 293 | // For Every TOOLCHAIN, TARGET\r |
294 | //\r | |
295 | String[] targetList = GlobalData.getToolChainInfo().getTargets();\r | |
296 | for (int i = 0; i < targetList.length; i ++){\r | |
297 | //\r | |
298 | // Prepare for target related common properties\r | |
299 | // TARGET\r | |
300 | //\r | |
aca6c736 | 301 | getProject().setProperty("TARGET", targetList[i]);\r |
a29c47e0 | 302 | String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();\r |
303 | for(int j = 0; j < toolchainList.length; j ++){\r | |
c773bec0 | 304 | //\r |
305 | // check if any tool is defined for current target + toolchain + arch\r | |
306 | // don't do anything if no tools found\r | |
ff225cbb | 307 | //\r |
c773bec0 | 308 | if (GlobalData.isCommandSet(targetList[i], toolchainList[j], archList[k]) == false) {\r |
fd6c41f5 | 309 | EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: No build issued. No tools found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");\r |
c773bec0 | 310 | continue;\r |
311 | }\r | |
312 | \r | |
a29c47e0 | 313 | //\r |
314 | // Prepare for toolchain related common properties\r | |
315 | // TOOLCHAIN\r | |
316 | //\r | |
aca6c736 | 317 | getProject().setProperty("TOOLCHAIN", toolchainList[j]);\r |
a29c47e0 | 318 | \r |
d965d1f6 | 319 | EdkLog.log(this, "Build " + moduleId + " start >>>");\r |
320 | EdkLog.log(this, "Target: " + targetList[i] + " Tagname: " + toolchainList[j] + " Arch: " + archList[k]);\r | |
83fba802 | 321 | saq.push(GlobalData.getDoc(fpdModuleId));\r |
ff225cbb | 322 | \r |
a29c47e0 | 323 | //\r |
324 | // Prepare for all other common properties\r | |
325 | // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR\r | |
326 | // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE\r | |
327 | // MODULE_DIR, MODULE_RELATIVE_DIR\r | |
328 | // SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH\r | |
a29c47e0 | 329 | //\r |
330 | setModuleCommonProperties(archList[k]);\r | |
ff225cbb | 331 | \r |
a29c47e0 | 332 | //\r |
ff225cbb | 333 | // OutputManage prepare for\r |
a29c47e0 | 334 | // BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR\r |
335 | //\r | |
336 | OutputManager.getInstance().update(getProject());\r | |
ff225cbb | 337 | \r |
a29c47e0 | 338 | if (type.equalsIgnoreCase("all") || type.equalsIgnoreCase("build")) {\r |
339 | applyBuild(targetList[i], toolchainList[j], fpdModuleId);\r | |
e3cc4061 | 340 | } else {\r |
341 | applyNonBuildTarget(fpdModuleId);\r | |
a29c47e0 | 342 | }\r |
343 | }\r | |
344 | }\r | |
878ddf1f | 345 | }\r |
878ddf1f | 346 | }\r |
347 | \r | |
348 | /**\r | |
ff225cbb | 349 | This method is used to prepare Platform-related information.\r |
350 | \r | |
a29c47e0 | 351 | <p>In Single Module Build mode, platform-related information is not ready.\r |
ff225cbb | 352 | The method read the system environment variable <code>ACTIVE_PLATFORM</code>\r |
a29c47e0 | 353 | and search in the Framework Database. Note that platform name in the Framework\r |
354 | Database must be unique. </p>\r | |
ff225cbb | 355 | \r |
878ddf1f | 356 | **/\r |
892b0e7a | 357 | private void prepareSingleModuleBuild() throws EdkException {\r |
878ddf1f | 358 | //\r |
a29c47e0 | 359 | // Find out the package which the module belongs to\r |
878ddf1f | 360 | //\r |
a29c47e0 | 361 | PackageIdentification packageId = GlobalData.getPackageForModule(moduleId);\r |
892b0e7a | 362 | GlobalData.refreshPackageIdentification(packageId);\r |
a29c47e0 | 363 | moduleId.setPackage(packageId);\r |
892b0e7a | 364 | GlobalData.refreshModuleIdentification(moduleId);\r |
ff225cbb | 365 | \r |
878ddf1f | 366 | //\r |
82516887 | 367 | // Read ACTIVE_PLATFORM's FPD file \r |
878ddf1f | 368 | //\r |
de4bb9f6 | 369 | String filename = getProject().getProperty("PLATFORM_FILE");\r |
ff225cbb | 370 | \r |
de4bb9f6 | 371 | if (filename == null){\r |
391dbbb1 | 372 | throw new BuildException("Please set ACTIVE_PLATFORM in the file: Tools/Conf/target.txt if you want to build a single module!");\r |
878ddf1f | 373 | }\r |
ff225cbb | 374 | \r |
de4bb9f6 | 375 | PlatformIdentification platformId = GlobalData.getPlatform(filename);\r |
ff225cbb | 376 | \r |
878ddf1f | 377 | //\r |
82516887 | 378 | // Read FPD file (Call FpdParserTask's method)\r |
878ddf1f | 379 | //\r |
a29c47e0 | 380 | FpdParserTask fpdParser = new FpdParserTask();\r |
381 | fpdParser.setProject(getProject());\r | |
07193171 | 382 | fpdParser.parseFpdFile(platformId.getFpdFile());\r |
aca6c736 | 383 | getProject().setProperty("ARCH", fpdParser.getAllArchForModule(moduleId));\r |
878ddf1f | 384 | }\r |
385 | \r | |
aca6c736 | 386 | private void cleanupProperties() {\r |
387 | Project newProject = new Project();\r | |
388 | \r | |
389 | Hashtable<String, String> passdownProperties = FrameworkBuildTask.originalProperties;\r | |
390 | Iterator<String> iter = passdownProperties.keySet().iterator();\r | |
391 | while (iter.hasNext()) {\r | |
392 | String item = iter.next();\r | |
393 | newProject.setProperty(item, passdownProperties.get(item));\r | |
394 | }\r | |
395 | \r | |
396 | newProject.setInputHandler(getProject().getInputHandler());\r | |
397 | \r | |
398 | Iterator listenerIter = getProject().getBuildListeners().iterator();\r | |
399 | while (listenerIter.hasNext()) {\r | |
400 | newProject.addBuildListener((BuildListener) listenerIter.next());\r | |
401 | }\r | |
402 | \r | |
403 | getProject().initSubProject(newProject);\r | |
404 | \r | |
405 | setProject(newProject);\r | |
406 | }\r | |
878ddf1f | 407 | \r |
408 | /**\r | |
a29c47e0 | 409 | Set Module-Related information to properties.\r |
82516887 | 410 | \r |
411 | @param arch current build ARCH\r | |
878ddf1f | 412 | **/\r |
a29c47e0 | 413 | private void setModuleCommonProperties(String arch) {\r |
878ddf1f | 414 | //\r |
a29c47e0 | 415 | // Prepare for all other common properties\r |
416 | // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR\r | |
878ddf1f | 417 | //\r |
a29c47e0 | 418 | PackageIdentification packageId = moduleId.getPackage();\r |
aca6c736 | 419 | getProject().setProperty("PACKAGE", packageId.getName());\r |
420 | getProject().setProperty("PACKAGE_GUID", packageId.getGuid());\r | |
421 | getProject().setProperty("PACKAGE_VERSION", packageId.getVersion());\r | |
422 | getProject().setProperty("PACKAGE_DIR", packageId.getPackageDir().replaceAll("(\\\\)", "/"));\r | |
423 | getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId.getPackageRelativeDir().replaceAll("(\\\\)", "/"));\r | |
ff225cbb | 424 | \r |
a29c47e0 | 425 | //\r |
426 | // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE\r | |
427 | // MODULE_DIR, MODULE_RELATIVE_DIR\r | |
428 | //\r | |
aca6c736 | 429 | getProject().setProperty("MODULE", moduleId.getName());\r |
83fba802 | 430 | String baseName = saq.getModuleOutputFileBasename();\r |
a29c47e0 | 431 | if (baseName == null) {\r |
aca6c736 | 432 | getProject().setProperty("BASE_NAME", moduleId.getName());\r |
82516887 | 433 | } else {\r |
aca6c736 | 434 | getProject().setProperty("BASE_NAME", baseName);\r |
a29c47e0 | 435 | }\r |
aca6c736 | 436 | getProject().setProperty("GUID", moduleId.getGuid());\r |
437 | getProject().setProperty("FILE_GUID", moduleId.getGuid());\r | |
438 | getProject().setProperty("VERSION", moduleId.getVersion());\r | |
439 | getProject().setProperty("MODULE_TYPE", moduleId.getModuleType());\r | |
86f3fef0 | 440 | File msaFile = moduleId.getMsaFile();\r |
441 | String msaFileName = msaFile.getName();\r | |
442 | getProject().setProperty("MODULE_DIR", msaFile.getParent().replaceAll("(\\\\)", "/"));\r | |
443 | getProject().setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/") \r | |
bc022470 | 444 | + File.separatorChar + msaFileName.substring(0, msaFileName.lastIndexOf('.')));\r |
ff225cbb | 445 | \r |
a29c47e0 | 446 | //\r |
447 | // SUBSYSTEM\r | |
448 | //\r | |
449 | String[][] subsystemMap = { { "BASE", "EFI_BOOT_SERVICE_DRIVER"},\r | |
ff225cbb | 450 | { "SEC", "EFI_BOOT_SERVICE_DRIVER" },\r |
451 | { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" },\r | |
452 | { "PEIM", "EFI_BOOT_SERVICE_DRIVER" },\r | |
a29c47e0 | 453 | { "DXE_CORE", "EFI_BOOT_SERVICE_DRIVER" },\r |
ff225cbb | 454 | { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },\r |
455 | { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" },\r | |
456 | { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },\r | |
457 | { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },\r | |
458 | { "TOOL", "EFI_BOOT_SERVICE_DRIVER" },\r | |
a29c47e0 | 459 | { "UEFI_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },\r |
ff225cbb | 460 | { "UEFI_APPLICATION", "EFI_APPLICATION" },\r |
461 | { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} };\r | |
462 | \r | |
a29c47e0 | 463 | String subsystem = "EFI_BOOT_SERVICE_DRIVER";\r |
464 | for (int i = 0; i < subsystemMap.length; i++) {\r | |
465 | if (moduleId.getModuleType().equalsIgnoreCase(subsystemMap[i][0])) {\r | |
466 | subsystem = subsystemMap[i][1];\r | |
467 | break ;\r | |
878ddf1f | 468 | }\r |
469 | }\r | |
aca6c736 | 470 | getProject().setProperty("SUBSYSTEM", subsystem);\r |
ff225cbb | 471 | \r |
a29c47e0 | 472 | //\r |
473 | // ENTRYPOINT\r | |
474 | //\r | |
475 | if (arch.equalsIgnoreCase("EBC")) {\r | |
aca6c736 | 476 | getProject().setProperty("ENTRYPOINT", "EfiStart");\r |
82516887 | 477 | } else {\r |
aca6c736 | 478 | getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");\r |
878ddf1f | 479 | }\r |
ff225cbb | 480 | \r |
aca6c736 | 481 | getProject().setProperty("OBJECTS", "");\r |
878ddf1f | 482 | }\r |
483 | \r | |
a29c47e0 | 484 | private void getCompilerFlags(String target, String toolchain, FpdModuleIdentification fpdModuleId) throws EdkException {\r |
485 | String[] cmd = GlobalData.getToolChainInfo().getCommands();\r | |
486 | for ( int m = 0; m < cmd.length; m++) {\r | |
878ddf1f | 487 | //\r |
a29c47e0 | 488 | // Set cmd, like CC, DLINK\r |
878ddf1f | 489 | //\r |
a29c47e0 | 490 | String[] key = new String[]{target, toolchain, fpdModuleId.getArch(), cmd[m], null};\r |
4a6a5026 | 491 | key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_PATH;\r |
a29c47e0 | 492 | String cmdPath = GlobalData.getCommandSetting(key, fpdModuleId);\r |
4a6a5026 | 493 | key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_NAME;\r |
a29c47e0 | 494 | String cmdName = GlobalData.getCommandSetting(key, fpdModuleId);\r |
1549f516 | 495 | if (cmdName.length() == 0) {\r |
fd6c41f5 | 496 | EdkLog.log(this, EdkLog.EDK_VERBOSE, "Warning: " + cmd[m] + " hasn't been defined!");\r |
497 | getProject().setProperty(cmd[m], "");\r | |
1549f516 | 498 | continue;\r |
499 | }\r | |
a29c47e0 | 500 | File cmdFile = new File(cmdPath + File.separatorChar + cmdName);\r |
aca6c736 | 501 | getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));\r |
ff225cbb | 502 | \r |
878ddf1f | 503 | //\r |
a29c47e0 | 504 | // set CC_FLAGS\r |
878ddf1f | 505 | //\r |
4a6a5026 | 506 | key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS;\r |
a29c47e0 | 507 | String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId);\r |
e04a8a9a | 508 | if (cmdFlags != null) \r |
509 | {\r | |
e04a8a9a | 510 | getProject().setProperty(cmd[m] + "_FLAGS", cmdFlags);\r |
511 | } \r | |
512 | else \r | |
513 | {\r | |
514 | getProject().setProperty(cmd[m] + "_FLAGS", "");\r | |
515 | }\r | |
516 | \r | |
878ddf1f | 517 | //\r |
a29c47e0 | 518 | // Set CC_EXT\r |
878ddf1f | 519 | //\r |
4a6a5026 | 520 | key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_EXT;\r |
a29c47e0 | 521 | String extName = GlobalData.getCommandSetting(key, fpdModuleId);\r |
a29c47e0 | 522 | if ( extName != null && ! extName.equalsIgnoreCase("")) {\r |
aca6c736 | 523 | getProject().setProperty(cmd[m] + "_EXT", extName);\r |
82516887 | 524 | } else {\r |
aca6c736 | 525 | getProject().setProperty(cmd[m] + "_EXT", "");\r |
878ddf1f | 526 | }\r |
ff225cbb | 527 | \r |
878ddf1f | 528 | //\r |
a29c47e0 | 529 | // set CC_FAMILY\r |
878ddf1f | 530 | //\r |
4a6a5026 | 531 | key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FAMILY;\r |
a29c47e0 | 532 | String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId);\r |
a29c47e0 | 533 | if (toolChainFamily != null) {\r |
aca6c736 | 534 | getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily);\r |
878ddf1f | 535 | }\r |
ff225cbb | 536 | \r |
878ddf1f | 537 | //\r |
a29c47e0 | 538 | // set CC_SPATH\r |
878ddf1f | 539 | //\r |
4a6a5026 | 540 | key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_SPATH;\r |
a29c47e0 | 541 | String spath = GlobalData.getCommandSetting(key, fpdModuleId);\r |
a29c47e0 | 542 | if (spath != null) {\r |
aca6c736 | 543 | getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));\r |
82516887 | 544 | } else {\r |
aca6c736 | 545 | getProject().setProperty(cmd[m] + "_SPATH", "");\r |
878ddf1f | 546 | }\r |
ff225cbb | 547 | \r |
878ddf1f | 548 | //\r |
a29c47e0 | 549 | // set CC_DPATH\r |
878ddf1f | 550 | //\r |
4a6a5026 | 551 | key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_DPATH;\r |
a29c47e0 | 552 | String dpath = GlobalData.getCommandSetting(key, fpdModuleId);\r |
a29c47e0 | 553 | if (dpath != null) {\r |
aca6c736 | 554 | getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));\r |
82516887 | 555 | } else {\r |
aca6c736 | 556 | getProject().setProperty(cmd[m] + "_DPATH", "");\r |
878ddf1f | 557 | }\r |
c639781e | 558 | \r |
559 | //\r | |
560 | // Set CC_LIBPATH\r | |
561 | //\r | |
562 | key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_LIBPATH;\r | |
563 | String libpath = GlobalData.getCommandSetting(key, fpdModuleId);\r | |
564 | if (libpath != null) {\r | |
565 | getProject().setProperty(cmd[m] + "_LIBPATH", libpath.replaceAll("(\\\\)", "/"));\r | |
566 | } else {\r | |
567 | getProject().setProperty(cmd[m] + "_LIBPATH", "");\r | |
568 | }\r | |
569 | \r | |
570 | //\r | |
571 | // Set CC_INCLUDEPATH\r | |
572 | //\r | |
573 | key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_INCLUDEPATH;\r | |
574 | String includepath = GlobalData.getCommandSetting(key, fpdModuleId);\r | |
575 | if (dpath != null) {\r | |
576 | getProject().setProperty(cmd[m] + "_INCLUDEPATH", includepath.replaceAll("(\\\\)", "/"));\r | |
577 | } else {\r | |
578 | getProject().setProperty(cmd[m] + "_INCLUDEPATH", "");\r | |
579 | }\r | |
878ddf1f | 580 | }\r |
a29c47e0 | 581 | }\r |
ff225cbb | 582 | \r |
a29c47e0 | 583 | public void setMsaFile(File msaFile) {\r |
584 | this.msaFile = msaFile;\r | |
878ddf1f | 585 | }\r |
586 | \r | |
587 | /**\r | |
ff225cbb | 588 | Method is for ANT to initialize MSA file.\r |
589 | \r | |
a29c47e0 | 590 | @param msaFilename MSA file name\r |
878ddf1f | 591 | **/\r |
a29c47e0 | 592 | public void setMsaFile(String msaFilename) {\r |
593 | String moduleDir = getProject().getProperty("MODULE_DIR");\r | |
ff225cbb | 594 | \r |
a29c47e0 | 595 | //\r |
596 | // If is Single Module Build, then use the Base Dir defined in build.xml\r | |
597 | //\r | |
598 | if (moduleDir == null) {\r | |
599 | moduleDir = getProject().getBaseDir().getPath();\r | |
878ddf1f | 600 | }\r |
a29c47e0 | 601 | msaFile = new File(moduleDir + File.separatorChar + msaFilename);\r |
602 | }\r | |
ff225cbb | 603 | \r |
a29c47e0 | 604 | public void addConfiguredModuleItem(ModuleItem moduleItem) {\r |
605 | PackageIdentification packageId = new PackageIdentification(moduleItem.getPackageGuid(), moduleItem.getPackageVersion());\r | |
606 | ModuleIdentification moduleId = new ModuleIdentification(moduleItem.getModuleGuid(), moduleItem.getModuleVersion());\r | |
607 | moduleId.setPackage(packageId);\r | |
608 | this.moduleId = moduleId;\r | |
609 | }\r | |
ff225cbb | 610 | \r |
a29c47e0 | 611 | /**\r |
ff225cbb | 612 | Add a property.\r |
613 | \r | |
a29c47e0 | 614 | @param p property\r |
615 | **/\r | |
616 | public void addProperty(Property p) {\r | |
617 | properties.addElement(p);\r | |
618 | }\r | |
619 | \r | |
620 | public void setType(String type) {\r | |
621 | this.type = type;\r | |
622 | }\r | |
ff225cbb | 623 | \r |
892b0e7a | 624 | private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws EdkException {\r |
a29c47e0 | 625 | //\r |
a6a0e024 | 626 | // Call AutoGen to generate AutoGen.c and AutoGen.h for non-binary module\r |
a29c47e0 | 627 | //\r |
a6a0e024 | 628 | if (!fpdModuleId.getModule().isBinary()) {\r |
629 | AutoGen autogen = new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId.getModule(),fpdModuleId.getArch(), saq, parentId);\r | |
630 | autogen.genAutogen();\r | |
631 | }\r | |
ff225cbb | 632 | \r |
a29c47e0 | 633 | //\r |
634 | // Get compiler flags\r | |
635 | //\r | |
82516887 | 636 | try {\r |
637 | getCompilerFlags(buildTarget, buildTagname, fpdModuleId);\r | |
638 | }\r | |
639 | catch (EdkException ee) {\r | |
640 | throw new BuildException(ee.getMessage());\r | |
641 | }\r | |
642 | \r | |
a29c47e0 | 643 | //\r |
644 | // Prepare LIBS\r | |
645 | //\r | |
83fba802 | 646 | ModuleIdentification[] libinstances = saq.getLibraryInstance(fpdModuleId.getArch());\r |
a29c47e0 | 647 | String propertyLibs = "";\r |
648 | for (int i = 0; i < libinstances.length; i++) {\r | |
498e9021 | 649 | propertyLibs += getProject().getProperty("BIN_DIR") + File.separatorChar + libinstances[i].getName() + ".lib" + " ";\r |
878ddf1f | 650 | }\r |
aca6c736 | 651 | getProject().setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/"));\r |
ff225cbb | 652 | \r |
bf3a7173 | 653 | //\r |
654 | // Get all includepath and set to INCLUDE_PATHS\r | |
655 | //\r | |
656 | String[] includes = prepareIncludePaths(fpdModuleId);\r | |
657 | \r | |
a29c47e0 | 658 | //\r |
659 | // if it is CUSTOM_BUILD\r | |
660 | // then call the exist BaseName_build.xml directly.\r | |
661 | //\r | |
98840b10 | 662 | String buildFilename = "";\r |
663 | if ((buildFilename = GetCustomizedBuildFile(fpdModuleId.getArch())) != "") {\r | |
664 | EdkLog.log(this, "Call user-defined " + buildFilename);\r | |
82516887 | 665 | \r |
98840b10 | 666 | String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + buildFilename;\r |
82516887 | 667 | antCall(antFilename, null);\r |
668 | \r | |
a29c47e0 | 669 | return ;\r |
878ddf1f | 670 | }\r |
ff225cbb | 671 | \r |
878ddf1f | 672 | //\r |
a29c47e0 | 673 | // Generate ${BASE_NAME}_build.xml\r |
674 | // TBD\r | |
878ddf1f | 675 | //\r |
83fba802 | 676 | String ffsKeyword = saq.getModuleFfsKeyword();\r |
677 | ModuleBuildFileGenerator fileGenerator = new ModuleBuildFileGenerator(getProject(), ffsKeyword, fpdModuleId, includes, saq);\r | |
98840b10 | 678 | buildFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";\r |
a29c47e0 | 679 | fileGenerator.genBuildFile(buildFilename);\r |
ff225cbb | 680 | \r |
a29c47e0 | 681 | //\r |
682 | // Ant call ${BASE_NAME}_build.xml\r | |
683 | //\r | |
82516887 | 684 | String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";\r |
685 | antCall(antFilename, null);\r | |
a29c47e0 | 686 | }\r |
ff225cbb | 687 | \r |
e3cc4061 | 688 | private void applyNonBuildTarget(FpdModuleIdentification fpdModuleId){\r |
689 | //\r | |
690 | // if it is CUSTOM_BUILD\r | |
691 | // then call the exist BaseName_build.xml directly.\r | |
692 | //\r | |
693 | if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {\r | |
694 | EdkLog.log(this, "Calling user-defined " + moduleId.getName() + "_build.xml");\r | |
695 | \r | |
696 | String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";\r | |
697 | antCall(antFilename, this.type);\r | |
698 | \r | |
699 | return ;\r | |
700 | }\r | |
701 | \r | |
702 | String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";\r | |
703 | antCall(antFilename, this.type);\r | |
704 | }\r | |
705 | \r | |
a29c47e0 | 706 | private void applyClean(FpdModuleIdentification fpdModuleId){\r |
707 | //\r | |
708 | // if it is CUSTOM_BUILD\r | |
709 | // then call the exist BaseName_build.xml directly.\r | |
710 | //\r | |
711 | if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {\r | |
d965d1f6 | 712 | EdkLog.log(this, "Calling user-defined " + moduleId.getName() + "_build.xml");\r |
82516887 | 713 | \r |
714 | String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";\r | |
715 | antCall(antFilename, "clean");\r | |
716 | \r | |
a29c47e0 | 717 | return ;\r |
878ddf1f | 718 | }\r |
ff225cbb | 719 | \r |
82516887 | 720 | String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";\r |
721 | antCall(antFilename, "clean");\r | |
a29c47e0 | 722 | }\r |
ff225cbb | 723 | \r |
a29c47e0 | 724 | private void applyCleanall(FpdModuleIdentification fpdModuleId){\r |
725 | //\r | |
726 | // if it is CUSTOM_BUILD\r | |
727 | // then call the exist BaseName_build.xml directly.\r | |
728 | //\r | |
729 | if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {\r | |
d965d1f6 | 730 | EdkLog.log(this, "Calling user-defined " + moduleId.getName() + "_build.xml");\r |
82516887 | 731 | \r |
732 | String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";\r | |
733 | antCall(antFilename, "cleanall");\r | |
734 | \r | |
a29c47e0 | 735 | return ;\r |
878ddf1f | 736 | }\r |
82516887 | 737 | \r |
738 | String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";\r | |
739 | antCall(antFilename, "cleanall");\r | |
740 | }\r | |
ff225cbb | 741 | \r |
82516887 | 742 | private void antCall(String antFilename, String target) {\r |
a29c47e0 | 743 | Ant ant = new Ant();\r |
744 | ant.setProject(getProject());\r | |
82516887 | 745 | ant.setAntfile(antFilename);\r |
746 | if (target != null) {\r | |
747 | ant.setTarget(target);\r | |
748 | }\r | |
a29c47e0 | 749 | ant.setInheritAll(true);\r |
750 | ant.init();\r | |
751 | ant.execute();\r | |
878ddf1f | 752 | }\r |
753 | \r | |
de4bb9f6 | 754 | public void setSingleModuleBuild(boolean isSingleModuleBuild) {\r |
755 | this.isSingleModuleBuild = isSingleModuleBuild;\r | |
756 | }\r | |
bf3a7173 | 757 | \r |
892b0e7a | 758 | private String[] prepareIncludePaths(FpdModuleIdentification fpdModuleId) throws EdkException{\r |
bf3a7173 | 759 | //\r |
760 | // Prepare the includes: PackageDependencies and Output debug direactory\r | |
761 | //\r | |
762 | Set<String> includes = new LinkedHashSet<String>();\r | |
763 | String arch = fpdModuleId.getArch();\r | |
764 | \r | |
765 | //\r | |
766 | // WORKSPACE\r | |
767 | //\r | |
768 | includes.add("${WORKSPACE_DIR}" + File.separatorChar);\r | |
769 | \r | |
770 | //\r | |
771 | // Module iteself\r | |
772 | //\r | |
773 | includes.add("${MODULE_DIR}");\r | |
774 | includes.add("${MODULE_DIR}" + File.separatorChar + archDir(arch));\r | |
775 | \r | |
776 | //\r | |
777 | // Packages in PackageDenpendencies\r | |
778 | //\r | |
83fba802 | 779 | PackageIdentification[] packageDependencies = saq.getDependencePkg(fpdModuleId.getArch());\r |
bf3a7173 | 780 | for (int i = 0; i < packageDependencies.length; i++) {\r |
781 | GlobalData.refreshPackageIdentification(packageDependencies[i]);\r | |
782 | File packageFile = packageDependencies[i].getSpdFile();\r | |
783 | includes.add(packageFile.getParent() + File.separatorChar + "Include");\r | |
784 | includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + archDir(arch));\r | |
785 | }\r | |
786 | \r | |
787 | //\r | |
788 | // All Dependency Library Instance's PackageDependencies\r | |
789 | //\r | |
83fba802 | 790 | ModuleIdentification[] libinstances = saq.getLibraryInstance(fpdModuleId.getArch());\r |
bf3a7173 | 791 | for (int i = 0; i < libinstances.length; i++) {\r |
83fba802 | 792 | saq.push(GlobalData.getDoc(libinstances[i], fpdModuleId.getArch()));\r |
793 | PackageIdentification[] libraryPackageDependencies = saq.getDependencePkg(fpdModuleId.getArch());\r | |
bf3a7173 | 794 | for (int j = 0; j < libraryPackageDependencies.length; j++) {\r |
795 | GlobalData.refreshPackageIdentification(libraryPackageDependencies[j]);\r | |
796 | File packageFile = libraryPackageDependencies[j].getSpdFile();\r | |
797 | includes.add(packageFile.getParent() + File.separatorChar + "Include");\r | |
798 | includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + archDir(arch));\r | |
799 | }\r | |
83fba802 | 800 | saq.pop();\r |
bf3a7173 | 801 | }\r |
802 | \r | |
803 | \r | |
804 | //\r | |
805 | // The package which the module belongs to\r | |
806 | // TBD\r | |
807 | includes.add(fpdModuleId.getModule().getPackage().getPackageDir() + File.separatorChar + "Include");\r | |
808 | includes.add(fpdModuleId.getModule().getPackage().getPackageDir() + File.separatorChar + "Include" + File.separatorChar + archDir(arch));\r | |
809 | \r | |
810 | //\r | |
811 | // Debug files output directory\r | |
812 | //\r | |
813 | includes.add("${DEST_DIR_DEBUG}");\r | |
814 | \r | |
815 | //\r | |
816 | // set to INCLUDE_PATHS property\r | |
817 | //\r | |
818 | Iterator<String> iter = includes.iterator();\r | |
819 | StringBuffer includePaths = new StringBuffer();\r | |
820 | while (iter.hasNext()) {\r | |
821 | includePaths.append(iter.next());\r | |
822 | includePaths.append("; ");\r | |
823 | }\r | |
aca6c736 | 824 | getProject().setProperty("INCLUDE_PATHS", getProject().replaceProperties(includePaths.toString()).replaceAll("(\\\\)", "/"));\r |
bf3a7173 | 825 | \r |
826 | return includes.toArray(new String[includes.size()]);\r | |
827 | }\r | |
828 | \r | |
829 | /**\r | |
830 | Return the name of the directory that corresponds to the architecture.\r | |
831 | This is a translation from the XML Schema tag to a directory that\r | |
832 | corresponds to our directory name coding convention.\r | |
833 | \r | |
834 | **/\r | |
835 | private String archDir(String arch) {\r | |
836 | return arch.replaceFirst("X64", "x64")\r | |
837 | .replaceFirst("IPF", "Ipf")\r | |
838 | .replaceFirst("IA32", "Ia32")\r | |
839 | .replaceFirst("ARM", "Arm")\r | |
840 | .replaceFirst("EBC", "Ebc");\r | |
19bf6b15 | 841 | }\r |
842 | \r | |
843 | \r | |
844 | public void setExternalProperties(Vector<Property> v) {\r | |
845 | this.properties = v;\r | |
846 | }\r | |
98840b10 | 847 | \r |
848 | private String GetCustomizedBuildFile(String arch) {\r | |
849 | String[][] files = saq.getSourceFiles(arch);\r | |
850 | for (int i = 0; i < files.length; ++i) {\r | |
851 | if (files[i][1].endsWith("build.xml")) {\r | |
852 | return files[i][1];\r | |
853 | }\r | |
854 | }\r | |
855 | \r | |
856 | return "";\r | |
857 | }\r | |
878ddf1f | 858 | }\r |