BaseTools/Source/Python: New Target/ToolChain/Arch in DSC [BuildOptions]
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3359 Update BaseTools to support new build targets, new tool chains, and new architectures declared in DSC file [BuildOptions] sections. * Do not expand * when tools_def.txt is parsed. Only expand when both tools_def.txt and DSC [BuilsOptions] sections have been parsed. This also requires more flexible matching of tool keys that contain * in tool key fields. * Pre-scan the platform DSC file for FAMILY and TOOLCHAIN declarations DSC in [BuildOptions] sections before the FAMILY and TOOLCHAIN need to be known. Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <gaoliming@byosoft.com.cn> Cc: Yuwei Chen <yuwei.chen@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
612edbe6cd
commit
ab957f036f
@ -827,6 +827,33 @@ class PlatformAutoGen(AutoGen):
|
||||
RetVal = RetVal + _SplitOption(Flags.strip())
|
||||
return RetVal
|
||||
|
||||
## Compute a tool defintion key priority value in range 0..15
|
||||
#
|
||||
# TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE 15
|
||||
# ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE 14
|
||||
# TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE 13
|
||||
# ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE 12
|
||||
# TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE 11
|
||||
# ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE 10
|
||||
# TARGET_*********_****_COMMANDTYPE_ATTRIBUTE 9
|
||||
# ******_*********_****_COMMANDTYPE_ATTRIBUTE 8
|
||||
# TARGET_TOOLCHAIN_ARCH_***********_ATTRIBUTE 7
|
||||
# ******_TOOLCHAIN_ARCH_***********_ATTRIBUTE 6
|
||||
# TARGET_*********_ARCH_***********_ATTRIBUTE 5
|
||||
# ******_*********_ARCH_***********_ATTRIBUTE 4
|
||||
# TARGET_TOOLCHAIN_****_***********_ATTRIBUTE 3
|
||||
# ******_TOOLCHAIN_****_***********_ATTRIBUTE 2
|
||||
# TARGET_*********_****_***********_ATTRIBUTE 1
|
||||
# ******_*********_****_***********_ATTRIBUTE 0
|
||||
#
|
||||
def ToolDefinitionPriority (self,Key):
|
||||
KeyList = Key.split('_')
|
||||
Priority = 0
|
||||
for Index in range (0, min(4, len(KeyList))):
|
||||
if KeyList[Index] != '*':
|
||||
Priority += (1 << Index)
|
||||
return Priority
|
||||
|
||||
## Get tool chain definition
|
||||
#
|
||||
# Get each tool definition for given tool chain from tools_def.txt and platform
|
||||
@ -839,8 +866,16 @@ class PlatformAutoGen(AutoGen):
|
||||
ExtraData="[%s]" % self.MetaFile)
|
||||
RetVal = OrderedDict()
|
||||
DllPathList = set()
|
||||
for Def in ToolDefinition:
|
||||
|
||||
PrioritizedDefList = sorted(ToolDefinition.keys(), key=self.ToolDefinitionPriority, reverse=True)
|
||||
for Def in PrioritizedDefList:
|
||||
Target, Tag, Arch, Tool, Attr = Def.split("_")
|
||||
if Target == TAB_STAR:
|
||||
Target = self.BuildTarget
|
||||
if Tag == TAB_STAR:
|
||||
Tag = self.ToolChain
|
||||
if Arch == TAB_STAR:
|
||||
Arch = self.Arch
|
||||
if Target != self.BuildTarget or Tag != self.ToolChain or Arch != self.Arch:
|
||||
continue
|
||||
|
||||
@ -850,9 +885,14 @@ class PlatformAutoGen(AutoGen):
|
||||
DllPathList.add(Value)
|
||||
continue
|
||||
|
||||
#
|
||||
# ToolDefinition is sorted from highest priority to lowest priority.
|
||||
# Only add the first(highest priority) match to RetVal
|
||||
#
|
||||
if Tool not in RetVal:
|
||||
RetVal[Tool] = OrderedDict()
|
||||
RetVal[Tool][Attr] = Value
|
||||
if Attr not in RetVal[Tool]:
|
||||
RetVal[Tool][Attr] = Value
|
||||
|
||||
ToolsDef = ''
|
||||
if GlobalData.gOptions.SilentMode and "MAKE" in RetVal:
|
||||
@ -860,9 +900,21 @@ class PlatformAutoGen(AutoGen):
|
||||
RetVal["MAKE"]["FLAGS"] = ""
|
||||
RetVal["MAKE"]["FLAGS"] += " -s"
|
||||
MakeFlags = ''
|
||||
for Tool in RetVal:
|
||||
for Attr in RetVal[Tool]:
|
||||
Value = RetVal[Tool][Attr]
|
||||
|
||||
ToolList = list(RetVal.keys())
|
||||
ToolList.sort()
|
||||
for Tool in ToolList:
|
||||
if Tool == TAB_STAR:
|
||||
continue
|
||||
AttrList = list(RetVal[Tool].keys())
|
||||
if TAB_STAR in ToolList:
|
||||
AttrList += list(RetVal[TAB_STAR])
|
||||
AttrList.sort()
|
||||
for Attr in AttrList:
|
||||
if Attr in RetVal[Tool]:
|
||||
Value = RetVal[Tool][Attr]
|
||||
else:
|
||||
Value = RetVal[TAB_STAR][Attr]
|
||||
if Tool in self._BuildOptionWithToolDef(RetVal) and Attr in self._BuildOptionWithToolDef(RetVal)[Tool]:
|
||||
# check if override is indicated
|
||||
if self._BuildOptionWithToolDef(RetVal)[Tool][Attr].startswith('='):
|
||||
@ -877,7 +929,7 @@ class PlatformAutoGen(AutoGen):
|
||||
if Attr == "PATH":
|
||||
# Don't put MAKE definition in the file
|
||||
if Tool != "MAKE":
|
||||
ToolsDef += "%s = %s\n" % (Tool, Value)
|
||||
ToolsDef += "%s_%s = %s\n" % (Tool, Attr, Value)
|
||||
elif Attr != "DLL":
|
||||
# Don't put MAKE definition in the file
|
||||
if Tool == "MAKE":
|
||||
@ -1469,17 +1521,31 @@ class PlatformAutoGen(AutoGen):
|
||||
Family = Key[0]
|
||||
Target, Tag, Arch, Tool, Attr = Key[1].split("_")
|
||||
# if tool chain family doesn't match, skip it
|
||||
if Tool in ToolDef and Family != "":
|
||||
FamilyIsNull = False
|
||||
if ToolDef[Tool].get(TAB_TOD_DEFINES_BUILDRULEFAMILY, "") != "":
|
||||
if Family != ToolDef[Tool][TAB_TOD_DEFINES_BUILDRULEFAMILY]:
|
||||
continue
|
||||
else:
|
||||
if ToolDef[Tool].get(TAB_TOD_DEFINES_FAMILY, "") == "":
|
||||
continue
|
||||
if Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
|
||||
continue
|
||||
FamilyMatch = True
|
||||
if Family != "":
|
||||
Found = False
|
||||
if Tool in ToolDef:
|
||||
FamilyIsNull = False
|
||||
if TAB_TOD_DEFINES_BUILDRULEFAMILY in ToolDef[Tool]:
|
||||
if Family == ToolDef[Tool][TAB_TOD_DEFINES_BUILDRULEFAMILY]:
|
||||
FamilyMatch = True
|
||||
Found = True
|
||||
if TAB_TOD_DEFINES_FAMILY in ToolDef[Tool]:
|
||||
if Family == ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
|
||||
FamilyMatch = True
|
||||
Found = True
|
||||
if TAB_STAR in ToolDef:
|
||||
FamilyIsNull = False
|
||||
if TAB_TOD_DEFINES_BUILDRULEFAMILY in ToolDef[TAB_STAR]:
|
||||
if Family == ToolDef[TAB_STAR][TAB_TOD_DEFINES_BUILDRULEFAMILY]:
|
||||
FamilyMatch = True
|
||||
Found = True
|
||||
if TAB_TOD_DEFINES_FAMILY in ToolDef[TAB_STAR]:
|
||||
if Family == ToolDef[TAB_STAR][TAB_TOD_DEFINES_FAMILY]:
|
||||
FamilyMatch = True
|
||||
Found = True
|
||||
if not Found:
|
||||
continue
|
||||
|
||||
# expand any wildcard
|
||||
if Target == TAB_STAR or Target == self.BuildTarget:
|
||||
if Tag == TAB_STAR or Tag == self.ToolChain:
|
||||
@ -1509,12 +1575,19 @@ class PlatformAutoGen(AutoGen):
|
||||
Family = Key[0]
|
||||
Target, Tag, Arch, Tool, Attr = Key[1].split("_")
|
||||
# if tool chain family doesn't match, skip it
|
||||
if Tool not in ToolDef or Family == "":
|
||||
if Family == "":
|
||||
continue
|
||||
# option has been added before
|
||||
if TAB_TOD_DEFINES_FAMILY not in ToolDef[Tool]:
|
||||
continue
|
||||
if Family != ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
|
||||
Found = False
|
||||
if Tool in ToolDef:
|
||||
if TAB_TOD_DEFINES_FAMILY in ToolDef[Tool]:
|
||||
if Family == ToolDef[Tool][TAB_TOD_DEFINES_FAMILY]:
|
||||
Found = True
|
||||
if TAB_STAR in ToolDef:
|
||||
if TAB_TOD_DEFINES_FAMILY in ToolDef[TAB_STAR]:
|
||||
if Family == ToolDef[TAB_STAR][TAB_TOD_DEFINES_FAMILY]:
|
||||
Found = True
|
||||
if not Found:
|
||||
continue
|
||||
|
||||
# expand any wildcard
|
||||
|
Reference in New Issue
Block a user