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> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
@ -2184,6 +2184,19 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
return False
|
return False
|
||||||
return True
|
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):
|
def GenerateByteArrayValue (self, StructuredPcds):
|
||||||
#
|
#
|
||||||
# Generate/Compile/Run C application to determine if there are any flexible array members
|
# Generate/Compile/Run C application to determine if there are any flexible array members
|
||||||
@ -2300,34 +2313,28 @@ class DscBuildData(PlatformBuildClassObject):
|
|||||||
Target, Tag, Arch, Tool, Attr = Options[1].split("_")
|
Target, Tag, Arch, Tool, Attr = Options[1].split("_")
|
||||||
if Tool != 'CC':
|
if Tool != 'CC':
|
||||||
continue
|
continue
|
||||||
|
if Attr != "FLAGS":
|
||||||
|
continue
|
||||||
if Target == "*" or Target == self._Target:
|
if Target == "*" or Target == self._Target:
|
||||||
if Tag == "*" or Tag == self._Toolchain:
|
if Tag == "*" or Tag == self._Toolchain:
|
||||||
|
if 'COMMON' not in BuildOptions:
|
||||||
|
BuildOptions['COMMON'] = set()
|
||||||
if Arch == "*":
|
if Arch == "*":
|
||||||
if Tool not in BuildOptions:
|
BuildOptions['COMMON'].add(self.BuildOptions[Options])
|
||||||
BuildOptions[Tool] = OrderedDict()
|
if Arch in self.SupArchList:
|
||||||
if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or self.BuildOptions[Options].startswith('='):
|
if Arch not in BuildOptions:
|
||||||
BuildOptions[Tool][Attr] = self.BuildOptions[Options]
|
BuildOptions[Arch] = set()
|
||||||
else:
|
BuildOptions[Arch] |= self.ParseCCFlags(self.BuildOptions[Options])
|
||||||
# append options for the same tool except PATH
|
|
||||||
if Attr != 'PATH':
|
|
||||||
BuildOptions[Tool][Attr] += " " + self.BuildOptions[Options]
|
|
||||||
else:
|
|
||||||
BuildOptions[Tool][Attr] = self.BuildOptions[Options]
|
|
||||||
if BuildOptions:
|
if BuildOptions:
|
||||||
for Tool in BuildOptions:
|
ArchBuildOptions = {arch:flags for arch,flags in BuildOptions.items() if arch != 'COMMON'}
|
||||||
for Attr in BuildOptions[Tool]:
|
if len(ArchBuildOptions.keys()) == 1:
|
||||||
if Attr == "FLAGS":
|
BuildOptions['COMMON'] |= (ArchBuildOptions.values()[0])
|
||||||
Value = BuildOptions[Tool][Attr]
|
elif len(ArchBuildOptions.keys()) > 1:
|
||||||
ValueList = Value.split()
|
CommonBuildOptions = reduce(lambda x,y: x&y, ArchBuildOptions.values())
|
||||||
if ValueList:
|
BuildOptions['COMMON'] |= CommonBuildOptions
|
||||||
for Id, Item in enumerate(ValueList):
|
ValueList = list(BuildOptions['COMMON'])
|
||||||
if Item in ['-D', '/D', '-U', '/U']:
|
CC_FLAGS += " ".join([item for item in ValueList if item.startswith(('-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
|
|
||||||
MakeApp += CC_FLAGS
|
MakeApp += CC_FLAGS
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
|
Reference in New Issue
Block a user