)\r
Count += 1\r
\r
+ def _GenFdsCommand(self):\r
+ return (GenMake.TopLevelMakefile(self)._TEMPLATE_.Replace(GenMake.TopLevelMakefile(self)._TemplateDict)).strip()\r
\r
## Create makefile for the platform and modules in it\r
#\r
# modules will be created as well\r
#\r
def CreateMakeFile(self, CreateDepsMakeFile=False):\r
- # create makefile for platform\r
- Makefile = GenMake.TopLevelMakefile(self)\r
- if Makefile.Generate():\r
- EdkLogger.debug(EdkLogger.DEBUG_9, "Generated makefile for platform [%s] %s\n" %\r
- (self.MetaFile, self.ArchList))\r
- else:\r
- EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of makefile for platform [%s] %s\n" %\r
- (self.MetaFile, self.ArchList))\r
-\r
if CreateDepsMakeFile:\r
for Pa in self.AutoGenObjectList:\r
Pa.CreateMakeFile(CreateDepsMakeFile)\r
FvDir = property(_GetFvDir)\r
MakeFileDir = property(_GetMakeFileDir)\r
BuildCommand = property(_GetBuildCommand)\r
+ GenFdsCommand = property(_GenFdsCommand)\r
\r
## AutoGen class for platform\r
#\r
self._LibraryAutoGenList = None\r
self._BuildCommand = None\r
\r
+ # get library/modules for build\r
+ self.LibraryBuildDirectoryList = []\r
+ self.ModuleBuildDirectoryList = []\r
# get the original module/package/platform objects\r
self.BuildDatabase = Workspace.BuildDatabase\r
return True\r
# don't do this twice\r
self.IsCodeFileCreated = True\r
\r
+ ## Generate Fds Command\r
+ def _GenFdsCommand(self):\r
+ return self.Workspace.GenFdsCommand\r
+ \r
## Create makefile for the platform and mdoules in it\r
#\r
# @param CreateModuleMakeFile Flag indicating if the makefile for\r
if self.IsMakeFileCreated:\r
return\r
\r
- # create makefile for platform\r
+ # create library/module build dirs for platform\r
Makefile = GenMake.PlatformMakefile(self)\r
- if Makefile.Generate():\r
- EdkLogger.debug(EdkLogger.DEBUG_9, "Generated makefile for platform [%s] [%s]\n" %\r
- (self.MetaFile, self.Arch))\r
- else:\r
- EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of makefile for platform [%s] [%s]\n" %\r
- (self.MetaFile, self.Arch))\r
+ self.LibraryBuildDirectoryList = Makefile.GetLibraryBuildDirectoryList()\r
+ self.ModuleBuildDirectoryList = Makefile.GetModuleBuildDirectoryList()\r
+\r
self.IsMakeFileCreated = True\r
\r
## Deal with Shared FixedAtBuild Pcds\r
self.IntermediateDirectoryList = []\r
self.ModuleBuildDirectoryList = []\r
self.LibraryBuildDirectoryList = []\r
+ self.LibraryMakeCommandList = []\r
\r
# Compose a dict object containing information used to do replacement in template\r
def _CreateTemplateDict(self):\r
Command = self._MAKE_TEMPLATE_[self._FileType] % {"file":Makefile}\r
LibraryMakefileList.append(Makefile)\r
LibraryMakeCommandList.append(Command)\r
+ self.LibraryMakeCommandList = LibraryMakeCommandList\r
\r
ModuleMakefileList = []\r
ModuleMakeCommandList = []\r
#\r
class TopLevelMakefile(BuildFile):\r
## template used to generate toplevel makefile\r
- _TEMPLATE_ = TemplateString('''\\r
-${makefile_header}\r
-\r
-#\r
-# Platform Macro Definition\r
-#\r
-PLATFORM_NAME = ${platform_name}\r
-PLATFORM_GUID = ${platform_guid}\r
-PLATFORM_VERSION = ${platform_version}\r
-\r
-#\r
-# Build Configuration Macro Definition\r
-#\r
-TOOLCHAIN = ${toolchain_tag}\r
-TOOLCHAIN_TAG = ${toolchain_tag}\r
-TARGET = ${build_target}\r
-\r
-#\r
-# Build Directory Macro Definition\r
-#\r
-BUILD_DIR = ${platform_build_directory}\r
-FV_DIR = ${platform_build_directory}${separator}FV\r
-\r
-#\r
-# Shell Command Macro\r
-#\r
-${BEGIN}${shell_command_code} = ${shell_command}\r
-${END}\r
-\r
-MAKE = ${make_path}\r
-MAKE_FILE = ${makefile_path}\r
-\r
-#\r
-# Default target\r
-#\r
-all: modules fds\r
-\r
-#\r
-# Initialization target: print build information and create necessary directories\r
-#\r
-init:\r
-\t-@\r
-\t${BEGIN}-@${create_directory_command}\r
-\t${END}\r
-#\r
-# library build target\r
-#\r
-libraries: init\r
-${BEGIN}\t@cd $(BUILD_DIR)${separator}${arch} && "$(MAKE)" $(MAKE_FLAGS) libraries\r
-${END}\t@cd $(BUILD_DIR)\r
-\r
-#\r
-# module build target\r
-#\r
-modules: init\r
-${BEGIN}\t@cd $(BUILD_DIR)${separator}${arch} && "$(MAKE)" $(MAKE_FLAGS) modules\r
-${END}\t@cd $(BUILD_DIR)\r
-\r
-#\r
-# Flash Device Image Target\r
-#\r
-fds: init\r
-\t-@cd $(FV_DIR)\r
-${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} -C ${cap} ${END}${BEGIN} -D ${macro} ${END}\r
-\r
-#\r
-# run command for emulator platform only\r
-#\r
-run:\r
-\tcd $(BUILD_DIR)${separator}IA32 && ".${separator}SecMain"\r
-\tcd $(BUILD_DIR)\r
-\r
-#\r
-# Clean intermediate files\r
-#\r
-clean:\r
-${BEGIN}\t-@${sub_build_command} clean\r
-${END}\t@cd $(BUILD_DIR)\r
-\r
-#\r
-# Clean all generated files except to makefile\r
-#\r
-cleanall:\r
-${BEGIN}\t${cleanall_command}\r
-${END}\r
-\r
-#\r
-# Clean all library files\r
-#\r
-cleanlib:\r
-${BEGIN}\t-@${sub_build_command} cleanlib\r
-${END}\t@cd $(BUILD_DIR)\n\r
-''')\r
+ _TEMPLATE_ = TemplateString('''${BEGIN}\tGenFds -f "${fdf_file}" -o "${platform_build_directory}" -t ${toolchain_tag} -b ${build_target} -p "${active_platform}" -a ${build_architecture_list} ${extra_options}${END}${BEGIN} -r ${fd} ${END}${BEGIN} -i ${fv} ${END}${BEGIN} -C ${cap} ${END}${BEGIN} -D ${macro} ${END}''')\r
\r
## Constructor of TopLevelMakefile\r
#\r
# @param CreateDepModuleMakeFile Flag used to indicate creating makefile\r
# for dependent modules/Libraries\r
#\r
- def _Build(self, Target, AutoGenObject, CreateDepsCodeFile=True, CreateDepsMakeFile=True):\r
+ def _BuildPa(self, Target, AutoGenObject, CreateDepsCodeFile=True, CreateDepsMakeFile=True, BuildModule=False):\r
if AutoGenObject == None:\r
return False\r
\r
if not self.SkipAutoGen or Target == 'genmake':\r
self.Progress.Start("Generating makefile")\r
AutoGenObject.CreateMakeFile(CreateDepsMakeFile)\r
- AutoGenObject.CreateAsBuiltInf()\r
self.Progress.Stop("done!")\r
if Target == "genmake":\r
return True\r
(AutoGenObject.BuildTarget, AutoGenObject.ToolChain, AutoGenObject.Arch),\r
ExtraData=str(AutoGenObject))\r
\r
+ makefile = GenMake.BuildFile(AutoGenObject)._FILE_NAME_[GenMake.gMakeType]\r
+\r
+ # genfds\r
+ if Target == 'fds':\r
+ LaunchCommand(AutoGenObject.GenFdsCommand, AutoGenObject.MakeFileDir)\r
+ return True\r
+\r
+ # run\r
+ if Target == 'run':\r
+ RunDir = os.path.normpath(os.path.join(AutoGenObject.BuildDir, 'IA32'))\r
+ Command = '.\SecMain'\r
+ os.chdir(RunDir)\r
+ LaunchCommand(Command, RunDir)\r
+ return True\r
+\r
+ # build modules\r
+ if BuildModule:\r
+ BuildCommand = BuildCommand + [Target]\r
+ LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)\r
+ self.CreateAsBuiltInf()\r
+ return True\r
+\r
+ # build library\r
+ if Target == 'libraries':\r
+ for Lib in AutoGenObject.LibraryBuildDirectoryList:\r
+ NewBuildCommand = BuildCommand + ['-f', os.path.normpath(os.path.join(Lib, makefile)), 'pbuild']\r
+ LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)\r
+ return True\r
+\r
+ # build module\r
+ if Target == 'modules':\r
+ for Lib in AutoGenObject.LibraryBuildDirectoryList:\r
+ NewBuildCommand = BuildCommand + ['-f', os.path.normpath(os.path.join(Lib, makefile)), 'pbuild']\r
+ LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)\r
+ for Mod in AutoGenObject.ModuleBuildDirectoryList:\r
+ NewBuildCommand = BuildCommand + ['-f', os.path.normpath(os.path.join(Mod, makefile)), 'pbuild']\r
+ LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)\r
+ self.CreateAsBuiltInf()\r
+ return True\r
+\r
+ # cleanlib\r
+ if Target == 'cleanlib':\r
+ for Lib in AutoGenObject.LibraryBuildDirectoryList:\r
+ LibMakefile = os.path.normpath(os.path.join(Lib, makefile))\r
+ if os.path.exists(LibMakefile):\r
+ NewBuildCommand = BuildCommand + ['-f', LibMakefile, 'cleanall']\r
+ LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)\r
+ return True\r
+\r
+ # clean\r
+ if Target == 'clean':\r
+ for Mod in AutoGenObject.ModuleBuildDirectoryList:\r
+ ModMakefile = os.path.normpath(os.path.join(Mod, makefile))\r
+ if os.path.exists(ModMakefile):\r
+ NewBuildCommand = BuildCommand + ['-f', ModMakefile, 'cleanall']\r
+ LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)\r
+ for Lib in AutoGenObject.LibraryBuildDirectoryList:\r
+ LibMakefile = os.path.normpath(os.path.join(Lib, makefile))\r
+ if os.path.exists(LibMakefile):\r
+ NewBuildCommand = BuildCommand + ['-f', LibMakefile, 'cleanall']\r
+ LaunchCommand(NewBuildCommand, AutoGenObject.MakeFileDir)\r
+ return True\r
+\r
+ # cleanall\r
+ if Target == 'cleanall':\r
+ try:\r
+ #os.rmdir(AutoGenObject.BuildDir)\r
+ RemoveDirectory(AutoGenObject.BuildDir, True)\r
+ #\r
+ # First should close DB.\r
+ #\r
+ self.Db.Close()\r
+ RemoveDirectory(os.path.dirname(GlobalData.gDatabasePath), True)\r
+ except WindowsError, X:\r
+ EdkLogger.error("build", FILE_DELETE_FAILURE, ExtraData=str(X))\r
+ return True\r
+\r
+ ## Build a module or platform\r
+ #\r
+ # Create autogen code and makefile for a module or platform, and the launch\r
+ # "make" command to build it\r
+ #\r
+ # @param Target The target of build command\r
+ # @param Platform The platform file\r
+ # @param Module The module file\r
+ # @param BuildTarget The name of build target, one of "DEBUG", "RELEASE"\r
+ # @param ToolChain The name of toolchain to build\r
+ # @param Arch The arch of the module/platform\r
+ # @param CreateDepModuleCodeFile Flag used to indicate creating code\r
+ # for dependent modules/Libraries\r
+ # @param CreateDepModuleMakeFile Flag used to indicate creating makefile\r
+ # for dependent modules/Libraries\r
+ #\r
+ def _Build(self, Target, AutoGenObject, CreateDepsCodeFile=True, CreateDepsMakeFile=True, BuildModule=False):\r
+ if AutoGenObject == None:\r
+ return False\r
+\r
+ # skip file generation for cleanxxx targets, run and fds target\r
+ if Target not in ['clean', 'cleanlib', 'cleanall', 'run', 'fds']:\r
+ # for target which must generate AutoGen code and makefile\r
+ if not self.SkipAutoGen or Target == 'genc':\r
+ self.Progress.Start("Generating code")\r
+ AutoGenObject.CreateCodeFile(CreateDepsCodeFile)\r
+ self.Progress.Stop("done!")\r
+ if Target == "genc":\r
+ return True\r
+\r
+ if not self.SkipAutoGen or Target == 'genmake':\r
+ self.Progress.Start("Generating makefile")\r
+ AutoGenObject.CreateMakeFile(CreateDepsMakeFile)\r
+ #AutoGenObject.CreateAsBuiltInf()\r
+ self.Progress.Stop("done!")\r
+ if Target == "genmake":\r
+ return True\r
+ else:\r
+ # always recreate top/platform makefile when clean, just in case of inconsistency\r
+ AutoGenObject.CreateCodeFile(False)\r
+ AutoGenObject.CreateMakeFile(False)\r
+\r
+ if EdkLogger.GetLevel() == EdkLogger.QUIET:\r
+ EdkLogger.quiet("Building ... %s" % repr(AutoGenObject))\r
+\r
+ BuildCommand = AutoGenObject.BuildCommand\r
+ if BuildCommand == None or len(BuildCommand) == 0:\r
+ EdkLogger.error("build", OPTION_MISSING,\r
+ "No build command found for this module. "\r
+ "Please check your setting of %s_%s_%s_MAKE_PATH in Conf/tools_def.txt file." %\r
+ (AutoGenObject.BuildTarget, AutoGenObject.ToolChain, AutoGenObject.Arch),\r
+ ExtraData=str(AutoGenObject))\r
+\r
+ # genfds\r
+ if Target == 'fds':\r
+ LaunchCommand(AutoGenObject.GenFdsCommand, AutoGenObject.MakeFileDir)\r
+ return True\r
+\r
+ # run\r
+ if Target == 'run':\r
+ RunDir = os.path.normpath(os.path.join(AutoGenObject.BuildDir, 'IA32'))\r
+ Command = '.\SecMain'\r
+ os.chdir(RunDir)\r
+ LaunchCommand(Command, RunDir)\r
+ return True\r
+\r
+ # build modules\r
BuildCommand = BuildCommand + [Target]\r
- LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)\r
+ if BuildModule:\r
+ LaunchCommand(BuildCommand, AutoGenObject.MakeFileDir)\r
+ self.CreateAsBuiltInf()\r
+ return True\r
+\r
+ # build library\r
+ if Target == 'libraries':\r
+ pass\r
+\r
+ # not build modules\r
+\r
+\r
+ # cleanall\r
if Target == 'cleanall':\r
try:\r
#os.rmdir(AutoGenObject.BuildDir)\r
self.LoadFixAddress = Wa.Platform.LoadFixAddress\r
self.BuildReport.AddPlatformReport(Wa)\r
self.Progress.Stop("done!")\r
- self._Build(self.Target, Wa)\r
+ for Arch in Wa.ArchList:\r
+ GlobalData.gGlobalDefines['ARCH'] = Arch\r
+ Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch)\r
+ for Module in Pa.Platform.Modules:\r
+ # Get ModuleAutoGen object to generate C code file and makefile\r
+ Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile)\r
+ if Ma == None:\r
+ continue\r
+ self.BuildModules.append(Ma)\r
+ self._BuildPa(self.Target, Pa)\r
\r
# Create MAP file when Load Fix Address is enabled.\r
if self.Target in ["", "all", "fds"]:\r
Ma = ModuleAutoGen(Wa, self.ModuleFile, BuildTarget, ToolChain, Arch, self.PlatformFile)\r
if Ma == None: continue\r
MaList.append(Ma)\r
- self._Build(self.Target, Ma)\r
+ self.BuildModules.append(Ma)\r
+ if not Ma.IsBinaryModule:\r
+ self._Build(self.Target, Ma, BuildModule=True)\r
\r
self.BuildReport.AddPlatformReport(Wa, MaList)\r
if MaList == []:\r
#\r
# Generate FD image if there's a FDF file found\r
#\r
- LaunchCommand(Wa.BuildCommand + ["fds"], Wa.MakeFileDir)\r
+ LaunchCommand(Wa.GenFdsCommand, os.getcwd())\r
+\r
#\r
# Create MAP file for all platform FVs after GenFds.\r
#\r