From 37de70b764200718cc39a21abc491c335e3da7b3 Mon Sep 17 00:00:00 2001 From: Yonghong Zhu Date: Wed, 22 Nov 2017 15:42:25 +0800 Subject: BaseTools: Update Makefile to support FFS file generation Update Makefile to support FFS file generation with new build option --genfds-multi-thread. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu Signed-off-by: Yunhua Feng Reviewed-by: Liming Gao --- BaseTools/Source/Python/build/build.py | 48 +++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'BaseTools/Source/Python/build/build.py') diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index 53f12457f8..f94285a964 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -50,6 +50,7 @@ from PatchPcdValue.PatchPcdValue import * import Common.EdkLogger import Common.GlobalData as GlobalData +from GenFds.GenFds import GenFds # Version and Copyright VersionNumber = "0.60" + ' ' + gBUILD_VERSION @@ -774,6 +775,7 @@ class Build(): GlobalData.gUseHashCache = BuildOptions.UseHashCache GlobalData.gBinCacheDest = BuildOptions.BinCacheDest GlobalData.gBinCacheSource = BuildOptions.BinCacheSource + GlobalData.gEnableGenfdsMultiThread = BuildOptions.GenfdsMultiThread if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache: EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData="--binary-destination must be used together with --hash.") @@ -1208,7 +1210,7 @@ class Build(): # @param CreateDepModuleMakeFile Flag used to indicate creating makefile # for dependent modules/Libraries # - def _BuildPa(self, Target, AutoGenObject, CreateDepsCodeFile=True, CreateDepsMakeFile=True, BuildModule=False): + def _BuildPa(self, Target, AutoGenObject, CreateDepsCodeFile=True, CreateDepsMakeFile=True, BuildModule=False, FfsCommand={}): if AutoGenObject == None: return False @@ -1224,7 +1226,7 @@ class Build(): if not self.SkipAutoGen or Target == 'genmake': self.Progress.Start("Generating makefile") - AutoGenObject.CreateMakeFile(CreateDepsMakeFile) + AutoGenObject.CreateMakeFile(CreateDepsMakeFile, FfsCommand) self.Progress.Stop("done!") if Target == "genmake": return True @@ -1731,6 +1733,12 @@ class Build(): self.LoadFixAddress = Wa.Platform.LoadFixAddress self.BuildReport.AddPlatformReport(Wa) self.Progress.Stop("done!") + + # Add ffs build to makefile + CmdListDict = {} + if GlobalData.gEnableGenfdsMultiThread and self.Fdf: + CmdListDict = self._GenFfsCmd() + for Arch in Wa.ArchList: GlobalData.gGlobalDefines['ARCH'] = Arch Pa = PlatformAutoGen(Wa, self.PlatformFile, BuildTarget, ToolChain, Arch) @@ -1740,7 +1748,7 @@ class Build(): if Ma == None: continue self.BuildModules.append(Ma) - self._BuildPa(self.Target, Pa) + self._BuildPa(self.Target, Pa, FfsCommand=CmdListDict) # Create MAP file when Load Fix Address is enabled. if self.Target in ["", "all", "fds"]: @@ -1819,6 +1827,10 @@ class Build(): self.Fdf = Wa.FdfFile self.LoadFixAddress = Wa.Platform.LoadFixAddress Wa.CreateMakeFile(False) + # Add ffs build to makefile + CmdListDict = None + if GlobalData.gEnableGenfdsMultiThread and self.Fdf: + CmdListDict = self._GenFfsCmd() self.Progress.Stop("done!") MaList = [] ExitFlag = threading.Event() @@ -1838,7 +1850,11 @@ class Build(): if not self.SkipAutoGen or self.Target == 'genc': Ma.CreateCodeFile(True) if not self.SkipAutoGen or self.Target == 'genmake': - Ma.CreateMakeFile(True) + if CmdListDict and self.Fdf and (Module.File, Arch) in CmdListDict: + Ma.CreateMakeFile(True, CmdListDict[Module.File, Arch]) + del CmdListDict[Module.File, Arch] + else: + Ma.CreateMakeFile(True) MaList.append(Ma) self.BuildModules.append(Ma) self.AutoGenTime += int(round((time.time() - AutoGenStart))) @@ -1922,6 +1938,17 @@ class Build(): # self._SaveMapFile (MapBuffer, Wa) + def _GenFfsCmd(self): + CmdListDict = {} + GenFfsDict = GenFds.GenFfsMakefile('', GlobalData.gFdfParser, self, self.ArchList, GlobalData) + for Cmd in GenFfsDict: + tmpInf, tmpArch = GenFfsDict[Cmd] + if (tmpInf, tmpArch) not in CmdListDict.keys(): + CmdListDict[tmpInf, tmpArch] = [Cmd] + else: + CmdListDict[tmpInf, tmpArch].append(Cmd) + return CmdListDict + ## Build a platform in multi-thread mode # def _MultiThreadBuildPlatform(self): @@ -1957,6 +1984,11 @@ class Build(): self.BuildReport.AddPlatformReport(Wa) Wa.CreateMakeFile(False) + # Add ffs build to makefile + CmdListDict = None + if GlobalData.gEnableGenfdsMultiThread and self.Fdf: + CmdListDict = self._GenFfsCmd() + # multi-thread exit flag ExitFlag = threading.Event() ExitFlag.clear() @@ -1995,7 +2027,11 @@ class Build(): continue if not self.SkipAutoGen or self.Target == 'genmake': - Ma.CreateMakeFile(True) + if CmdListDict and self.Fdf and (Module.File, Arch) in CmdListDict: + Ma.CreateMakeFile(True, CmdListDict[Module.File, Arch]) + del CmdListDict[Module.File, Arch] + else: + Ma.CreateMakeFile(True) if self.Target == "genmake": continue self.BuildModules.append(Ma) @@ -2311,7 +2347,7 @@ def MyOptionParser(): Parser.add_option("--hash", action="store_true", dest="UseHashCache", default=False, help="Enable hash-based caching during build process.") Parser.add_option("--binary-destination", action="store", type="string", dest="BinCacheDest", help="Generate a cache of binary files in the specified directory.") Parser.add_option("--binary-source", action="store", type="string", dest="BinCacheSource", help="Consume a cache of binary files from the specified directory.") - + Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=False, help="Enable GenFds multi thread to generate ffs file.") (Opt, Args) = Parser.parse_args() return (Opt, Args) -- cgit v1.2.3