From nobody Wed May 1 22:25:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1514278358755563.3099914416415; Tue, 26 Dec 2017 00:52:38 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7C10F222F4E09; Tue, 26 Dec 2017 00:47:43 -0800 (PST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 680BF21CB87A2 for ; Tue, 26 Dec 2017 00:47:42 -0800 (PST) Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2017 00:52:36 -0800 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga008.jf.intel.com with ESMTP; 26 Dec 2017 00:52:35 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,459,1508828400"; d="scan'208";a="5643804" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Tue, 26 Dec 2017 16:52:32 +0800 Message-Id: <1514278352-5824-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [edk2] [Patch] BaseTools: Add Platform Override Build Options for PcdValueInit X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add Platform's CC_FLAGS /D option for PcdValueInit generation. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu Reviewed-by: Liming Gao --- BaseTools/Source/Python/Workspace/DscBuildData.py | 77 +++++++++++++++++++= ++-- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index 135b608..9262650 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -21,11 +21,12 @@ from Common.String import * from Common.DataType import * from Common.Misc import * from types import * =20 from CommonDataClass.CommonClass import SkuInfoClass - +from Common.TargetTxtClassObject import * +from Common.ToolDefClassObject import * from MetaDataTable import * from MetaFileTable import * from MetaFileParser import * =20 from WorkspaceCommon import GetDeclaredPcd @@ -75,15 +76,15 @@ PcdMakefileHeader =3D ''' # This file is auto-generated by build utility # =20 ''' =20 +WindowsCFLAGS =3D 'CFLAGS =3D $(CFLAGS) /wd4200 /wd4034 /wd4101 ' +LinuxCFLAGS =3D 'BUILD_CFLAGS +=3D -Wno-pointer-to-int-cast -Wno-unused-va= riable ' PcdMakefileEnd =3D ''' !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common =20 -CFLAGS =3D $(CFLAGS) /wd4200 /wd4034 /wd4101 - LIBS =3D $(LIB_PATH)\Common.lib =20 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app ''' =20 @@ -150,10 +151,11 @@ class DscBuildData(PlatformBuildClassObject): self._RawData =3D RawData self._Bdb =3D BuildDataBase self._Arch =3D Arch self._Target =3D Target self._Toolchain =3D Toolchain + self._ToolChainFamily =3D None self._Clear() self._HandleOverridePath() if os.getenv("WORKSPACE"): self.OutputPath =3D os.path.join(os.getenv("WORKSPACE"), 'Buil= d', PcdValueInitName) else: @@ -1456,11 +1458,11 @@ class DscBuildData(PlatformBuildClassObject): if sys.platform =3D=3D "win32": MakeApp =3D MakeApp + 'ARCH =3D IA32\nAPPNAME =3D %s\n' % (Pcd= ValueInitName) + 'OBJECTS =3D %s\%s.obj\n' % (self.OutputPath, PcdValueInit= Name) + 'INC =3D ' else: MakeApp =3D MakeApp + PcdGccMakefile MakeApp =3D MakeApp + 'APPNAME =3D %s\n' % (PcdValueInitName) = + 'OBJECTS =3D %s/%s.o\n' % (self.OutputPath, PcdValueInitName) + \ - 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'BU= ILD_CFLAGS +=3D -Wno-pointer-to-int-cast -Wno-unused-variable\n' + 'INCLUDE= +=3D' + 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'IN= CLUDE +=3D' =20 PlatformInc =3D {} for Cache in self._Bdb._CACHE_.values(): if Cache.MetaFile.Ext.lower() !=3D '.dec': continue @@ -1481,10 +1483,54 @@ class DscBuildData(PlatformBuildClassObject): for pkg in PcdDependDEC: if pkg in PlatformInc: for inc in PlatformInc[pkg]: MakeApp +=3D '-I' + str(inc) + ' ' MakeApp =3D MakeApp + '\n' + + CC_FLAGS =3D LinuxCFLAGS + if sys.platform =3D=3D "win32": + CC_FLAGS =3D WindowsCFLAGS + BuildOptions =3D {} + for Options in self.BuildOptions: + if Options[2] !=3D EDKII_NAME: + continue + Family =3D Options[0] + if Family and Family !=3D self.ToolChainFamily: + continue + Target, Tag, Arch, Tool, Attr =3D Options[1].split("_") + if Tool !=3D 'CC': + continue + + if Target =3D=3D "*" or Target =3D=3D self._Target: + if Tag =3D=3D "*" or Tag =3D=3D self._Toolchain: + if Arch =3D=3D "*" or Arch =3D=3D self.Arch: + if Tool not in BuildOptions: + BuildOptions[Tool] =3D {} + if Attr !=3D "FLAGS" or Attr not in BuildOptions[T= ool] or self.BuildOptions[Options].startswith('=3D'): + BuildOptions[Tool][Attr] =3D self.BuildOptions= [Options] + else: + # append options for the same tool except PATH + if Attr !=3D 'PATH': + BuildOptions[Tool][Attr] +=3D " " + self.B= uildOptions[Options] + else: + BuildOptions[Tool][Attr] =3D self.BuildOpt= ions[Options] + if BuildOptions: + for Tool in BuildOptions: + for Attr in BuildOptions[Tool]: + if Attr =3D=3D "FLAGS": + Value =3D BuildOptions[Tool][Attr] + ValueList =3D Value.split() + if ValueList: + for Id, Item in enumerate(ValueList): + if Item =3D=3D '-D' or Item =3D=3D '/D': + CC_FLAGS +=3D ' ' + Item + if Id + 1 < len(ValueList): + CC_FLAGS +=3D ' ' + ValueList[Id += 1] + elif Item.startswith('/D') or Item.startsw= ith('-D'): + CC_FLAGS +=3D ' ' + Item + MakeApp +=3D CC_FLAGS + if sys.platform =3D=3D "win32": MakeApp =3D MakeApp + PcdMakefileEnd MakeFileName =3D os.path.join(self.OutputPath, 'Makefile') File =3D open (MakeFileName, 'w') File.write(MakeApp) @@ -1962,10 +2008,32 @@ class DscBuildData(PlatformBuildClassObject): if FilePath not in self.Modules: Module =3D ModuleBuildClassObject() Module.MetaFile =3D FilePath self.Modules.append(Module) =20 + def _GetToolChainFamily(self): + self._ToolChainFamily =3D "MSFT" + BuildConfigurationFile =3D os.path.normpath(os.path.join(GlobalDat= a.gConfDirectory, "target.txt")) + if os.path.isfile(BuildConfigurationFile) =3D=3D True: + TargetTxt =3D TargetTxtClassObject() + TargetTxt.LoadTargetTxtFile(BuildConfigurationFile) + ToolDefinitionFile =3D TargetTxt.TargetTxtDictionary[DataType.= TAB_TAT_DEFINES_TOOL_CHAIN_CONF] + if ToolDefinitionFile =3D=3D '': + ToolDefinitionFile =3D "tools_def.txt" + ToolDefinitionFile =3D os.path.normpath(mws.join(self.Work= spaceDir, 'Conf', ToolDefinitionFile)) + if os.path.isfile(ToolDefinitionFile) =3D=3D True: + ToolDef =3D ToolDefClassObject() + ToolDef.LoadToolDefFile(ToolDefinitionFile) + ToolDefinition =3D ToolDef.ToolsDefTxtDatabase + if TAB_TOD_DEFINES_FAMILY not in ToolDefinition \ + or self._Toolchain not in ToolDefinition[TAB_TOD_DEFINE= S_FAMILY] \ + or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][self._Too= lchain]: + self._ToolChainFamily =3D "MSFT" + else: + self._ToolChainFamily =3D ToolDefinition[TAB_TOD_DEFIN= ES_FAMILY][self._Toolchain] + return self._ToolChainFamily + ## Add external PCDs # # The external PCDs are mostly those listed in FDF file to specify a= ddress # or offset information. # @@ -2006,5 +2074,6 @@ class DscBuildData(PlatformBuildClassObject): Modules =3D property(_GetModules) LibraryInstances =3D property(_GetLibraryInstances) LibraryClasses =3D property(_GetLibraryClasses) Pcds =3D property(_GetPcds) BuildOptions =3D property(_GetBuildOptions) + ToolChainFamily =3D property(_GetToolChainFamily) --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel