## @file\r
# Generate AutoGen.h, AutoGen.c and *.depex files\r
#\r
-# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
from Common.MultipleWorkspace import MultipleWorkspace as mws\r
import InfSectionParser\r
import datetime\r
+import hashlib\r
+from GenVar import VariableMgr,var_info\r
+from collections import OrderedDict\r
+from collections import defaultdict\r
\r
## Regular expression for splitting Dependency Expression string into tokens\r
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")\r
\r
+## Regular expression for match: PCD(xxxx.yyy)\r
+gPCDAsGuidPattern = re.compile(r"^PCD\(.+\..+\)$")\r
+\r
+#\r
+# Regular expression for finding Include Directories, the difference between MSFT and INTEL/GCC/RVCT\r
+# is the former use /I , the Latter used -I to specify include directories\r
+#\r
+gBuildOptIncludePatternMsft = re.compile(r"(?:.*?)/I[ \t]*([^ ]*)", re.MULTILINE | re.DOTALL)\r
+gBuildOptIncludePatternOther = re.compile(r"(?:.*?)-I[ \t]*([^ ]*)", re.MULTILINE | re.DOTALL)\r
+\r
#\r
# Match name = variable\r
#\r
# This class just implements the cache mechanism of AutoGen objects.\r
#\r
class AutoGen(object):\r
- # database to maintain the objects of xxxAutoGen\r
- _CACHE_ = {} # (BuildTarget, ToolChain) : {ARCH : {platform file: AutoGen object}}}\r
+ # database to maintain the objects in each child class\r
+ __ObjectCache = {} # (BuildTarget, ToolChain, ARCH, platform file): AutoGen object\r
\r
## Factory method\r
#\r
# @param *args The specific class related parameters\r
# @param **kwargs The specific class related dict parameters\r
#\r
- def __new__(Class, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
+ def __new__(cls, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
# check if the object has been created\r
- Key = (Target, Toolchain)\r
- if Key not in Class._CACHE_ or Arch not in Class._CACHE_[Key] \\r
- or MetaFile not in Class._CACHE_[Key][Arch]:\r
- AutoGenObject = super(AutoGen, Class).__new__(Class)\r
- # call real constructor\r
- if not AutoGenObject._Init(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
- return None\r
- if Key not in Class._CACHE_:\r
- Class._CACHE_[Key] = {}\r
- if Arch not in Class._CACHE_[Key]:\r
- Class._CACHE_[Key][Arch] = {}\r
- Class._CACHE_[Key][Arch][MetaFile] = AutoGenObject\r
- else:\r
- AutoGenObject = Class._CACHE_[Key][Arch][MetaFile]\r
+ Key = (Target, Toolchain, Arch, MetaFile)\r
+ try:\r
+ # if it exists, just return it directly\r
+ return cls.__ObjectCache[Key]\r
+ except:\r
+ # it didnt exist. create it, cache it, then return it\r
+ cls.__ObjectCache[Key] = super(AutoGen, cls).__new__(cls)\r
+ return cls.__ObjectCache[Key]\r
\r
- return AutoGenObject\r
+ def __init__ (self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
+ super(AutoGen, self).__init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r
\r
## hash() operator\r
#\r
# architecture. This class will generate top level makefile.\r
#\r
class WorkspaceAutoGen(AutoGen):\r
- ## Real constructor of WorkspaceAutoGen\r
- #\r
- # This method behaves the same as __init__ except that it needs explicit invoke\r
- # (in super class's __new__ method)\r
+ # call super().__init__ then call the worker function with different parameter count\r
+ def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
+ try:\r
+ self._Init\r
+ except:\r
+ super(WorkspaceAutoGen, self).__init__(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r
+ self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r
+ self._Init = True\r
+ \r
+ ## Initialize WorkspaceAutoGen\r
#\r
# @param WorkspaceDir Root directory of workspace\r
# @param ActivePlatform Meta-file of active platform\r
# @param Caps Capsule list to be generated\r
# @param SkuId SKU id from command line\r
#\r
- def _Init(self, WorkspaceDir, ActivePlatform, Target, Toolchain, ArchList, MetaFileDb,\r
+ def _InitWorker(self, WorkspaceDir, ActivePlatform, Target, Toolchain, ArchList, MetaFileDb,\r
BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=None, Fvs=None, Caps=None, SkuId='', UniFlag=None,\r
Progress=None, BuildModule=None):\r
if Fds is None:\r
self.FvTargetList = Fvs\r
self.CapTargetList = Caps\r
self.AutoGenObjectList = []\r
+ self._BuildDir = None\r
+ self._FvDir = None\r
+ self._MakeFileDir = None\r
+ self._BuildCommand = None\r
+ self._GuidDict = {}\r
\r
# there's many relative directory operations, so ...\r
os.chdir(self.WorkspaceDir)\r
MetaFile_cache = {}\r
for Arch in self.ArchList:\r
Platform_cache[Arch] = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r
- MetaFile_cache[Arch] = []\r
- for Pkey in Platform_cache[Arch].Modules.keys():\r
- MetaFile_cache[Arch].append(Platform_cache[Arch].Modules[Pkey].MetaFile)\r
+ MetaFile_cache[Arch] = set()\r
+ for Pkey in Platform_cache[Arch].Modules:\r
+ MetaFile_cache[Arch].add(Platform_cache[Arch].Modules[Pkey].MetaFile)\r
for Inf in self.FdfProfile.InfDict[key]:\r
ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)\r
for Arch in self.ArchList:\r
for Arch in self.ArchList:\r
if Arch == key:\r
Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r
- MetaFileList = []\r
- for Pkey in Platform.Modules.keys():\r
- MetaFileList.append(Platform.Modules[Pkey].MetaFile)\r
+ MetaFileList = set()\r
+ for Pkey in Platform.Modules:\r
+ MetaFileList.add(Platform.Modules[Pkey].MetaFile)\r
for Inf in self.FdfProfile.InfDict[key]:\r
ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)\r
if ModuleFile in MetaFileList:\r
for Arch in self.ArchList:\r
Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r
\r
- DecPcds = {}\r
- DecPcdsKey = set()\r
- PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r
- if GlobalData.BuildOptionPcd:\r
- for i, pcd in enumerate(GlobalData.BuildOptionPcd):\r
- if type(pcd) is tuple:\r
- continue\r
- (pcdname, pcdvalue) = pcd.split('=')\r
- if not pcdvalue:\r
- EdkLogger.error('build', AUTOGEN_ERROR, "No Value specified for the PCD %s." % (pcdname))\r
- if '.' in pcdname:\r
- (TokenSpaceGuidCName, TokenCName) = pcdname.split('.')\r
- HasTokenSpace = True\r
- else:\r
- TokenCName = pcdname\r
- TokenSpaceGuidCName = ''\r
- HasTokenSpace = False\r
- TokenSpaceGuidCNameList = []\r
- FoundFlag = False\r
- PcdDatumType = ''\r
- NewValue = ''\r
- for package in PGen.PackageList:\r
- for key in package.Pcds:\r
- PcdItem = package.Pcds[key]\r
- if HasTokenSpace:\r
- if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName):\r
- PcdDatumType = PcdItem.DatumType\r
- NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
- FoundFlag = True\r
- else:\r
- if PcdItem.TokenCName == TokenCName:\r
- if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList:\r
- if len (TokenSpaceGuidCNameList) < 1:\r
- TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName)\r
- PcdDatumType = PcdItem.DatumType\r
- TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName\r
- NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
- FoundFlag = True\r
- else:\r
- EdkLogger.error(\r
- 'build',\r
- AUTOGEN_ERROR,\r
- "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0])\r
- )\r
-\r
- GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, NewValue)\r
-\r
- if not FoundFlag:\r
- if HasTokenSpace:\r
- EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s.%s is not found in the DEC file." % (TokenSpaceGuidCName, TokenCName))\r
- else:\r
- EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s is not found in the DEC file." % (TokenCName))\r
-\r
- for BuildData in PGen.BuildDatabase._CACHE_.values():\r
- if BuildData.Arch != Arch:\r
- continue\r
- if BuildData.MetaFile.Ext == '.dec':\r
- continue\r
- for key in BuildData.Pcds:\r
- PcdItem = BuildData.Pcds[key]\r
- if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName):\r
- PcdItem.DefaultValue = NewValue\r
-\r
- if (TokenCName, TokenSpaceGuidCName) in PcdSet:\r
- PcdSet[(TokenCName, TokenSpaceGuidCName)] = NewValue\r
-\r
- SourcePcdDict = {'DynamicEx':[], 'PatchableInModule':[],'Dynamic':[],'FixedAtBuild':[]}\r
- BinaryPcdDict = {'DynamicEx':[], 'PatchableInModule':[]}\r
+ SourcePcdDict = {'DynamicEx':set(), 'PatchableInModule':set(),'Dynamic':set(),'FixedAtBuild':set()}\r
+ BinaryPcdDict = {'DynamicEx':set(), 'PatchableInModule':set()}\r
SourcePcdDict_Keys = SourcePcdDict.keys()\r
BinaryPcdDict_Keys = BinaryPcdDict.keys()\r
\r
# generate the SourcePcdDict and BinaryPcdDict\r
+ PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r
for BuildData in PGen.BuildDatabase._CACHE_.values():\r
if BuildData.Arch != Arch:\r
continue\r
\r
if 'DynamicEx' in BuildData.Pcds[key].Type:\r
if BuildData.IsBinaryModule:\r
- if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in BinaryPcdDict['DynamicEx']:\r
- BinaryPcdDict['DynamicEx'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+ BinaryPcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
else:\r
- if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['DynamicEx']:\r
- SourcePcdDict['DynamicEx'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+ SourcePcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
\r
elif 'PatchableInModule' in BuildData.Pcds[key].Type:\r
if BuildData.MetaFile.Ext == '.inf':\r
if BuildData.IsBinaryModule:\r
- if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in BinaryPcdDict['PatchableInModule']:\r
- BinaryPcdDict['PatchableInModule'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+ BinaryPcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
else:\r
- if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['PatchableInModule']:\r
- SourcePcdDict['PatchableInModule'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+ SourcePcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
\r
elif 'Dynamic' in BuildData.Pcds[key].Type:\r
- if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['Dynamic']:\r
- SourcePcdDict['Dynamic'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+ SourcePcdDict['Dynamic'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
elif 'FixedAtBuild' in BuildData.Pcds[key].Type:\r
- if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['FixedAtBuild']:\r
- SourcePcdDict['FixedAtBuild'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+ SourcePcdDict['FixedAtBuild'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
else:\r
pass\r
#\r
for i in SourcePcdDict_Keys:\r
for j in SourcePcdDict_Keys:\r
if i != j:\r
- IntersectionList = list(set(SourcePcdDict[i]).intersection(set(SourcePcdDict[j])))\r
- if len(IntersectionList) > 0:\r
+ Intersections = SourcePcdDict[i].intersection(SourcePcdDict[j])\r
+ if len(Intersections) > 0:\r
EdkLogger.error(\r
'build',\r
FORMAT_INVALID,\r
"Building modules from source INFs, following PCD use %s and %s access method. It must be corrected to use only one access method." % (i, j),\r
- ExtraData="%s" % '\n\t'.join([str(P[1]+'.'+P[0]) for P in IntersectionList])\r
+ ExtraData="%s" % '\n\t'.join([str(P[1]+'.'+P[0]) for P in Intersections])\r
)\r
- else:\r
- pass\r
\r
#\r
# intersection the BinaryPCD for Mixed PCD\r
for i in BinaryPcdDict_Keys:\r
for j in BinaryPcdDict_Keys:\r
if i != j:\r
- IntersectionList = list(set(BinaryPcdDict[i]).intersection(set(BinaryPcdDict[j])))\r
- for item in IntersectionList:\r
+ Intersections = BinaryPcdDict[i].intersection(BinaryPcdDict[j])\r
+ for item in Intersections:\r
NewPcd1 = (item[0] + '_' + i, item[1])\r
NewPcd2 = (item[0] + '_' + j, item[1])\r
if item not in GlobalData.MixedPcd:\r
GlobalData.MixedPcd[item].append(NewPcd1)\r
if NewPcd2 not in GlobalData.MixedPcd[item]:\r
GlobalData.MixedPcd[item].append(NewPcd2)\r
- else:\r
- pass\r
\r
#\r
# intersection the SourcePCD and BinaryPCD for Mixed PCD\r
for i in SourcePcdDict_Keys:\r
for j in BinaryPcdDict_Keys:\r
if i != j:\r
- IntersectionList = list(set(SourcePcdDict[i]).intersection(set(BinaryPcdDict[j])))\r
- for item in IntersectionList:\r
+ Intersections = SourcePcdDict[i].intersection(BinaryPcdDict[j])\r
+ for item in Intersections:\r
NewPcd1 = (item[0] + '_' + i, item[1])\r
NewPcd2 = (item[0] + '_' + j, item[1])\r
if item not in GlobalData.MixedPcd:\r
GlobalData.MixedPcd[item].append(NewPcd1)\r
if NewPcd2 not in GlobalData.MixedPcd[item]:\r
GlobalData.MixedPcd[item].append(NewPcd2)\r
- else:\r
- pass\r
\r
for BuildData in PGen.BuildDatabase._CACHE_.values():\r
if BuildData.Arch != Arch:\r
del BuildData.Pcds[key]\r
BuildData.Pcds[newkey] = Value\r
break\r
- else:\r
- pass\r
break\r
- else:\r
- pass\r
\r
# handle the mixed pcd in FDF file\r
for key in PcdSet:\r
ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]\r
PkgSet.update(ModuleData.Packages)\r
Pkgs = list(PkgSet) + list(PGen.PackageList)\r
+ DecPcds = set()\r
+ DecPcdsKey = set()\r
for Pkg in Pkgs:\r
for Pcd in Pkg.Pcds:\r
- DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd]\r
+ DecPcds.add((Pcd[0], Pcd[1]))\r
DecPcdsKey.add((Pcd[0], Pcd[1], Pcd[2]))\r
\r
Platform.SkuName = self.SkuId\r
Pa.CollectFixedAtBuildPcds()\r
self.AutoGenObjectList.append(Pa)\r
\r
+ #\r
+ # Generate Package level hash value\r
+ #\r
+ GlobalData.gPackageHash[Arch] = {}\r
+ if GlobalData.gUseHashCache:\r
+ for Pkg in Pkgs:\r
+ self._GenPkgLevelHash(Pkg)\r
+\r
#\r
# Check PCDs token value conflict in each DEC file.\r
#\r
# if self.FdfFile:\r
# self._CheckDuplicateInFV(Fdf)\r
\r
- self._BuildDir = None\r
- self._FvDir = None\r
- self._MakeFileDir = None\r
- self._BuildCommand = None\r
-\r
#\r
# Create BuildOptions Macro & PCD metafile, also add the Active Platform and FDF file.\r
#\r
if self.FdfFile:\r
content += 'Flash Image Definition: '\r
content += str(self.FdfFile)\r
+ content += os.linesep\r
SaveFileOnChange(os.path.join(self.BuildDir, 'BuildOptions'), content, False)\r
\r
#\r
SrcTimeStamp = os.stat(f)[8]\r
self._SrcTimeStamp = SrcTimeStamp\r
\r
+ if GlobalData.gUseHashCache:\r
+ m = hashlib.md5()\r
+ for files in AllWorkSpaceMetaFiles:\r
+ if files.endswith('.dec'):\r
+ continue\r
+ f = open(files, 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+ SaveFileOnChange(os.path.join(self.BuildDir, 'AutoGen.hash'), m.hexdigest(), True)\r
+ GlobalData.gPlatformHash = m.hexdigest()\r
+\r
#\r
# Write metafile list to build directory\r
#\r
print >> file, f\r
return True\r
\r
+ def _GenPkgLevelHash(self, Pkg):\r
+ PkgDir = os.path.join(self.BuildDir, Pkg.Arch, Pkg.PackageName)\r
+ CreateDirectory(PkgDir)\r
+ HashFile = os.path.join(PkgDir, Pkg.PackageName + '.hash')\r
+ m = hashlib.md5()\r
+ # Get .dec file's hash value\r
+ f = open(Pkg.MetaFile.Path, 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+ # Get include files hash value\r
+ if Pkg.Includes:\r
+ for inc in Pkg.Includes:\r
+ for Root, Dirs, Files in os.walk(str(inc)):\r
+ for File in Files:\r
+ File_Path = os.path.join(Root, File)\r
+ f = open(File_Path, 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+ SaveFileOnChange(HashFile, m.hexdigest(), True)\r
+ if Pkg.PackageName not in GlobalData.gPackageHash[Pkg.Arch]:\r
+ GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = m.hexdigest()\r
\r
def _GetMetaFiles(self, Target, Toolchain, Arch):\r
AllWorkSpaceMetaFiles = set()\r
for Fv in Fdf.Profile.FvDict:\r
_GuidDict = {}\r
for FfsFile in Fdf.Profile.FvDict[Fv].FfsList:\r
- if FfsFile.InfFileName and FfsFile.NameGuid == None:\r
+ if FfsFile.InfFileName and FfsFile.NameGuid is None:\r
#\r
# Get INF file GUID\r
#\r
ExtraData=self.FdfFile)\r
InfFoundFlag = False\r
\r
- if FfsFile.NameGuid != None:\r
- _CheckPCDAsGuidPattern = re.compile("^PCD\(.+\..+\)$")\r
-\r
+ if FfsFile.NameGuid is not None:\r
#\r
# If the NameGuid reference a PCD name. \r
# The style must match: PCD(xxxx.yyy)\r
#\r
- if _CheckPCDAsGuidPattern.match(FfsFile.NameGuid):\r
+ if gPCDAsGuidPattern.match(FfsFile.NameGuid):\r
#\r
# Replace the PCD value.\r
#\r
]\r
\r
# This dict store PCDs which are not used by any modules with specified arches\r
- UnusedPcd = sdict()\r
+ UnusedPcd = OrderedDict()\r
for Pa in self.AutoGenObjectList:\r
# Key of DSC's Pcds dictionary is PcdCName, TokenSpaceGuid\r
for Pcd in Pa.Platform.Pcds:\r
\r
## Return the directory to store FV files\r
def _GetFvDir(self):\r
- if self._FvDir == None:\r
+ if self._FvDir is None:\r
self._FvDir = path.join(self.BuildDir, 'FV')\r
return self._FvDir\r
\r
## Return the directory to store all intermediate and final files built\r
def _GetBuildDir(self):\r
- return self.AutoGenObjectList[0].BuildDir\r
+ if self._BuildDir is None:\r
+ return self.AutoGenObjectList[0].BuildDir\r
\r
## Return the build output directory platform specifies\r
def _GetOutputDir(self):\r
# @retval string Makefile directory\r
#\r
def _GetMakeFileDir(self):\r
- if self._MakeFileDir == None:\r
+ if self._MakeFileDir is None:\r
self._MakeFileDir = self.BuildDir\r
return self._MakeFileDir\r
\r
# @retval string Build command string\r
#\r
def _GetBuildCommand(self):\r
- if self._BuildCommand == None:\r
+ if self._BuildCommand is None:\r
# BuildCommand should be all the same. So just get one from platform AutoGen\r
self._BuildCommand = self.AutoGenObjectList[0].BuildCommand\r
return self._BuildCommand\r
# file in order to generate makefile for platform.\r
#\r
class PlatformAutoGen(AutoGen):\r
+ # call super().__init__ then call the worker function with different parameter count\r
+ def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
+ try:\r
+ self._Init\r
+ except:\r
+ super(PlatformAutoGen, self).__init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r
+ self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch)\r
+ self._Init = True\r
#\r
# Used to store all PCDs for both PEI and DXE phase, in order to generate \r
# correct PCD database\r
"0x10001" : 2, # TARGET_*********_****_***********_ATTRIBUTE\r
"0x00001" : 1} # ******_*********_****_***********_ATTRIBUTE (Lowest)\r
\r
- ## The real constructor of PlatformAutoGen\r
+ ## Initialize PlatformAutoGen\r
#\r
- # This method is not supposed to be called by users of PlatformAutoGen. It's\r
- # only used by factory method __new__() to do real initialization work for an\r
- # object of PlatformAutoGen\r
#\r
# @param Workspace WorkspaceAutoGen object\r
# @param PlatformFile Platform file (DSC file)\r
# @param Toolchain Name of tool chain\r
# @param Arch arch of the platform supports\r
#\r
- def _Init(self, Workspace, PlatformFile, Target, Toolchain, Arch):\r
+ def _InitWorker(self, Workspace, PlatformFile, Target, Toolchain, Arch):\r
EdkLogger.debug(EdkLogger.DEBUG_9, "AutoGen platform [%s] [%s]" % (PlatformFile, Arch))\r
GlobalData.gProcessingFile = "%s [%s, %s, %s]" % (PlatformFile, Arch, Toolchain, Target)\r
\r
self.AllPcdList = []\r
# get the original module/package/platform objects\r
self.BuildDatabase = Workspace.BuildDatabase\r
+ self.DscBuildDataObj = Workspace.Platform\r
+ self._GuidDict = Workspace._GuidDict\r
\r
# flag indicating if the makefile/C-code file has been created or not\r
self.IsMakeFileCreated = False\r
self._BuildCommand = None\r
self._AsBuildInfList = []\r
self._AsBuildModuleList = []\r
- if GlobalData.gFdfParser != None:\r
+\r
+ self.VariableInfo = None\r
+\r
+ if GlobalData.gFdfParser is not None:\r
self._AsBuildInfList = GlobalData.gFdfParser.Profile.InfList\r
for Inf in self._AsBuildInfList:\r
InfClass = PathClass(NormPath(Inf), GlobalData.gWorkspace, self.Arch)\r
# get library/modules for build\r
self.LibraryBuildDirectoryList = []\r
self.ModuleBuildDirectoryList = []\r
+\r
return True\r
\r
def __repr__(self):\r
# @param CreateModuleMakeFile Flag indicating if the makefile for\r
# modules will be created as well\r
#\r
- def CreateMakeFile(self, CreateModuleMakeFile=False):\r
+ def CreateMakeFile(self, CreateModuleMakeFile=False, FfsCommand = {}):\r
if CreateModuleMakeFile:\r
for ModuleFile in self.Platform.Modules:\r
Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget,\r
self.ToolChain, self.Arch, self.MetaFile)\r
- Ma.CreateMakeFile(True)\r
+ if (ModuleFile.File, self.Arch) in FfsCommand:\r
+ Ma.CreateMakeFile(True, FfsCommand[ModuleFile.File, self.Arch])\r
+ else:\r
+ Ma.CreateMakeFile(True)\r
#Ma.CreateAsBuiltInf()\r
\r
# no need to create makefile for the platform more than once\r
if key in ShareFixedAtBuildPcdsSameValue and ShareFixedAtBuildPcdsSameValue[key]: \r
LibAuto.ConstPcd[key] = Pcd.DefaultValue\r
\r
+ def CollectVariables(self, DynamicPcdSet):\r
+\r
+ VpdRegionSize = 0\r
+ VpdRegionBase = 0\r
+ if self.Workspace.FdfFile:\r
+ FdDict = self.Workspace.FdfProfile.FdDict[GlobalData.gFdfParser.CurrentFdName]\r
+ for FdRegion in FdDict.RegionList:\r
+ for item in FdRegion.RegionDataList:\r
+ if self.Platform.VpdToolGuid.strip() and self.Platform.VpdToolGuid in item:\r
+ VpdRegionSize = FdRegion.Size\r
+ VpdRegionBase = FdRegion.Offset\r
+ break\r
+\r
+\r
+ VariableInfo = VariableMgr(self.DscBuildDataObj._GetDefaultStores(),self.DscBuildDataObj._GetSkuIds())\r
+ VariableInfo.SetVpdRegionMaxSize(VpdRegionSize)\r
+ VariableInfo.SetVpdRegionOffset(VpdRegionBase)\r
+ Index = 0\r
+ for Pcd in DynamicPcdSet:\r
+ pcdname = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName))\r
+ for SkuName in Pcd.SkuInfoList:\r
+ Sku = Pcd.SkuInfoList[SkuName]\r
+ SkuId = Sku.SkuId\r
+ if SkuId is None or SkuId == '':\r
+ continue\r
+ if len(Sku.VariableName) > 0:\r
+ VariableGuidStructure = Sku.VariableGuidValue\r
+ VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure)\r
+ for StorageName in Sku.DefaultStoreDict:\r
+ VariableInfo.append_variable(var_info(Index,pcdname,StorageName,SkuName, StringToArray(Sku.VariableName),VariableGuid, Sku.VariableOffset, Sku.VariableAttribute , Sku.HiiDefaultValue,Sku.DefaultStoreDict[StorageName],Pcd.DatumType))\r
+ Index += 1\r
+ return VariableInfo\r
+\r
+ def UpdateNVStoreMaxSize(self,OrgVpdFile):\r
+ if self.VariableInfo:\r
+ VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)\r
+ PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]\r
+\r
+ if PcdNvStoreDfBuffer:\r
+ if os.path.exists(VpdMapFilePath):\r
+ OrgVpdFile.Read(VpdMapFilePath)\r
+ PcdItems = OrgVpdFile.GetOffset(PcdNvStoreDfBuffer[0])\r
+ NvStoreOffset = PcdItems.values()[0].strip() if PcdItems else '0'\r
+ else:\r
+ EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)\r
+\r
+ NvStoreOffset = int(NvStoreOffset,16) if NvStoreOffset.upper().startswith("0X") else int(NvStoreOffset)\r
+ default_skuobj = PcdNvStoreDfBuffer[0].SkuInfoList.get("DEFAULT")\r
+ maxsize = self.VariableInfo.VpdRegionSize - NvStoreOffset if self.VariableInfo.VpdRegionSize else len(default_skuobj.DefaultValue.split(","))\r
+ var_data = self.VariableInfo.PatchNVStoreDefaultMaxSize(maxsize)\r
+\r
+ if var_data and default_skuobj:\r
+ default_skuobj.DefaultValue = var_data\r
+ PcdNvStoreDfBuffer[0].DefaultValue = var_data\r
+ PcdNvStoreDfBuffer[0].SkuInfoList.clear()\r
+ PcdNvStoreDfBuffer[0].SkuInfoList['DEFAULT'] = default_skuobj\r
+ PcdNvStoreDfBuffer[0].MaxDatumSize = str(len(default_skuobj.DefaultValue.split(",")))\r
+\r
+ return OrgVpdFile\r
+\r
## Collect dynamic PCDs\r
#\r
# Gather dynamic PCDs list from each module and their settings from platform\r
# This interface should be invoked explicitly when platform action is created.\r
#\r
def CollectPlatformDynamicPcds(self):\r
- # Override the platform Pcd's value by build option\r
- if GlobalData.BuildOptionPcd:\r
- for key in self.Platform.Pcds:\r
- PlatformPcd = self.Platform.Pcds[key]\r
- for PcdItem in GlobalData.BuildOptionPcd:\r
- if (PlatformPcd.TokenSpaceGuidCName, PlatformPcd.TokenCName) == (PcdItem[0], PcdItem[1]):\r
- PlatformPcd.DefaultValue = PcdItem[2]\r
- if PlatformPcd.SkuInfoList:\r
- Sku = PlatformPcd.SkuInfoList[PlatformPcd.SkuInfoList.keys()[0]]\r
- Sku.DefaultValue = PcdItem[2]\r
- break\r
\r
for key in self.Platform.Pcds:\r
for SinglePcd in GlobalData.MixedPcd:\r
\r
# for gathering error information\r
NoDatumTypePcdList = set()\r
- PcdNotInDb = []\r
- self._GuidValue = {}\r
FdfModuleList = []\r
for InfName in self._AsBuildInfList:\r
InfName = mws.join(self.WorkspaceDir, InfName)\r
if PcdFromModule.Type in GenC.gDynamicPcd and \\r
PcdFromModule.IsFromBinaryInf == False:\r
# Print warning message to let the developer make a determine.\r
- if PcdFromModule not in PcdNotInDb:\r
- PcdNotInDb.append(PcdFromModule)\r
continue\r
# If one of the Source built modules listed in the DSC is not listed in \r
# FDF modules, and the INF lists a PCD can only use the PcdsDynamicEx \r
# PCD as PcdsDynamicEx), then DO NOT break the build; DO NOT add the \r
# PCD to the Platform's PCD Database.\r
if PcdFromModule.Type in GenC.gDynamicExPcd:\r
- if PcdFromModule not in PcdNotInDb:\r
- PcdNotInDb.append(PcdFromModule)\r
continue\r
#\r
# If a dynamic PCD used by a PEM module/PEI module & DXE module,\r
#\r
# The reason of sorting is make sure the unicode string is in double-byte alignment in string table.\r
#\r
- UnicodePcdArray = []\r
- HiiPcdArray = []\r
- OtherPcdArray = []\r
+ UnicodePcdArray = set()\r
+ HiiPcdArray = set()\r
+ OtherPcdArray = set()\r
VpdPcdDict = {}\r
VpdFile = VpdInfoFile.VpdInfoFile()\r
NeedProcessVpdMapFile = False\r
if pcd not in self._PlatformPcds.keys():\r
self._PlatformPcds[pcd] = self.Platform.Pcds[pcd]\r
\r
+ for item in self._PlatformPcds:\r
+ if self._PlatformPcds[item].DatumType and self._PlatformPcds[item].DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
+ self._PlatformPcds[item].DatumType = "VOID*"\r
+\r
if (self.Workspace.ArchList[-1] == self.Arch): \r
for Pcd in self._DynamicPcdList:\r
# just pick the a value to determine whether is unicode string type\r
Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
Sku.VpdOffset = Sku.VpdOffset.strip()\r
\r
- PcdValue = Sku.DefaultValue\r
- if Pcd.DatumType == 'VOID*' and PcdValue.startswith("L"):\r
+ if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
+ Pcd.DatumType = "VOID*"\r
+\r
# if found PCD which datum value is unicode string the insert to left size of UnicodeIndex\r
- UnicodePcdArray.append(Pcd)\r
- elif len(Sku.VariableName) > 0:\r
# if found HII type PCD then insert to right of UnicodeIndex\r
- HiiPcdArray.append(Pcd)\r
- else:\r
- OtherPcdArray.append(Pcd)\r
if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
VpdPcdDict[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)] = Pcd\r
\r
+ #Collect DynamicHii PCD values and assign it to DynamicExVpd PCD gEfiMdeModulePkgTokenSpaceGuid.PcdNvStoreDefaultValueBuffer\r
+ PcdNvStoreDfBuffer = VpdPcdDict.get(("PcdNvStoreDefaultValueBuffer","gEfiMdeModulePkgTokenSpaceGuid"))\r
+ if PcdNvStoreDfBuffer:\r
+ self.VariableInfo = self.CollectVariables(self._DynamicPcdList)\r
+ vardump = self.VariableInfo.dump()\r
+ if vardump:\r
+ PcdNvStoreDfBuffer.DefaultValue = vardump\r
+ for skuname in PcdNvStoreDfBuffer.SkuInfoList:\r
+ PcdNvStoreDfBuffer.SkuInfoList[skuname].DefaultValue = vardump\r
+ PcdNvStoreDfBuffer.MaxDatumSize = str(len(vardump.split(",")))\r
+\r
PlatformPcds = self._PlatformPcds.keys()\r
PlatformPcds.sort()\r
#\r
# Add VPD type PCD into VpdFile and determine whether the VPD PCD need to be fixed up.\r
#\r
+ VpdSkuMap = {}\r
for PcdKey in PlatformPcds:\r
Pcd = self._PlatformPcds[PcdKey]\r
if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD] and \\r
PcdKey in VpdPcdDict:\r
Pcd = VpdPcdDict[PcdKey]\r
+ SkuValueMap = {}\r
+ DefaultSku = Pcd.SkuInfoList.get('DEFAULT')\r
+ if DefaultSku:\r
+ PcdValue = DefaultSku.DefaultValue\r
+ if PcdValue not in SkuValueMap:\r
+ SkuValueMap[PcdValue] = []\r
+ VpdFile.Add(Pcd, 'DEFAULT',DefaultSku.VpdOffset)\r
+ SkuValueMap[PcdValue].append(DefaultSku)\r
+\r
for (SkuName,Sku) in Pcd.SkuInfoList.items():\r
Sku.VpdOffset = Sku.VpdOffset.strip()\r
PcdValue = Sku.DefaultValue\r
EdkLogger.warn("build", "The offset value of PCD %s.%s is not 8-byte aligned!" %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName), File=self.MetaFile)\r
else:\r
EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Alignment))\r
- VpdFile.Add(Pcd, Sku.VpdOffset)\r
+ if PcdValue not in SkuValueMap:\r
+ SkuValueMap[PcdValue] = []\r
+ VpdFile.Add(Pcd, SkuName,Sku.VpdOffset)\r
+ SkuValueMap[PcdValue].append(Sku)\r
# if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
NeedProcessVpdMapFile = True\r
- if self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == '':\r
+ if self.Platform.VpdToolGuid is None or self.Platform.VpdToolGuid == '':\r
EdkLogger.error("Build", FILE_NOT_FOUND, \\r
"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.")\r
\r
-\r
+ VpdSkuMap[PcdKey] = SkuValueMap\r
#\r
# Fix the PCDs define in VPD PCD section that never referenced by module.\r
# An example is PCD for signature usage.\r
for DscPcd in PlatformPcds:\r
DscPcdEntry = self._PlatformPcds[DscPcd]\r
if DscPcdEntry.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
- if not (self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == ''):\r
+ if not (self.Platform.VpdToolGuid is None or self.Platform.VpdToolGuid == ''):\r
FoundFlag = False\r
for VpdPcd in VpdFile._VpdArray.keys():\r
# This PCD has been referenced by module\r
# Not found, it should be signature\r
if not FoundFlag :\r
# just pick the a value to determine whether is unicode string type\r
- for (SkuName,Sku) in DscPcdEntry.SkuInfoList.items():\r
+ SkuValueMap = {}\r
+ SkuObjList = DscPcdEntry.SkuInfoList.items()\r
+ DefaultSku = DscPcdEntry.SkuInfoList.get('DEFAULT')\r
+ if DefaultSku:\r
+ defaultindex = SkuObjList.index(('DEFAULT',DefaultSku))\r
+ SkuObjList[0],SkuObjList[defaultindex] = SkuObjList[defaultindex],SkuObjList[0]\r
+ for (SkuName,Sku) in SkuObjList:\r
Sku.VpdOffset = Sku.VpdOffset.strip() \r
\r
# Need to iterate DEC pcd information to get the value & datumtype\r
\r
if DscPcdEntry not in self._DynamicPcdList:\r
self._DynamicPcdList.append(DscPcdEntry)\r
-# Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]\r
Sku.VpdOffset = Sku.VpdOffset.strip()\r
PcdValue = Sku.DefaultValue\r
if PcdValue == "":\r
EdkLogger.warn("build", "The offset value of PCD %s.%s is not 8-byte aligned!" %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName), File=self.MetaFile)\r
else:\r
EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, Alignment))\r
- VpdFile.Add(DscPcdEntry, Sku.VpdOffset)\r
+ if PcdValue not in SkuValueMap:\r
+ SkuValueMap[PcdValue] = []\r
+ VpdFile.Add(DscPcdEntry, SkuName,Sku.VpdOffset)\r
+ SkuValueMap[PcdValue].append(Sku)\r
if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
NeedProcessVpdMapFile = True \r
if DscPcdEntry.DatumType == 'VOID*' and PcdValue.startswith("L"):\r
- UnicodePcdArray.append(DscPcdEntry)\r
+ UnicodePcdArray.add(DscPcdEntry)\r
elif len(Sku.VariableName) > 0:\r
- HiiPcdArray.append(DscPcdEntry)\r
+ HiiPcdArray.add(DscPcdEntry)\r
else:\r
- OtherPcdArray.append(DscPcdEntry)\r
- \r
+ OtherPcdArray.add(DscPcdEntry)\r
+\r
# if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
- \r
- \r
- \r
- if (self.Platform.FlashDefinition == None or self.Platform.FlashDefinition == '') and \\r
+ VpdSkuMap[DscPcd] = SkuValueMap\r
+ if (self.Platform.FlashDefinition is None or self.Platform.FlashDefinition == '') and \\r
VpdFile.GetCount() != 0:\r
EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, \r
"Fail to get FLASH_DEFINITION definition in DSC file %s which is required when DSC contains VPD PCD." % str(self.Platform.MetaFile))\r
\r
if VpdFile.GetCount() != 0:\r
- FvPath = os.path.join(self.BuildDir, "FV")\r
- if not os.path.exists(FvPath):\r
- try:\r
- os.makedirs(FvPath)\r
- except:\r
- EdkLogger.error("build", FILE_WRITE_FAILURE, "Fail to create FV folder under %s" % self.BuildDir)\r
-\r
- VpdFilePath = os.path.join(FvPath, "%s.txt" % self.Platform.VpdToolGuid)\r
-\r
- if VpdFile.Write(VpdFilePath):\r
- # retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.\r
- BPDGToolName = None\r
- for ToolDef in self.ToolDefinition.values():\r
- if ToolDef.has_key("GUID") and ToolDef["GUID"] == self.Platform.VpdToolGuid:\r
- if not ToolDef.has_key("PATH"):\r
- EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % self.Platform.VpdToolGuid)\r
- BPDGToolName = ToolDef["PATH"]\r
- break\r
- # Call third party GUID BPDG tool.\r
- if BPDGToolName != None:\r
- VpdInfoFile.CallExtenalBPDGTool(BPDGToolName, VpdFilePath)\r
- else:\r
- 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.")\r
+\r
+ self.FixVpdOffset(VpdFile)\r
+\r
+ self.FixVpdOffset(self.UpdateNVStoreMaxSize(VpdFile))\r
\r
# Process VPD map file generated by third party BPDG tool\r
if NeedProcessVpdMapFile:\r
VpdFile.Read(VpdMapFilePath)\r
\r
# Fixup "*" offset\r
- for Pcd in self._DynamicPcdList:\r
+ for pcd in VpdSkuMap:\r
+ vpdinfo = VpdFile.GetVpdInfo(pcd)\r
+ if vpdinfo is None:\r
# just pick the a value to determine whether is unicode string type\r
- i = 0\r
- for (SkuName,Sku) in Pcd.SkuInfoList.items(): \r
- if Sku.VpdOffset == "*":\r
- Sku.VpdOffset = VpdFile.GetOffset(Pcd)[i].strip()\r
- i += 1\r
+ continue\r
+ for pcdvalue in VpdSkuMap[pcd]:\r
+ for sku in VpdSkuMap[pcd][pcdvalue]:\r
+ for item in vpdinfo:\r
+ if item[2] == pcdvalue:\r
+ sku.VpdOffset = item[1]\r
else:\r
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)\r
\r
- # Delete the DynamicPcdList At the last time enter into this function \r
+ # Delete the DynamicPcdList At the last time enter into this function\r
+ for Pcd in self._DynamicPcdList:\r
+ # just pick the a value to determine whether is unicode string type\r
+ Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
+ Sku.VpdOffset = Sku.VpdOffset.strip()\r
+\r
+ if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
+ Pcd.DatumType = "VOID*"\r
+\r
+ PcdValue = Sku.DefaultValue\r
+ if Pcd.DatumType == 'VOID*' and PcdValue.startswith("L"):\r
+ # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex\r
+ UnicodePcdArray.add(Pcd)\r
+ elif len(Sku.VariableName) > 0:\r
+ # if found HII type PCD then insert to right of UnicodeIndex\r
+ HiiPcdArray.add(Pcd)\r
+ else:\r
+ OtherPcdArray.add(Pcd)\r
del self._DynamicPcdList[:]\r
- self._DynamicPcdList.extend(UnicodePcdArray)\r
- self._DynamicPcdList.extend(HiiPcdArray)\r
- self._DynamicPcdList.extend(OtherPcdArray)\r
+ self._DynamicPcdList.extend(list(UnicodePcdArray))\r
+ self._DynamicPcdList.extend(list(HiiPcdArray))\r
+ self._DynamicPcdList.extend(list(OtherPcdArray))\r
+ allskuset = [(SkuName,Sku.SkuId) for pcd in self._DynamicPcdList for (SkuName,Sku) in pcd.SkuInfoList.items()]\r
+ for pcd in self._DynamicPcdList:\r
+ if len(pcd.SkuInfoList) == 1:\r
+ for (SkuName,SkuId) in allskuset:\r
+ if type(SkuId) in (str,unicode) and eval(SkuId) == 0 or SkuId == 0:\r
+ continue\r
+ pcd.SkuInfoList[SkuName] = copy.deepcopy(pcd.SkuInfoList['DEFAULT'])\r
+ pcd.SkuInfoList[SkuName].SkuId = SkuId\r
self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList\r
- \r
+\r
+ def FixVpdOffset(self,VpdFile ):\r
+ FvPath = os.path.join(self.BuildDir, "FV")\r
+ if not os.path.exists(FvPath):\r
+ try:\r
+ os.makedirs(FvPath)\r
+ except:\r
+ EdkLogger.error("build", FILE_WRITE_FAILURE, "Fail to create FV folder under %s" % self.BuildDir)\r
+\r
+ VpdFilePath = os.path.join(FvPath, "%s.txt" % self.Platform.VpdToolGuid)\r
+\r
+ if VpdFile.Write(VpdFilePath):\r
+ # retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.\r
+ BPDGToolName = None\r
+ for ToolDef in self.ToolDefinition.values():\r
+ if ToolDef.has_key("GUID") and ToolDef["GUID"] == self.Platform.VpdToolGuid:\r
+ if not ToolDef.has_key("PATH"):\r
+ EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % self.Platform.VpdToolGuid)\r
+ BPDGToolName = ToolDef["PATH"]\r
+ break\r
+ # Call third party GUID BPDG tool.\r
+ if BPDGToolName is not None:\r
+ VpdInfoFile.CallExtenalBPDGTool(BPDGToolName, VpdFilePath)\r
+ else:\r
+ 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.")\r
+\r
## Return the platform build data object\r
def _GetPlatform(self):\r
- if self._Platform == None:\r
+ if self._Platform is None:\r
self._Platform = self.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]\r
return self._Platform\r
\r
\r
## Return the FDF file name\r
def _GetFdfFile(self):\r
- if self._FdfFile == None:\r
+ if self._FdfFile is None:\r
if self.Workspace.FdfFile != "":\r
self._FdfFile= mws.join(self.WorkspaceDir, self.Workspace.FdfFile)\r
else:\r
\r
## Return the directory to store all intermediate and final files built\r
def _GetBuildDir(self):\r
- if self._BuildDir == None:\r
+ if self._BuildDir is None:\r
if os.path.isabs(self.OutputDir):\r
self._BuildDir = path.join(\r
path.abspath(self.OutputDir),\r
self.OutputDir,\r
self.BuildTarget + "_" + self.ToolChain,\r
)\r
+ GlobalData.gBuildDirectory = self._BuildDir\r
return self._BuildDir\r
\r
## Return directory of platform makefile\r
# @retval string Makefile directory\r
#\r
def _GetMakeFileDir(self):\r
- if self._MakeFileDir == None:\r
+ if self._MakeFileDir is None:\r
self._MakeFileDir = path.join(self.BuildDir, self.Arch)\r
return self._MakeFileDir\r
\r
# @retval string Build command string\r
#\r
def _GetBuildCommand(self):\r
- if self._BuildCommand == None:\r
+ if self._BuildCommand is None:\r
self._BuildCommand = []\r
if "MAKE" in self.ToolDefinition and "PATH" in self.ToolDefinition["MAKE"]:\r
self._BuildCommand += SplitOption(self.ToolDefinition["MAKE"]["PATH"])\r
NewOption = self.ToolDefinition["MAKE"]["FLAGS"].strip()\r
if NewOption != '':\r
self._BuildCommand += SplitOption(NewOption)\r
+ if "MAKE" in self.EdkIIBuildOption:\r
+ if "FLAGS" in self.EdkIIBuildOption["MAKE"]:\r
+ Flags = self.EdkIIBuildOption["MAKE"]["FLAGS"]\r
+ if Flags.startswith('='):\r
+ self._BuildCommand = [self._BuildCommand[0]] + [Flags[1:]]\r
+ else:\r
+ self._BuildCommand += [Flags]\r
return self._BuildCommand\r
\r
## Get tool chain definition\r
# Get each tool defition for given tool chain from tools_def.txt and platform\r
#\r
def _GetToolDefinition(self):\r
- if self._ToolDefinitions == None:\r
+ if self._ToolDefinitions is None:\r
ToolDefinition = self.Workspace.ToolDef.ToolsDefTxtDictionary\r
if TAB_TOD_DEFINES_COMMAND_TYPE not in self.Workspace.ToolDef.ToolsDefTxtDatabase:\r
EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "No tools found in configuration",\r
self._ToolDefinitions[Tool][Attr] = Value\r
\r
ToolsDef = ''\r
- MakePath = ''\r
if GlobalData.gOptions.SilentMode and "MAKE" in self._ToolDefinitions:\r
if "FLAGS" not in self._ToolDefinitions["MAKE"]:\r
self._ToolDefinitions["MAKE"]["FLAGS"] = ""\r
\r
if Attr == "PATH":\r
# Don't put MAKE definition in the file\r
- if Tool == "MAKE":\r
- MakePath = Value\r
- else:\r
+ if Tool != "MAKE":\r
ToolsDef += "%s = %s\n" % (Tool, Value)\r
elif Attr != "DLL":\r
# Don't put MAKE definition in the file\r
\r
## Return the paths of tools\r
def _GetToolDefFile(self):\r
- if self._ToolDefFile == None:\r
+ if self._ToolDefFile is None:\r
self._ToolDefFile = os.path.join(self.MakeFileDir, "TOOLS_DEF." + self.Arch)\r
return self._ToolDefFile\r
\r
## Retrieve the toolchain family of given toolchain tag. Default to 'MSFT'.\r
def _GetToolChainFamily(self):\r
- if self._ToolChainFamily == None:\r
+ if self._ToolChainFamily is None:\r
ToolDefinition = self.Workspace.ToolDef.ToolsDefTxtDatabase\r
if TAB_TOD_DEFINES_FAMILY not in ToolDefinition \\r
or self.ToolChain not in ToolDefinition[TAB_TOD_DEFINES_FAMILY] \\r
return self._ToolChainFamily\r
\r
def _GetBuildRuleFamily(self):\r
- if self._BuildRuleFamily == None:\r
+ if self._BuildRuleFamily is None:\r
ToolDefinition = self.Workspace.ToolDef.ToolsDefTxtDatabase\r
if TAB_TOD_DEFINES_BUILDRULEFAMILY not in ToolDefinition \\r
or self.ToolChain not in ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY] \\r
\r
## Return the build options specific for all modules in this platform\r
def _GetBuildOptions(self):\r
- if self._BuildOption == None:\r
+ if self._BuildOption is None:\r
self._BuildOption = self._ExpandBuildOption(self.Platform.BuildOptions)\r
return self._BuildOption\r
\r
## Return the build options specific for EDK modules in this platform\r
def _GetEdkBuildOptions(self):\r
- if self._EdkBuildOption == None:\r
+ if self._EdkBuildOption is None:\r
self._EdkBuildOption = self._ExpandBuildOption(self.Platform.BuildOptions, EDK_NAME)\r
return self._EdkBuildOption\r
\r
## Return the build options specific for EDKII modules in this platform\r
def _GetEdkIIBuildOptions(self):\r
- if self._EdkIIBuildOption == None:\r
+ if self._EdkIIBuildOption is None:\r
self._EdkIIBuildOption = self._ExpandBuildOption(self.Platform.BuildOptions, EDKII_NAME)\r
return self._EdkIIBuildOption\r
\r
# @retval BuildRule object\r
#\r
def _GetBuildRule(self):\r
- if self._BuildRule == None:\r
+ if self._BuildRule is None:\r
BuildRuleFile = None\r
if TAB_TAT_DEFINES_BUILD_RULE_CONF in self.Workspace.TargetTxt.TargetTxtDictionary:\r
BuildRuleFile = self.Workspace.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]\r
\r
## Summarize the packages used by modules in this platform\r
def _GetPackageList(self):\r
- if self._PackageList == None:\r
+ if self._PackageList is None:\r
self._PackageList = set()\r
for La in self.LibraryAutoGenList:\r
self._PackageList.update(La.DependentPackageList)\r
\r
## Get list of non-dynamic PCDs\r
def _GetNonDynamicPcdList(self):\r
- if self._NonDynamicPcdList == None:\r
+ if self._NonDynamicPcdList is None:\r
self.CollectPlatformDynamicPcds()\r
return self._NonDynamicPcdList\r
\r
## Get list of dynamic PCDs\r
def _GetDynamicPcdList(self):\r
- if self._DynamicPcdList == None:\r
+ if self._DynamicPcdList is None:\r
self.CollectPlatformDynamicPcds()\r
return self._DynamicPcdList\r
\r
## Generate Token Number for all PCD\r
def _GetPcdTokenNumbers(self):\r
- if self._PcdTokenNumber == None:\r
- self._PcdTokenNumber = sdict()\r
+ if self._PcdTokenNumber is None:\r
+ self._PcdTokenNumber = OrderedDict()\r
TokenNumber = 1\r
#\r
# Make the Dynamic and DynamicEx PCD use within different TokenNumber area. \r
\r
## Summarize ModuleAutoGen objects of all modules to be built for this platform\r
def _GetModuleAutoGenList(self):\r
- if self._ModuleAutoGenList == None:\r
+ if self._ModuleAutoGenList is None:\r
self._GetAutoGenObjectList()\r
return self._ModuleAutoGenList\r
\r
## Summarize ModuleAutoGen objects of all libraries to be built for this platform\r
def _GetLibraryAutoGenList(self):\r
- if self._LibraryAutoGenList == None:\r
+ if self._LibraryAutoGenList is None:\r
self._GetAutoGenObjectList()\r
return self._LibraryAutoGenList\r
\r
# EdkII module\r
LibraryConsumerList = [Module]\r
Constructor = []\r
- ConsumedByList = sdict()\r
- LibraryInstance = sdict()\r
+ ConsumedByList = OrderedDict()\r
+ LibraryInstance = OrderedDict()\r
\r
EdkLogger.verbose("")\r
EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), self.Arch))\r
LibraryPath = PlatformModule.LibraryClasses[LibraryClassName]\r
else:\r
LibraryPath = self.Platform.LibraryClasses[LibraryClassName, ModuleType]\r
- if LibraryPath == None or LibraryPath == "":\r
+ if LibraryPath is None or LibraryPath == "":\r
LibraryPath = M.LibraryClasses[LibraryClassName]\r
- if LibraryPath == None or LibraryPath == "":\r
+ if LibraryPath is None or LibraryPath == "":\r
EdkLogger.error("build", RESOURCE_NOT_AVAILABLE,\r
"Instance of library class [%s] is not found" % LibraryClassName,\r
File=self.MetaFile,\r
# for those forced library instance (NULL library), add a fake library class\r
if LibraryClassName.startswith("NULL"):\r
LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, [ModuleType]))\r
- elif LibraryModule.LibraryClass == None \\r
+ elif LibraryModule.LibraryClass is None \\r
or len(LibraryModule.LibraryClass) == 0 \\r
or (ModuleType != 'USER_DEFINED'\r
and ModuleType not in LibraryModule.LibraryClass[0].SupModList):\r
else:\r
LibraryModule = LibraryInstance[LibraryClassName]\r
\r
- if LibraryModule == None:\r
+ if LibraryModule is None:\r
continue\r
\r
if LibraryModule.ConstructorList != [] and LibraryModule not in Constructor:\r
if (ToPcd.TokenCName, ToPcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r
TokenCName = PcdItem[0]\r
break\r
- if FromPcd != None:\r
- if GlobalData.BuildOptionPcd:\r
- for pcd in GlobalData.BuildOptionPcd:\r
- if (FromPcd.TokenSpaceGuidCName, FromPcd.TokenCName) == (pcd[0], pcd[1]):\r
- FromPcd.DefaultValue = pcd[2]\r
- break\r
+ if FromPcd is not None:\r
if ToPcd.Pending and FromPcd.Type not in [None, '']:\r
ToPcd.Type = FromPcd.Type\r
elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in [None, ''])\\r
ToPcd.Type, Module, FromPcd.Type),\r
File=self.MetaFile)\r
\r
- if FromPcd.MaxDatumSize not in [None, '']:\r
+ if FromPcd.MaxDatumSize:\r
ToPcd.MaxDatumSize = FromPcd.MaxDatumSize\r
- if FromPcd.DefaultValue not in [None, '']:\r
+ if FromPcd.DefaultValue:\r
ToPcd.DefaultValue = FromPcd.DefaultValue\r
- if FromPcd.TokenValue not in [None, '']:\r
+ if FromPcd.TokenValue:\r
ToPcd.TokenValue = FromPcd.TokenValue\r
- if FromPcd.MaxDatumSize not in [None, '']:\r
- ToPcd.MaxDatumSize = FromPcd.MaxDatumSize\r
- if FromPcd.DatumType not in [None, '']:\r
+ if FromPcd.DatumType:\r
ToPcd.DatumType = FromPcd.DatumType\r
- if FromPcd.SkuInfoList not in [None, '', []]:\r
+ if FromPcd.SkuInfoList:\r
ToPcd.SkuInfoList = FromPcd.SkuInfoList\r
+ # Add Flexible PCD format parse\r
+ if ToPcd.DefaultValue:\r
+ try:\r
+ ToPcd.DefaultValue = ValueExpressionEx(ToPcd.DefaultValue, ToPcd.DatumType, self._GuidDict)(True)\r
+ except BadExpression, Value:\r
+ EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.DefaultValue, Value),\r
+ File=self.MetaFile)\r
\r
# check the validation of datum\r
IsValid, Cause = CheckPcdDatum(ToPcd.DatumType, ToPcd.DefaultValue)\r
ToPcd.validlists = FromPcd.validlists\r
ToPcd.expressions = FromPcd.expressions\r
\r
- if ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:\r
+ if FromPcd is not None and ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:\r
EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \\r
% (ToPcd.TokenSpaceGuidCName, TokenCName))\r
Value = ToPcd.DefaultValue\r
else:\r
SkuName = 'DEFAULT'\r
ToPcd.SkuInfoList = {\r
- SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuName], '', '', '', '', '', ToPcd.DefaultValue)\r
+ SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuName][0], '', '', '', '', '', ToPcd.DefaultValue)\r
}\r
\r
## Apply PCD setting defined platform to a module\r
Sku = PcdInModule.SkuInfoList[SkuId]\r
if Sku.VariableGuid == '': continue\r
Sku.VariableGuidValue = GuidValue(Sku.VariableGuid, self.PackageList, self.MetaFile.Path)\r
- if Sku.VariableGuidValue == None:\r
+ if Sku.VariableGuidValue is None:\r
PackageList = "\n\t".join([str(P) for P in self.PackageList])\r
EdkLogger.error(\r
'build',\r
break\r
if Flag:\r
self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module)\r
+ # use PCD value to calculate the MaxDatumSize when it is not specified\r
+ for Name, Guid in Pcds:\r
+ Pcd = Pcds[Name, Guid]\r
+ if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]:\r
+ Value = Pcd.DefaultValue\r
+ if Value in [None, '']:\r
+ Pcd.MaxDatumSize = '1'\r
+ elif Value[0] == 'L':\r
+ Pcd.MaxDatumSize = str((len(Value) - 2) * 2)\r
+ elif Value[0] == '{':\r
+ Pcd.MaxDatumSize = str(len(Value.split(',')))\r
+ else:\r
+ Pcd.MaxDatumSize = str(len(Value) - 1)\r
return Pcds.values()\r
\r
## Resolve library names to library modules\r
M = LibraryConsumerList.pop()\r
for LibraryName in M.Libraries:\r
Library = self.Platform.LibraryClasses[LibraryName, ':dummy:']\r
- if Library == None:\r
+ if Library is None:\r
for Key in self.Platform.LibraryClasses.data.keys():\r
if LibraryName.upper() == Key.upper():\r
Library = self.Platform.LibraryClasses[Key, ':dummy:']\r
break\r
- if Library == None:\r
+ if Library is None:\r
EdkLogger.warn("build", "Library [%s] is not found" % LibraryName, File=str(M),\r
ExtraData="\t%s [%s]" % (str(Module), self.Arch))\r
continue\r
# Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE\r
#\r
if (Key[0] == self.BuildRuleFamily and\r
- (ModuleStyle == None or len(Key) < 3 or (len(Key) > 2 and Key[2] == ModuleStyle))):\r
+ (ModuleStyle is None or len(Key) < 3 or (len(Key) > 2 and Key[2] == ModuleStyle))):\r
Target, ToolChain, Arch, CommandType, Attr = Key[1].split('_')\r
if Target == self.BuildTarget or Target == "*":\r
if ToolChain == self.ToolChain or ToolChain == "*":\r
if Arch == self.Arch or Arch == "*":\r
if Options[Key].startswith("="):\r
- if OverrideList.get(Key[1]) != None:\r
+ if OverrideList.get(Key[1]) is not None:\r
OverrideList.pop(Key[1])\r
OverrideList[Key[1]] = Options[Key]\r
\r
if CommandType1 == CommandType2 or CommandType1 == "*" or CommandType2 == "*":\r
if Attr1 == Attr2 or Attr1 == "*" or Attr2 == "*":\r
if self.CalculatePriorityValue(NowKey) > self.CalculatePriorityValue(NextKey):\r
- if Options.get((self.BuildRuleFamily, NextKey)) != None:\r
+ if Options.get((self.BuildRuleFamily, NextKey)) is not None:\r
Options.pop((self.BuildRuleFamily, NextKey))\r
else:\r
- if Options.get((self.BuildRuleFamily, NowKey)) != None:\r
+ if Options.get((self.BuildRuleFamily, NowKey)) is not None:\r
Options.pop((self.BuildRuleFamily, NowKey))\r
\r
for Key in Options:\r
- if ModuleStyle != None and len (Key) > 2:\r
+ if ModuleStyle is not None and len (Key) > 2:\r
# Check Module style is EDK or EDKII.\r
# Only append build option for the matched style module.\r
if ModuleStyle == EDK_NAME and Key[2] != EDK_NAME:\r
return BuildOptions\r
\r
for Key in Options:\r
- if ModuleStyle != None and len (Key) > 2:\r
+ if ModuleStyle is not None and len (Key) > 2:\r
# Check Module style is EDK or EDKII.\r
# Only append build option for the matched style module.\r
if ModuleStyle == EDK_NAME and Key[2] != EDK_NAME:\r
AllTools = set(ModuleOptions.keys() + PlatformOptions.keys() +\r
PlatformModuleOptions.keys() + ModuleTypeOptions.keys() +\r
self.ToolDefinition.keys())\r
- BuildOptions = {}\r
+ BuildOptions = defaultdict(lambda: defaultdict(str))\r
for Tool in AllTools:\r
- if Tool not in BuildOptions:\r
- BuildOptions[Tool] = {}\r
-\r
for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions, ModuleTypeOptions, PlatformModuleOptions]:\r
if Tool not in Options:\r
continue\r
for Attr in Options[Tool]:\r
- Value = Options[Tool][Attr]\r
#\r
# Do not generate it in Makefile\r
#\r
if Attr == TAB_TOD_DEFINES_BUILDRULEORDER:\r
continue\r
- if Attr not in BuildOptions[Tool]:\r
- BuildOptions[Tool][Attr] = ""\r
+ Value = Options[Tool][Attr]\r
# check if override is indicated\r
if Value.startswith('='):\r
- ToolPath = Value[1:]\r
- ToolPath = mws.handleWsMacro(ToolPath)\r
- BuildOptions[Tool][Attr] = ToolPath\r
+ BuildOptions[Tool][Attr] = mws.handleWsMacro(Value[1:])\r
else:\r
- Value = mws.handleWsMacro(Value)\r
if Attr != 'PATH':\r
- BuildOptions[Tool][Attr] += " " + Value\r
+ BuildOptions[Tool][Attr] += " " + mws.handleWsMacro(Value)\r
else:\r
- BuildOptions[Tool][Attr] = Value\r
- if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag != None:\r
+ BuildOptions[Tool][Attr] = mws.handleWsMacro(Value)\r
+\r
+ if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag is not None:\r
#\r
# Override UNI flag only for EDK module.\r
#\r
- if 'BUILD' not in BuildOptions:\r
- BuildOptions['BUILD'] = {}\r
BuildOptions['BUILD']['FLAGS'] = self.Workspace.UniFlag\r
return BuildOptions, BuildRuleOrder\r
\r
# to the [depex] section in module's inf file.\r
#\r
class ModuleAutoGen(AutoGen):\r
+ # call super().__init__ then call the worker function with different parameter count\r
+ def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
+ try:\r
+ self._Init\r
+ except:\r
+ super(ModuleAutoGen, self).__init__(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r
+ self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, *args)\r
+ self._Init = True\r
+\r
## Cache the timestamps of metafiles of every module in a class variable\r
#\r
TimeDict = {}\r
\r
- ## The real constructor of ModuleAutoGen\r
- #\r
- # This method is not supposed to be called by users of ModuleAutoGen. It's\r
- # only used by factory method __new__() to do real initialization work for an\r
- # object of ModuleAutoGen\r
+ def __new__(cls, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
+ obj = super(ModuleAutoGen, cls).__new__(cls, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r
+ # check if this module is employed by active platform\r
+ if not PlatformAutoGen(Workspace, args[0], Target, Toolchain, Arch).ValidModule(MetaFile):\r
+ EdkLogger.verbose("Module [%s] for [%s] is not employed by active platform\n" \\r
+ % (MetaFile, Arch))\r
+ return None\r
+ return obj\r
+ \r
+ ## Initialize ModuleAutoGen\r
#\r
# @param Workspace EdkIIWorkspaceBuild object\r
# @param ModuleFile The path of module file\r
# @param Arch The arch the module supports\r
# @param PlatformFile Platform meta-file\r
#\r
- def _Init(self, Workspace, ModuleFile, Target, Toolchain, Arch, PlatformFile):\r
+ def _InitWorker(self, Workspace, ModuleFile, Target, Toolchain, Arch, PlatformFile):\r
EdkLogger.debug(EdkLogger.DEBUG_9, "AutoGen module [%s] [%s]" % (ModuleFile, Arch))\r
GlobalData.gProcessingFile = "%s [%s, %s, %s]" % (ModuleFile, Arch, Toolchain, Target)\r
\r
\r
self.MetaFile = ModuleFile\r
self.PlatformInfo = PlatformAutoGen(Workspace, PlatformFile, Target, Toolchain, Arch)\r
- # check if this module is employed by active platform\r
- if not self.PlatformInfo.ValidModule(self.MetaFile):\r
- EdkLogger.verbose("Module [%s] for [%s] is not employed by active platform\n" \\r
- % (self.MetaFile, Arch))\r
- return False\r
\r
self.SourceDir = self.MetaFile.SubDir\r
self.SourceDir = mws.relpath(self.SourceDir, self.WorkspaceDir)\r
\r
self._BuildDir = None\r
self._OutputDir = None\r
+ self._FfsOutputDir = None\r
self._DebugDir = None\r
self._MakeFileDir = None\r
\r
self._DerivedPackageList = None\r
self._ModulePcdList = None\r
self._LibraryPcdList = None\r
- self._PcdComments = sdict()\r
+ self._PcdComments = OrderedDict()\r
self._GuidList = None\r
self._GuidsUsedByPcd = None\r
- self._GuidComments = sdict()\r
+ self._GuidComments = OrderedDict()\r
self._ProtocolList = None\r
- self._ProtocolComments = sdict()\r
+ self._ProtocolComments = OrderedDict()\r
self._PpiList = None\r
- self._PpiComments = sdict()\r
+ self._PpiComments = OrderedDict()\r
self._DepexList = None\r
self._DepexExpressionList = None\r
self._BuildOption = None\r
\r
# Macros could be used in build_rule.txt (also Makefile)\r
def _GetMacros(self):\r
- if self._Macro == None:\r
- self._Macro = sdict()\r
+ if self._Macro is None:\r
+ self._Macro = OrderedDict()\r
self._Macro["WORKSPACE" ] = self.WorkspaceDir\r
self._Macro["MODULE_NAME" ] = self.Name\r
self._Macro["MODULE_NAME_GUID" ] = self._GetUniqueBaseName()\r
self._Macro["PLATFORM_RELATIVE_DIR" ] = self.PlatformInfo.SourceDir\r
self._Macro["PLATFORM_DIR" ] = mws.join(self.WorkspaceDir, self.PlatformInfo.SourceDir)\r
self._Macro["PLATFORM_OUTPUT_DIR" ] = self.PlatformInfo.OutputDir\r
+ self._Macro["FFS_OUTPUT_DIR" ] = self.FfsOutputDir\r
return self._Macro\r
\r
## Return the module build data object\r
def _GetModule(self):\r
- if self._Module == None:\r
+ if self._Module is None:\r
self._Module = self.Workspace.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]\r
return self._Module\r
\r
\r
## Check if the module is library or not\r
def _IsLibrary(self):\r
- if self._LibraryFlag == None:\r
- if self.Module.LibraryClass != None and self.Module.LibraryClass != []:\r
+ if self._LibraryFlag is None:\r
+ if self.Module.LibraryClass is not None and self.Module.LibraryClass != []:\r
self._LibraryFlag = True\r
else:\r
self._LibraryFlag = False\r
\r
## Return the directory to store intermediate files of the module\r
def _GetBuildDir(self):\r
- if self._BuildDir == None:\r
+ if self._BuildDir is None:\r
self._BuildDir = path.join(\r
self.PlatformInfo.BuildDir,\r
self.Arch,\r
\r
## Return the directory to store the intermediate object files of the mdoule\r
def _GetOutputDir(self):\r
- if self._OutputDir == None:\r
+ if self._OutputDir is None:\r
self._OutputDir = path.join(self.BuildDir, "OUTPUT")\r
CreateDirectory(self._OutputDir)\r
return self._OutputDir\r
\r
+ ## Return the directory to store ffs file\r
+ def _GetFfsOutputDir(self):\r
+ if self._FfsOutputDir is None:\r
+ if GlobalData.gFdfParser is not None:\r
+ self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, "FV", "Ffs", self.Guid + self.Name)\r
+ else:\r
+ self._FfsOutputDir = ''\r
+ return self._FfsOutputDir\r
+\r
## Return the directory to store auto-gened source files of the mdoule\r
def _GetDebugDir(self):\r
- if self._DebugDir == None:\r
+ if self._DebugDir is None:\r
self._DebugDir = path.join(self.BuildDir, "DEBUG")\r
CreateDirectory(self._DebugDir)\r
return self._DebugDir\r
\r
## Return the path of custom file\r
def _GetCustomMakefile(self):\r
- if self._CustomMakefile == None:\r
+ if self._CustomMakefile is None:\r
self._CustomMakefile = {}\r
for Type in self.Module.CustomMakefile:\r
if Type in gMakeTypeMap:\r
MakeType = gMakeTypeMap[Type]\r
else:\r
MakeType = 'nmake'\r
- if self.SourceOverrideDir != None:\r
+ if self.SourceOverrideDir is not None:\r
File = os.path.join(self.SourceOverrideDir, self.Module.CustomMakefile[Type])\r
if not os.path.exists(File):\r
File = os.path.join(self.SourceDir, self.Module.CustomMakefile[Type])\r
# @retval list The token list of the dependency expression after parsed\r
#\r
def _GetDepexTokenList(self):\r
- if self._DepexList == None:\r
+ if self._DepexList is None:\r
self._DepexList = {}\r
if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:\r
return self._DepexList\r
# @retval list The token list of the dependency expression after parsed\r
#\r
def _GetDepexExpressionTokenList(self):\r
- if self._DepexExpressionList == None:\r
+ if self._DepexExpressionList is None:\r
self._DepexExpressionList = {}\r
if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:\r
return self._DepexExpressionList\r
# @retval dict The dict containing valid options\r
#\r
def _GetModuleBuildOption(self):\r
- if self._BuildOption == None:\r
+ if self._BuildOption is None:\r
self._BuildOption, self.BuildRuleOrder = self.PlatformInfo.ApplyBuildOption(self.Module)\r
if self.BuildRuleOrder:\r
self.BuildRuleOrder = ['.%s' % Ext for Ext in self.BuildRuleOrder.split()]\r
# @retval list The include path list\r
#\r
def _GetBuildOptionIncPathList(self):\r
- if self._BuildOptionIncPathList == None:\r
+ if self._BuildOptionIncPathList is None:\r
#\r
# Regular expression for finding Include Directories, the difference between MSFT and INTEL/GCC/RVCT\r
# is the former use /I , the Latter used -I to specify include directories\r
#\r
if self.PlatformInfo.ToolChainFamily in ('MSFT'):\r
- gBuildOptIncludePattern = re.compile(r"(?:.*?)/I[ \t]*([^ ]*)", re.MULTILINE | re.DOTALL)\r
+ BuildOptIncludeRegEx = gBuildOptIncludePatternMsft\r
elif self.PlatformInfo.ToolChainFamily in ('INTEL', 'GCC', 'RVCT'):\r
- gBuildOptIncludePattern = re.compile(r"(?:.*?)-I[ \t]*([^ ]*)", re.MULTILINE | re.DOTALL)\r
+ BuildOptIncludeRegEx = gBuildOptIncludePatternOther\r
else:\r
#\r
# New ToolChainFamily, don't known whether there is option to specify include directories\r
FlagOption = ''\r
\r
if self.PlatformInfo.ToolChainFamily != 'RVCT':\r
- IncPathList = [NormPath(Path, self.Macros) for Path in gBuildOptIncludePattern.findall(FlagOption)]\r
+ IncPathList = [NormPath(Path, self.Macros) for Path in BuildOptIncludeRegEx.findall(FlagOption)]\r
else:\r
#\r
# RVCT may specify a list of directory seperated by commas\r
#\r
IncPathList = []\r
- for Path in gBuildOptIncludePattern.findall(FlagOption):\r
+ for Path in BuildOptIncludeRegEx.findall(FlagOption):\r
PathList = GetSplitList(Path, TAB_COMMA_SPLIT)\r
IncPathList += [NormPath(PathEntry, self.Macros) for PathEntry in PathList]\r
\r
# $(CONF_DIRECTORY)/build_rule.txt and toolchain family.\r
#\r
def _GetSourceFileList(self):\r
- if self._SourceFileList == None:\r
+ if self._SourceFileList is None:\r
self._SourceFileList = []\r
for F in self.Module.Sources:\r
# match tool chain\r
EdkLogger.debug(EdkLogger.DEBUG_9, "The toolchain [%s] for processing file [%s] is found, "\r
"but [%s] is needed" % (F.TagName, str(F), self.ToolChain))\r
continue\r
- # match tool chain family\r
- if F.ToolChainFamily not in ("", "*", self.ToolChainFamily):\r
+ # match tool chain family or build rule family\r
+ if F.ToolChainFamily not in ("", "*", self.ToolChainFamily, self.BuildRuleFamily):\r
EdkLogger.debug(\r
EdkLogger.DEBUG_0,\r
"The file [%s] must be built by tools of [%s], " \\r
- "but current toolchain family is [%s]" \\r
- % (str(F), F.ToolChainFamily, self.ToolChainFamily))\r
+ "but current toolchain family is [%s], buildrule family is [%s]" \\r
+ % (str(F), F.ToolChainFamily, self.ToolChainFamily, self.BuildRuleFamily))\r
continue\r
\r
# add the file path into search path list for file including\r
\r
## Return the list of unicode files\r
def _GetUnicodeFileList(self):\r
- if self._UnicodeFileList == None:\r
+ if self._UnicodeFileList is None:\r
if TAB_UNICODE_FILE in self.FileTypes:\r
self._UnicodeFileList = self.FileTypes[TAB_UNICODE_FILE]\r
else:\r
\r
## Return the list of vfr files\r
def _GetVfrFileList(self):\r
- if self._VfrFileList == None:\r
+ if self._VfrFileList is None:\r
if TAB_VFR_FILE in self.FileTypes:\r
self._VfrFileList = self.FileTypes[TAB_VFR_FILE]\r
else:\r
\r
## Return the list of Image Definition files\r
def _GetIdfFileList(self):\r
- if self._IdfFileList == None:\r
+ if self._IdfFileList is None:\r
if TAB_IMAGE_FILE in self.FileTypes:\r
self._IdfFileList = self.FileTypes[TAB_IMAGE_FILE]\r
else:\r
# @retval list The list of files which can be built later\r
#\r
def _GetBinaryFiles(self):\r
- if self._BinaryFileList == None:\r
+ if self._BinaryFileList is None:\r
self._BinaryFileList = []\r
for F in self.Module.Binaries:\r
if F.Target not in ['COMMON', '*'] and F.Target != self.BuildTarget:\r
return self._BinaryFileList\r
\r
def _GetBuildRules(self):\r
- if self._BuildRules == None:\r
+ if self._BuildRules is None:\r
BuildRules = {}\r
BuildRuleDatabase = self.PlatformInfo.BuildRule\r
for Type in BuildRuleDatabase.FileTypeList:\r
return self._BuildRules\r
\r
def _ApplyBuildRule(self, File, FileType):\r
- if self._BuildTargets == None:\r
+ if self._BuildTargets is None:\r
self._IntroBuildTargetList = set()\r
self._FinalBuildTargetList = set()\r
- self._BuildTargets = {}\r
- self._FileTypes = {}\r
+ self._BuildTargets = defaultdict(set)\r
+ self._FileTypes = defaultdict(set)\r
\r
SubDirectory = os.path.join(self.OutputDir, File.SubDir)\r
if not os.path.exists(SubDirectory):\r
if Source != File:\r
CreateDirectory(Source.Dir)\r
\r
- if File.IsBinary and File == Source and self._BinaryFileList != None and File in self._BinaryFileList:\r
+ if File.IsBinary and File == Source and self._BinaryFileList is not None and File in self._BinaryFileList:\r
# Skip all files that are not binary libraries\r
if not self.IsLibrary:\r
continue\r
break\r
\r
FileType = RuleObject.SourceFileType\r
- if FileType not in self._FileTypes:\r
- self._FileTypes[FileType] = set()\r
self._FileTypes[FileType].add(Source)\r
\r
# stop at STATIC_LIBRARY for library\r
# Only do build for target with outputs\r
self._FinalBuildTargetList.add(Target)\r
\r
- if FileType not in self._BuildTargets:\r
- self._BuildTargets[FileType] = set()\r
self._BuildTargets[FileType].add(Target)\r
\r
if not Source.IsBinary and Source == File:\r
FileType = TAB_UNKNOWN_FILE\r
\r
def _GetTargets(self):\r
- if self._BuildTargets == None:\r
+ if self._BuildTargets is None:\r
self._IntroBuildTargetList = set()\r
self._FinalBuildTargetList = set()\r
- self._BuildTargets = {}\r
- self._FileTypes = {}\r
+ self._BuildTargets = defaultdict(set)\r
+ self._FileTypes = defaultdict(set)\r
\r
#TRICK: call _GetSourceFileList to apply build rule for source files\r
if self.SourceFileList:\r
if self.BuildType == 'UEFI_HII':\r
UniStringAutoGenC = False\r
IdfStringAutoGenC = False\r
- if self._AutoGenFileList == None:\r
+ if self._AutoGenFileList is None:\r
self._AutoGenFileList = {}\r
AutoGenC = TemplateString()\r
AutoGenH = TemplateString()\r
AutoFile = PathClass(gAutoGenStringFileName % {"module_name":self.Name}, self.DebugDir)\r
self._AutoGenFileList[AutoFile] = str(StringH)\r
self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
- if UniStringBinBuffer != None and UniStringBinBuffer.getvalue() != "":\r
+ if UniStringBinBuffer is not None and UniStringBinBuffer.getvalue() != "":\r
AutoFile = PathClass(gAutoGenStringFormFileName % {"module_name":self.Name}, self.OutputDir)\r
self._AutoGenFileList[AutoFile] = UniStringBinBuffer.getvalue()\r
AutoFile.IsBinary = True\r
self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
- if UniStringBinBuffer != None:\r
+ if UniStringBinBuffer is not None:\r
UniStringBinBuffer.close()\r
if str(StringIdf) != "":\r
AutoFile = PathClass(gAutoGenImageDefFileName % {"module_name":self.Name}, self.DebugDir)\r
self._AutoGenFileList[AutoFile] = str(StringIdf)\r
self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
- if IdfGenBinBuffer != None and IdfGenBinBuffer.getvalue() != "":\r
+ if IdfGenBinBuffer is not None and IdfGenBinBuffer.getvalue() != "":\r
AutoFile = PathClass(gAutoGenIdfFileName % {"module_name":self.Name}, self.OutputDir)\r
self._AutoGenFileList[AutoFile] = IdfGenBinBuffer.getvalue()\r
AutoFile.IsBinary = True\r
self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
- if IdfGenBinBuffer != None:\r
+ if IdfGenBinBuffer is not None:\r
IdfGenBinBuffer.close()\r
return self._AutoGenFileList\r
\r
## Return the list of library modules explicitly or implicityly used by this module\r
def _GetLibraryList(self):\r
- if self._DependentLibraryList == None:\r
+ if self._DependentLibraryList is None:\r
# only merge library classes and PCD for non-library module\r
if self.IsLibrary:\r
self._DependentLibraryList = []\r
# @retval list The list of PCD\r
#\r
def _GetModulePcdList(self):\r
- if self._ModulePcdList == None:\r
+ if self._ModulePcdList is None:\r
# apply PCD settings from platform\r
self._ModulePcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, self.Module.Pcds)\r
self.UpdateComments(self._PcdComments, self.Module.PcdComments)\r
# @retval list The list of PCD\r
#\r
def _GetLibraryPcdList(self):\r
- if self._LibraryPcdList == None:\r
- Pcds = sdict()\r
+ if self._LibraryPcdList is None:\r
+ Pcds = OrderedDict()\r
if not self.IsLibrary:\r
# get PCDs from dependent libraries\r
for Library in self.DependentLibraryList:\r
# @retval dict The mapping between GUID cname and its value\r
#\r
def _GetGuidList(self):\r
- if self._GuidList == None:\r
- self._GuidList = sdict()\r
+ if self._GuidList is None:\r
+ self._GuidList = OrderedDict()\r
self._GuidList.update(self.Module.Guids)\r
for Library in self.DependentLibraryList:\r
self._GuidList.update(Library.Guids)\r
return self._GuidList\r
\r
def GetGuidsUsedByPcd(self):\r
- if self._GuidsUsedByPcd == None:\r
- self._GuidsUsedByPcd = sdict()\r
+ if self._GuidsUsedByPcd is None:\r
+ self._GuidsUsedByPcd = OrderedDict()\r
self._GuidsUsedByPcd.update(self.Module.GetGuidsUsedByPcd())\r
for Library in self.DependentLibraryList:\r
self._GuidsUsedByPcd.update(Library.GetGuidsUsedByPcd())\r
# @retval dict The mapping between protocol cname and its value\r
#\r
def _GetProtocolList(self):\r
- if self._ProtocolList == None:\r
- self._ProtocolList = sdict()\r
+ if self._ProtocolList is None:\r
+ self._ProtocolList = OrderedDict()\r
self._ProtocolList.update(self.Module.Protocols)\r
for Library in self.DependentLibraryList:\r
self._ProtocolList.update(Library.Protocols)\r
# @retval dict The mapping between PPI cname and its value\r
#\r
def _GetPpiList(self):\r
- if self._PpiList == None:\r
- self._PpiList = sdict()\r
+ if self._PpiList is None:\r
+ self._PpiList = OrderedDict()\r
self._PpiList.update(self.Module.Ppis)\r
for Library in self.DependentLibraryList:\r
self._PpiList.update(Library.Ppis)\r
# @retval list The list path\r
#\r
def _GetIncludePathList(self):\r
- if self._IncludePathList == None:\r
+ if self._IncludePathList is None:\r
self._IncludePathList = []\r
if self.AutoGenVersion < 0x00010005:\r
for Inc in self.Module.Includes:\r
if not self.SourceFileList:\r
return []\r
\r
- NameGuids = []\r
+ NameGuids = set()\r
for SrcFile in self.SourceFileList:\r
if SrcFile.Ext.lower() != '.vfr':\r
continue\r
if not Guid:\r
break\r
NameArray = ConvertStringToByteArray('L"' + Name.group(1) + '"')\r
- NameGuids.append((NameArray, GuidStructureStringToGuidString(Guid.group(1))))\r
+ NameGuids.add((NameArray, GuidStructureStringToGuidString(Guid.group(1))))\r
Pos = Content.find('efivarstore', Name.end())\r
if not NameGuids:\r
return []\r
VfrGuid = [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2]\r
VfrGuid = [chr(ItemGuid) for ItemGuid in VfrGuid]\r
fStringIO.write(''.join(VfrGuid)) \r
- type (Item[1]) \r
VfrValue = pack ('Q', int (Item[1], 16))\r
fStringIO.write (VfrValue)\r
#\r
\r
## Create AsBuilt INF file the module\r
#\r
- def CreateAsBuiltInf(self):\r
+ def CreateAsBuiltInf(self, IsOnlyCopy = False):\r
+ self.OutputFile = set()\r
+ if IsOnlyCopy:\r
+ if GlobalData.gBinCacheDest:\r
+ self.CopyModuleToCache()\r
+ return\r
+\r
if self.IsAsBuiltInfCreated:\r
return\r
\r
return\r
\r
# Skip the following code for modules with no source files\r
- if self.SourceFileList == None or self.SourceFileList == []:\r
+ if not self.SourceFileList:\r
return\r
\r
# Skip the following code for modules without any binary files\r
- if self.BinaryFileList <> None and self.BinaryFileList <> []:\r
+ if not self.BinaryFileList:\r
return\r
\r
### TODO: How to handles mixed source and binary modules\r
PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx'))\r
PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic'))\r
PcdTokenSpaceList.append(Pcd.TokenSpaceGuidCName)\r
- GuidList = sdict()\r
+ GuidList = OrderedDict()\r
GuidList.update(self.GuidList)\r
for TokenSpace in self.GetGuidsUsedByPcd():\r
# If token space is not referred by patch PCD or Ex PCD, remove the GUID from GUID list\r
AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']]\r
\r
OutputDir = self.OutputDir.replace('\\', '/').strip('/')\r
-\r
+ DebugDir = self.DebugDir.replace('\\', '/').strip('/')\r
for Item in self.CodaTargetList:\r
- File = Item.Target.Path.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/')\r
+ File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/')\r
+ self.OutputFile.add(File)\r
+ if os.path.isabs(File):\r
+ File = File.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/')\r
if Item.Target.Ext.lower() == '.aml':\r
AsBuiltInfDict['binary_item'] += ['ASL|' + File]\r
elif Item.Target.Ext.lower() == '.acpi':\r
else:\r
AsBuiltInfDict['binary_item'] += ['BIN|' + File]\r
if self.DepexGenerated:\r
+ self.OutputFile.add(self.Name + '.depex')\r
if self.ModuleType in ['PEIM']:\r
AsBuiltInfDict['binary_item'] += ['PEI_DEPEX|' + self.Name + '.depex']\r
if self.ModuleType in ['DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'UEFI_DRIVER']:\r
Bin = self._GenOffsetBin()\r
if Bin:\r
AsBuiltInfDict['binary_item'] += ['BIN|%s' % Bin]\r
+ self.OutputFile.add(Bin)\r
\r
for Root, Dirs, Files in os.walk(OutputDir):\r
for File in Files:\r
if File.lower().endswith('.pdb'):\r
AsBuiltInfDict['binary_item'] += ['DISPOSABLE|' + File]\r
+ self.OutputFile.add(File)\r
HeaderComments = self.Module.HeaderComments\r
StartPos = 0\r
for Index in range(len(HeaderComments)):\r
elif BoolValue == 'FALSE':\r
Pcd.DefaultValue = '0'\r
\r
- if Pcd.DatumType != 'VOID*':\r
+ if Pcd.DatumType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']:\r
HexFormat = '0x%02x'\r
if Pcd.DatumType == 'UINT16':\r
HexFormat = '0x%04x'\r
HexFormat = '0x%016x'\r
PcdValue = HexFormat % int(Pcd.DefaultValue, 0)\r
else:\r
- if Pcd.MaxDatumSize == None or Pcd.MaxDatumSize == '':\r
+ if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '':\r
EdkLogger.error("build", AUTOGEN_ERROR,\r
"Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, TokenCName)\r
)\r
PcdItem = PcdComments + '\n ' + PcdItem\r
AsBuiltInfDict['patchablepcd_item'].append(PcdItem)\r
\r
- HiiPcds = []\r
+ HiiPcds = set()\r
for Pcd in Pcds + VfrPcds:\r
PcdComments = ''\r
PcdCommentList = []\r
#\r
if (SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in HiiPcds:\r
continue\r
- else:\r
- HiiPcds.append((SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
+ HiiPcds.add((SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments:\r
PcdCommentList = self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName][:]\r
if HiiInfo:\r
SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False)\r
\r
self.IsAsBuiltInfCreated = True\r
- \r
+ if GlobalData.gBinCacheDest:\r
+ self.CopyModuleToCache()\r
+\r
+ def CopyModuleToCache(self):\r
+ FileDir = path.join(GlobalData.gBinCacheDest, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r
+ CreateDirectory (FileDir)\r
+ HashFile = path.join(self.BuildDir, self.Name + '.hash')\r
+ ModuleFile = path.join(self.OutputDir, self.Name + '.inf')\r
+ if os.path.exists(HashFile):\r
+ shutil.copy2(HashFile, FileDir)\r
+ if os.path.exists(ModuleFile):\r
+ shutil.copy2(ModuleFile, FileDir)\r
+ if not self.OutputFile:\r
+ Ma = self.Workspace.BuildDatabase[PathClass(ModuleFile), self.Arch, self.BuildTarget, self.ToolChain]\r
+ self.OutputFile = Ma.Binaries\r
+ if self.OutputFile:\r
+ for File in self.OutputFile:\r
+ File = str(File)\r
+ if not os.path.isabs(File):\r
+ File = os.path.join(self.OutputDir, File)\r
+ if os.path.exists(File):\r
+ shutil.copy2(File, FileDir)\r
+\r
+ def AttemptModuleCacheCopy(self):\r
+ if self.IsBinaryModule:\r
+ return False\r
+ FileDir = path.join(GlobalData.gBinCacheSource, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r
+ HashFile = path.join(FileDir, self.Name + '.hash')\r
+ if os.path.exists(HashFile):\r
+ f = open(HashFile, 'r')\r
+ CacheHash = f.read()\r
+ f.close()\r
+ if GlobalData.gModuleHash[self.Arch][self.Name]:\r
+ if CacheHash == GlobalData.gModuleHash[self.Arch][self.Name]:\r
+ for root, dir, files in os.walk(FileDir):\r
+ for f in files:\r
+ if self.Name + '.hash' in f:\r
+ shutil.copy2(HashFile, self.BuildDir)\r
+ else:\r
+ File = path.join(root, f)\r
+ shutil.copy2(File, self.OutputDir)\r
+ if self.Name == "PcdPeim" or self.Name == "PcdDxe":\r
+ CreatePcdDatabaseCode(self, TemplateString(), TemplateString())\r
+ return True\r
+ return False\r
+\r
## Create makefile for the module and its dependent libraries\r
#\r
# @param CreateLibraryMakeFile Flag indicating if or not the makefiles of\r
# dependent libraries will be created\r
#\r
- def CreateMakeFile(self, CreateLibraryMakeFile=True):\r
+ def CreateMakeFile(self, CreateLibraryMakeFile=True, GenFfsList = []):\r
# Ignore generating makefile when it is a binary module\r
if self.IsBinaryModule:\r
return\r
\r
if self.IsMakeFileCreated:\r
return\r
- if self.CanSkip():\r
- return\r
-\r
+ self.GenFfsList = GenFfsList\r
if not self.IsLibrary and CreateLibraryMakeFile:\r
for LibraryAutoGen in self.LibraryAutoGenList:\r
LibraryAutoGen.CreateMakeFile()\r
\r
+ if self.CanSkip():\r
+ return\r
+\r
if len(self.CustomMakefile) == 0:\r
Makefile = GenMake.ModuleMakefile(self)\r
else:\r
def CreateCodeFile(self, CreateLibraryCodeFile=True):\r
if self.IsCodeFileCreated:\r
return\r
- if self.CanSkip():\r
- return\r
\r
# Need to generate PcdDatabase even PcdDriver is binarymodule\r
if self.IsBinaryModule and self.PcdIsDriver != '':\r
for LibraryAutoGen in self.LibraryAutoGenList:\r
LibraryAutoGen.CreateCodeFile()\r
\r
+ if self.CanSkip():\r
+ return\r
+\r
AutoGenList = []\r
IgoredAutoGenList = []\r
\r
\r
## Summarize the ModuleAutoGen objects of all libraries used by this module\r
def _GetLibraryAutoGenList(self):\r
- if self._LibraryAutoGenList == None:\r
+ if self._LibraryAutoGenList is None:\r
self._LibraryAutoGenList = []\r
for Library in self.DependentLibraryList:\r
La = ModuleAutoGen(\r
self._ApplyBuildRule(Lib.Target, TAB_UNKNOWN_FILE)\r
return self._LibraryAutoGenList\r
\r
+ def GenModuleHash(self):\r
+ if self.Arch not in GlobalData.gModuleHash:\r
+ GlobalData.gModuleHash[self.Arch] = {}\r
+ m = hashlib.md5()\r
+ # Add Platform level hash\r
+ m.update(GlobalData.gPlatformHash)\r
+ # Add Package level hash\r
+ if self.DependentPackageList:\r
+ for Pkg in self.DependentPackageList:\r
+ if Pkg.PackageName in GlobalData.gPackageHash[self.Arch]:\r
+ m.update(GlobalData.gPackageHash[self.Arch][Pkg.PackageName])\r
+\r
+ # Add Library hash\r
+ if self.LibraryAutoGenList:\r
+ for Lib in self.LibraryAutoGenList:\r
+ if Lib.Name not in GlobalData.gModuleHash[self.Arch]:\r
+ Lib.GenModuleHash()\r
+ m.update(GlobalData.gModuleHash[self.Arch][Lib.Name])\r
+\r
+ # Add Module self\r
+ f = open(str(self.MetaFile), 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+ # Add Module's source files\r
+ if self.SourceFileList:\r
+ for File in self.SourceFileList:\r
+ f = open(str(File), 'r')\r
+ Content = f.read()\r
+ f.close()\r
+ m.update(Content)\r
+\r
+ ModuleHashFile = path.join(self.BuildDir, self.Name + ".hash")\r
+ if self.Name not in GlobalData.gModuleHash[self.Arch]:\r
+ GlobalData.gModuleHash[self.Arch][self.Name] = m.hexdigest()\r
+ if GlobalData.gBinCacheSource:\r
+ CacheValid = self.AttemptModuleCacheCopy()\r
+ if CacheValid:\r
+ return False\r
+ return SaveFileOnChange(ModuleHashFile, m.hexdigest(), True)\r
+\r
+ ## Decide whether we can skip the ModuleAutoGen process\r
+ def CanSkipbyHash(self):\r
+ if GlobalData.gUseHashCache:\r
+ return not self.GenModuleHash()\r
+\r
## Decide whether we can skip the ModuleAutoGen process\r
- # If any source file is newer than the modeule than we cannot skip\r
+ # If any source file is newer than the module than we cannot skip\r
#\r
def CanSkip(self):\r
if not os.path.exists(self.GetTimeStampPath()):\r
return True\r
\r
def GetTimeStampPath(self):\r
- if self._TimeStampPath == None:\r
+ if self._TimeStampPath is None:\r
self._TimeStampPath = os.path.join(self.MakeFileDir, 'AutoGenTimeStamp')\r
return self._TimeStampPath\r
def CreateTimeStamp(self, Makefile):\r
IsBinaryModule = property(_IsBinaryModule)\r
BuildDir = property(_GetBuildDir)\r
OutputDir = property(_GetOutputDir)\r
+ FfsOutputDir = property(_GetFfsOutputDir)\r
DebugDir = property(_GetDebugDir)\r
MakeFileDir = property(_GetMakeFileDir)\r
CustomMakefile = property(_GetCustomMakefile)\r