From: "Gao, Liming" <liming.gao@intel.com>
To: "Feng, Bob C" <bob.c.feng@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [Patch V3] BaseTools: Use common cc flag for building PcdValueInit.
Date: Fri, 2 Nov 2018 14:37:13 +0000 [thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E36401B@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20181102055638.49172-1-bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of BobCF
> Sent: Friday, November 2, 2018 1:57 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [Patch V3] BaseTools: Use common cc flag for building PcdValueInit.
>
> V3:
>
> Update the patch to avoid "reduce" function fail.
>
> V2:
> Support to extract the common cc flag from a
> combined cc flag string. For example
> MSFT:*_*_IA32_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES /DDEF_IA32
> MSFT:*_*_X64_CC_FLAGS = /DDEF_X64 /D DISABLE_NEW_DEPRECATED_INTERFACES
>
> 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.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> ---
> .../Source/Python/Workspace/DscBuildData.py | 55 +++++++++++--------
> 1 file changed, 31 insertions(+), 24 deletions(-)
>
> diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/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
>
> + def ParseCCFlags(self, ccflag):
> + ccflags = set()
> + flag = ""
> + for ch in ccflag:
> + if ch in (r"/", "-"):
> + if flag.strip():
> + ccflags.add(flag.strip())
> + flag = ch
> + else:
> + flag += ch
> + if flag.strip():
> + ccflags.add(flag.strip())
> + return ccflags
> def GenerateByteArrayValue (self, StructuredPcds):
> #
> # Generate/Compile/Run C application to determine if there are any flexible array members
> #
> if not StructuredPcds:
> @@ -2298,38 +2311,32 @@ class DscBuildData(PlatformBuildClassObject):
> if Family and Family != self.ToolChainFamily:
> continue
> Target, Tag, Arch, Tool, Attr = Options[1].split("_")
> if Tool != 'CC':
> continue
> -
> + if Attr != "FLAGS":
> + continue
> if Target == "*" or Target == self._Target:
> if Tag == "*" or Tag == self._Toolchain:
> + if 'COMMON' not in BuildOptions:
> + BuildOptions['COMMON'] = set()
> if Arch == "*":
> - if Tool not in BuildOptions:
> - BuildOptions[Tool] = OrderedDict()
> - if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or self.BuildOptions[Options].startswith('='):
> - BuildOptions[Tool][Attr] = self.BuildOptions[Options]
> - else:
> - # append options for the same tool except PATH
> - if Attr != 'PATH':
> - BuildOptions[Tool][Attr] += " " + self.BuildOptions[Options]
> - else:
> - BuildOptions[Tool][Attr] = self.BuildOptions[Options]
> + BuildOptions['COMMON'].add(self.BuildOptions[Options])
> + if Arch in self.SupArchList:
> + if Arch not in BuildOptions:
> + BuildOptions[Arch] = set()
> + BuildOptions[Arch] |= self.ParseCCFlags(self.BuildOptions[Options])
> +
> if BuildOptions:
> - for Tool in BuildOptions:
> - for Attr in BuildOptions[Tool]:
> - if Attr == "FLAGS":
> - Value = BuildOptions[Tool][Attr]
> - ValueList = Value.split()
> - if ValueList:
> - for Id, Item in enumerate(ValueList):
> - if Item in ['-D', '/D', '-U', '/U']:
> - CC_FLAGS += ' ' + Item
> - if Id + 1 < len(ValueList):
> - CC_FLAGS += ' ' + ValueList[Id + 1]
> - elif Item.startswith(('-D', '/D', '-U', '/U')):
> - CC_FLAGS += ' ' + Item
> + ArchBuildOptions = {arch:flags for arch,flags in BuildOptions.items() if arch != 'COMMON'}
> + if len(ArchBuildOptions.keys()) == 1:
> + BuildOptions['COMMON'] |= (ArchBuildOptions.values()[0])
> + elif len(ArchBuildOptions.keys()) > 1:
> + CommonBuildOptions = reduce(lambda x,y: x&y, ArchBuildOptions.values())
> + BuildOptions['COMMON'] |= CommonBuildOptions
> + ValueList = list(BuildOptions['COMMON'])
> + CC_FLAGS += " ".join([item for item in ValueList if item.startswith(('-D', '/D', '-U', '/U'))])
> MakeApp += CC_FLAGS
>
> if sys.platform == "win32":
> MakeApp = MakeApp + PcdMakefileEnd
> MakeApp = MakeApp + AppTarget % ("""\tcopy $(APPLICATION) $(APPFILE) /y """)
> --
> 2.18.0.windows.1
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
prev parent reply other threads:[~2018-11-02 14:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-02 5:56 [Patch V3] BaseTools: Use common cc flag for building PcdValueInit BobCF
2018-11-02 14:37 ` Gao, Liming [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E36401B@SHSMSX104.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox