2 # Create makefile for MS nmake and GNU make
4 # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 import os
.path
as path
22 from Common
.BuildToolError
import *
23 from Common
.Misc
import *
24 from Common
.String
import *
25 from BuildEngine
import *
26 import Common
.GlobalData
as GlobalData
28 ## Regular expression for finding header file inclusions
29 gIncludePattern
= re
.compile(r
"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?
[ \t]*)([-\w
.\\/() \t]+)(?
:[ \t]*[\">]?\
)?
)", re.MULTILINE|re.UNICODE|re.IGNORECASE)
31 ## Regular expression for matching macro used in header file inclusion
32 gMacroPattern = re.compile("([_A
-Z
][_A
-Z0
-9]*)[ \t]*\
((.+)\
)", re.UNICODE)
34 ## pattern for include style in R8.x code
35 gProtocolDefinition = "Protocol
/%(HeaderKey)s/%(HeaderKey)s.h
"
36 gGuidDefinition = "Guid
/%(HeaderKey)s/%(HeaderKey)s.h
"
37 gArchProtocolDefinition = "ArchProtocol
/%(HeaderKey)s/%(HeaderKey)s.h
"
38 gPpiDefinition = "Ppi
/%(HeaderKey)s/%(HeaderKey)s.h
"
39 gIncludeMacroConversion = {
40 "EFI_PROTOCOL_DEFINITION
" : gProtocolDefinition,
41 "EFI_GUID_DEFINITION
" : gGuidDefinition,
42 "EFI_ARCH_PROTOCOL_DEFINITION
" : gArchProtocolDefinition,
43 "EFI_PROTOCOL_PRODUCER
" : gProtocolDefinition,
44 "EFI_PROTOCOL_CONSUMER
" : gProtocolDefinition,
45 "EFI_PROTOCOL_DEPENDENCY
" : gProtocolDefinition,
46 "EFI_ARCH_PROTOCOL_PRODUCER
" : gArchProtocolDefinition,
47 "EFI_ARCH_PROTOCOL_CONSUMER
" : gArchProtocolDefinition,
48 "EFI_ARCH_PROTOCOL_DEPENDENCY
" : gArchProtocolDefinition,
49 "EFI_PPI_DEFINITION
" : gPpiDefinition,
50 "EFI_PPI_PRODUCER
" : gPpiDefinition,
51 "EFI_PPI_CONSUMER
" : gPpiDefinition,
52 "EFI_PPI_DEPENDENCY
" : gPpiDefinition,
55 ## default makefile type
57 if sys.platform == "win32
":
65 # This base class encapsules build file and its generation. It uses template to generate
66 # the content of build file. The content of build file will be got from AutoGen objects.
68 class BuildFile(object):
69 ## template used to generate the build file (i.e. makefile if using make)
70 _TEMPLATE_ = TemplateString('')
72 _DEFAULT_FILE_NAME_ = "Makefile
"
74 ## default file name for each type of build file
77 "gmake
" : "GNUmakefile
"
80 ## Fixed header string for makefile
81 _MAKEFILE_HEADER = '''#
83 # This file is auto-generated by build utility
91 # Auto-generated makefile for building modules, libraries or platform
95 ## Header string for each type of build file
97 "nmake
" : _MAKEFILE_HEADER % _FILE_NAME_["nmake
"],
98 "gmake
" : _MAKEFILE_HEADER % _FILE_NAME_["gmake
"]
101 ## shell commands which can be used in build file in the form of macro
102 # $(CP) copy file command
103 # $(MV) move file command
104 # $(RM) remove file command
105 # $(MD) create dir command
106 # $(RD) remove dir command
114 "RD
" : "rmdir
/s
/q
",
126 ## directory separator
132 ## directory creation template
134 "nmake
" : 'if not exist %(dir)s $(MD) %(dir)s',
135 "gmake
" : "$
(MD
) %(dir)s"
138 ## directory removal template
140 "nmake
" : 'if exist %(dir)s $(RD) %(dir)s',
141 "gmake
" : "$
(RD
) %(dir)s"
145 "nmake
" : 'if exist %(dir)s cd %(dir)s',
146 "gmake
" : "test
-e
%(dir)s && cd
%(dir)s"
150 "nmake
" : 'if exist %(file)s "$
(MAKE
)" $(MAKE_FLAGS) -f %(file)s',
151 "gmake
" : 'test -e %(file)s && "$
(MAKE
)" $(MAKE_FLAGS) -f %(file)s'
155 "nmake
" : '!INCLUDE',
159 _INC_FLAG_ = {"MSFT
" : "/I
", "GCC
" : "-I
", "INTEL
" : "-I
", "RVCT
" : "-I
"}
161 ## Constructor of BuildFile
163 # @param AutoGenObject Object of AutoGen class
165 def __init__(self, AutoGenObject):
166 self._AutoGenObject = AutoGenObject
167 self._FileType = gMakeType
171 # @param FileType Type of build file. Only nmake and gmake are supported now.
173 # @retval TRUE The build file is created or re-created successfully
174 # @retval FALSE The build file exists and is the same as the one to be generated
176 def Generate(self, FileType=gMakeType):
177 if FileType not in self._FILE_NAME_:
178 EdkLogger.error("build
", PARAMETER_INVALID, "Invalid build
type [%s]" % FileType,
179 ExtraData="[%s]" % str(self._AutoGenObject))
180 self._FileType = FileType
181 FileContent = self._TEMPLATE_.Replace(self._TemplateDict)
182 FileName = self._FILE_NAME_[FileType]
183 return SaveFileOnChange(os.path.join(self._AutoGenObject.MakeFileDir, FileName), FileContent, False)
185 ## Return a list of directory creation command string
187 # @param DirList The list of directory to be created
189 # @retval list The directory creation command list
191 def GetCreateDirectoryCommand(self, DirList):
192 return [self._MD_TEMPLATE_[self._FileType] % {'dir':Dir} for Dir in DirList]
194 ## Return a list of directory removal command string
196 # @param DirList The list of directory to be removed
198 # @retval list The directory removal command list
200 def GetRemoveDirectoryCommand(self, DirList):
201 return [self._RD_TEMPLATE_[self._FileType] % {'dir':Dir} for Dir in DirList]
203 def PlaceMacro(self, Path, MacroDefinitions={}):
204 if Path.startswith("$
("):
207 PathLength = len(Path)
208 for MacroName in MacroDefinitions:
209 MacroValue = MacroDefinitions[MacroName]
210 MacroValueLength = len(MacroValue)
211 if MacroValueLength <= PathLength and Path.startswith(MacroValue):
212 Path = "$
(%s)%s" % (MacroName, Path[MacroValueLength:])
216 ## ModuleMakefile class
218 # This class encapsules makefie and its generation for module. It uses template to generate
219 # the content of makefile. The content of makefile will be got from ModuleAutoGen object.
221 class ModuleMakefile(BuildFile):
222 ## template used to generate the makefile for module
223 _TEMPLATE_ = TemplateString('''\
227 # Platform Macro Definition
229 PLATFORM_NAME = ${platform_name}
230 PLATFORM_GUID = ${platform_guid}
231 PLATFORM_VERSION = ${platform_version}
232 PLATFORM_RELATIVE_DIR = ${platform_relative_directory}
233 PLATFORM_DIR = $(WORKSPACE)${separator}${platform_relative_directory}
234 PLATFORM_OUTPUT_DIR = ${platform_output_directory}
237 # Module Macro Definition
239 MODULE_NAME = ${module_name}
240 MODULE_GUID = ${module_guid}
241 MODULE_VERSION = ${module_version}
242 MODULE_TYPE = ${module_type}
243 MODULE_FILE = ${module_file}
244 MODULE_FILE_BASE_NAME = ${module_file_base_name}
245 BASE_NAME = $(MODULE_NAME)
246 MODULE_RELATIVE_DIR = ${module_relative_directory}
247 MODULE_DIR = $(WORKSPACE)${separator}${module_relative_directory}
249 MODULE_ENTRY_POINT = ${module_entry_point}
250 ARCH_ENTRY_POINT = ${arch_entry_point}
251 IMAGE_ENTRY_POINT = ${image_entry_point}
253 ${BEGIN}${module_extra_defines}
256 # Build Configuration Macro Definition
258 ARCH = ${architecture}
259 TOOLCHAIN = ${toolchain_tag}
260 TOOLCHAIN_TAG = ${toolchain_tag}
261 TARGET = ${build_target}
264 # Build Directory Macro Definition
266 # PLATFORM_BUILD_DIR = ${platform_build_directory}
267 BUILD_DIR = ${platform_build_directory}
268 BIN_DIR = $(BUILD_DIR)${separator}${architecture}
270 MODULE_BUILD_DIR = ${module_build_directory}
271 OUTPUT_DIR = ${module_output_directory}
272 DEBUG_DIR = ${module_debug_directory}
273 DEST_DIR_OUTPUT = $(OUTPUT_DIR)
274 DEST_DIR_DEBUG = $(DEBUG_DIR)
277 # Shell Command Macro
279 ${BEGIN}${shell_command_code} = ${shell_command}
283 # Tools definitions specific to this module
285 ${BEGIN}${module_tool_definitions}
287 MAKE_FILE = ${makefile_path}
292 ${BEGIN}${file_macro}
295 COMMON_DEPS = ${BEGIN}${common_dependency_file} \\
299 # Overridable Target Macro Definitions
301 FORCE_REBUILD = force_build
304 BC_TARGET = ${BEGIN}${backward_compatible_target} ${END}
305 CODA_TARGET = ${BEGIN}${remaining_build_target} \\
309 # Default target, which will build dependent libraries in addition to source files
316 # Target used when called from platform makefile, which will bypass the build of dependent libraries
319 pbuild: $(INIT_TARGET) $(BC_TARGET) $(PCH_TARGET) $(CODA_TARGET)
325 mbuild: $(INIT_TARGET) $(BC_TARGET) gen_libs $(PCH_TARGET) $(CODA_TARGET)
328 # Build Target used in multi-thread build mode, which will bypass the init and gen_libs targets
331 tbuild: $(BC_TARGET) $(PCH_TARGET) $(CODA_TARGET)
334 # Phony target which is used to force executing commands for a target
340 # Target to update the FD
346 # Initialization target: print build information and create necessary directories
351 \t-@echo Building ... $(MODULE_DIR)${separator}$(MODULE_FILE) [$(ARCH)]
354 ${BEGIN}\t-@${create_directory_command}\n${END}
357 \t-@$(CP) $(DEBUG_DIR)${separator}AutoGen.h $(DEBUG_DIR)${separator}$(MODULE_NAME)StrDefs.h
363 \t${BEGIN}@"$
(MAKE
)" $(MAKE_FLAGS) -f ${dependent_library_build_directory}${separator}${makefile_name}
364 \t${END}@cd $(MODULE_BUILD_DIR)
367 # Build Flash Device Image
370 \t@"$
(MAKE
)" $(MAKE_FLAGS) -f $(BUILD_DIR)${separator}${makefile_name} fds
371 \t@cd $(MODULE_BUILD_DIR)
374 # Individual Object Build Targets
376 ${BEGIN}${file_build_target}
380 # clean all intermediate files
383 \t${BEGIN}${clean_command}
387 # clean all generated files
390 ${BEGIN}\t${cleanall_command}
391 ${END}\t$(RM) *.pdb *.idb > NUL 2>&1
392 \t$(RM) $(BIN_DIR)${separator}$(MODULE_NAME).efi
395 # clean all dependent libraries built
398 \t${BEGIN}-@${library_build_command} cleanall
399 \t${END}@cd $(MODULE_BUILD_DIR)\n\n''')
401 _FILE_MACRO_TEMPLATE = TemplateString("${macro_name}
= ${BEGIN}
\\\n ${source_file}${END}
\n")
402 _BUILD_TARGET_TEMPLATE = TemplateString("${BEGIN}${target}
: ${deps}
\n${END}
\t${cmd}
\n")
404 ## Constructor of ModuleMakefile
406 # @param ModuleAutoGen Object of ModuleAutoGen class
408 def __init__(self, ModuleAutoGen):
409 BuildFile.__init__(self, ModuleAutoGen)
410 self.PlatformInfo = self._AutoGenObject.PlatformInfo
412 self.ResultFileList = []
413 self.IntermediateDirectoryList = ["$
(DEBUG_DIR
)", "$
(OUTPUT_DIR
)"]
415 self.SourceFileDatabase = {} # {file type : file path}
416 self.DestFileDatabase = {} # {file type : file path}
417 self.FileBuildTargetList = [] # [(src, target string)]
418 self.BuildTargetList = [] # [target string]
419 self.PendingBuildTargetList = [] # [FileBuildRule objects]
420 self.CommonFileDependency = []
421 self.FileListMacros = {}
422 self.ListFileMacros = {}
424 self.FileDependency = []
425 self.LibraryBuildCommandList = []
426 self.LibraryFileList = []
427 self.LibraryMakefileList = []
428 self.LibraryBuildDirectoryList = []
429 self.SystemLibraryList = []
430 self.Macros = sdict()
431 self.Macros["OUTPUT_DIR
" ] = self._AutoGenObject.Macros["OUTPUT_DIR
"]
432 self.Macros["DEBUG_DIR
" ] = self._AutoGenObject.Macros["DEBUG_DIR
"]
433 self.Macros["MODULE_BUILD_DIR
"] = self._AutoGenObject.Macros["MODULE_BUILD_DIR
"]
434 self.Macros["BIN_DIR
" ] = self._AutoGenObject.Macros["BIN_DIR
"]
435 self.Macros["BUILD_DIR
" ] = self._AutoGenObject.Macros["BUILD_DIR
"]
436 self.Macros["WORKSPACE
" ] = self._AutoGenObject.Macros["WORKSPACE
"]
438 # Compose a dict object containing information used to do replacement in template
439 def _CreateTemplateDict(self):
440 if self._FileType not in self._SEP_:
441 EdkLogger.error("build
", PARAMETER_INVALID, "Invalid Makefile
type [%s]" % self._FileType,
442 ExtraData="[%s]" % str(self._AutoGenObject))
443 Separator = self._SEP_[self._FileType]
445 # break build if no source files and binary files are found
446 if len(self._AutoGenObject.SourceFileList) == 0 and len(self._AutoGenObject.BinaryFileList) == 0:
447 EdkLogger.error("build
", AUTOGEN_ERROR, "No files to be built
in module
[%s, %s, %s]"
448 % (self._AutoGenObject.BuildTarget, self._AutoGenObject.ToolChain, self._AutoGenObject.Arch),
449 ExtraData="[%s]" % str(self._AutoGenObject))
451 # convert dependent libaries to build command
452 self.ProcessDependentLibrary()
453 if len(self._AutoGenObject.Module.ModuleEntryPointList) > 0:
454 ModuleEntryPoint = self._AutoGenObject.Module.ModuleEntryPointList[0]
456 ModuleEntryPoint = "_ModuleEntryPoint
"
458 # Intel EBC compiler enforces EfiMain
459 if self._AutoGenObject.AutoGenVersion < 0x00010005 and self._AutoGenObject.Arch == "EBC
":
460 ArchEntryPoint = "EfiMain
"
462 ArchEntryPoint = ModuleEntryPoint
464 if self._AutoGenObject.Arch == "EBC
":
465 # EBC compiler always use "EfiStart
" as entry point. Only applies to R9 modules
466 ImageEntryPoint = "EfiStart
"
467 elif self._AutoGenObject.AutoGenVersion < 0x00010005:
468 # R8 modules use entry point specified in INF file
469 ImageEntryPoint = ModuleEntryPoint
471 # R9 modules always use "_ModuleEntryPoint
" as entry point
472 ImageEntryPoint = "_ModuleEntryPoint
"
476 IncPrefix = self._INC_FLAG_[self._AutoGenObject.ToolChainFamily]
477 for Tool in self._AutoGenObject.BuildOption:
478 for Attr in self._AutoGenObject.BuildOption[Tool]:
479 Value = self._AutoGenObject.BuildOption[Tool][Attr]
483 ToolsDef.append("%s = %s" % (Tool, Value))
485 # Don't generate MAKE_FLAGS in makefile. It's put in environment variable.
488 # Remove duplicated include path, if any
490 Value = RemoveDupOption(Value, IncPrefix, self._AutoGenObject.IncludePathList)
491 ToolsDef.append("%s_%s = %s" % (Tool, Attr, Value))
494 # convert source files and binary files to build targets
495 self.ResultFileList = [str(T.Target) for T in self._AutoGenObject.CodaTargetList]
496 if len(self.ResultFileList) == 0:
497 EdkLogger.error("build
", AUTOGEN_ERROR, "Nothing to build
",
498 ExtraData="[%s]" % str(self._AutoGenObject))
500 self.ProcessBuildTargetList()
502 # Generate macros used to represent input files
503 FileMacroList = [] # macro name = file list
504 for FileListMacro in self.FileListMacros:
505 FileMacro = self._FILE_MACRO_TEMPLATE.Replace(
507 "macro_name
" : FileListMacro,
508 "source_file
" : self.FileListMacros[FileListMacro]
511 FileMacroList.append(FileMacro)
513 # INC_LIST is special
516 for P in self._AutoGenObject.IncludePathList:
517 IncludePathList.append(IncPrefix+self.PlaceMacro(P, self.Macros))
518 if FileBuildRule.INC_LIST_MACRO in self.ListFileMacros:
519 self.ListFileMacros[FileBuildRule.INC_LIST_MACRO].append(IncPrefix+P)
520 FileMacro += self._FILE_MACRO_TEMPLATE.Replace(
522 "macro_name
" : "INC
",
523 "source_file
" : IncludePathList
526 FileMacroList.append(FileMacro)
528 # Generate macros used to represent files containing list of input files
529 for ListFileMacro in self.ListFileMacros:
530 ListFileName = os.path.join(self._AutoGenObject.OutputDir, "%s.lst
" % ListFileMacro.lower()[:len(ListFileMacro)-5])
531 FileMacroList.append("%s = %s" % (ListFileMacro, ListFileName))
534 "\n".join(self.ListFileMacros[ListFileMacro]),
538 # R8 modules need <BaseName>StrDefs.h for string ID
539 #if self._AutoGenObject.AutoGenVersion < 0x00010005 and len(self._AutoGenObject.UnicodeFileList) > 0:
540 # BcTargetList = ['strdefs']
545 MakefileName = self._FILE_NAME_[self._FileType]
546 LibraryMakeCommandList = []
547 for D in self.LibraryBuildDirectoryList:
548 Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":os.path.join(D, MakefileName)}
549 LibraryMakeCommandList.append(Command)
551 MakefileTemplateDict = {
552 "makefile_header
" : self._FILE_HEADER_[self._FileType],
553 "makefile_path
" : os.path.join("$
(MODULE_BUILD_DIR
)", MakefileName),
554 "makefile_name
" : MakefileName,
555 "platform_name
" : self.PlatformInfo.Name,
556 "platform_guid
" : self.PlatformInfo.Guid,
557 "platform_version
" : self.PlatformInfo.Version,
558 "platform_relative_directory
": self.PlatformInfo.SourceDir,
559 "platform_output_directory
" : self.PlatformInfo.OutputDir,
561 "module_name
" : self._AutoGenObject.Name,
562 "module_guid
" : self._AutoGenObject.Guid,
563 "module_version
" : self._AutoGenObject.Version,
564 "module_type
" : self._AutoGenObject.ModuleType,
565 "module_file
" : self._AutoGenObject.MetaFile.Name,
566 "module_file_base_name
" : self._AutoGenObject.MetaFile.BaseName,
567 "module_relative_directory
" : self._AutoGenObject.SourceDir,
568 "module_extra_defines
" : ["%s = %s" % (k, v) for k,v in self._AutoGenObject.Module.Defines.iteritems()],
570 "architecture
" : self._AutoGenObject.Arch,
571 "toolchain_tag
" : self._AutoGenObject.ToolChain,
572 "build_target
" : self._AutoGenObject.BuildTarget,
574 "platform_build_directory
" : self.PlatformInfo.BuildDir,
575 "module_build_directory
" : self._AutoGenObject.BuildDir,
576 "module_output_directory
" : self._AutoGenObject.OutputDir,
577 "module_debug_directory
" : self._AutoGenObject.DebugDir,
579 "separator
" : Separator,
580 "module_tool_definitions
" : ToolsDef,
582 "shell_command_code
" : self._SHELL_CMD_[self._FileType].keys(),
583 "shell_command
" : self._SHELL_CMD_[self._FileType].values(),
585 "module_entry_point
" : ModuleEntryPoint,
586 "image_entry_point
" : ImageEntryPoint,
587 "arch_entry_point
" : ArchEntryPoint,
588 "remaining_build_target
" : self.ResultFileList,
589 "common_dependency_file
" : self.CommonFileDependency,
590 "create_directory_command
" : self.GetCreateDirectoryCommand(self.IntermediateDirectoryList),
591 "clean_command
" : self.GetRemoveDirectoryCommand(["$
(OUTPUT_DIR
)"]),
592 "cleanall_command
" : self.GetRemoveDirectoryCommand(["$
(DEBUG_DIR
)", "$
(OUTPUT_DIR
)"]),
593 "dependent_library_build_directory
" : self.LibraryBuildDirectoryList,
594 "library_build_command
" : LibraryMakeCommandList,
595 "file_macro
" : FileMacroList,
596 "file_build_target
" : self.BuildTargetList,
597 "backward_compatible_target
": BcTargetList,
600 return MakefileTemplateDict
602 def ProcessBuildTargetList(self):
604 # Search dependency file list for each source file
606 ForceIncludedFile = []
607 for File in self._AutoGenObject.AutoGenFileList:
609 ForceIncludedFile.append(File)
611 for Target in self._AutoGenObject.IntroTargetList:
612 SourceFileList.extend(Target.Inputs)
614 self.FileDependency = self.GetFileDependency(
617 self._AutoGenObject.IncludePathList
620 for File in self.FileDependency:
621 if not self.FileDependency[File]:
622 self.FileDependency[File] = ['$(FORCE_REBUILD)']
625 if File.Ext not in [".c
", ".C
"] or File.Name == "AutoGen
.c
":
628 DepSet = set(self.FileDependency[File])
630 DepSet &= set(self.FileDependency[File])
631 # in case nothing in SourceFileList
635 # Extract comman files list in the dependency files
638 self.CommonFileDependency.append(self.PlaceMacro(File.Path, self.Macros))
640 for File in self.FileDependency:
642 if File.Ext not in [".c
", ".C
"] or File.Name == "AutoGen
.c
":
644 NewDepSet = set(self.FileDependency[File])
646 self.FileDependency[File] = ["$
(COMMON_DEPS
)"] + list(NewDepSet)
648 # Convert target description object to target string in makefile
649 for Type in self._AutoGenObject.Targets:
650 for T in self._AutoGenObject.Targets[Type]:
651 # Generate related macros if needed
652 if T.GenFileListMacro and T.FileListMacro not in self.FileListMacros:
653 self.FileListMacros[T.FileListMacro] = []
654 if T.GenListFile and T.ListFileMacro not in self.ListFileMacros:
655 self.ListFileMacros[T.ListFileMacro] = []
656 if T.GenIncListFile and T.IncListFileMacro not in self.ListFileMacros:
657 self.ListFileMacros[T.IncListFileMacro] = []
660 # Add force-dependencies
661 for Dep in T.Dependencies:
662 Deps.append(self.PlaceMacro(str(Dep), self.Macros))
663 # Add inclusion-dependencies
664 if len(T.Inputs) == 1 and T.Inputs[0] in self.FileDependency:
665 for F in self.FileDependency[T.Inputs[0]]:
666 Deps.append(self.PlaceMacro(str(F), self.Macros))
667 # Add source-dependencies
669 NewFile = self.PlaceMacro(str(F), self.Macros)
670 # In order to use file list macro as dependency
672 self.ListFileMacros[T.ListFileMacro].append(str(F))
673 self.FileListMacros[T.FileListMacro].append(NewFile)
674 elif T.GenFileListMacro:
675 self.FileListMacros[T.FileListMacro].append(NewFile)
679 # Use file list macro as dependency
680 if T.GenFileListMacro:
681 Deps.append("$
(%s)" % T.FileListMacro)
684 "target
" : self.PlaceMacro(T.Target.Path, self.Macros),
685 "cmd
" : "\n\t".join(T.Commands),
688 self.BuildTargetList.append(self._BUILD_TARGET_TEMPLATE.Replace(TargetDict))
690 ## For creating makefile targets for dependent libraries
691 def ProcessDependentLibrary(self):
692 for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:
693 self.LibraryBuildDirectoryList.append(self.PlaceMacro(LibraryAutoGen.BuildDir, self.Macros))
695 ## Return a list containing source file's dependencies
697 # @param FileList The list of source files
698 # @param ForceInculeList The list of files which will be included forcely
699 # @param SearchPathList The list of search path
701 # @retval dict The mapping between source file path and its dependencies
703 def GetFileDependency(self, FileList, ForceInculeList, SearchPathList):
706 Dependency[F] = self.GetDependencyList(F, ForceInculeList, SearchPathList)
709 ## Find dependencies for one source file
711 # By searching recursively "#include" directive in file, find out all the
712 # files needed by given source file. The dependecies will be only searched
713 # in given search path list.
715 # @param File The source file
716 # @param ForceInculeList The list of files which will be included forcely
717 # @param SearchPathList The list of search path
719 # @retval list The list of files the given source file depends on
721 def GetDependencyList(self
, File
, ForceList
, SearchPathList
):
722 EdkLogger
.debug(EdkLogger
.DEBUG_1
, "Try to get dependency files for %s" % File
)
723 FileStack
= [File
] + ForceList
724 DependencySet
= set()
725 MacroUsedByIncludedFile
= False
727 if self
._AutoGenObject
.Arch
not in gDependencyDatabase
:
728 gDependencyDatabase
[self
._AutoGenObject
.Arch
] = {}
729 DepDb
= gDependencyDatabase
[self
._AutoGenObject
.Arch
]
731 while len(FileStack
) > 0:
734 CurrentFileDependencyList
= []
736 CurrentFileDependencyList
= DepDb
[F
]
737 for Dep
in CurrentFileDependencyList
:
738 if Dep
not in FileStack
and Dep
not in DependencySet
:
739 FileStack
.append(Dep
)
742 Fd
= open(F
.Path
, 'r')
743 except BaseException
, X
:
744 EdkLogger
.error("build", FILE_OPEN_FAILURE
, ExtraData
=F
.Path
+"\n\t"+str(X
))
746 FileContent
= Fd
.read()
748 if len(FileContent
) == 0:
751 if FileContent
[0] == 0xff or FileContent
[0] == 0xfe:
752 FileContent
= unicode(FileContent
, "utf-16")
753 IncludedFileList
= gIncludePattern
.findall(FileContent
)
755 CurrentFilePath
= F
.Dir
756 for Inc
in IncludedFileList
:
758 # if there's macro used to reference header file, expand it
759 HeaderList
= gMacroPattern
.findall(Inc
)
760 if len(HeaderList
) == 1 and len(HeaderList
[0]) == 2:
761 HeaderType
= HeaderList
[0][0]
762 HeaderKey
= HeaderList
[0][1]
763 if HeaderType
in gIncludeMacroConversion
:
764 Inc
= gIncludeMacroConversion
[HeaderType
] % {"HeaderKey" : HeaderKey
}
766 # not known macro used in #include
767 MacroUsedByIncludedFile
= True
769 Inc
= os
.path
.normpath(Inc
)
770 for SearchPath
in [CurrentFilePath
] + SearchPathList
:
771 FilePath
= os
.path
.join(SearchPath
, Inc
)
772 if not os
.path
.isfile(FilePath
) or FilePath
in CurrentFileDependencyList
:
774 FilePath
= PathClass(FilePath
)
775 CurrentFileDependencyList
.append(FilePath
)
776 if FilePath
not in FileStack
and FilePath
not in DependencySet
:
777 FileStack
.append(FilePath
)
780 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "%s included by %s was not found"\
781 "in any given path:\n\t%s" % (Inc
, F
, "\n\t".join(SearchPathList
)))
783 if not MacroUsedByIncludedFile
:
785 CurrentFileDependencyList
+= ForceList
787 # Don't keep the file in cache if it uses macro in included file.
788 # So it will be scanned again if another file includes this file.
790 DepDb
[F
] = CurrentFileDependencyList
791 DependencySet
.update(CurrentFileDependencyList
)
794 # If there's macro used in included file, always build the file by
795 # returning a empty dependency
797 if MacroUsedByIncludedFile
:
800 DependencyList
= list(DependencySet
) # remove duplicate ones
802 return DependencyList
804 _TemplateDict
= property(_CreateTemplateDict
)
806 ## CustomMakefile class
808 # This class encapsules makefie and its generation for module. It uses template to generate
809 # the content of makefile. The content of makefile will be got from ModuleAutoGen object.
811 class CustomMakefile(BuildFile
):
812 ## template used to generate the makefile for module with custom makefile
813 _TEMPLATE_
= TemplateString('''\
817 # Platform Macro Definition
819 PLATFORM_NAME = ${platform_name}
820 PLATFORM_GUID = ${platform_guid}
821 PLATFORM_VERSION = ${platform_version}
822 PLATFORM_RELATIVE_DIR = ${platform_relative_directory}
823 PLATFORM_DIR = $(WORKSPACE)${separator}${platform_relative_directory}
824 PLATFORM_OUTPUT_DIR = ${platform_output_directory}
827 # Module Macro Definition
829 MODULE_NAME = ${module_name}
830 MODULE_GUID = ${module_guid}
831 MODULE_VERSION = ${module_version}
832 MODULE_TYPE = ${module_type}
833 MODULE_FILE = ${module_file}
834 MODULE_FILE_BASE_NAME = ${module_file_base_name}
835 BASE_NAME = $(MODULE_NAME)
836 MODULE_RELATIVE_DIR = ${module_relative_directory}
837 MODULE_DIR = $(WORKSPACE)${separator}${module_relative_directory}
840 # Build Configuration Macro Definition
842 ARCH = ${architecture}
843 TOOLCHAIN = ${toolchain_tag}
844 TOOLCHAIN_TAG = ${toolchain_tag}
845 TARGET = ${build_target}
848 # Build Directory Macro Definition
850 # PLATFORM_BUILD_DIR = ${platform_build_directory}
851 BUILD_DIR = ${platform_build_directory}
852 BIN_DIR = $(BUILD_DIR)${separator}${architecture}
854 MODULE_BUILD_DIR = ${module_build_directory}
855 OUTPUT_DIR = ${module_output_directory}
856 DEBUG_DIR = ${module_debug_directory}
857 DEST_DIR_OUTPUT = $(OUTPUT_DIR)
858 DEST_DIR_DEBUG = $(DEBUG_DIR)
861 # Tools definitions specific to this module
863 ${BEGIN}${module_tool_definitions}
865 MAKE_FILE = ${makefile_path}
868 # Shell Command Macro
870 ${BEGIN}${shell_command_code} = ${shell_command}
873 ${custom_makefile_content}
876 # Target used when called from platform makefile, which will bypass the build of dependent libraries
889 # Build Target used in multi-thread build mode, which no init target is needed
895 # Initialization target: print build information and create necessary directories
898 \t-@echo Building ... $(MODULE_DIR)${separator}$(MODULE_FILE) [$(ARCH)]
899 ${BEGIN}\t-@${create_directory_command}\n${END}\
903 ## Constructor of CustomMakefile
905 # @param ModuleAutoGen Object of ModuleAutoGen class
907 def __init__(self
, ModuleAutoGen
):
908 BuildFile
.__init
__(self
, ModuleAutoGen
)
909 self
.PlatformInfo
= self
._AutoGenObject
.PlatformInfo
910 self
.IntermediateDirectoryList
= ["$(DEBUG_DIR)", "$(OUTPUT_DIR)"]
912 # Compose a dict object containing information used to do replacement in template
913 def _CreateTemplateDict(self
):
914 Separator
= self
._SEP
_[self
._FileType
]
915 if self
._FileType
not in self
._AutoGenObject
.CustomMakefile
:
916 EdkLogger
.error('build', OPTION_NOT_SUPPORTED
, "No custom makefile for %s" % self
._FileType
,
917 ExtraData
="[%s]" % str(self
._AutoGenObject
))
918 MakefilePath
= os
.path
.join(
919 self
._AutoGenObject
.WorkspaceDir
,
920 self
._AutoGenObject
.CustomMakefile
[self
._FileType
]
923 CustomMakefile
= open(MakefilePath
, 'r').read()
925 EdkLogger
.error('build', FILE_OPEN_FAILURE
, File
=str(self
._AutoGenObject
),
926 ExtraData
=self
._AutoGenObject
.CustomMakefile
[self
._FileType
])
930 for Tool
in self
._AutoGenObject
.BuildOption
:
931 # Don't generate MAKE_FLAGS in makefile. It's put in environment variable.
934 for Attr
in self
._AutoGenObject
.BuildOption
[Tool
]:
938 ToolsDef
.append("%s = %s" % (Tool
, self
._AutoGenObject
.BuildOption
[Tool
][Attr
]))
940 ToolsDef
.append("%s_%s = %s" % (Tool
, Attr
, self
._AutoGenObject
.BuildOption
[Tool
][Attr
]))
943 MakefileName
= self
._FILE
_NAME
_[self
._FileType
]
944 MakefileTemplateDict
= {
945 "makefile_header" : self
._FILE
_HEADER
_[self
._FileType
],
946 "makefile_path" : os
.path
.join("$(MODULE_BUILD_DIR)", MakefileName
),
947 "platform_name" : self
.PlatformInfo
.Name
,
948 "platform_guid" : self
.PlatformInfo
.Guid
,
949 "platform_version" : self
.PlatformInfo
.Version
,
950 "platform_relative_directory": self
.PlatformInfo
.SourceDir
,
951 "platform_output_directory" : self
.PlatformInfo
.OutputDir
,
953 "module_name" : self
._AutoGenObject
.Name
,
954 "module_guid" : self
._AutoGenObject
.Guid
,
955 "module_version" : self
._AutoGenObject
.Version
,
956 "module_type" : self
._AutoGenObject
.ModuleType
,
957 "module_file" : self
._AutoGenObject
.MetaFile
,
958 "module_file_base_name" : self
._AutoGenObject
.MetaFile
.BaseName
,
959 "module_relative_directory" : self
._AutoGenObject
.SourceDir
,
961 "architecture" : self
._AutoGenObject
.Arch
,
962 "toolchain_tag" : self
._AutoGenObject
.ToolChain
,
963 "build_target" : self
._AutoGenObject
.BuildTarget
,
965 "platform_build_directory" : self
.PlatformInfo
.BuildDir
,
966 "module_build_directory" : self
._AutoGenObject
.BuildDir
,
967 "module_output_directory" : self
._AutoGenObject
.OutputDir
,
968 "module_debug_directory" : self
._AutoGenObject
.DebugDir
,
970 "separator" : Separator
,
971 "module_tool_definitions" : ToolsDef
,
973 "shell_command_code" : self
._SHELL
_CMD
_[self
._FileType
].keys(),
974 "shell_command" : self
._SHELL
_CMD
_[self
._FileType
].values(),
976 "create_directory_command" : self
.GetCreateDirectoryCommand(self
.IntermediateDirectoryList
),
977 "custom_makefile_content" : CustomMakefile
980 return MakefileTemplateDict
982 _TemplateDict
= property(_CreateTemplateDict
)
984 ## PlatformMakefile class
986 # This class encapsules makefie and its generation for platform. It uses
987 # template to generate the content of makefile. The content of makefile will be
988 # got from PlatformAutoGen object.
990 class PlatformMakefile(BuildFile
):
991 ## template used to generate the makefile for platform
992 _TEMPLATE_
= TemplateString('''\
996 # Platform Macro Definition
998 PLATFORM_NAME = ${platform_name}
999 PLATFORM_GUID = ${platform_guid}
1000 PLATFORM_VERSION = ${platform_version}
1001 PLATFORM_FILE = ${platform_file}
1002 PLATFORM_DIR = $(WORKSPACE)${separator}${platform_relative_directory}
1003 PLATFORM_OUTPUT_DIR = ${platform_output_directory}
1006 # Build Configuration Macro Definition
1008 TOOLCHAIN = ${toolchain_tag}
1009 TOOLCHAIN_TAG = ${toolchain_tag}
1010 TARGET = ${build_target}
1013 # Build Directory Macro Definition
1015 BUILD_DIR = ${platform_build_directory}
1016 FV_DIR = ${platform_build_directory}${separator}FV
1019 # Shell Command Macro
1021 ${BEGIN}${shell_command_code} = ${shell_command}
1025 MAKE_FILE = ${makefile_path}
1030 all: init build_libraries build_modules
1033 # Initialization target: print build information and create necessary directories
1036 \t-@echo Building ... $(PLATFORM_FILE) [${build_architecture_list}]
1037 \t${BEGIN}-@${create_directory_command}
1040 # library build target
1042 libraries: init build_libraries
1045 # module build target
1047 modules: init build_libraries build_modules
1050 # Build all libraries:
1053 ${BEGIN}\t@"$(MAKE)" $(MAKE_FLAGS) -f ${library_makefile_list} pbuild
1054 ${END}\t@cd $(BUILD_DIR)
1057 # Build all modules:
1060 ${BEGIN}\t@"$(MAKE)" $(MAKE_FLAGS) -f ${module_makefile_list} pbuild
1061 ${END}\t@cd $(BUILD_DIR)
1064 # Clean intermediate files
1067 \t${BEGIN}-@${library_build_command} clean
1068 \t${END}${BEGIN}-@${module_build_command} clean
1069 \t${END}@cd $(BUILD_DIR)
1072 # Clean all generated files except to makefile
1075 ${BEGIN}\t${cleanall_command}
1079 # Clean all library files
1082 \t${BEGIN}-@${library_build_command} cleanall
1083 \t${END}@cd $(BUILD_DIR)\n
1086 ## Constructor of PlatformMakefile
1088 # @param ModuleAutoGen Object of PlatformAutoGen class
1090 def __init__(self
, PlatformAutoGen
):
1091 BuildFile
.__init
__(self
, PlatformAutoGen
)
1092 self
.ModuleBuildCommandList
= []
1093 self
.ModuleMakefileList
= []
1094 self
.IntermediateDirectoryList
= []
1095 self
.ModuleBuildDirectoryList
= []
1096 self
.LibraryBuildDirectoryList
= []
1098 # Compose a dict object containing information used to do replacement in template
1099 def _CreateTemplateDict(self
):
1100 Separator
= self
._SEP
_[self
._FileType
]
1102 PlatformInfo
= self
._AutoGenObject
1103 if "MAKE" not in PlatformInfo
.ToolDefinition
or "PATH" not in PlatformInfo
.ToolDefinition
["MAKE"]:
1104 EdkLogger
.error("build", OPTION_MISSING
, "No MAKE command defined. Please check your tools_def.txt!",
1105 ExtraData
="[%s]" % str(self
._AutoGenObject
))
1107 self
.IntermediateDirectoryList
= ["$(BUILD_DIR)"]
1108 self
.ModuleBuildDirectoryList
= self
.GetModuleBuildDirectoryList()
1109 self
.LibraryBuildDirectoryList
= self
.GetLibraryBuildDirectoryList()
1111 MakefileName
= self
._FILE
_NAME
_[self
._FileType
]
1112 LibraryMakefileList
= []
1113 LibraryMakeCommandList
= []
1114 for D
in self
.LibraryBuildDirectoryList
:
1115 D
= self
.PlaceMacro(D
, {"BUILD_DIR":PlatformInfo
.BuildDir
})
1116 Makefile
= os
.path
.join(D
, MakefileName
)
1117 Command
= self
._MAKE
_TEMPLATE
_[self
._FileType
] % {"file":Makefile
}
1118 LibraryMakefileList
.append(Makefile
)
1119 LibraryMakeCommandList
.append(Command
)
1121 ModuleMakefileList
= []
1122 ModuleMakeCommandList
= []
1123 for D
in self
.ModuleBuildDirectoryList
:
1124 D
= self
.PlaceMacro(D
, {"BUILD_DIR":PlatformInfo
.BuildDir
})
1125 Makefile
= os
.path
.join(D
, MakefileName
)
1126 Command
= self
._MAKE
_TEMPLATE
_[self
._FileType
] % {"file":Makefile
}
1127 ModuleMakefileList
.append(Makefile
)
1128 ModuleMakeCommandList
.append(Command
)
1130 MakefileTemplateDict
= {
1131 "makefile_header" : self
._FILE
_HEADER
_[self
._FileType
],
1132 "makefile_path" : os
.path
.join("$(BUILD_DIR)", MakefileName
),
1133 "make_path" : PlatformInfo
.ToolDefinition
["MAKE"]["PATH"],
1134 "makefile_name" : MakefileName
,
1135 "platform_name" : PlatformInfo
.Name
,
1136 "platform_guid" : PlatformInfo
.Guid
,
1137 "platform_version" : PlatformInfo
.Version
,
1138 "platform_file" : self
._AutoGenObject
.MetaFile
,
1139 "platform_relative_directory": PlatformInfo
.SourceDir
,
1140 "platform_output_directory" : PlatformInfo
.OutputDir
,
1141 "platform_build_directory" : PlatformInfo
.BuildDir
,
1143 "toolchain_tag" : PlatformInfo
.ToolChain
,
1144 "build_target" : PlatformInfo
.BuildTarget
,
1145 "shell_command_code" : self
._SHELL
_CMD
_[self
._FileType
].keys(),
1146 "shell_command" : self
._SHELL
_CMD
_[self
._FileType
].values(),
1147 "build_architecture_list" : self
._AutoGenObject
.Arch
,
1148 "architecture" : self
._AutoGenObject
.Arch
,
1149 "separator" : Separator
,
1150 "create_directory_command" : self
.GetCreateDirectoryCommand(self
.IntermediateDirectoryList
),
1151 "cleanall_command" : self
.GetRemoveDirectoryCommand(self
.IntermediateDirectoryList
),
1152 "library_makefile_list" : LibraryMakefileList
,
1153 "module_makefile_list" : ModuleMakefileList
,
1154 "library_build_command" : LibraryMakeCommandList
,
1155 "module_build_command" : ModuleMakeCommandList
,
1158 return MakefileTemplateDict
1160 ## Get the root directory list for intermediate files of all modules build
1162 # @retval list The list of directory
1164 def GetModuleBuildDirectoryList(self
):
1166 for ModuleAutoGen
in self
._AutoGenObject
.ModuleAutoGenList
:
1167 DirList
.append(os
.path
.join(self
._AutoGenObject
.BuildDir
, ModuleAutoGen
.BuildDir
))
1170 ## Get the root directory list for intermediate files of all libraries build
1172 # @retval list The list of directory
1174 def GetLibraryBuildDirectoryList(self
):
1176 for LibraryAutoGen
in self
._AutoGenObject
.LibraryAutoGenList
:
1177 DirList
.append(os
.path
.join(self
._AutoGenObject
.BuildDir
, LibraryAutoGen
.BuildDir
))
1180 _TemplateDict
= property(_CreateTemplateDict
)
1182 ## TopLevelMakefile class
1184 # This class encapsules makefie and its generation for entrance makefile. It
1185 # uses template to generate the content of makefile. The content of makefile
1186 # will be got from WorkspaceAutoGen object.
1188 class TopLevelMakefile(BuildFile
):
1189 ## template used to generate toplevel makefile
1190 _TEMPLATE_
= TemplateString('''\
1194 # Platform Macro Definition
1196 PLATFORM_NAME = ${platform_name}
1197 PLATFORM_GUID = ${platform_guid}
1198 PLATFORM_VERSION = ${platform_version}
1201 # Build Configuration Macro Definition
1203 TOOLCHAIN = ${toolchain_tag}
1204 TOOLCHAIN_TAG = ${toolchain_tag}
1205 TARGET = ${build_target}
1208 # Build Directory Macro Definition
1210 BUILD_DIR = ${platform_build_directory}
1211 FV_DIR = ${platform_build_directory}${separator}FV
1214 # Shell Command Macro
1216 ${BEGIN}${shell_command_code} = ${shell_command}
1220 MAKE_FILE = ${makefile_path}
1228 # Initialization target: print build information and create necessary directories
1232 \t${BEGIN}-@${create_directory_command}
1235 # library build target
1238 ${BEGIN}\t@cd $(BUILD_DIR)${separator}${arch} && "$(MAKE)" $(MAKE_FLAGS) libraries
1239 ${END}\t@cd $(BUILD_DIR)
1242 # module build target
1245 ${BEGIN}\t@cd $(BUILD_DIR)${separator}${arch} && "$(MAKE)" $(MAKE_FLAGS) modules
1246 ${END}\t@cd $(BUILD_DIR)
1249 # Flash Device Image Target
1253 ${BEGIN}\tGenFds -f ${fdf_file} -o $(BUILD_DIR) -t $(TOOLCHAIN) -b $(TARGET) -p ${active_platform} -a ${build_architecture_list} ${extra_options}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv} ${END}${BEGIN} -D ${macro} ${END}
1256 # run command for emulator platform only
1259 \tcd $(BUILD_DIR)${separator}IA32 && ".${separator}SecMain"
1263 # Clean intermediate files
1266 ${BEGIN}\t-@${sub_build_command} clean
1267 ${END}\t@cd $(BUILD_DIR)
1270 # Clean all generated files except to makefile
1273 ${BEGIN}\t${cleanall_command}
1277 # Clean all library files
1280 ${BEGIN}\t-@${sub_build_command} cleanlib
1281 ${END}\t@cd $(BUILD_DIR)\n
1284 ## Constructor of TopLevelMakefile
1286 # @param Workspace Object of WorkspaceAutoGen class
1288 def __init__(self
, Workspace
):
1289 BuildFile
.__init
__(self
, Workspace
)
1290 self
.IntermediateDirectoryList
= []
1292 # Compose a dict object containing information used to do replacement in template
1293 def _CreateTemplateDict(self
):
1294 Separator
= self
._SEP
_[self
._FileType
]
1296 # any platform autogen object is ok because we just need common information
1297 PlatformInfo
= self
._AutoGenObject
1299 if "MAKE" not in PlatformInfo
.ToolDefinition
or "PATH" not in PlatformInfo
.ToolDefinition
["MAKE"]:
1300 EdkLogger
.error("build", OPTION_MISSING
, "No MAKE command defined. Please check your tools_def.txt!",
1301 ExtraData
="[%s]" % str(self
._AutoGenObject
))
1303 for Arch
in PlatformInfo
.ArchList
:
1304 self
.IntermediateDirectoryList
.append(Separator
.join(["$(BUILD_DIR)", Arch
]))
1305 self
.IntermediateDirectoryList
.append("$(FV_DIR)")
1307 # TRICK: for not generating GenFds call in makefile if no FDF file
1309 if PlatformInfo
.FdfFile
!= None and PlatformInfo
.FdfFile
!= "":
1310 FdfFileList
= [PlatformInfo
.FdfFile
]
1311 # macros passed to GenFds
1312 # MacroList.append('"%s=%s"' % ("WORKSPACE", GlobalData.gWorkspace))
1313 MacroList
.append('"%s=%s"' % ("EFI_SOURCE", GlobalData
.gEfiSource
))
1314 MacroList
.append('"%s=%s"' % ("EDK_SOURCE", GlobalData
.gEdkSource
))
1315 for MacroName
in GlobalData
.gGlobalDefines
:
1316 if GlobalData
.gGlobalDefines
[MacroName
] != "":
1317 MacroList
.append('"%s=%s"' % (MacroName
, GlobalData
.gGlobalDefines
[MacroName
]))
1319 MacroList
.append('"%s"' % MacroName
)
1323 # pass extra common options to external program called in makefile, currently GenFds.exe
1325 LogLevel
= EdkLogger
.GetLevel()
1326 if LogLevel
== EdkLogger
.VERBOSE
:
1327 ExtraOption
+= " -v"
1328 elif LogLevel
<= EdkLogger
.DEBUG_9
:
1329 ExtraOption
+= " -d %d" % (LogLevel
- 1)
1330 elif LogLevel
== EdkLogger
.QUIET
:
1331 ExtraOption
+= " -q"
1333 if GlobalData
.gCaseInsensitive
:
1334 ExtraOption
+= " -c"
1336 MakefileName
= self
._FILE
_NAME
_[self
._FileType
]
1337 SubBuildCommandList
= []
1338 for A
in PlatformInfo
.ArchList
:
1339 Command
= self
._MAKE
_TEMPLATE
_[self
._FileType
] % {"file":os
.path
.join("$(BUILD_DIR)", A
, MakefileName
)}
1340 SubBuildCommandList
.append(Command
)
1342 MakefileTemplateDict
= {
1343 "makefile_header" : self
._FILE
_HEADER
_[self
._FileType
],
1344 "makefile_path" : os
.path
.join("$(BUILD_DIR)", MakefileName
),
1345 "make_path" : PlatformInfo
.ToolDefinition
["MAKE"]["PATH"],
1346 "platform_name" : PlatformInfo
.Name
,
1347 "platform_guid" : PlatformInfo
.Guid
,
1348 "platform_version" : PlatformInfo
.Version
,
1349 "platform_build_directory" : PlatformInfo
.BuildDir
,
1351 "toolchain_tag" : PlatformInfo
.ToolChain
,
1352 "build_target" : PlatformInfo
.BuildTarget
,
1353 "shell_command_code" : self
._SHELL
_CMD
_[self
._FileType
].keys(),
1354 "shell_command" : self
._SHELL
_CMD
_[self
._FileType
].values(),
1355 'arch' : list(PlatformInfo
.ArchList
),
1356 "build_architecture_list" : ','.join(PlatformInfo
.ArchList
),
1357 "separator" : Separator
,
1358 "create_directory_command" : self
.GetCreateDirectoryCommand(self
.IntermediateDirectoryList
),
1359 "cleanall_command" : self
.GetRemoveDirectoryCommand(self
.IntermediateDirectoryList
),
1360 "sub_build_command" : SubBuildCommandList
,
1361 "fdf_file" : FdfFileList
,
1362 "active_platform" : str(PlatformInfo
),
1363 "fd" : PlatformInfo
.FdTargetList
,
1364 "fv" : PlatformInfo
.FvTargetList
,
1365 "extra_options" : ExtraOption
,
1366 "macro" : MacroList
,
1369 return MakefileTemplateDict
1371 ## Get the root directory list for intermediate files of all modules build
1373 # @retval list The list of directory
1375 def GetModuleBuildDirectoryList(self
):
1377 for ModuleAutoGen
in self
._AutoGenObject
.ModuleAutoGenList
:
1378 DirList
.append(os
.path
.join(self
._AutoGenObject
.BuildDir
, ModuleAutoGen
.BuildDir
))
1381 ## Get the root directory list for intermediate files of all libraries build
1383 # @retval list The list of directory
1385 def GetLibraryBuildDirectoryList(self
):
1387 for LibraryAutoGen
in self
._AutoGenObject
.LibraryAutoGenList
:
1388 DirList
.append(os
.path
.join(self
._AutoGenObject
.BuildDir
, LibraryAutoGen
.BuildDir
))
1391 _TemplateDict
= property(_CreateTemplateDict
)
1393 # This acts like the main() function for the script, unless it is 'import'ed into another script.
1394 if __name__
== '__main__':