[edk2-devel] [Patch 1/1] BaseTools: Split WorkspaceAutoGen._InitWorker into multiple functions
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875 The WorkspaceAutoGen.__InitWorker function is too long, it's hard to read and understand. This patch is to separate the __InitWorker into multiple small ones. Cc: Liming Gao Signed-off-by: Bob Feng --- BaseTools/Source/Python/AutoGen/AutoGen.py | 247 + 1 file changed, 152 insertions(+), 95 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 8bf71d770e2c..088cad9f145a 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -333,13 +333,58 @@ class WorkspaceAutoGen(AutoGen): self._GuidDict = {} # there's many relative directory operations, so ... os.chdir(self.WorkspaceDir) +self.MergeArch() +self.ValidateBuildTarget() + +EdkLogger.info("") +if self.ArchList: +EdkLogger.info('%-16s = %s' % ("Architecture(s)", ' '.join(self.ArchList))) +EdkLogger.info('%-16s = %s' % ("Build target", self.BuildTarget)) +EdkLogger.info('%-16s = %s' % ("Toolchain", self.ToolChain)) + +EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.Platform)) +if BuildModule: +EdkLogger.info('%-24s = %s' % ("Active Module", BuildModule)) + +if self.FdfFile: +EdkLogger.info('%-24s = %s' % ("Flash Image Definition", self.FdfFile)) + +EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile) + +if Progress: +Progress.Start("\nProcessing meta-data") # -# Merge Arch +# Mark now build in AutoGen Phase # +GlobalData.gAutoGenPhase = True +self.ProcessModuleFromPdf() +self.ProcessPcdType() +self.ProcessMixedPcd() +self.GetPcdsFromFDF() +self.CollectAllPcds() +self.GeneratePkgLevelHash() +# +# Check PCDs token value conflict in each DEC file. +# +self._CheckAllPcdsTokenValueConflict() +# +# Check PCD type and definition between DSC and DEC +# +self._CheckPcdDefineAndType() + +self.CreateBuildOptionsFile() +self.CreatePcdTokenNumberFile() +self.CreateModuleHashInfo() +GlobalData.gAutoGenPhase = False + +# +# Merge Arch +# +def MergeArch(self): if not self.ArchList: ArchList = set(self.Platform.SupArchList) else: ArchList = set(self.ArchList) & set(self.Platform.SupArchList) if not ArchList: @@ -349,57 +394,49 @@ class WorkspaceAutoGen(AutoGen): SkippedArchList = set(self.ArchList).symmetric_difference(set(self.Platform.SupArchList)) EdkLogger.verbose("\nArch [%s] is ignored because the platform supports [%s] only!" % (" ".join(SkippedArchList), " ".join(self.Platform.SupArchList))) self.ArchList = tuple(ArchList) -# Validate build target +# Validate build target +def ValidateBuildTarget(self): if self.BuildTarget not in self.Platform.BuildTargets: EdkLogger.error("build", PARAMETER_INVALID, ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]" % (self.BuildTarget, " ".join(self.Platform.BuildTargets))) - - -# parse FDF file to get PCDs in it, if any +@cached_property +def FdfProfile(self): if not self.FdfFile: self.FdfFile = self.Platform.FlashDefinition -EdkLogger.info("") -if self.ArchList: -EdkLogger.info('%-16s = %s' % ("Architecture(s)", ' '.join(self.ArchList))) -EdkLogger.info('%-16s = %s' % ("Build target", self.BuildTarget)) -EdkLogger.info('%-16s = %s' % ("Toolchain", self.ToolChain)) - -EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.Platform)) -if BuildModule: -EdkLogger.info('%-24s = %s' % ("Active Module", BuildModule)) - +FdfProfile = None if self.FdfFile: -EdkLogger.info('%-24s = %s' % ("Flash Image Definition", self.FdfFile)) - -EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile) - -if Progress: -Progress.Start("\nProcessing meta-data") - -if self.FdfFile: -# -# Mark now build in AutoGen Phase -# -GlobalData.gAutoGenPhase = True Fdf = FdfParser(self.FdfFile.Path) Fdf.ParseFile() GlobalData.gFdfParser = Fdf -GlobalData.gAutoGenPhase = False -PcdSet = Fdf.Profile.PcdDict if Fdf.CurrentFdName and Fdf.CurrentFdName in Fdf.Profile.FdDict: FdDict = Fdf.Profile.FdDict[Fdf.CurrentFdName] for FdRegion in FdDict.RegionList: if
[edk2-devel] [Patch 1/1] BaseTools: Split WorkspaceAutoGen._InitWorker into multiple functions
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875 The WorkspaceAutoGen.__InitWorker function is too long, it's hard to read and understand. This patch is to separate the __InitWorker into multiple small ones. Cc: Liming Gao Signed-off-by: Bob Feng --- BaseTools/Source/Python/AutoGen/AutoGen.py | 249 + 1 file changed, 154 insertions(+), 95 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index a1f7f5641e09..598a5330da2c 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -333,13 +333,58 @@ class WorkspaceAutoGen(AutoGen): self._GuidDict = {} # there's many relative directory operations, so ... os.chdir(self.WorkspaceDir) +self.MergeArch() +self.ValidateBuildTarget() + +EdkLogger.info("") +if self.ArchList: +EdkLogger.info('%-16s = %s' % ("Architecture(s)", ' '.join(self.ArchList))) +EdkLogger.info('%-16s = %s' % ("Build target", self.BuildTarget)) +EdkLogger.info('%-16s = %s' % ("Toolchain", self.ToolChain)) + +EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.Platform)) +if BuildModule: +EdkLogger.info('%-24s = %s' % ("Active Module", BuildModule)) + +if self.FdfFile: +EdkLogger.info('%-24s = %s' % ("Flash Image Definition", self.FdfFile)) + +EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile) + +if Progress: +Progress.Start("\nProcessing meta-data") # -# Merge Arch +# Mark now build in AutoGen Phase # +GlobalData.gAutoGenPhase = True +self.ProcessModuleFromPdf() +self.ProcessPcdType() +self.ProcessMixedPcd() +self.GetPcdsFromFDF() +self.CollectAllPcds() +self.GeneratePkgLevelHash() +# +# Check PCDs token value conflict in each DEC file. +# +self._CheckAllPcdsTokenValueConflict() +# +# Check PCD type and definition between DSC and DEC +# +self._CheckPcdDefineAndType() + +self.CreateBuildOptionsFile() +self.CreatePcdTokenNumberFile() +self.CreateModuleHashInfo() +GlobalData.gAutoGenPhase = False + +# +# Merge Arch +# +def MergeArch(self): if not self.ArchList: ArchList = set(self.Platform.SupArchList) else: ArchList = set(self.ArchList) & set(self.Platform.SupArchList) if not ArchList: @@ -349,57 +394,49 @@ class WorkspaceAutoGen(AutoGen): SkippedArchList = set(self.ArchList).symmetric_difference(set(self.Platform.SupArchList)) EdkLogger.verbose("\nArch [%s] is ignored because the platform supports [%s] only!" % (" ".join(SkippedArchList), " ".join(self.Platform.SupArchList))) self.ArchList = tuple(ArchList) -# Validate build target +# Validate build target +def ValidateBuildTarget(self): if self.BuildTarget not in self.Platform.BuildTargets: EdkLogger.error("build", PARAMETER_INVALID, ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]" % (self.BuildTarget, " ".join(self.Platform.BuildTargets))) - - -# parse FDF file to get PCDs in it, if any +@cached_property +def FdfProfile(self): if not self.FdfFile: self.FdfFile = self.Platform.FlashDefinition -EdkLogger.info("") -if self.ArchList: -EdkLogger.info('%-16s = %s' % ("Architecture(s)", ' '.join(self.ArchList))) -EdkLogger.info('%-16s = %s' % ("Build target", self.BuildTarget)) -EdkLogger.info('%-16s = %s' % ("Toolchain", self.ToolChain)) - -EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.Platform)) -if BuildModule: -EdkLogger.info('%-24s = %s' % ("Active Module", BuildModule)) - +FdfProfile = None if self.FdfFile: -EdkLogger.info('%-24s = %s' % ("Flash Image Definition", self.FdfFile)) - -EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile) - -if Progress: -Progress.Start("\nProcessing meta-data") - -if self.FdfFile: -# -# Mark now build in AutoGen Phase -# -GlobalData.gAutoGenPhase = True Fdf = FdfParser(self.FdfFile.Path) Fdf.ParseFile() GlobalData.gFdfParser = Fdf -GlobalData.gAutoGenPhase = False -PcdSet = Fdf.Profile.PcdDict if Fdf.CurrentFdName and Fdf.CurrentFdName in Fdf.Profile.FdDict: FdDict = Fdf.Profile.FdDict[Fdf.CurrentFdName] for FdRegion in FdDict.RegionList: if