From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 7B3ED222447DF for ; Tue, 26 Dec 2017 18:28:39 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2017 18:33:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,462,1508828400"; d="scan'208";a="15372071" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga003.jf.intel.com with ESMTP; 26 Dec 2017 18:33:33 -0800 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 26 Dec 2017 18:33:33 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 26 Dec 2017 18:33:32 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Wed, 27 Dec 2017 10:33:31 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch] BaseTools: Add Platform Override Build Options for PcdValueInit Thread-Index: AQHTfibtldp4vL/Nx0W8gFdqxG9udqNWedfg Date: Wed, 27 Dec 2017 02:33:30 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E198E92@SHSMSX104.ccr.corp.intel.com> References: <1514278352-5824-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1514278352-5824-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: , X-List-Received-Date: Wed, 27 Dec 2017 02:28:39 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of >Yonghong Zhu >Sent: Tuesday, December 26, 2017 4:53 PM >To: edk2-devel@lists.01.org >Subject: [edk2] [Patch] BaseTools: Add Platform Override Build Options for >PcdValueInit > >Add Platform's CC_FLAGS /D option for PcdValueInit generation. > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Yonghong Zhu >--- > 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 * > > from CommonDataClass.CommonClass import SkuInfoClass >- >+from Common.TargetTxtClassObject import * >+from Common.ToolDefClassObject import * > from MetaDataTable import * > from MetaFileTable import * > from MetaFileParser import * > > from WorkspaceCommon import GetDeclaredPcd >@@ -75,15 +76,15 @@ PcdMakefileHeader =3D ''' > # This file is auto-generated by build utility > # > > ''' > >+WindowsCFLAGS =3D 'CFLAGS =3D $(CFLAGS) /wd4200 /wd4034 /wd4101 ' >+LinuxCFLAGS =3D 'BUILD_CFLAGS +=3D -Wno-pointer-to-int-cast -Wno-unused- >variable ' > PcdMakefileEnd =3D ''' > !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common > >-CFLAGS =3D $(CFLAGS) /wd4200 /wd4034 /wd4101 >- > LIBS =3D $(LIB_PATH)\Common.lib > > !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app > ''' > >@@ -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"), 'Bui= ld', >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' % >(PcdValueInitName) + 'OBJECTS =3D %s\%s.obj\n' % (self.OutputPath, >PcdValueInitName) + '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' + >'BUILD_CFLAGS +=3D -Wno-pointer-to-int-cast -Wno-unused-variable\n' + >'INCLUDE +=3D' >+ 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'I= NCLUDE +=3D' > > 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[= Tool] or >self.BuildOptions[Options].startswith('=3D'): >+ BuildOptions[Tool][Attr] =3D self.BuildOption= s[Options] >+ else: >+ # append options for the same tool except PAT= H >+ if Attr !=3D 'PATH': >+ BuildOptions[Tool][Attr] +=3D " " + self.= BuildOptions[Options] >+ else: >+ BuildOptions[Tool][Attr] =3D self.BuildOp= tions[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.starts= with('-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) > >+ def _GetToolChainFamily(self): >+ self._ToolChainFamily =3D "MSFT" >+ BuildConfigurationFile =3D >os.path.normpath(os.path.join(GlobalData.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_C >ONF] >+ if ToolDefinitionFile =3D=3D '': >+ ToolDefinitionFile =3D "tools_def.txt" >+ ToolDefinitionFile =3D os.path.normpath(mws.join(self.Wor= kspaceDir, >'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_DEFIN= ES_FAMILY] >\ >+ or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][self._To= olchain]: >+ self._ToolChainFamily =3D "MSFT" >+ else: >+ self._ToolChainFamily =3D >ToolDefinition[TAB_TOD_DEFINES_FAMILY][self._Toolchain] >+ return self._ToolChainFamily >+ > ## Add external PCDs > # > # The external PCDs are mostly those listed in FDF file to specify = address > # 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) >-- >2.6.1.windows.1 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel