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.93; helo=mga11.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org 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 B33A621189FB9 for ; Fri, 2 Nov 2018 07:37:17 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2018 07:37:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,456,1534834800"; d="scan'208";a="88992789" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga008.jf.intel.com with ESMTP; 02 Nov 2018 07:37:16 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 2 Nov 2018 07:37:16 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 2 Nov 2018 07:37:15 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.214]) with mapi id 14.03.0415.000; Fri, 2 Nov 2018 22:37:14 +0800 From: "Gao, Liming" To: "Feng, Bob C" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch V3] BaseTools: Use common cc flag for building PcdValueInit. Thread-Index: AQHUcnDho6NDFjDMZ0yDvTA8c3l/cKU8ji+g Date: Fri, 2 Nov 2018 14:37:13 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E36401B@SHSMSX104.ccr.corp.intel.com> References: <20181102055638.49172-1-bob.c.feng@intel.com> In-Reply-To: <20181102055638.49172-1-bob.c.feng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNGVmYTYxZGItMDVmZC00NDE4LTk3MjYtMmQzY2M5ZjYyMDYxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiY0FuK3p6V0hmM0I0Y3p4SWQ1bm1MZmRcL0VjYTFwQjZCQTZ3S1JoMUl1VmVBTVFSYkJhdkUzMDRxWlwveml4aEw2In0= dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch V3] BaseTools: Use common cc flag for building PcdValueInit. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Nov 2018 14:37:17 -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 Bo= bCF > Sent: Friday, November 2, 2018 1:57 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [edk2] [Patch V3] BaseTools: Use common cc flag for building Pcd= ValueInit. >=20 > V3: >=20 > Update the patch to avoid "reduce" function fail. >=20 > V2: > Support to extract the common cc flag from a > combined cc flag string. For example > MSFT:*_*_IA32_CC_FLAGS =3D /D DISABLE_NEW_DEPRECATED_INTERFACES /DDEF_IA3= 2 > MSFT:*_*_X64_CC_FLAGS =3D /DDEF_X64 /D DISABLE_NEW_DEPRECATED_INTERFACES >=20 > V1: > Use common cc flags for building PcdValueInit. The common > cc flags include the cc flag which is under common arch and > under all build arches. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Bob Feng > Cc: Liming Gao > --- > .../Source/Python/Workspace/DscBuildData.py | 55 +++++++++++-------- > 1 file changed, 31 insertions(+), 24 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTool= s/Source/Python/Workspace/DscBuildData.py > index 6d596b2b54..11aa63fb26 100644 > --- a/BaseTools/Source/Python/Workspace/DscBuildData.py > +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py > @@ -2182,10 +2182,23 @@ class DscBuildData(PlatformBuildClassObject): > for key in OverrideValues: > if OverrideValues[key]: > return False > return True >=20 > + def ParseCCFlags(self, ccflag): > + ccflags =3D set() > + flag =3D "" > + for ch in ccflag: > + if ch in (r"/", "-"): > + if flag.strip(): > + ccflags.add(flag.strip()) > + flag =3D ch > + else: > + flag +=3D ch > + if flag.strip(): > + ccflags.add(flag.strip()) > + return ccflags > def GenerateByteArrayValue (self, StructuredPcds): > # > # Generate/Compile/Run C application to determine if there are a= ny flexible array members > # > if not StructuredPcds: > @@ -2298,38 +2311,32 @@ class DscBuildData(PlatformBuildClassObject): > if Family and Family !=3D self.ToolChainFamily: > continue > Target, Tag, Arch, Tool, Attr =3D Options[1].split("_") > if Tool !=3D 'CC': > continue > - > + if Attr !=3D "FLAGS": > + continue > if Target =3D=3D "*" or Target =3D=3D self._Target: > if Tag =3D=3D "*" or Tag =3D=3D self._Toolchain: > + if 'COMMON' not in BuildOptions: > + BuildOptions['COMMON'] =3D set() > if Arch =3D=3D "*": > - if Tool not in BuildOptions: > - BuildOptions[Tool] =3D OrderedDict() > - if Attr !=3D "FLAGS" or Attr not in BuildOptions= [Tool] or self.BuildOptions[Options].startswith('=3D'): > - BuildOptions[Tool][Attr] =3D self.BuildOptio= ns[Options] > - else: > - # append options for the same tool except PA= TH > - if Attr !=3D 'PATH': > - BuildOptions[Tool][Attr] +=3D " " + self= .BuildOptions[Options] > - else: > - BuildOptions[Tool][Attr] =3D self.BuildO= ptions[Options] > + BuildOptions['COMMON'].add(self.BuildOptions[Opt= ions]) > + if Arch in self.SupArchList: > + if Arch not in BuildOptions: > + BuildOptions[Arch] =3D set() > + BuildOptions[Arch] |=3D self.ParseCCFlags(self.B= uildOptions[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 in ['-D', '/D', '-U', '/U']: > - CC_FLAGS +=3D ' ' + Item > - if Id + 1 < len(ValueList): > - CC_FLAGS +=3D ' ' + ValueList[Id= + 1] > - elif Item.startswith(('-D', '/D', '-U', = '/U')): > - CC_FLAGS +=3D ' ' + Item > + ArchBuildOptions =3D {arch:flags for arch,flags in BuildOpti= ons.items() if arch !=3D 'COMMON'} > + if len(ArchBuildOptions.keys()) =3D=3D 1: > + BuildOptions['COMMON'] |=3D (ArchBuildOptions.values()[0= ]) > + elif len(ArchBuildOptions.keys()) > 1: > + CommonBuildOptions =3D reduce(lambda x,y: x&y, ArchBuild= Options.values()) > + BuildOptions['COMMON'] |=3D CommonBuildOptions > + ValueList =3D list(BuildOptions['COMMON']) > + CC_FLAGS +=3D " ".join([item for item in ValueList if item.s= tartswith(('-D', '/D', '-U', '/U'))]) > MakeApp +=3D CC_FLAGS >=20 > if sys.platform =3D=3D "win32": > MakeApp =3D MakeApp + PcdMakefileEnd > MakeApp =3D MakeApp + AppTarget % ("""\tcopy $(APPLICATION) = $(APPFILE) /y """) > -- > 2.18.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel