X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FAutoGen%2FAutoGen.py;h=d51c59e2048d9d43483c81fbb1acd0e967179ad1;hb=b36d134faf4305247830522b8e2bb255e98c5699;hp=d95f40bf82ae52c4c5820617289fe8f956e134a2;hpb=e56468c072e0d53834787f4ad0e292b33cc6be08;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index d95f40bf82..d51c59e204 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1,7 +1,7 @@
## @file
# Generate AutoGen.h, AutoGen.c and *.depex files
#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -53,6 +53,39 @@ gAutoGenStringFileName = "%(module_name)sStrDefs.h"
gAutoGenStringFormFileName = "%(module_name)sStrDefs.hpk"
gAutoGenDepexFileName = "%(module_name)s.depex"
+#
+# Template string to generic AsBuilt INF
+#
+gAsBuiltInfHeaderString = TemplateString("""## @file
+# ${module_name}
+#
+# DO NOT EDIT
+# FILE auto-generated Binary INF
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010016
+ BASE_NAME = ${module_name}
+ FILE_GUID = ${module_guid}
+ MODULE_TYPE = ${module_module_type}
+ VERSION_STRING = ${module_version_string}${BEGIN}
+ UEFI_SPECIFICATION_VERSION = ${module_uefi_specification_version}${END}${BEGIN}
+ PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END}
+
+[Packages]${BEGIN}
+ ${package_item}${END}
+
+[Binaries.${module_arch}]${BEGIN}
+ ${binary_item}${END}
+
+[PcdEx]${BEGIN}
+ ${pcd_item}${END}
+
+## @AsBuilt${BEGIN}
+## ${flags_item}${END}
+""")
+
## Base class for AutoGen
#
# This class just implements the cache mechanism of AutoGen objects.
@@ -136,10 +169,17 @@ class WorkspaceAutoGen(AutoGen):
# @param FlashDefinitionFile File of flash definition
# @param Fds FD list to be generated
# @param Fvs FV list to be generated
+ # @param Caps Capsule list to be generated
# @param SkuId SKU id from command line
#
def _Init(self, WorkspaceDir, ActivePlatform, Target, Toolchain, ArchList, MetaFileDb,
- BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=[], Fvs=[], SkuId='', UniFlag=None):
+ BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=None, Fvs=None, Caps=None, SkuId='', UniFlag=None):
+ if Fds is None:
+ Fds = []
+ if Fvs is None:
+ Fvs = []
+ if Caps is None:
+ Caps = []
self.MetaFile = ActivePlatform.MetaFile
self.WorkspaceDir = WorkspaceDir
self.Platform = ActivePlatform
@@ -155,6 +195,7 @@ class WorkspaceAutoGen(AutoGen):
self.FdfFile = FlashDefinitionFile
self.FdTargetList = Fds
self.FvTargetList = Fvs
+ self.CapTargetList = Caps
self.AutoGenObjectList = []
# there's many relative directory operations, so ...
@@ -162,6 +203,10 @@ class WorkspaceAutoGen(AutoGen):
# parse FDF file to get PCDs in it, if any
if self.FdfFile != None and self.FdfFile != '':
+ #
+ # Make global macros available when parsing FDF file
+ #
+ InputMacroDict.update(self.BuildDatabase.WorkspaceDb._GlobalMacros)
Fdf = FdfParser(self.FdfFile.Path)
Fdf.ParseFile()
PcdSet = Fdf.Profile.PcdDict
@@ -185,7 +230,17 @@ class WorkspaceAutoGen(AutoGen):
#
Pa.CollectPlatformDynamicPcds()
self.AutoGenObjectList.append(Pa)
-
+
+ #
+ # Check PCDs token value conflict in each DEC file.
+ #
+ self._CheckAllPcdsTokenValueConflict()
+
+ #
+ # Check PCD type and definition between DSC and DEC
+ #
+ self._CheckPcdDefineAndType()
+
self._BuildDir = None
self._FvDir = None
self._MakeFileDir = None
@@ -193,6 +248,56 @@ class WorkspaceAutoGen(AutoGen):
return True
+ def _CheckPcdDefineAndType(self):
+ PcdTypeList = [
+ "FixedAtBuild", "PatchableInModule", "FeatureFlag",
+ "Dynamic", #"DynamicHii", "DynamicVpd",
+ "DynamicEx", # "DynamicExHii", "DynamicExVpd"
+ ]
+
+ # This dict store PCDs which are not used by any modules with specified arches
+ UnusedPcd = sdict()
+ for Pa in self.AutoGenObjectList:
+ # Key of DSC's Pcds dictionary is PcdCName, TokenSpaceGuid
+ for Pcd in Pa.Platform.Pcds:
+ PcdType = Pa.Platform.Pcds[Pcd].Type
+
+ # If no PCD type, this PCD comes from FDF
+ if not PcdType:
+ continue
+
+ # Try to remove Hii and Vpd suffix
+ if PcdType.startswith("DynamicEx"):
+ PcdType = "DynamicEx"
+ elif PcdType.startswith("Dynamic"):
+ PcdType = "Dynamic"
+
+ for Package in Pa.PackageList:
+ # Key of DEC's Pcds dictionary is PcdCName, TokenSpaceGuid, PcdType
+ if (Pcd[0], Pcd[1], PcdType) in Package.Pcds:
+ break
+ for Type in PcdTypeList:
+ if (Pcd[0], Pcd[1], Type) in Package.Pcds:
+ EdkLogger.error(
+ 'build',
+ FORMAT_INVALID,
+ "Type [%s] of PCD [%s.%s] in DSC file doesn't match the type [%s] defined in DEC file." \
+ % (Pa.Platform.Pcds[Pcd].Type, Pcd[1], Pcd[0], Type),
+ ExtraData=None
+ )
+ return
+ else:
+ UnusedPcd.setdefault(Pcd, []).append(Pa.Arch)
+
+ for Pcd in UnusedPcd:
+ EdkLogger.warn(
+ 'build',
+ "The PCD was not specified by any INF module in the platform for the given architecture.\n"
+ "\tPCD: [%s.%s]\n\tPlatform: [%s]\n\tArch: %s"
+ % (Pcd[1], Pcd[0], os.path.basename(str(self.MetaFile)), str(UnusedPcd[Pcd])),
+ ExtraData=None
+ )
+
def __repr__(self):
return "%s [%s]" % (self.MetaFile, ", ".join(self.ArchList))
@@ -244,6 +349,75 @@ class WorkspaceAutoGen(AutoGen):
# BuildCommand should be all the same. So just get one from platform AutoGen
self._BuildCommand = self.AutoGenObjectList[0].BuildCommand
return self._BuildCommand
+
+ ## Check the PCDs token value conflict in each DEC file.
+ #
+ # Will cause build break and raise error message while two PCDs conflict.
+ #
+ # @return None
+ #
+ def _CheckAllPcdsTokenValueConflict(self):
+ for Pa in self.AutoGenObjectList:
+ for Package in Pa.PackageList:
+ PcdList = Package.Pcds.values()
+ PcdList.sort(lambda x, y: cmp(x.TokenValue, y.TokenValue))
+ Count = 0
+ while (Count < len(PcdList) - 1) :
+ Item = PcdList[Count]
+ ItemNext = PcdList[Count + 1]
+ #
+ # Make sure in the same token space the TokenValue should be unique
+ #
+ if (Item.TokenValue == ItemNext.TokenValue):
+ SameTokenValuePcdList = []
+ SameTokenValuePcdList.append(Item)
+ SameTokenValuePcdList.append(ItemNext)
+ RemainPcdListLength = len(PcdList) - Count - 2
+ for ValueSameCount in range(RemainPcdListLength):
+ if PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount].TokenValue == Item.TokenValue:
+ SameTokenValuePcdList.append(PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount])
+ else:
+ break;
+ #
+ # Sort same token value PCD list with TokenGuid and TokenCName
+ #
+ SameTokenValuePcdList.sort(lambda x, y: cmp("%s.%s"%(x.TokenSpaceGuidCName, x.TokenCName), "%s.%s"%(y.TokenSpaceGuidCName, y.TokenCName)))
+ SameTokenValuePcdListCount = 0
+ while (SameTokenValuePcdListCount < len(SameTokenValuePcdList) - 1):
+ TemListItem = SameTokenValuePcdList[SameTokenValuePcdListCount]
+ TemListItemNext = SameTokenValuePcdList[SameTokenValuePcdListCount + 1]
+
+ if (TemListItem.TokenSpaceGuidCName == TemListItemNext.TokenSpaceGuidCName) and (TemListItem.TokenCName != TemListItemNext.TokenCName):
+ EdkLogger.error(
+ 'build',
+ FORMAT_INVALID,
+ "The TokenValue [%s] of PCD [%s.%s] is conflict with: [%s.%s] in %s"\
+ % (TemListItem.TokenValue, TemListItem.TokenSpaceGuidCName, TemListItem.TokenCName, TemListItemNext.TokenSpaceGuidCName, TemListItemNext.TokenCName, Package),
+ ExtraData=None
+ )
+ SameTokenValuePcdListCount += 1
+ Count += SameTokenValuePcdListCount
+ Count += 1
+
+ PcdList = Package.Pcds.values()
+ PcdList.sort(lambda x, y: cmp("%s.%s"%(x.TokenSpaceGuidCName, x.TokenCName), "%s.%s"%(y.TokenSpaceGuidCName, y.TokenCName)))
+ Count = 0
+ while (Count < len(PcdList) - 1) :
+ Item = PcdList[Count]
+ ItemNext = PcdList[Count + 1]
+ #
+ # Check PCDs with same TokenSpaceGuidCName.TokenCName have same token value as well.
+ #
+ if (Item.TokenSpaceGuidCName == ItemNext.TokenSpaceGuidCName) and (Item.TokenCName == ItemNext.TokenCName) and (Item.TokenValue != ItemNext.TokenValue):
+ EdkLogger.error(
+ 'build',
+ FORMAT_INVALID,
+ "The TokenValue [%s] of PCD [%s.%s] in %s defined in two places should be same as well."\
+ % (Item.TokenValue, Item.TokenSpaceGuidCName, Item.TokenCName, Package),
+ ExtraData=None
+ )
+ Count += 1
+
## Create makefile for the platform and modules in it
#
@@ -278,6 +452,11 @@ class WorkspaceAutoGen(AutoGen):
for Pa in self.AutoGenObjectList:
Pa.CreateCodeFile(CreateDepsCodeFile)
+ ## Create AsBuilt INF file the platform
+ #
+ def CreateAsBuiltInf(self):
+ return
+
Name = property(_GetName)
Guid = property(_GetGuid)
Version = property(_GetVersion)
@@ -302,7 +481,27 @@ class PlatformAutoGen(AutoGen):
#
_DynaPcdList_ = []
_NonDynaPcdList_ = []
-
+
+ #
+ # The priority list while override build option
+ #
+ PrioList = {"0x11111" : 16, # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE (Highest)
+ "0x01111" : 15, # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
+ "0x10111" : 14, # TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE
+ "0x00111" : 13, # ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE
+ "0x11011" : 12, # TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE
+ "0x01011" : 11, # ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE
+ "0x10011" : 10, # TARGET_*********_****_COMMANDTYPE_ATTRIBUTE
+ "0x00011" : 9, # ******_*********_****_COMMANDTYPE_ATTRIBUTE
+ "0x11101" : 8, # TARGET_TOOLCHAIN_ARCH_***********_ATTRIBUTE
+ "0x01101" : 7, # ******_TOOLCHAIN_ARCH_***********_ATTRIBUTE
+ "0x10101" : 6, # TARGET_*********_ARCH_***********_ATTRIBUTE
+ "0x00101" : 5, # ******_*********_ARCH_***********_ATTRIBUTE
+ "0x11001" : 4, # TARGET_TOOLCHAIN_****_***********_ATTRIBUTE
+ "0x01001" : 3, # ******_TOOLCHAIN_****_***********_ATTRIBUTE
+ "0x10001" : 2, # TARGET_*********_****_***********_ATTRIBUTE
+ "0x00001" : 1} # ******_*********_****_***********_ATTRIBUTE (Lowest)
+
## The real constructor of PlatformAutoGen
#
# This method is not supposed to be called by users of PlatformAutoGen. It's
@@ -401,6 +600,7 @@ class PlatformAutoGen(AutoGen):
Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget,
self.ToolChain, self.Arch, self.MetaFile)
Ma.CreateMakeFile(True)
+ Ma.CreateAsBuiltInf()
# no need to create makefile for the platform more than once
if self.IsMakeFileCreated:
@@ -477,12 +677,12 @@ class PlatformAutoGen(AutoGen):
UnicodePcdArray = []
HiiPcdArray = []
OtherPcdArray = []
+ VpdPcdDict = {}
VpdFile = VpdInfoFile.VpdInfoFile()
NeedProcessVpdMapFile = False
if (self.Workspace.ArchList[-1] == self.Arch):
for Pcd in self._DynamicPcdList:
-
# just pick the a value to determine whether is unicode string type
Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
Sku.VpdOffset = Sku.VpdOffset.strip()
@@ -496,32 +696,47 @@ class PlatformAutoGen(AutoGen):
HiiPcdArray.append(Pcd)
else:
OtherPcdArray.append(Pcd)
-
if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:
- if not (self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == ''):
- #
- # Fix the optional data of VPD PCD.
- #
- if (Pcd.DatumType.strip() != "VOID*"):
- if Sku.DefaultValue == '':
- Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]].DefaultValue = Pcd.MaxDatumSize
- Pcd.MaxDatumSize = None
- else:
- EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",
- File=self.MetaFile,
- ExtraData="\n\tPCD: %s.%s format incorrect in DSC: %s\n\t\t\n"
- % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, self.Platform.MetaFile.Path))
-
- VpdFile.Add(Pcd, Sku.VpdOffset)
- # if the offset of a VPD is *, then it need to be fixed up by third party tool.
- if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
- NeedProcessVpdMapFile = True
+ VpdPcdDict[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)] = Pcd
+
+ PlatformPcds = self.Platform.Pcds.keys()
+ PlatformPcds.sort()
+ #
+ # Add VPD type PCD into VpdFile and determine whether the VPD PCD need to be fixed up.
+ #
+ for PcdKey in PlatformPcds:
+ Pcd = self.Platform.Pcds[PcdKey]
+ if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:
+ Pcd = VpdPcdDict[PcdKey]
+ Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
+ Sku.VpdOffset = Sku.VpdOffset.strip()
+ #
+ # Fix the optional data of VPD PCD.
+ #
+ if (Pcd.DatumType.strip() != "VOID*"):
+ if Sku.DefaultValue == '':
+ Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]].DefaultValue = Pcd.MaxDatumSize
+ Pcd.MaxDatumSize = None
+ else:
+ EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",
+ File=self.MetaFile,
+ ExtraData="\n\tPCD: %s.%s format incorrect in DSC: %s\n\t\t\n"
+ % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, self.Platform.MetaFile.Path))
+
+ VpdFile.Add(Pcd, Sku.VpdOffset)
+ # if the offset of a VPD is *, then it need to be fixed up by third party tool.
+ if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
+ NeedProcessVpdMapFile = True
+ if self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == '':
+ EdkLogger.error("Build", FILE_NOT_FOUND, \
+ "Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")
+
#
# Fix the PCDs define in VPD PCD section that never referenced by module.
# An example is PCD for signature usage.
- #
- for DscPcd in self.Platform.Pcds:
+ #
+ for DscPcd in PlatformPcds:
DscPcdEntry = self.Platform.Pcds[DscPcd]
if DscPcdEntry.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:
if not (self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == ''):
@@ -544,9 +759,18 @@ class PlatformAutoGen(AutoGen):
DecPcdEntry = eachDec.Pcds[DecPcd]
if (DecPcdEntry.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \
(DecPcdEntry.TokenCName == DscPcdEntry.TokenCName):
+ # Print warning message to let the developer make a determine.
+ EdkLogger.warn("build", "Unreferenced vpd pcd used!",
+ File=self.MetaFile, \
+ ExtraData = "PCD: %s.%s used in the DSC file %s is unreferenced." \
+ %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path))
+
DscPcdEntry.DatumType = DecPcdEntry.DatumType
DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue
- Sku.DefaultValue = DecPcdEntry.DefaultValue
+ # Only fix the value while no value provided in DSC file.
+ if (Sku.DefaultValue == "" or Sku.DefaultValue==None):
+ DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue
+
VpdFile.Add(DscPcdEntry, Sku.VpdOffset)
# if the offset of a VPD is *, then it need to be fixed up by third party tool.
@@ -569,11 +793,9 @@ class PlatformAutoGen(AutoGen):
except:
EdkLogger.error("build", FILE_WRITE_FAILURE, "Fail to create FV folder under %s" % self.BuildDir)
- VpdFileName = self.Platform.VpdFileName
- if VpdFileName == None or VpdFileName == "" :
- VpdFilePath = os.path.join(FvPath, "%s.txt" % self.Platform.VpdToolGuid)
- else :
- VpdFilePath = os.path.join(FvPath, "%s.txt" % VpdFileName)
+
+ VpdFilePath = os.path.join(FvPath, "%s.txt" % self.Platform.VpdToolGuid)
+
if not os.path.exists(VpdFilePath) or os.path.getmtime(VpdFilePath) < DscTimeStamp:
VpdFile.Write(VpdFilePath)
@@ -588,16 +810,13 @@ class PlatformAutoGen(AutoGen):
break
# Call third party GUID BPDG tool.
if BPDGToolName != None:
- VpdInfoFile.CallExtenalBPDGTool(BPDGToolName, VpdFilePath, VpdFileName)
+ VpdInfoFile.CallExtenalBPDGTool(BPDGToolName, VpdFilePath)
else:
EdkLogger.error("Build", FILE_NOT_FOUND, "Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")
# Process VPD map file generated by third party BPDG tool
if NeedProcessVpdMapFile:
- if VpdFileName == None or VpdFileName == "" :
- VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)
- else :
- VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % VpdFileName)
+ VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)
if os.path.exists(VpdMapFilePath):
VpdFile.Read(VpdMapFilePath)
@@ -606,7 +825,7 @@ class PlatformAutoGen(AutoGen):
# just pick the a value to determine whether is unicode string type
Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
if Sku.VpdOffset == "*":
- Sku.VpdOffset = VpdFile.GetOffset(Pcd)[0]
+ Sku.VpdOffset = VpdFile.GetOffset(Pcd)[0]
else:
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
@@ -685,7 +904,7 @@ class PlatformAutoGen(AutoGen):
if "FLAGS" in self.ToolDefinition["MAKE"]:
NewOption = self.ToolDefinition["MAKE"]["FLAGS"].strip()
if NewOption != '':
- self._BuildCommand += SplitOption(NewOption)
+ self._BuildCommand += SplitOption(NewOption)
return self._BuildCommand
## Get tool chain definition
@@ -919,16 +1138,21 @@ class PlatformAutoGen(AutoGen):
PlatformModule = self.Platform.Modules[str(Module)]
# add forced library instances (specified under LibraryClasses sections)
- for LibraryClass in self.Platform.LibraryClasses.GetKeys():
- if LibraryClass.startswith("NULL"):
- Module.LibraryClasses[LibraryClass] = self.Platform.LibraryClasses[LibraryClass]
+ #
+ # If a module has a MODULE_TYPE of USER_DEFINED,
+ # do not link in NULL library class instances from the global [LibraryClasses.*] sections.
+ #
+ if Module.ModuleType != SUP_MODULE_USER_DEFINED:
+ for LibraryClass in self.Platform.LibraryClasses.GetKeys():
+ if LibraryClass.startswith("NULL") and self.Platform.LibraryClasses[LibraryClass, Module.ModuleType]:
+ Module.LibraryClasses[LibraryClass] = self.Platform.LibraryClasses[LibraryClass, Module.ModuleType]
# add forced library instances (specified in module overrides)
for LibraryClass in PlatformModule.LibraryClasses:
if LibraryClass.startswith("NULL"):
Module.LibraryClasses[LibraryClass] = PlatformModule.LibraryClasses[LibraryClass]
- # R9 module
+ # EdkII module
LibraryConsumerList = [Module]
Constructor = []
ConsumedByList = sdict()
@@ -1177,7 +1401,7 @@ class PlatformAutoGen(AutoGen):
## Resolve library names to library modules
#
- # (for R8.x modules)
+ # (for Edk.x modules)
#
# @param Module The module from which the library names will be resolved
#
@@ -1188,7 +1412,7 @@ class PlatformAutoGen(AutoGen):
EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), self.Arch))
LibraryConsumerList = [Module]
- # "CompilerStub" is a must for R8 modules
+ # "CompilerStub" is a must for Edk modules
if Module.Libraries:
Module.Libraries.append("CompilerStub")
LibraryList = []
@@ -1212,16 +1436,86 @@ class PlatformAutoGen(AutoGen):
EdkLogger.verbose("\t" + LibraryName + " : " + str(Library) + ' ' + str(type(Library)))
return LibraryList
+ ## Calculate the priority value of the build option
+ #
+ # @param Key Build option definition contain: TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
+ #
+ # @retval Value Priority value based on the priority list.
+ #
+ def CalculatePriorityValue(self, Key):
+ Target, ToolChain, Arch, CommandType, Attr = Key.split('_')
+ PriorityValue = 0x11111
+ if Target == "*":
+ PriorityValue &= 0x01111
+ if ToolChain == "*":
+ PriorityValue &= 0x10111
+ if Arch == "*":
+ PriorityValue &= 0x11011
+ if CommandType == "*":
+ PriorityValue &= 0x11101
+ if Attr == "*":
+ PriorityValue &= 0x11110
+
+ return self.PrioList["0x%0.5x"%PriorityValue]
+
+
## Expand * in build option key
#
# @param Options Options to be expanded
#
# @retval options Options expanded
- #
+ #
def _ExpandBuildOption(self, Options, ModuleStyle=None):
BuildOptions = {}
FamilyMatch = False
FamilyIsNull = True
+
+ OverrideList = {}
+ #
+ # Construct a list contain the build options which need override.
+ #
+ for Key in Options:
+ #
+ # Key[0] -- tool family
+ # Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
+ #
+ if Key[0] == self.BuildRuleFamily :
+ Target, ToolChain, Arch, CommandType, Attr = Key[1].split('_')
+ if Target == self.BuildTarget or Target == "*":
+ if ToolChain == self.ToolChain or ToolChain == "*":
+ if Arch == self.Arch or Arch == "*":
+ if Options[Key].startswith("="):
+ if OverrideList.get(Key[1]) != None:
+ OverrideList.pop(Key[1])
+ OverrideList[Key[1]] = Options[Key]
+
+ #
+ # Use the highest priority value.
+ #
+ if (len(OverrideList) >= 2):
+ KeyList = OverrideList.keys()
+ for Index in range(len(KeyList)):
+ NowKey = KeyList[Index]
+ Target1, ToolChain1, Arch1, CommandType1, Attr1 = NowKey.split("_")
+ for Index1 in range(len(KeyList) - Index - 1):
+ NextKey = KeyList[Index1 + Index + 1]
+ #
+ # Compare two Key, if one is included by another, choose the higher priority one
+ #
+ Target2, ToolChain2, Arch2, CommandType2, Attr2 = NextKey.split("_")
+ if Target1 == Target2 or Target1 == "*" or Target2 == "*":
+ if ToolChain1 == ToolChain2 or ToolChain1 == "*" or ToolChain2 == "*":
+ if Arch1 == Arch2 or Arch1 == "*" or Arch2 == "*":
+ if CommandType1 == CommandType2 or CommandType1 == "*" or CommandType2 == "*":
+ if Attr1 == Attr2 or Attr1 == "*" or Attr2 == "*":
+ if self.CalculatePriorityValue(NowKey) > self.CalculatePriorityValue(NextKey):
+ if Options.get((self.BuildRuleFamily, NextKey)) != None:
+ Options.pop((self.BuildRuleFamily, NextKey))
+ else:
+ if Options.get((self.BuildRuleFamily, NowKey)) != None:
+ Options.pop((self.BuildRuleFamily, NowKey))
+
+
for Key in Options:
if ModuleStyle != None and len (Key) > 2:
# Check Module style is EDK or EDKII.
@@ -1409,6 +1703,8 @@ class ModuleAutoGen(AutoGen):
self.IsMakeFileCreated = False
self.IsCodeFileCreated = False
+ self.IsAsBuiltInfCreated = False
+ self.DepexGenerated = False
self.BuildDatabase = self.Workspace.BuildDatabase
@@ -1498,6 +1794,10 @@ class ModuleAutoGen(AutoGen):
def _GetBaseName(self):
return self.Module.BaseName
+ ## Return the module DxsFile if exist
+ def _GetDxsFile(self):
+ return self.Module.DxsFile
+
## Return the module SourceOverridePath
def _GetSourceOverridePath(self):
return self.Module.SourceOverridePath
@@ -1514,7 +1814,7 @@ class ModuleAutoGen(AutoGen):
def _GetModuleType(self):
return self.Module.ModuleType
- ## Return the component type (for R8.x style of module)
+ ## Return the component type (for Edk.x style of module)
def _GetComponentType(self):
return self.Module.ComponentType
@@ -1617,7 +1917,7 @@ class ModuleAutoGen(AutoGen):
def _GetDepexTokenList(self):
if self._DepexList == None:
self._DepexList = {}
- if self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:
+ if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:
return self._DepexList
self._DepexList[self.ModuleType] = []
@@ -1653,7 +1953,7 @@ class ModuleAutoGen(AutoGen):
def _GetDepexExpressionTokenList(self):
if self._DepexExpressionList == None:
self._DepexExpressionList = {}
- if self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:
+ if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:
return self._DepexExpressionList
self._DepexExpressionList[self.ModuleType] = ''
@@ -1709,12 +2009,12 @@ class ModuleAutoGen(AutoGen):
self._SourceFileList = []
for F in self.Module.Sources:
# match tool chain
- if F.TagName != "" and F.TagName != self.ToolChain:
+ if F.TagName not in ("", "*", self.ToolChain):
EdkLogger.debug(EdkLogger.DEBUG_9, "The toolchain [%s] for processing file [%s] is found, "
"but [%s] is needed" % (F.TagName, str(F), self.ToolChain))
continue
# match tool chain family
- if F.ToolChainFamily != "" and F.ToolChainFamily != self.ToolChainFamily:
+ if F.ToolChainFamily not in ("", "*", self.ToolChainFamily):
EdkLogger.debug(
EdkLogger.DEBUG_0,
"The file [%s] must be built by tools of [%s], " \
@@ -1800,6 +2100,9 @@ class ModuleAutoGen(AutoGen):
CreateDirectory(Source.Dir)
if File.IsBinary and File == Source and self._BinaryFileList != None and File in self._BinaryFileList:
+ # Skip all files that are not binary libraries
+ if not self.IsLibrary:
+ continue
RuleObject = self.BuildRules[TAB_DEFAULT_BINARY_FILE]
elif FileType in self.BuildRules:
RuleObject = self.BuildRules[FileType]
@@ -1854,7 +2157,7 @@ class ModuleAutoGen(AutoGen):
self._BuildTargets = {}
self._FileTypes = {}
- #TRICK: call _GetSourceFileList to apply build rule for binary files
+ #TRICK: call _GetSourceFileList to apply build rule for source files
if self.SourceFileList:
pass
@@ -1889,9 +2192,8 @@ class ModuleAutoGen(AutoGen):
#
def _GetAutoGenFileList(self):
UniStringAutoGenC = True
- UniStringBinBuffer = None
+ UniStringBinBuffer = StringIO()
if self.BuildType == 'UEFI_HII':
- UniStringBinBuffer = StringIO()
UniStringAutoGenC = False
if self._AutoGenFileList == None:
self._AutoGenFileList = {}
@@ -2008,11 +2310,11 @@ class ModuleAutoGen(AutoGen):
for Inc in self.Module.Includes:
if Inc not in self._IncludePathList:
self._IncludePathList.append(Inc)
- # for r8 modules
+ # for Edk modules
Inc = path.join(Inc, self.Arch.capitalize())
if os.path.exists(Inc) and Inc not in self._IncludePathList:
self._IncludePathList.append(Inc)
- # r8 module needs to put DEBUG_DIR at the end of search path and not to use SOURCE_DIR all the time
+ # Edk module needs to put DEBUG_DIR at the end of search path and not to use SOURCE_DIR all the time
self._IncludePathList.append(self.DebugDir)
else:
self._IncludePathList.append(self.MetaFile.Dir)
@@ -2027,6 +2329,107 @@ class ModuleAutoGen(AutoGen):
self._IncludePathList.append(str(Inc))
return self._IncludePathList
+ ## Create AsBuilt INF file the module
+ #
+ def CreateAsBuiltInf(self):
+ if self.IsAsBuiltInfCreated:
+ return
+
+ # Skip the following code for EDK I inf
+ if self.AutoGenVersion < 0x00010005:
+ return
+
+ # Skip the following code for libraries
+ if self.IsLibrary:
+ return
+
+ # Skip the following code for modules with no source files
+ if self.SourceFileList == None or self.SourceFileList == []:
+ return
+
+ # Skip the following code for modules without any binary files
+ if self.BinaryFileList <> None and self.BinaryFileList <> []:
+ return
+
+ ### TODO: How to handles mixed source and binary modules
+
+ # Find all DynamicEx PCDs used by this module and dependent libraries
+ # Also find all packages that the DynamicEx PCDs depend on
+ Pcds = []
+ Packages = []
+ for Pcd in self.ModulePcdList + self.LibraryPcdList:
+ if Pcd.Type in GenC.gDynamicExPcd:
+ if Pcd not in Pcds:
+ Pcds += [Pcd]
+ for Package in self.DerivedPackageList:
+ if Package not in Packages:
+ if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx') in Package.Pcds:
+ Packages += [Package]
+ elif (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic') in Package.Pcds:
+ Packages += [Package]
+
+ ModuleType = self.ModuleType
+ if ModuleType == 'UEFI_DRIVER' and self.DepexGenerated:
+ ModuleType = 'DXE_DRIVER'
+
+ AsBuiltInfDict = {
+ 'module_name' : self.Name,
+ 'module_guid' : self.Guid,
+ 'module_module_type' : ModuleType,
+ 'module_version_string' : self.Version,
+ 'module_uefi_specification_version' : [],
+ 'module_pi_specification_version' : [],
+ 'module_arch' : self.Arch,
+ 'package_item' : ['%s' % (Package.MetaFile.File.replace('\\','/')) for Package in Packages],
+ 'binary_item' : [],
+ 'pcd_item' : [],
+ 'flags_item' : []
+ }
+
+ if 'UEFI_SPECIFICATION_VERSION' in self.Specification:
+ AsBuiltInfDict['module_uefi_specification_version'] += [self.Specification['UEFI_SPECIFICATION_VERSION']]
+ if 'PI_SPECIFICATION_VERSION' in self.Specification:
+ AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']]
+
+ OutputDir = self.OutputDir.replace('\\','/').strip('/')
+ if self.ModuleType in ['BASE', 'USER_DEFINED']:
+ for Item in self.CodaTargetList:
+ File = Item.Target.Path.replace('\\','/').strip('/').replace(OutputDir,'').strip('/')
+ if Item.Target.Ext.lower() == '.aml':
+ AsBuiltInfDict['binary_item'] += ['ASL|' + File]
+ elif Item.Target.Ext.lower() == '.acpi':
+ AsBuiltInfDict['binary_item'] += ['ACPI|' + File]
+ else:
+ AsBuiltInfDict['binary_item'] += ['BIN|' + File]
+ else:
+ for Item in self.CodaTargetList:
+ File = Item.Target.Path.replace('\\','/').strip('/').replace(OutputDir,'').strip('/')
+ if Item.Target.Ext.lower() == '.efi':
+ AsBuiltInfDict['binary_item'] += ['PE32|' + self.Name + '.efi']
+ else:
+ AsBuiltInfDict['binary_item'] += ['BIN|' + File]
+ if self.DepexGenerated:
+ if self.ModuleType in ['PEIM']:
+ AsBuiltInfDict['binary_item'] += ['PEI_DEPEX|' + self.Name + '.depex']
+ if self.ModuleType in ['DXE_DRIVER','DXE_RUNTIME_DRIVER','DXE_SAL_DRIVER','UEFI_DRIVER']:
+ AsBuiltInfDict['binary_item'] += ['DXE_DEPEX|' + self.Name + '.depex']
+ if self.ModuleType in ['DXE_SMM_DRIVER']:
+ AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex']
+
+ for Pcd in Pcds:
+ AsBuiltInfDict['pcd_item'] += [Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName]
+
+ for Item in self.BuildOption:
+ if 'FLAGS' in self.BuildOption[Item]:
+ AsBuiltInfDict['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())]
+
+ AsBuiltInf = TemplateString()
+ AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict))
+
+ SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False)
+
+ self.IsAsBuiltInfCreated = True
+
## Create makefile for the module and its dependent libraries
#
# @param CreateLibraryMakeFile Flag indicating if or not the makefiles of
@@ -2071,7 +2474,7 @@ class ModuleAutoGen(AutoGen):
for File in self.AutoGenFileList:
if GenC.Generate(File.Path, self.AutoGenFileList[File], File.IsBinary):
- #Ignore R8 AutoGen.c
+ #Ignore Edk AutoGen.c
if self.AutoGenVersion < 0x00010005 and File.Name == 'AutoGen.c':
continue
@@ -2091,6 +2494,9 @@ class ModuleAutoGen(AutoGen):
Dpx = GenDepex.DependencyExpression(self.DepexList[ModuleType], ModuleType, True)
DpxFile = gAutoGenDepexFileName % {"module_name" : self.Name}
+ if len(Dpx.PostfixNotation) <> 0:
+ self.DepexGenerated = True
+
if Dpx.Generate(path.join(self.OutputDir, DpxFile)):
AutoGenList.append(str(DpxFile))
else:
@@ -2128,14 +2534,6 @@ class ModuleAutoGen(AutoGen):
self._ApplyBuildRule(Lib.Target, TAB_UNKNOWN_FILE)
return self._LibraryAutoGenList
- ## Return build command string
- #
- # @retval string Build command string
- #
- def _GetBuildCommand(self):
- return self.PlatformInfo.BuildCommand
-
-
Module = property(_GetModule)
Name = property(_GetBaseName)
Guid = property(_GetGuid)
@@ -2178,6 +2576,7 @@ class ModuleAutoGen(AutoGen):
ProtocolList = property(_GetProtocolList)
PpiList = property(_GetPpiList)
DepexList = property(_GetDepexTokenList)
+ DxsFile = property(_GetDxsFile)
DepexExpressionList = property(_GetDepexExpressionTokenList)
BuildOption = property(_GetModuleBuildOption)
BuildCommand = property(_GetBuildCommand)