From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: bob.c.feng@intel.com) Received: from mga03.intel.com (mga03.intel.com []) by groups.io with SMTP; Mon, 22 Jul 2019 01:55:46 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jul 2019 01:51:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,294,1559545200"; d="scan'208";a="320624174" Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.47]) by orsmga004.jf.intel.com with ESMTP; 22 Jul 2019 01:51:43 -0700 From: "Bob Feng" To: devel@edk2.groups.io Cc: Liming Gao , Bob Feng Subject: [Patch 3/9 V2] BaseTools: Add functions to get platform scope build options Date: Mon, 22 Jul 2019 16:50:54 +0800 Message-Id: <20190722085100.20552-4-bob.c.feng@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 In-Reply-To: <20190722085100.20552-1-bob.c.feng@intel.com> References: <20190722085100.20552-1-bob.c.feng@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875 These functions are used for get platform scope build options. They will be used in later patches. Cc: Liming Gao Signed-off-by: Bob Feng --- BaseTools/Source/Python/AutoGen/AutoGen.py | 10 +++++++++- .../Source/Python/Workspace/DscBuildData.py | 20 +++++++++++++++++++ .../Source/Python/Workspace/InfBuildData.py | 10 ++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 9e06bb942126..792beed65e6b 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -2485,11 +2485,19 @@ class PlatformAutoGen(AutoGen): if Attr != 'PATH': BuildOptions[Tool][Attr] += " " + Options[Key] else: BuildOptions[Tool][Attr] = Options[Key] return BuildOptions - + def GetGlobalBuildOptions(self,Module): + ModuleTypeOptions = self.Platform.GetBuildOptionsByPkg(Module, Module.ModuleType) + ModuleTypeOptions = self._ExpandBuildOption(ModuleTypeOptions) + if Module in self.Platform.Modules: + PlatformModule = self.Platform.Modules[str(Module)] + PlatformModuleOptions = self._ExpandBuildOption(PlatformModule.BuildOptions) + else: + PlatformModuleOptions = {} + return ModuleTypeOptions, PlatformModuleOptions ## Append build options in platform to a module # # @param Module The module to which the build options will be appended # # @retval options The options appended with build options in platform diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index e7ec2aba57d2..dd5c3c2bd1f2 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1222,11 +1222,31 @@ class DscBuildData(PlatformBuildClassObject): self._BuildOptions[CurKey] = Option else: if ' ' + Option not in self._BuildOptions[CurKey]: self._BuildOptions[CurKey] += ' ' + Option return self._BuildOptions + def GetBuildOptionsByPkg(self, Module, ModuleType): + local_pkg = os.path.split(Module.LocalPkg())[0] + if self._ModuleTypeOptions is None: + self._ModuleTypeOptions = OrderedDict() + if ModuleType not in self._ModuleTypeOptions: + options = OrderedDict() + self._ModuleTypeOptions[ ModuleType] = options + RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch] + for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4, Dummy5 in RecordList: + if Dummy2 not in (TAB_COMMON,local_pkg.upper(),"EDKII"): + continue + Type = Dummy3 + if Type.upper() == ModuleType.upper(): + Key = (ToolChainFamily, ToolChain) + if Key not in options or not ToolChain.endswith('_FLAGS') or Option.startswith('='): + options[Key] = Option + else: + if ' ' + Option not in options[Key]: + options[Key] += ' ' + Option + return self._ModuleTypeOptions[ModuleType] def GetBuildOptionsByModuleType(self, Edk, ModuleType): if self._ModuleTypeOptions is None: self._ModuleTypeOptions = OrderedDict() if (Edk, ModuleType) not in self._ModuleTypeOptions: options = OrderedDict() diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py index 60970cd92836..da35391d3aff 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -817,11 +817,21 @@ class InfBuildData(ModuleBuildClassObject): for Token in TokenList: TemporaryDictionary[Arch, ModuleType] = TemporaryDictionary[Arch, ModuleType] + Token.strip() + ' ' for Arch, ModuleType in TemporaryDictionary: RetVal[Arch, ModuleType] = TemporaryDictionary[Arch, ModuleType] return RetVal + def LocalPkg(self): + module_path = self.MetaFile.File + subdir = os.path.split(module_path)[0] + TopDir = "" + while subdir: + subdir,TopDir = os.path.split(subdir) + for file_name in os.listdir(os.path.join(self.MetaFile.Root,TopDir)): + if file_name.upper().endswith("DEC"): + pkg = os.path.join(TopDir,file_name) + return pkg @cached_class_function def GetGuidsUsedByPcd(self): self.Pcds return self._GuidsUsedByPcd -- 2.20.1.windows.1