import Common.GlobalData as GlobalData\r
\r
# Version and Copyright\r
-VersionNumber = "0.51" + ' ' + gBUILD_VERSION\r
+VersionNumber = "0.60" + ' ' + gBUILD_VERSION\r
__version__ = "%prog Version " + VersionNumber\r
__copyright__ = "Copyright (c) 2007 - 2014, Intel Corporation All rights reserved."\r
\r
gSupportedTarget = ['all', 'genc', 'genmake', 'modules', 'libraries', 'fds', 'clean', 'cleanall', 'cleanlib', 'run']\r
\r
## build configuration file\r
-gBuildConfiguration = "Conf/target.txt"\r
-gBuildCacheDir = "Conf/.cache"\r
-gToolsDefinition = "Conf/tools_def.txt"\r
+gBuildConfiguration = "target.txt"\r
+gToolsDefinition = "tools_def.txt"\r
\r
TemporaryTablePattern = re.compile(r'^_\d+_\d+_[a-fA-F0-9]+$')\r
TmpTableDict = {}\r
# if working directory doesn't exist, Popen() will raise an exception\r
if not os.path.isdir(WorkingDir):\r
EdkLogger.error("build", FILE_NOT_FOUND, ExtraData=WorkingDir)\r
+ \r
+ # Command is used as the first Argument in following Popen().\r
+ # It could be a string or sequence. We find that if command is a string in following Popen(),\r
+ # ubuntu may fail with an error message that the command is not found.\r
+ # So here we may need convert command from string to list instance.\r
+ if not isinstance(Command, list):\r
+ if platform.system() != 'Windows':\r
+ Command = Command.split()\r
\r
Proc = None\r
EndOfProcedure = None\r
#\r
def AddDependency(self, Dependency):\r
for Dep in Dependency:\r
- self.DependencyList.append(BuildTask.New(Dep)) # BuildTask list\r
+ if not Dep.BuildObject.IsBinaryModule:\r
+ self.DependencyList.append(BuildTask.New(Dep)) # BuildTask list\r
\r
## The thread wrapper of LaunchCommand function\r
#\r
self.SkipAutoGen = BuildOptions.SkipAutoGen\r
self.Reparse = BuildOptions.Reparse\r
self.SkuId = BuildOptions.SkuId\r
+ self.ConfDirectory = BuildOptions.ConfDirectory\r
self.SpawnMode = True\r
self.BuildReport = BuildReport(BuildOptions.ReportFile, BuildOptions.ReportType)\r
self.TargetTxt = TargetTxtClassObject()\r
self.ToolDef = ToolDefClassObject()\r
+ #Set global flag for build mode\r
+ GlobalData.gIgnoreSource = BuildOptions.IgnoreSources\r
+\r
+ if self.ConfDirectory:\r
+ # Get alternate Conf location, if it is absolute, then just use the absolute directory name\r
+ ConfDirectoryPath = os.path.normpath(self.ConfDirectory)\r
+\r
+ if not os.path.isabs(ConfDirectoryPath):\r
+ # Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE\r
+ # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf\r
+ ConfDirectoryPath = os.path.join(self.WorkspaceDir, ConfDirectoryPath)\r
+ else:\r
+ # Get standard WORKSPACE/Conf use the absolute path to the WORKSPACE/Conf\r
+ ConfDirectoryPath = os.path.join(self.WorkspaceDir, 'Conf')\r
+ GlobalData.gConfDirectory = ConfDirectoryPath\r
+ GlobalData.gDatabasePath = os.path.normpath(os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath))\r
+\r
if BuildOptions.DisableCache:\r
self.Db = WorkspaceDatabase(":memory:")\r
else:\r
- self.Db = WorkspaceDatabase(None, self.Reparse)\r
- self.BuildDatabase = self.Db.BuildObject\r
- self.Platform = None\r
+ self.Db = WorkspaceDatabase(GlobalData.gDatabasePath, self.Reparse)\r
+ self.BuildDatabase = self.Db.BuildObject\r
+ self.Platform = None\r
self.LoadFixAddress = 0\r
self.UniFlag = BuildOptions.Flag\r
+ self.BuildModules = []\r
\r
# print dot character during doing some time-consuming work\r
self.Progress = Utils.Progressor()\r
#\r
# Check target.txt and tools_def.txt and Init them\r
#\r
- BuildConfigurationFile = os.path.normpath(os.path.join(self.WorkspaceDir, gBuildConfiguration))\r
+ BuildConfigurationFile = os.path.normpath(os.path.join(GlobalData.gConfDirectory, gBuildConfiguration))\r
if os.path.isfile(BuildConfigurationFile) == True:\r
StatusCode = self.TargetTxt.LoadTargetTxtFile(BuildConfigurationFile)\r
\r
ToolDefinitionFile = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]\r
if ToolDefinitionFile == '':\r
ToolDefinitionFile = gToolsDefinition\r
- ToolDefinitionFile = os.path.normpath(os.path.join(self.WorkspaceDir, ToolDefinitionFile))\r
+ ToolDefinitionFile = os.path.normpath(os.path.join(self.WorkspaceDir, 'Conf', ToolDefinitionFile))\r
if os.path.isfile(ToolDefinitionFile) == True:\r
StatusCode = self.ToolDef.LoadToolDefFile(ToolDefinitionFile)\r
else:\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
+ # 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
+ 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
+ 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
if not self.SkipAutoGen or Target == 'genmake':\r
self.Progress.Start("Generating makefile")\r
AutoGenObject.CreateMakeFile(CreateDepsMakeFile)\r
- AutoGenObject.CreateAsBuiltInf()\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
+ # 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
# First should close DB.\r
#\r
self.Db.Close()\r
- RemoveDirectory(gBuildCacheDir, True)\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
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
Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch)\r
if Pa == None:\r
continue\r
- pModules = []\r
- for Module in Pa.Platform.Modules:\r
+ ModuleList = []\r
+ for Inf in Pa.Platform.Modules:\r
+ ModuleList.append(Inf)\r
+ # Add the INF only list in FDF\r
+ if GlobalData.gFdfParser != None:\r
+ for InfName in GlobalData.gFdfParser.Profile.InfList:\r
+ Inf = PathClass(NormPath(InfName), self.WorkspaceDir, Arch)\r
+ if Inf in Pa.Platform.Modules:\r
+ continue\r
+ ModuleList.append(Inf)\r
+ for Module in ModuleList:\r
# Get ModuleAutoGen object to generate C code file and makefile\r
Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile)\r
+ \r
if Ma == None:\r
continue\r
# Not to auto-gen for targets 'clean', 'cleanlib', 'cleanall', 'run', 'fds'\r
\r
if not self.SkipAutoGen or self.Target == 'genmake':\r
Ma.CreateMakeFile(True)\r
- Ma.CreateAsBuiltInf()\r
if self.Target == "genmake":\r
continue\r
- pModules.append(Ma)\r
+ self.BuildModules.append(Ma)\r
self.Progress.Stop("done!")\r
\r
- for Ma in pModules:\r
+ for Ma in self.BuildModules:\r
# Generate build task for the module\r
- Bt = BuildTask.New(ModuleMakeUnit(Ma, self.Target))\r
+ if not Ma.IsBinaryModule:\r
+ Bt = BuildTask.New(ModuleMakeUnit(Ma, self.Target))\r
# Break build if any build thread has error\r
if BuildTask.HasError():\r
# we need a full version of makefile for platform\r
#\r
ExitFlag.set()\r
BuildTask.WaitForComplete()\r
+ self.CreateAsBuiltInf()\r
\r
#\r
# Check for build error, and raise exception if one\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
self.SpawnMode = False\r
self._BuildModule()\r
\r
+ def CreateAsBuiltInf(self):\r
+ for Module in self.BuildModules:\r
+ Module.CreateAsBuiltInf()\r
+ self.BuildModules = []\r
## Do some clean-up works when error occurred\r
def Relinquish(self):\r
OldLogLevel = EdkLogger.GetLevel()\r
EdkLogger.SetLevel(OldLogLevel)\r
\r
def DumpBuildData(self):\r
- CacheDirectory = os.path.join(self.WorkspaceDir, gBuildCacheDir)\r
+ CacheDirectory = os.path.dirname(GlobalData.gDatabasePath)\r
Utils.CreateDirectory(CacheDirectory)\r
Utils.DataDump(Utils.gFileTimeStampCache, os.path.join(CacheDirectory, "gFileTimeStampCache"))\r
Utils.DataDump(Utils.gDependencyDatabase, os.path.join(CacheDirectory, "gDependencyDatabase"))\r
\r
def RestoreBuildData(self):\r
- FilePath = os.path.join(self.WorkspaceDir, gBuildCacheDir, "gFileTimeStampCache")\r
+ FilePath = os.path.join(os.path.dirname(GlobalData.gDatabasePath), "gFileTimeStampCache")\r
if Utils.gFileTimeStampCache == {} and os.path.isfile(FilePath):\r
Utils.gFileTimeStampCache = Utils.DataRestore(FilePath)\r
if Utils.gFileTimeStampCache == None:\r
Utils.gFileTimeStampCache = {}\r
\r
- FilePath = os.path.join(self.WorkspaceDir, gBuildCacheDir, "gDependencyDatabase")\r
+ FilePath = os.path.join(os.path.dirname(GlobalData.gDatabasePath), "gDependencyDatabase")\r
if Utils.gDependencyDatabase == {} and os.path.isfile(FilePath):\r
Utils.gDependencyDatabase = Utils.DataRestore(FilePath)\r
if Utils.gDependencyDatabase == None:\r
"This option can also be specified by setting *_*_*_BUILD_FLAGS in [BuildOptions] section of platform DSC. If they are both specified, this value "\\r
"will override the setting in [BuildOptions] section of platform DSC.")\r
Parser.add_option("-N", "--no-cache", action="store_true", dest="DisableCache", default=False, help="Disable build cache mechanism")\r
+ Parser.add_option("--conf", action="store", type="string", dest="ConfDirectory", help="Specify the customized Conf directory.")\r
+ Parser.add_option("--check-usage", action="store_true", dest="CheckUsage", default=False, help="Check usage content of entries listed in INF file.")\r
+ Parser.add_option("--ignore-sources", action="store_true", dest="IgnoreSources", default=False, help="Focus to a binary build and ignore all source files")\r
\r
(Opt, Args)=Parser.parse_args()\r
return (Opt, Args)\r
"\nbuild",\r
CODE_ERROR,\r
"Unknown fatal error when processing [%s]" % MetaFile,\r
- ExtraData="\n(Please send email to edk2-buildtools-devel@lists.sourceforge.net for help, attaching following call stack trace!)\n",\r
+ ExtraData="\n(Please send email to edk2-devel@lists.sourceforge.net for help, attaching following call stack trace!)\n",\r
RaiseError=False\r
)\r
EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc())\r
ReturnCode = CODE_ERROR\r
finally:\r
Utils.Progressor.Abort()\r
+ Utils.ClearDuplicatedInf()\r
\r
if ReturnCode == 0:\r
Conclusion = "Done"\r