2 # Create makefile for MS nmake and GNU make
4 # Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
7 from __future__
import absolute_import
8 from Workspace
.WorkspaceDatabase
import WorkspaceDatabase
,BuildDB
9 from Common
.caching
import cached_property
10 from AutoGen
.BuildEngine
import BuildRule
,AutoGenReqBuildRuleVerNum
11 from AutoGen
.AutoGen
import CalculatePriorityValue
12 from Common
.Misc
import CheckPcdDatum
,GuidValue
13 from Common
.Expression
import ValueExpressionEx
14 from Common
.DataType
import *
15 from CommonDataClass
.Exceptions
import *
16 from CommonDataClass
.CommonClass
import SkuInfoClass
17 import Common
.EdkLogger
as EdkLogger
18 from Common
.BuildToolError
import OPTION_CONFLICT
,FORMAT_INVALID
,RESOURCE_NOT_AVAILABLE
19 from Common
.MultipleWorkspace
import MultipleWorkspace
as mws
20 from collections
import defaultdict
21 from Common
.Misc
import PathClass
26 # The priority list while override build option
28 PrioList
= {"0x11111" : 16, # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE (Highest)
29 "0x01111" : 15, # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
30 "0x10111" : 14, # TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE
31 "0x00111" : 13, # ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE
32 "0x11011" : 12, # TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE
33 "0x01011" : 11, # ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE
34 "0x10011" : 10, # TARGET_*********_****_COMMANDTYPE_ATTRIBUTE
35 "0x00011" : 9, # ******_*********_****_COMMANDTYPE_ATTRIBUTE
36 "0x11101" : 8, # TARGET_TOOLCHAIN_ARCH_***********_ATTRIBUTE
37 "0x01101" : 7, # ******_TOOLCHAIN_ARCH_***********_ATTRIBUTE
38 "0x10101" : 6, # TARGET_*********_ARCH_***********_ATTRIBUTE
39 "0x00101" : 5, # ******_*********_ARCH_***********_ATTRIBUTE
40 "0x11001" : 4, # TARGET_TOOLCHAIN_****_***********_ATTRIBUTE
41 "0x01001" : 3, # ******_TOOLCHAIN_****_***********_ATTRIBUTE
42 "0x10001" : 2, # TARGET_*********_****_***********_ATTRIBUTE
43 "0x00001" : 1} # ******_*********_****_***********_ATTRIBUTE (Lowest)
44 ## Base class for AutoGen
46 # This class just implements the cache mechanism of AutoGen objects.
48 class AutoGenInfo(object):
49 # database to maintain the objects in each child class
50 __ObjectCache
= {} # (BuildTarget, ToolChain, ARCH, platform file): AutoGen object
54 # @param Class class object of real AutoGen class
55 # (WorkspaceAutoGen, ModuleAutoGen or PlatformAutoGen)
56 # @param Workspace Workspace directory or WorkspaceAutoGen object
57 # @param MetaFile The path of meta file
58 # @param Target Build target
59 # @param Toolchain Tool chain name
60 # @param Arch Target arch
61 # @param *args The specific class related parameters
62 # @param **kwargs The specific class related dict parameters
66 return cls
.__ObjectCache
67 def __new__(cls
, Workspace
, MetaFile
, Target
, Toolchain
, Arch
, *args
, **kwargs
):
68 # check if the object has been created
69 Key
= (Target
, Toolchain
, Arch
, MetaFile
)
70 if Key
in cls
.__ObjectCache
:
71 # if it exists, just return it directly
72 return cls
.__ObjectCache
[Key
]
73 # it didnt exist. create it, cache it, then return it
74 RetVal
= cls
.__ObjectCache
[Key
] = super(AutoGenInfo
, cls
).__new
__(cls
)
80 # The file path of platform file will be used to represent hash value of this object
82 # @retval int Hash value of the file path of platform file
85 return hash(self
.MetaFile
)
89 # The file path of platform file will be used to represent this object
91 # @retval string String of platform file path
94 return str(self
.MetaFile
)
97 def __eq__(self
, Other
):
98 return Other
and self
.MetaFile
== Other
100 ## Expand * in build option key
102 # @param Options Options to be expanded
103 # @param ToolDef Use specified ToolDef instead of full version.
104 # This is needed during initialization to prevent
105 # infinite recursion betweeh BuildOptions,
106 # ToolDefinition, and this function.
108 # @retval options Options expanded
110 def _ExpandBuildOption(self
, Options
, ModuleStyle
=None, ToolDef
=None):
112 ToolDef
= self
.ToolDefinition
119 # Construct a list contain the build options which need override.
123 # Key[0] -- tool family
124 # Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
126 if (Key
[0] == self
.BuildRuleFamily
and
127 (ModuleStyle
is None or len(Key
) < 3 or (len(Key
) > 2 and Key
[2] == ModuleStyle
))):
128 Target
, ToolChain
, Arch
, CommandType
, Attr
= Key
[1].split('_')
129 if (Target
== self
.BuildTarget
or Target
== TAB_STAR
) and\
130 (ToolChain
== self
.ToolChain
or ToolChain
== TAB_STAR
) and\
131 (Arch
== self
.Arch
or Arch
== TAB_STAR
) and\
132 Options
[Key
].startswith("="):
134 if OverrideList
.get(Key
[1]) is not None:
135 OverrideList
.pop(Key
[1])
136 OverrideList
[Key
[1]] = Options
[Key
]
139 # Use the highest priority value.
141 if (len(OverrideList
) >= 2):
142 KeyList
= list(OverrideList
.keys())
143 for Index
in range(len(KeyList
)):
144 NowKey
= KeyList
[Index
]
145 Target1
, ToolChain1
, Arch1
, CommandType1
, Attr1
= NowKey
.split("_")
146 for Index1
in range(len(KeyList
) - Index
- 1):
147 NextKey
= KeyList
[Index1
+ Index
+ 1]
149 # Compare two Key, if one is included by another, choose the higher priority one
151 Target2
, ToolChain2
, Arch2
, CommandType2
, Attr2
= NextKey
.split("_")
152 if (Target1
== Target2
or Target1
== TAB_STAR
or Target2
== TAB_STAR
) and\
153 (ToolChain1
== ToolChain2
or ToolChain1
== TAB_STAR
or ToolChain2
== TAB_STAR
) and\
154 (Arch1
== Arch2
or Arch1
== TAB_STAR
or Arch2
== TAB_STAR
) and\
155 (CommandType1
== CommandType2
or CommandType1
== TAB_STAR
or CommandType2
== TAB_STAR
) and\
156 (Attr1
== Attr2
or Attr1
== TAB_STAR
or Attr2
== TAB_STAR
):
158 if CalculatePriorityValue(NowKey
) > CalculatePriorityValue(NextKey
):
159 if Options
.get((self
.BuildRuleFamily
, NextKey
)) is not None:
160 Options
.pop((self
.BuildRuleFamily
, NextKey
))
162 if Options
.get((self
.BuildRuleFamily
, NowKey
)) is not None:
163 Options
.pop((self
.BuildRuleFamily
, NowKey
))
166 if ModuleStyle
is not None and len (Key
) > 2:
167 # Check Module style is EDK or EDKII.
168 # Only append build option for the matched style module.
169 if ModuleStyle
== EDK_NAME
and Key
[2] != EDK_NAME
:
171 elif ModuleStyle
== EDKII_NAME
and Key
[2] != EDKII_NAME
:
174 Target
, Tag
, Arch
, Tool
, Attr
= Key
[1].split("_")
175 # if tool chain family doesn't match, skip it
180 if TAB_TOD_DEFINES_BUILDRULEFAMILY
in ToolDef
[Tool
]:
181 if Family
== ToolDef
[Tool
][TAB_TOD_DEFINES_BUILDRULEFAMILY
]:
184 if TAB_STAR
in ToolDef
:
186 if TAB_TOD_DEFINES_BUILDRULEFAMILY
in ToolDef
[TAB_STAR
]:
187 if Family
== ToolDef
[TAB_STAR
][TAB_TOD_DEFINES_BUILDRULEFAMILY
]:
192 # expand any wildcard
193 if Target
== TAB_STAR
or Target
== self
.BuildTarget
:
194 if Tag
== TAB_STAR
or Tag
== self
.ToolChain
:
195 if Arch
== TAB_STAR
or Arch
== self
.Arch
:
196 if Tool
not in BuildOptions
:
197 BuildOptions
[Tool
] = {}
198 if Attr
!= "FLAGS" or Attr
not in BuildOptions
[Tool
] or Options
[Key
].startswith('='):
199 BuildOptions
[Tool
][Attr
] = Options
[Key
]
201 # append options for the same tool except PATH
203 BuildOptions
[Tool
][Attr
] += " " + Options
[Key
]
205 BuildOptions
[Tool
][Attr
] = Options
[Key
]
206 # Build Option Family has been checked, which need't to be checked again for family.
207 if FamilyMatch
or FamilyIsNull
:
211 if ModuleStyle
is not None and len (Key
) > 2:
212 # Check Module style is EDK or EDKII.
213 # Only append build option for the matched style module.
214 if ModuleStyle
== EDK_NAME
and Key
[2] != EDK_NAME
:
216 elif ModuleStyle
== EDKII_NAME
and Key
[2] != EDKII_NAME
:
219 Target
, Tag
, Arch
, Tool
, Attr
= Key
[1].split("_")
220 # if tool chain family doesn't match, skip it
223 # option has been added before
226 if TAB_TOD_DEFINES_FAMILY
in ToolDef
[Tool
]:
227 if Family
== ToolDef
[Tool
][TAB_TOD_DEFINES_FAMILY
]:
229 if TAB_STAR
in ToolDef
:
230 if TAB_TOD_DEFINES_FAMILY
in ToolDef
[TAB_STAR
]:
231 if Family
== ToolDef
[TAB_STAR
][TAB_TOD_DEFINES_FAMILY
]:
236 # expand any wildcard
237 if Target
== TAB_STAR
or Target
== self
.BuildTarget
:
238 if Tag
== TAB_STAR
or Tag
== self
.ToolChain
:
239 if Arch
== TAB_STAR
or Arch
== self
.Arch
:
240 if Tool
not in BuildOptions
:
241 BuildOptions
[Tool
] = {}
242 if Attr
!= "FLAGS" or Attr
not in BuildOptions
[Tool
] or Options
[Key
].startswith('='):
243 BuildOptions
[Tool
][Attr
] = Options
[Key
]
245 # append options for the same tool except PATH
247 BuildOptions
[Tool
][Attr
] += " " + Options
[Key
]
249 BuildOptions
[Tool
][Attr
] = Options
[Key
]
252 #This class is the pruned WorkSpaceAutoGen for ModuleAutoGen in multiple thread
254 class WorkSpaceInfo(AutoGenInfo
):
255 def __init__(self
,Workspace
, MetaFile
, Target
, ToolChain
, Arch
):
256 if not hasattr(self
, "_Init"):
257 self
.do_init(Workspace
, MetaFile
, Target
, ToolChain
, Arch
)
259 def do_init(self
,Workspace
, MetaFile
, Target
, ToolChain
, Arch
):
260 self
._SrcTimeStamp
= 0
262 self
.BuildDatabase
= self
.Db
.BuildObject
264 self
.ToolChain
= ToolChain
265 self
.WorkspaceDir
= Workspace
266 self
.ActivePlatform
= MetaFile
268 self
.AutoGenObjectList
= []
271 return self
.AutoGenObjectList
[0].BuildDir
275 return self
.AutoGenObjectList
[0].Platform
.PlatformName
278 def FlashDefinition(self
):
279 return self
.AutoGenObjectList
[0].Platform
.FlashDefinition
281 def GenFdsCommandDict(self
):
282 FdsCommandDict
= self
.AutoGenObjectList
[0].DataPipe
.Get("FdsCommandDict")
284 return FdsCommandDict
289 return os
.path
.join(self
.BuildDir
, TAB_FV_DIRECTORY
)
291 class PlatformInfo(AutoGenInfo
):
292 def __init__(self
, Workspace
, MetaFile
, Target
, ToolChain
, Arch
,DataPipe
):
293 if not hasattr(self
, "_Init"):
294 self
.do_init(Workspace
, MetaFile
, Target
, ToolChain
, Arch
,DataPipe
)
296 def do_init(self
,Workspace
, MetaFile
, Target
, ToolChain
, Arch
,DataPipe
):
298 self
.WorkspaceDir
= self
.Wa
.WorkspaceDir
299 self
.MetaFile
= MetaFile
302 self
.BuildTarget
= Target
303 self
.ToolChain
= ToolChain
304 self
.Platform
= self
.Wa
.BuildDatabase
[self
.MetaFile
, self
.Arch
, self
.Target
, self
.ToolChain
]
306 self
.SourceDir
= MetaFile
.SubDir
307 self
.DataPipe
= DataPipe
309 def _AsBuildModuleList(self
):
310 retVal
= self
.DataPipe
.Get("AsBuildModuleList")
315 ## Test if a module is supported by the platform
317 # An error will be raised directly if the module or its arch is not supported
318 # by the platform or current configuration
320 def ValidModule(self
, Module
):
321 return Module
in self
.Platform
.Modules
or Module
in self
.Platform
.LibraryInstances \
322 or Module
in self
._AsBuildModuleList
325 def ToolChainFamily(self
):
326 retVal
= self
.DataPipe
.Get("ToolChainFamily")
332 def BuildRuleFamily(self
):
333 retVal
= self
.DataPipe
.Get("BuildRuleFamily")
340 return [self
.Wa
.BuildDatabase
[m
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
] for m
in self
.Platform
.Modules
]
343 def PackageList(self
):
345 for dec_file
,Arch
in self
.DataPipe
.Get("PackageList"):
346 RetVal
.add(self
.Wa
.BuildDatabase
[dec_file
,Arch
,self
.BuildTarget
, self
.ToolChain
])
349 ## Return the directory to store all intermediate and final files built
352 if os
.path
.isabs(self
.OutputDir
):
353 RetVal
= os
.path
.join(
354 os
.path
.abspath(self
.OutputDir
),
355 self
.Target
+ "_" + self
.ToolChain
,
358 RetVal
= os
.path
.join(
361 self
.Target
+ "_" + self
.ToolChain
,
365 ## Return the build output directory platform specifies
368 return self
.Platform
.OutputDirectory
370 ## Return platform name
373 return self
.Platform
.PlatformName
375 ## Return meta-file GUID
378 return self
.Platform
.Guid
380 ## Return platform version
383 return self
.Platform
.Version
385 ## Return paths of tools
387 def ToolDefinition(self
):
388 retVal
= self
.DataPipe
.Get("TOOLDEF")
393 ## Return build command string
395 # @retval string Build command string
398 def BuildCommand(self
):
399 retVal
= self
.DataPipe
.Get("BuildCommand")
405 def PcdTokenNumber(self
):
406 retVal
= self
.DataPipe
.Get("PCD_TNUM")
411 ## Override PCD setting (type, value, ...)
413 # @param ToPcd The PCD to be overridden
414 # @param FromPcd The PCD overriding from
416 def _OverridePcd(self
, ToPcd
, FromPcd
, Module
="", Msg
="", Library
=""):
418 # in case there's PCDs coming from FDF file, which have no type given.
419 # at this point, ToPcd.Type has the type found from dependent
422 TokenCName
= ToPcd
.TokenCName
423 for PcdItem
in self
.MixedPcd
:
424 if (ToPcd
.TokenCName
, ToPcd
.TokenSpaceGuidCName
) in self
.MixedPcd
[PcdItem
]:
425 TokenCName
= PcdItem
[0]
427 if FromPcd
is not None:
428 if ToPcd
.Pending
and FromPcd
.Type
:
429 ToPcd
.Type
= FromPcd
.Type
430 elif ToPcd
.Type
and FromPcd
.Type\
431 and ToPcd
.Type
!= FromPcd
.Type
and ToPcd
.Type
in FromPcd
.Type
:
432 if ToPcd
.Type
.strip() == TAB_PCDS_DYNAMIC_EX
:
433 ToPcd
.Type
= FromPcd
.Type
434 elif ToPcd
.Type
and FromPcd
.Type \
435 and ToPcd
.Type
!= FromPcd
.Type
:
437 Module
= str(Module
) + " 's library file (" + str(Library
) + ")"
438 EdkLogger
.error("build", OPTION_CONFLICT
, "Mismatched PCD type",
439 ExtraData
="%s.%s is used as [%s] in module %s, but as [%s] in %s."\
440 % (ToPcd
.TokenSpaceGuidCName
, TokenCName
,
441 ToPcd
.Type
, Module
, FromPcd
.Type
, Msg
),
444 if FromPcd
.MaxDatumSize
:
445 ToPcd
.MaxDatumSize
= FromPcd
.MaxDatumSize
446 ToPcd
.MaxSizeUserSet
= FromPcd
.MaxDatumSize
447 if FromPcd
.DefaultValue
:
448 ToPcd
.DefaultValue
= FromPcd
.DefaultValue
449 if FromPcd
.TokenValue
:
450 ToPcd
.TokenValue
= FromPcd
.TokenValue
451 if FromPcd
.DatumType
:
452 ToPcd
.DatumType
= FromPcd
.DatumType
453 if FromPcd
.SkuInfoList
:
454 ToPcd
.SkuInfoList
= FromPcd
.SkuInfoList
455 if FromPcd
.UserDefinedDefaultStoresFlag
:
456 ToPcd
.UserDefinedDefaultStoresFlag
= FromPcd
.UserDefinedDefaultStoresFlag
457 # Add Flexible PCD format parse
458 if ToPcd
.DefaultValue
:
460 ToPcd
.DefaultValue
= ValueExpressionEx(ToPcd
.DefaultValue
, ToPcd
.DatumType
, self
._GuidDict
)(True)
461 except BadExpression
as Value
:
462 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %(ToPcd
.TokenSpaceGuidCName
, ToPcd
.TokenCName
, ToPcd
.DefaultValue
, Value
),
465 # check the validation of datum
466 IsValid
, Cause
= CheckPcdDatum(ToPcd
.DatumType
, ToPcd
.DefaultValue
)
468 EdkLogger
.error('build', FORMAT_INVALID
, Cause
, File
=self
.MetaFile
,
469 ExtraData
="%s.%s" % (ToPcd
.TokenSpaceGuidCName
, TokenCName
))
470 ToPcd
.validateranges
= FromPcd
.validateranges
471 ToPcd
.validlists
= FromPcd
.validlists
472 ToPcd
.expressions
= FromPcd
.expressions
473 ToPcd
.CustomAttribute
= FromPcd
.CustomAttribute
475 if FromPcd
is not None and ToPcd
.DatumType
== TAB_VOID
and not ToPcd
.MaxDatumSize
:
476 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "No MaxDatumSize specified for PCD %s.%s" \
477 % (ToPcd
.TokenSpaceGuidCName
, TokenCName
))
478 Value
= ToPcd
.DefaultValue
480 ToPcd
.MaxDatumSize
= '1'
481 elif Value
[0] == 'L':
482 ToPcd
.MaxDatumSize
= str((len(Value
) - 2) * 2)
483 elif Value
[0] == '{':
484 ToPcd
.MaxDatumSize
= str(len(Value
.split(',')))
486 ToPcd
.MaxDatumSize
= str(len(Value
) - 1)
488 # apply default SKU for dynamic PCDS if specified one is not available
489 if (ToPcd
.Type
in PCD_DYNAMIC_TYPE_SET
or ToPcd
.Type
in PCD_DYNAMIC_EX_TYPE_SET
) \
490 and not ToPcd
.SkuInfoList
:
491 if self
.Platform
.SkuName
in self
.Platform
.SkuIds
:
492 SkuName
= self
.Platform
.SkuName
494 SkuName
= TAB_DEFAULT
495 ToPcd
.SkuInfoList
= {
496 SkuName
: SkuInfoClass(SkuName
, self
.Platform
.SkuIds
[SkuName
][0], '', '', '', '', '', ToPcd
.DefaultValue
)
499 def ApplyPcdSetting(self
, Ma
, Pcds
, Library
=""):
500 # for each PCD in module
502 for Name
, Guid
in Pcds
:
503 PcdInModule
= Pcds
[Name
, Guid
]
504 # find out the PCD setting in platform
505 if (Name
, Guid
) in self
.Pcds
:
506 PcdInPlatform
= self
.Pcds
[Name
, Guid
]
509 # then override the settings if any
510 self
._OverridePcd
(PcdInModule
, PcdInPlatform
, Module
, Msg
="DSC PCD sections", Library
=Library
)
511 # resolve the VariableGuid value
512 for SkuId
in PcdInModule
.SkuInfoList
:
513 Sku
= PcdInModule
.SkuInfoList
[SkuId
]
514 if Sku
.VariableGuid
== '': continue
515 Sku
.VariableGuidValue
= GuidValue(Sku
.VariableGuid
, self
.PackageList
, self
.MetaFile
.Path
)
516 if Sku
.VariableGuidValue
is None:
517 PackageList
= "\n\t".join(str(P
) for P
in self
.PackageList
)
520 RESOURCE_NOT_AVAILABLE
,
521 "Value of GUID [%s] is not found in" % Sku
.VariableGuid
,
522 ExtraData
=PackageList
+ "\n\t(used with %s.%s from module %s)" \
523 % (Guid
, Name
, str(Module
)),
527 # override PCD settings with module specific setting
528 ModuleScopePcds
= self
.DataPipe
.Get("MOL_PCDS")
529 if Module
in self
.Platform
.Modules
:
530 PlatformModule
= self
.Platform
.Modules
[str(Module
)]
531 PCD_DATA
= ModuleScopePcds
.get(Ma
.Guid
,{})
532 mPcds
= {(pcd
.TokenCName
,pcd
.TokenSpaceGuidCName
): pcd
for pcd
in PCD_DATA
}
534 if self
.BuildOptionPcd
:
535 for pcd
in self
.BuildOptionPcd
:
536 (TokenSpaceGuidCName
, TokenCName
, FieldName
, pcdvalue
, _
) = pcd
537 if (TokenCName
, TokenSpaceGuidCName
) == Key
and FieldName
=="":
538 PlatformModule
.Pcds
[Key
].DefaultValue
= pcdvalue
539 PlatformModule
.Pcds
[Key
].PcdValueFromComm
= pcdvalue
545 elif Key
in self
.MixedPcd
:
546 for PcdItem
in self
.MixedPcd
[Key
]:
548 ToPcd
= Pcds
[PcdItem
]
552 self
._OverridePcd
(ToPcd
, mPcds
[Key
], Module
, Msg
="DSC Components Module scoped PCD section", Library
=Library
)
553 # use PCD value to calculate the MaxDatumSize when it is not specified
554 for Name
, Guid
in Pcds
:
555 Pcd
= Pcds
[Name
, Guid
]
556 if Pcd
.DatumType
== TAB_VOID
and not Pcd
.MaxDatumSize
:
557 Pcd
.MaxSizeUserSet
= None
558 Value
= Pcd
.DefaultValue
560 Pcd
.MaxDatumSize
= '1'
561 elif Value
[0] == 'L':
562 Pcd
.MaxDatumSize
= str((len(Value
) - 2) * 2)
563 elif Value
[0] == '{':
564 Pcd
.MaxDatumSize
= str(len(Value
.split(',')))
566 Pcd
.MaxDatumSize
= str(len(Value
) - 1)
567 return list(Pcds
.values())
571 PlatformPcdData
= self
.DataPipe
.Get("PLA_PCD")
572 # for pcd in PlatformPcdData:
573 # for skuid in pcd.SkuInfoList:
574 # pcd.SkuInfoList[skuid] = self.CreateSkuInfoFromDict(pcd.SkuInfoList[skuid])
575 return {(pcddata
.TokenCName
,pcddata
.TokenSpaceGuidCName
):pcddata
for pcddata
in PlatformPcdData
}
577 def CreateSkuInfoFromDict(self
,SkuInfoDict
):
579 SkuInfoDict
.get("SkuIdName"),
580 SkuInfoDict
.get("SkuId"),
581 SkuInfoDict
.get("VariableName"),
582 SkuInfoDict
.get("VariableGuid"),
583 SkuInfoDict
.get("VariableOffset"),
584 SkuInfoDict
.get("HiiDefaultValue"),
585 SkuInfoDict
.get("VpdOffset"),
586 SkuInfoDict
.get("DefaultValue"),
587 SkuInfoDict
.get("VariableGuidValue"),
588 SkuInfoDict
.get("VariableAttribute",""),
589 SkuInfoDict
.get("DefaultStore",None)
593 return self
.DataPipe
.Get("MixedPcd")
596 RetVal
= self
.DataPipe
.Get("GuidDict")
601 def BuildOptionPcd(self
):
602 return self
.DataPipe
.Get("BuildOptPcd")
603 def ApplyBuildOption(self
,module
):
604 PlatformOptions
= self
.DataPipe
.Get("PLA_BO")
605 ModuleBuildOptions
= self
.DataPipe
.Get("MOL_BO")
606 ModuleOptionFromDsc
= ModuleBuildOptions
.get((module
.MetaFile
.File
,module
.MetaFile
.Root
))
607 if ModuleOptionFromDsc
:
608 ModuleTypeOptions
, PlatformModuleOptions
= ModuleOptionFromDsc
["ModuleTypeOptions"],ModuleOptionFromDsc
["PlatformModuleOptions"]
610 ModuleTypeOptions
, PlatformModuleOptions
= {}, {}
611 ToolDefinition
= self
.DataPipe
.Get("TOOLDEF")
612 ModuleOptions
= self
._ExpandBuildOption
(module
.BuildOptions
)
613 BuildRuleOrder
= None
614 for Options
in [ToolDefinition
, ModuleOptions
, PlatformOptions
, ModuleTypeOptions
, PlatformModuleOptions
]:
616 for Attr
in Options
[Tool
]:
617 if Attr
== TAB_TOD_DEFINES_BUILDRULEORDER
:
618 BuildRuleOrder
= Options
[Tool
][Attr
]
620 AllTools
= set(list(ModuleOptions
.keys()) + list(PlatformOptions
.keys()) +
621 list(PlatformModuleOptions
.keys()) + list(ModuleTypeOptions
.keys()) +
622 list(ToolDefinition
.keys()))
623 BuildOptions
= defaultdict(lambda: defaultdict(str))
624 for Tool
in AllTools
:
625 for Options
in [ToolDefinition
, ModuleOptions
, PlatformOptions
, ModuleTypeOptions
, PlatformModuleOptions
]:
626 if Tool
not in Options
:
628 for Attr
in Options
[Tool
]:
630 # Do not generate it in Makefile
632 if Attr
== TAB_TOD_DEFINES_BUILDRULEORDER
:
634 Value
= Options
[Tool
][Attr
]
637 ToolList
= list(AllTools
)
638 ToolList
.remove(TAB_STAR
)
639 for ExpandedTool
in ToolList
:
640 # check if override is indicated
641 if Value
.startswith('='):
642 BuildOptions
[ExpandedTool
][Attr
] = mws
.handleWsMacro(Value
[1:])
645 BuildOptions
[ExpandedTool
][Attr
] += " " + mws
.handleWsMacro(Value
)
647 BuildOptions
[ExpandedTool
][Attr
] = mws
.handleWsMacro(Value
)
649 return BuildOptions
, BuildRuleOrder
651 def ApplyLibraryInstance(self
,module
):
652 alldeps
= self
.DataPipe
.Get("DEPS")
655 mod_libs
= alldeps
.get((module
.MetaFile
.File
,module
.MetaFile
.Root
,module
.Arch
,module
.MetaFile
.Path
),[])
657 for (file_path
,root
,arch
,abs_path
) in mod_libs
:
658 libMetaFile
= PathClass(file_path
,root
)
659 libMetaFile
.OriginalPath
= PathClass(file_path
,root
)
660 libMetaFile
.Path
= abs_path
661 retVal
.append(self
.Wa
.BuildDatabase
[libMetaFile
, arch
, self
.Target
,self
.ToolChain
])
664 ## Parse build_rule.txt in Conf Directory.
666 # @retval BuildRule object
670 WInfo
= self
.DataPipe
.Get("P_Info")
671 RetVal
= WInfo
.get("BuildRuleFile")
672 if RetVal
._FileVersion
== "":
673 RetVal
._FileVersion
= AutoGenReqBuildRuleVerNum