]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Python/buildgen/BuildFile.py
8514e4c8a4557fc4b63782ac518788288b54d67e
[mirror_edk2.git] / Tools / Python / buildgen / BuildFile.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 2007, Intel Corporation
4 # All rights reserved. This program and the accompanying materials
5 # are licensed and made available under the terms and conditions of the BSD License
6 # which accompanies this distribution. The full text of the license may be found at
7 # http://opensource.org/licenses/bsd-license.php
8 #
9 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 """Generate build file for given platform"""
13
14 import os, sys, copy
15 import xml.dom.minidom, pprint
16 import FrameworkElement
17
18 from SurfaceAreaElement import *
19 from XmlRoutines import *
20 from AntTasks import *
21 from sets import Set
22
23 class BuildFile:
24 def __init__(self, workspace, platform, toolchain, target):
25 if workspace == None or workspace == "":
26 raise Exception("No workspace, no build")
27 if platform == None or platform == "":
28 raise Exception("No platform, no build")
29 if toolchain == None or toolchain == "":
30 raise Exception("No toolchain, no build")
31 if target == None or target == "":
32 raise Exception("No target, no build")
33
34 self.Workspace = workspace
35 self.Platform = platform
36 self.Toolchain = toolchain
37 self.Target = target
38 self.Path = ""
39
40 def Generate(self):
41 """Generate the build file"""
42 pass
43
44 # generating build.xml for platform
45 class AntPlatformBuildFile(BuildFile):
46 def __init__(self, workspace, platform, toolchain, target):
47 BuildFile.__init__(self, workspace, platform, toolchain, target)
48 # Form the build file path, hard-coded at present. It should be specified by a configuration file
49 self.Path = os.path.join(self.Workspace.Path, self.Platform.OutputPath, target + "_" + toolchain, "build.xml")
50 print ""
51 # Generate a common build option property file in the format of Java's property file
52 self.DefaultBuildOptions()
53
54 # new a build file object
55 self.BuildXml = AntBuildFile(name="platform", basedir=".", default="all")
56
57 # generate the top level properties, tasks, etc.
58 self.Header()
59
60 # generate "prebuild" target
61 self.PreBuild()
62
63 # generate "libraries" target for building library modules
64 self.Libraries()
65
66 # generate "modules" target for building non-library modules
67 self.Modules()
68
69 # generate "fvs" target for building firmware volume. (not supported yet)
70
71 # generate "fds" target for building FlashDevice. (not supported yet)
72
73 # generate "postbuild" target
74 self.PostBuild()
75
76 def Generate(self):
77 print "Generating platform build file ...", self.Path
78 self.BuildXml.Create(self.Path)
79
80 def Header(self):
81 _topLevel = self.BuildXml
82 # import external tasks
83 _topLevel.SubTask("taskdef", resource="GenBuild.tasks")
84 _topLevel.SubTask("taskdef", resource="frameworktasks.tasks")
85 _topLevel.SubTask("taskdef", resource="net/sf/antcontrib/antlib.xml")
86
87 # platform wide properties
88 _topLevel.Blankline()
89 _topLevel.Comment("WORKSPACE wide attributes")
90 _topLevel.SubTask("property", environment="env")
91 _topLevel.SubTask("property", name="WORKSPACE_DIR", value="${env.WORKSPACE}")
92 _topLevel.SubTask("property", name="CONFIG_DIR", value="${WORKSPACE_DIR}/Tools/Conf")
93
94 _topLevel.Blankline()
95 _topLevel.Comment("Common build attributes")
96 _topLevel.SubTask("property", name="THREAD_COUNT", value=self.Workspace.ThreadCount)
97 _topLevel.SubTask("property", name="SINGLE_MODULE_BUILD", value="no")
98 _topLevel.SubTask("property", name="MODULE_BUILD_TARGET", value="platform_module_build")
99
100 _topLevel.Blankline()
101 _topLevel.SubTask("property", name="TOOLCHAIN", value=self.Toolchain)
102 _topLevel.SubTask("property", name="TARGET", value=self.Target)
103
104 _topLevel.Blankline()
105 _topLevel.Comment("Platform attributes")
106 _topLevel.SubTask("property", name="PLATFORM", value=self.Platform.Name)
107 _topLevel.SubTask("property", name="PLATFORM_GUID", value=self.Platform.GuidValue)
108 _topLevel.SubTask("property", name="PLATFORM_VERSION", value=self.Platform.Version)
109 _topLevel.SubTask("property", name="PLATFORM_RELATIVE_DIR", value=self.Platform.Dir)
110 _topLevel.SubTask("property", name="PLATFORM_DIR", value="${WORKSPACE_DIR}/${PLATFORM_RELATIVE_DIR}")
111 _topLevel.SubTask("property", name="PLATFORM_OUTPUT_DIR", value=self.Platform.OutputPath)
112
113 # user configurable build path for platform
114 _topLevel.Blankline()
115 _topLevel.Comment("Common path definition for platform build")
116 _topLevel.SubTask("property", file="${WORKSPACE_DIR}/Tools/Python/buildgen/platform_build_path.txt")
117
118 # common build tasks in the form of Ant macro
119 _topLevel.Blankline()
120 _topLevel.Comment("Task Macros for Compiling, Assembling, Linking, etc.")
121 _topLevel.SubTask("import", file="${CONFIG_DIR}/BuildMacro.xml")
122 _topLevel.Blankline()
123 _topLevel.SubTask("echo", message="${PLATFORM}-${PLATFORM_VERSION} (${PLATFORM_RELATIVE_DIR})", level="info")
124
125 # define the targets execution sequence
126 _topLevel.Blankline()
127 _topLevel.Comment("Default target")
128 _topLevel.SubTask("target", name="all", depends="prebuild, libraries, modules, postbuild")
129
130 def PreBuild(self):
131 _topLevel = self.BuildXml
132 _topLevel.Blankline()
133 _topLevel.Comment(" TARGET: prebuild ")
134
135 # prebuild is defined by user in the fpd file through <UserExtionsion> element,
136 # which has attribute "identifier=0" or "identifier=prebuild"
137 prebuildTasks = []
138 if self.Platform.UserExtensions.has_key("0"):
139 prebuildTasks = self.Platform.UserExtensions["0"]
140 elif self.Platform.UserExtensions.has_key("postbuild"):
141 prebuildTasks = self.Platform.UserExtensions["prebuild"]
142
143 _topLevel.SubTask("target", prebuildTasks, name="prebuild")
144
145 def Libraries(self):
146 _topLevel = self.BuildXml
147 _topLevel.Blankline()
148 _topLevel.Comment(" TARGET: libraries ")
149
150 librariesTarget = _topLevel.SubTask("target", name="libraries")
151 parallelBuild = librariesTarget.SubTask("parallel", threadCount="${THREAD_COUNT}")
152
153 libraryNumber = 0
154 for arch in self.Platform.Libraries:
155 libraryNumber += len(self.Platform.Libraries[arch])
156 libraryIndex = 0
157 for arch in self.Platform.Libraries:
158 for lib in self.Platform.Libraries[arch]:
159 libraryIndex += 1
160 print "Generating library build files ... %d%%\r" % int((float(libraryIndex) / float(libraryNumber)) * 100),
161 buildFile = AntModuleBuildFile(self.Workspace, self.Platform, lib, self.Toolchain, self.Target, arch)
162 buildFile.Generate()
163 buildDir = os.path.join("${TARGET_DIR}", arch, lib.Module.Package.SubPath(lib.Module.Dir),
164 lib.Module.FileBaseName)
165 parallelBuild.SubTask("ant", dir=buildDir,
166 #antfile="build.xml",
167 inheritAll="true",
168 target="${MODULE_BUILD_TARGET}")
169 print ""
170
171 def Modules(self):
172 _topLevel = self.BuildXml
173 _topLevel.Blankline()
174 _topLevel.Comment(" TARGET: modules ")
175
176 modulesTarget = _topLevel.SubTask("target", name="modules")
177 parallelBuild = modulesTarget.SubTask("parallel", threadCount="${THREAD_COUNT}")
178
179 moduleNumber = 0
180 for arch in self.Platform.Modules:
181 moduleNumber += len(self.Platform.Modules[arch])
182
183 moduleIndex = 0
184 for arch in self.Platform.Modules:
185 for module in self.Platform.Modules[arch]:
186 moduleIndex += 1
187 print "Generating module build files ... %d%%\r" % int((float(moduleIndex) / float(moduleNumber)) * 100),
188
189 buildDir = os.path.join("${TARGET_DIR}", arch, module.Module.Package.SubPath(module.Module.Dir),
190 module.Module.FileBaseName)
191 parallelBuild.SubTask("ant", dir=buildDir,
192 #antfile="build.xml",
193 inheritAll="true",
194 target="${MODULE_BUILD_TARGET}")
195 buildFile = AntModuleBuildFile(self.Workspace, self.Platform, module, self.Toolchain, self.Target, arch)
196 buildFile.Generate()
197 print ""
198
199 def Fvs(self):
200 pass
201
202 def Fds(self):
203 pass
204
205 def PostBuild(self):
206 _topLevel = self.BuildXml
207 _topLevel.Blankline()
208 _topLevel.Comment(" TARGET: postbuild ")
209
210 # postbuild is defined by user in the fpd file through <UserExtionsion> element,
211 # which has attribute "identifier=1" or "identifier=postbuild"
212 postbuildTasks = []
213 if self.Platform.UserExtensions.has_key("1"):
214 postbuildTasks = self.Platform.UserExtensions["1"]
215 elif self.Platform.UserExtensions.has_key("postbuild"):
216 postbuildTasks = self.Platform.UserExtensions["postbuild"]
217
218 _topLevel.SubTask("target", postbuildTasks, name="postbuild")
219
220 def Clean(self):
221 pass
222
223 def CleanAll(self):
224 pass
225
226 def UserExtensions(self):
227 pass
228
229 def DefaultBuildOptions(self):
230 """Generate ${ARCH}_build.opt which contains the default build&tool definitions"""
231 tools = self.Workspace.ToolConfig.ToolCodes
232 for arch in self.Workspace.ActiveArchs:
233 optFileDir = os.path.join(self.Workspace.Path, self.Platform.OutputPath,
234 self.Target + "_" + self.Toolchain)
235 optFileName = arch + "_build.opt"
236 if not os.path.exists(optFileDir): os.makedirs(optFileDir)
237 f = open(os.path.join(optFileDir, optFileName), "w")
238 for tool in tools:
239 key = (self.Toolchain, self.Target, arch, tool, "FLAGS")
240 flag = self.Workspace.ToolConfig[key]
241 f.write("DEFAULT_%s_FLAGS=%s\n" % (tool, flag))
242
243 f.write("\n")
244 for tool in tools:
245 key = (self.Toolchain, self.Target, arch, tool, "FLAGS")
246 if key in self.Platform.BuildOptions:
247 flag = self.Platform.BuildOptions[key]
248 else:
249 key = (self.Toolchain, self.Target, arch, tool, "FAMILY")
250 family = self.Workspace.ToolConfig[key]
251 key = (family, self.Target, arch, tool, "FLAGS")
252 if key in self.Platform.BuildOptions:
253 flag = self.Platform.BuildOptions[key]
254 else:
255 flag = ""
256 f.write("PLATFORM_%s_FLAGS=%s\n" % (tool, flag))
257
258 f.write("\n")
259 for tool in tools:
260 for attr in self.Workspace.ToolConfig.Attributes:
261 if attr == "FLAGS": continue
262 key = (self.Toolchain, self.Target, arch, tool, attr)
263 value = self.Workspace.ToolConfig[key]
264 if attr == "NAME":
265 f.write("%s=%s\n" % (tool, value))
266 else:
267 f.write("%s_%s=%s\n" % (tool, attr, value))
268 f.write("%s_FLAGS=${DEFAULT_%s_FLAGS} ${DEFAULT_MODULE_%s_FLAGS} ${PLATFORM_%s_FLAGS} ${MODULE_%s_FLAGS}\n" %
269 (tool, tool, tool, tool, tool))
270 f.write("\n")
271
272 f.close()
273
274 class AntModuleBuildFile(BuildFile):
275 def __init__(self, workspace, platform, module, toolchain, target, arch):
276 BuildFile.__init__(self, workspace, platform, toolchain, target)
277 self.Module = module
278 self.Arch = arch
279 self.Path = os.path.join(self.Workspace.Path, self.Platform.OutputPath,
280 target + "_" + toolchain, arch, self.Module.Module.Package.Dir,
281 self.Module.Module.Dir, self.Module.Module.FileBaseName, "build.xml")
282 self.BuildXml = AntBuildFile(self.Module.Module.Name)
283
284 self.SourceFiles = self.GetSourceFiles()
285
286 self.Header()
287 self.PreBuild()
288 self.Libraries()
289 self.Sourcefiles()
290 self.Sections()
291 self.Ffs()
292 self.PostBuild()
293
294 def Generate(self):
295 # print self.Path,"\r",
296 self.BuildXml.Create(self.Path)
297
298 def Header(self):
299 _topLevel = self.BuildXml
300 _topLevel.SubTask("taskdef", resource="frameworktasks.tasks")
301 _topLevel.SubTask("taskdef", resource="cpptasks.tasks")
302 _topLevel.SubTask("taskdef", resource="cpptasks.types")
303 _topLevel.SubTask("taskdef", resource="net/sf/antcontrib/antlib.xml")
304
305 _topLevel.Blankline()
306 _topLevel.Comment(" TODO ")
307 _topLevel.SubTask("property", environment="env")
308 _topLevel.SubTask("property", name="WORKSPACE_DIR", value="${env.WORKSPACE}")
309
310 _topLevel.Blankline()
311 _topLevel.Comment("Common build attributes")
312 _topLevel.SubTask("property", name="SINGLE_MODULE_BUILD", value="yes")
313 _topLevel.SubTask("property", name="MODULE_BUILD_TARGET", value="single_module_build")
314 _topLevel.SubTask("property", name="PLATFORM_PREBUILD", value="yes")
315 _topLevel.SubTask("property", name="PLATFORM_POSTBUILD", value="no")
316
317 _topLevel.Blankline()
318 _topLevel.Comment(" TODO ")
319 ifTask = _topLevel.SubTask("if")
320 ifTask.SubTask("istrue", value="${SINGLE_MODULE_BUILD}")
321 thenTask = ifTask.SubTask("then")
322 platformBuildFile = os.path.join("${WORKSPACE_DIR}", self.Platform.OutputPath,
323 self.Target + "_" + self.Toolchain, "build.xml")
324 thenTask.SubTask("import", file=platformBuildFile)
325
326 _topLevel.Blankline()
327 _topLevel.SubTask("property", name="ARCH", value=self.Arch)
328
329 module = self.Module.Module
330 package = module.Package
331 _topLevel.Blankline()
332 _topLevel.SubTask("property", name="PACKAGE", value=package.Name)
333 _topLevel.SubTask("property", name="PACKAGE_GUID", value=package.GuidValue)
334 _topLevel.SubTask("property", name="PACKAGE_VERSION", value=package.Version)
335 _topLevel.SubTask("property", name="PACKAGE_RELATIVE_DIR", value=package.Dir)
336 _topLevel.SubTask("property", name="PACKAGE_DIR", value=os.path.join("${WORKSPACE_DIR}","${PACKAGE_RELATIVE_DIR}"))
337
338 _topLevel.Blankline()
339 _topLevel.SubTask("property", name="MODULE", value=module.Name)
340 _topLevel.SubTask("property", name="MODULE_GUID", value=module.GuidValue)
341 _topLevel.SubTask("property", name="MODULE_VERSION", value=module.Version)
342 _topLevel.SubTask("property", name="MODULE_TYPE", value=module.Type)
343 _topLevel.SubTask("property", name="MODULE_FILE_BASE_NAME", value=module.FileBaseName)
344 _topLevel.SubTask("property", name="MODULE_RELATIVE_DIR", value=module.Dir)
345 _topLevel.SubTask("property", name="MODULE_DIR", value=os.path.join("${PACKAGE_DIR}", "${MODULE_RELATIVE_DIR}"))
346 _topLevel.SubTask("property", name="BASE_NAME", value=module.BaseName)
347
348 _topLevel.Blankline()
349 _topLevel.SubTask("property", file="${WORKSPACE_DIR}/Tools/Python/buildgen/module_build_path.txt")
350
351 self._BuildOption()
352
353 _topLevel.Blankline()
354 _topLevel.SubTask("property", name="ENTRYPOINT", value="_ModuleEntryPoint")
355
356 _topLevel.SubTask("property", name="SOURCE_FILES", value="\n ".join(self._GetSourceFileList()))
357 _topLevel.SubTask("property", name="LIBS", value="\n ".join(self._GetLibList()))
358
359 _topLevel.Blankline()
360 _topLevel.SubTask("property", file="${PLATFORM_BUILD_DIR}/%s_build.opt" % self.Arch)
361 _topLevel.Blankline()
362 _topLevel.SubTask("echo", message="${MODULE}-${MODULE_VERSION} [${ARCH}] from package ${PACKAGE}-${PACKAGE_VERSION} (${MODULE_RELATIVE_DIR})", level="info")
363
364 _topLevel.Blankline()
365 _topLevel.Comment("Default target")
366 _topLevel.SubTask("target", name="all", depends="single_module_build")
367 _topLevel.SubTask("target", name="platform_module_build", depends="prebuild, sourcefiles, sections, output, postbuild")
368 _topLevel.SubTask("target", name="single_module_build", depends="prebuild, libraries, sourcefiles, sections, output, postbuild")
369
370 def _BuildOption(self):
371 _topLevel = self.BuildXml
372 _topLevel.Blankline()
373 baseModule = self.Module.Module
374 tools = self.Workspace.ToolConfig.ToolCodes
375
376 for tool in tools:
377 key = (self.Toolchain, self.Target, self.Arch, tool, "FLAGS")
378 flag = ""
379 if key in baseModule.BuildOptions:
380 flag = baseModule.BuildOptions[key]
381 _topLevel.SubTask("property", name="DEFAULT_MODULE_%s_FLAGS" % tool, value=flag)
382
383 _topLevel.Blankline()
384 for tool in tools:
385 key = (self.Toolchain, self.Target, self.Arch, tool, "FLAGS")
386 flag = ""
387 if key in self.Module.BuildOptions:
388 flag = self.Module.BuildOptions[key]
389 _topLevel.SubTask("property", name="MODULE_%s_FLAGS" % tool, value=flag)
390
391 def PreBuild(self):
392 _topLevel = self.BuildXml
393 _topLevel.Blankline()
394 _topLevel.Comment(" TARGET: prebuild ")
395
396 prebuildTasks = []
397 module = self.Module.Module
398 if module.UserExtensions.has_key("0"):
399 prebuildTasks = module.UserExtensions["0"]
400 elif module.UserExtensions.has_key("postbuild"):
401 prebuildTasks = module.UserExtensions["prebuild"]
402
403 _topLevel.SubTask("target", prebuildTasks, name="prebuild")
404
405
406 def Libraries(self):
407 _topLevel = self.BuildXml
408 _topLevel.Blankline()
409 _topLevel.Comment(" TARGET: libraries ")
410
411 librariesTarget = _topLevel.SubTask("target", name="libraries")
412 parallelBuild = librariesTarget.SubTask("parallel", threadCount="${THREAD_COUNT}")
413 for lib in self.Module.Libraries:
414 module = lib.Module
415 buildDir = os.path.join("${BIN_DIR}", module.Package.SubPath(module.Dir), module.FileBaseName)
416 libTask = parallelBuild.SubTask("ant", dir=buildDir,
417 inheritAll="false",
418 target="${MODULE_BUILD_TARGET}")
419 libTask.SubTask("property", name="PLATFORM_PREBUILD", value="false")
420 libTask.SubTask("property", name="PLATFORM_POSTBUILD", value="false")
421
422 def Sourcefiles(self):
423 _topLevel = self.BuildXml
424 _topLevel.Blankline()
425 _topLevel.Comment(" TARGET: sourcefiles ")
426 _sourcefilesTarget = _topLevel.SubTask("target", name="sourcefiles")
427
428 _incTask = AntTask(self.BuildXml.Document, "EXTRA.INC")
429 _incTask.SubTask("includepath", path="${WORKSPACE_DIR}")
430 _incTask.SubTask("includepath", path="${MODULE_DIR}")
431 _incTask.SubTask("includepath", path=os.path.join("${MODULE_DIR}", self.Arch.capitalize()))
432 _incTask.SubTask("includepath", path="${DEST_DIR_DEBUG}")
433 if self.Arch in self.Module.Module.IncludePaths:
434 for inc in self.Module.Module.IncludePaths[self.Arch]:
435 _incTask.SubTask("includepath", path=os.path.join("${WORKSPACE_DIR}", inc))
436
437 # init
438 if not self.Module.Module.IsBinary:
439 _buildTask = _sourcefilesTarget.SubTask("Build_Init")
440 _buildTask.AddSubTask(_incTask)
441
442 # AutoGen firt
443 _buildTask = _sourcefilesTarget.SubTask("Build_AUTOGEN", FILEEXT="c", FILENAME="AutoGen", FILEPATH=".")
444 _buildTask.AddSubTask(_incTask)
445
446 # uni file follows
447 type = "UNI"
448 if type in self.SourceFiles:
449 for srcpath in self.SourceFiles[type]:
450 taskName = "Build_" + type
451 fileDir = os.path.dirname(srcpath)
452 if fileDir == "": fileDir = "."
453 fileBaseName,fileExt = os.path.basename(srcpath).rsplit(".", 1)
454 _buildTask = _sourcefilesTarget.SubTask(taskName, FILENAME=fileBaseName, FILEEXT=fileExt, FILEPATH=fileDir)
455 _buildTask.AddSubTask(_incTask)
456
457 # others: c, vfr, ...
458 for type in self.SourceFiles:
459 if type == "Unicode": continue
460 for srcpath in self.SourceFiles[type]:
461 taskName = "Build_" + type
462 fileDir = os.path.dirname(srcpath)
463 if fileDir == "": fileDir = "."
464 fileBaseName,fileExt = os.path.basename(srcpath).rsplit(".", 1)
465 _buildTask = _sourcefilesTarget.SubTask(taskName, FILENAME=fileBaseName, FILEEXT=fileExt, FILEPATH=fileDir)
466 _buildTask.AddSubTask(_incTask)
467
468 def Sections(self):
469 _topLevel = self.BuildXml
470 _topLevel.Blankline()
471 _topLevel.Comment(" TARGET: sections ")
472 _sectionsTarget = _topLevel.SubTask("target", name="sections")
473
474 def Ffs(self):
475 _topLevel = self.BuildXml
476 _topLevel.Blankline()
477 _topLevel.Comment(" TARGET: output ")
478 _sectionsTarget = _topLevel.SubTask("target", name="output")
479
480 def PostBuild(self):
481 _topLevel = self.BuildXml
482 _topLevel.Blankline()
483 _topLevel.Comment(" TARGET: postbuild ")
484
485 postbuildTasks = []
486 module = self.Module.Module
487 if module.UserExtensions.has_key("1"):
488 postbuildTasks = module.UserExtensions["1"]
489 elif module.UserExtensions.has_key("postbuild"):
490 postbuildTasks = module.UserExtensions["postbuild"]
491
492 _topLevel.SubTask("target", postbuildTasks, name="postbuild")
493
494 def Clean(self):
495 pass
496
497 def CleanAll(self):
498 pass
499
500 def UserExtensions(self):
501 pass
502
503 def GetSourceFiles(self):
504 ## check arch, toolchain, family, toolcode, ext
505 ## if the arch of source file supports active arch
506 ## if the toolchain of source file supports active toolchain
507 ## if the toolchain family of source file supports active toolchain family
508 ## if the ext of the source file is supported by the toolcode
509 module = self.Module.Module
510 files = {} # file type -> src
511 for type in module.SourceFiles[self.Arch]:
512 if not module.IsBuildable(type):
513 # print type,"is not buildable"
514 continue
515
516 if type not in files:
517 files[type] = []
518 for src in module.SourceFiles[self.Arch][type]:
519 if self.Toolchain not in src.Toolchains:
520 # print self.Toolchain,"not in ",src.Toolchains
521 continue
522 if not self.IsCompatible(src.Families, self.Workspace.ActiveFamilies):
523 # print src.Families,"not compatible with",self.Workspace.ActiveFamilies
524 continue
525 toolcode = src.GetToolCode(src.Type)
526 if toolcode != "":
527 ext = self.Workspace.GetToolDef(self.Toolchain, self.Target, self.Arch, toolcode, "EXT")
528 if ext != "" and ext != src.Ext:
529 # print ext,"in tools_def.txt is not the same as",src.Ext
530 continue
531 ## fileFullPath = os.path.join("${MODULE_DIR}", )
532 ## print fileFullPath
533 files[type].append(src.Path)
534
535 return files
536
537 def Intersection(self, list1, list2):
538 return list(Set(list1) & Set(list2))
539
540 def IsCompatible(self, list1, list2):
541 return len(self.Intersection(list1, list2)) > 0
542
543 def _GetLibList(self):
544 libList = []
545 for lib in self.Module.Libraries:
546 module = lib.Module
547 libList.append(os.path.join("${BIN_DIR}", module.Name + ".lib"))
548 return libList
549
550 def _GetSourceFileList(self):
551 srcList = []
552 for type in self.SourceFiles:
553 srcList.extend(self.SourceFiles[type])
554 return srcList
555
556 class NmakeFile(BuildFile):
557 pass
558
559 class GmakeFile(BuildFile):
560 pass
561
562 # for test
563 if __name__ == "__main__":
564 workspacePath = os.getenv("WORKSPACE", os.getcwd())
565 startTime = time.clock()
566 ws = Workspace(workspacePath, [], [])
567
568 # generate build.xml
569 ap = ws.ActivePlatform
570 for target in ws.ActiveTargets:
571 ant = AntPlatformBuildFile(ws, ap, ws.ActiveToolchain, target)
572 ant.Generate()
573
574 print "\n[Finished in %fs]" % (time.clock() - startTime)