class WorkspaceAutoGen(AutoGen):\r
## Real constructor of WorkspaceAutoGen\r
#\r
- # This method behaves the same as __init__ except that it needs explict invoke\r
+ # This method behaves the same as __init__ except that it needs explicit invoke\r
# (in super class's __new__ method)\r
#\r
# @param WorkspaceDir Root directory of workspace\r
# @param FlashDefinitionFile File of flash definition\r
# @param Fds FD list to be generated\r
# @param Fvs FV list to be generated\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
- BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=[], Fvs=[], SkuId='', UniFlag=None):\r
+ BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=None, Fvs=None, Caps=None, SkuId='', UniFlag=None):\r
+ if Fds is None:\r
+ Fds = []\r
+ if Fvs is None:\r
+ Fvs = []\r
+ if Caps is None:\r
+ Caps = []\r
self.MetaFile = ActivePlatform.MetaFile\r
self.WorkspaceDir = WorkspaceDir\r
self.Platform = ActivePlatform\r
self.FdfFile = FlashDefinitionFile\r
self.FdTargetList = Fds\r
self.FvTargetList = Fvs\r
+ self.CapTargetList = Caps\r
self.AutoGenObjectList = []\r
\r
# there's many relative directory operations, so ...\r
# Make global macros available when parsing FDF file\r
#\r
InputMacroDict.update(self.BuildDatabase.WorkspaceDb._GlobalMacros)\r
+ #\r
+ # Mark now build in AutoGen Phase\r
+ #\r
+ GlobalData.gAutoGenPhase = True \r
Fdf = FdfParser(self.FdfFile.Path)\r
Fdf.ParseFile()\r
+ GlobalData.gAutoGenPhase = False \r
PcdSet = Fdf.Profile.PcdDict\r
ModuleList = Fdf.Profile.InfList\r
self.FdfProfile = Fdf.Profile\r
#\r
self._CheckAllPcdsTokenValueConflict()\r
\r
+ #\r
+ # Check PCD type and definition between DSC and DEC\r
+ #\r
+ self._CheckPcdDefineAndType()\r
+ \r
+ if self.FdfFile:\r
+ self._CheckDuplicateInFV(Fdf)\r
+ \r
self._BuildDir = None\r
self._FvDir = None\r
self._MakeFileDir = None\r
\r
return True\r
\r
+ ## _CheckDuplicateInFV() method\r
+ #\r
+ # Check whether there is duplicate modules/files exist in FV section. \r
+ # The check base on the file GUID;\r
+ #\r
+ def _CheckDuplicateInFV(self, Fdf):\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
+ #\r
+ # Get INF file GUID\r
+ #\r
+ InfFoundFlag = False \r
+ for Pa in self.AutoGenObjectList:\r
+ for Module in Pa.ModuleAutoGenList:\r
+ if path.normpath(Module.MetaFile.File) == path.normpath(FfsFile.InfFileName):\r
+ InfFoundFlag = True\r
+ if not Module.Guid.upper() in _GuidDict.keys():\r
+ _GuidDict[Module.Guid.upper()] = FfsFile\r
+ else:\r
+ EdkLogger.error("build", \r
+ FORMAT_INVALID,\r
+ "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s"%(FfsFile.CurrentLineNum,\r
+ FfsFile.CurrentLineContent,\r
+ _GuidDict[Module.Guid.upper()].CurrentLineNum,\r
+ _GuidDict[Module.Guid.upper()].CurrentLineContent,\r
+ Module.Guid.upper()),\r
+ ExtraData=self.FdfFile)\r
+ #\r
+ # Some INF files not have entity in DSC file. \r
+ #\r
+ if not InfFoundFlag:\r
+ if FfsFile.InfFileName.find('$') == -1:\r
+ InfPath = NormPath(FfsFile.InfFileName)\r
+ if not os.path.exists(InfPath):\r
+ EdkLogger.error('build', GENFDS_ERROR, "Non-existant Module %s !" % (FfsFile.InfFileName))\r
+ \r
+ PathClassObj = PathClass(FfsFile.InfFileName, self.WorkspaceDir)\r
+ #\r
+ # Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use \r
+ # BuildObject from one of AutoGenObjectList is enough.\r
+ #\r
+ InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, 'COMMON', self.BuildTarget, self.ToolChain]\r
+ if not InfObj.Guid.upper() in _GuidDict.keys():\r
+ _GuidDict[InfObj.Guid.upper()] = FfsFile\r
+ else:\r
+ EdkLogger.error("build", \r
+ FORMAT_INVALID,\r
+ "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s"%(FfsFile.CurrentLineNum,\r
+ FfsFile.CurrentLineContent,\r
+ _GuidDict[InfObj.Guid.upper()].CurrentLineNum,\r
+ _GuidDict[InfObj.Guid.upper()].CurrentLineContent,\r
+ InfObj.Guid.upper()),\r
+ ExtraData=self.FdfFile)\r
+ InfFoundFlag = False\r
+ \r
+ if FfsFile.NameGuid != None:\r
+ _CheckPCDAsGuidPattern = re.compile("^PCD\(.+\..+\)$")\r
+ \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
+ #\r
+ # Replace the PCD value.\r
+ #\r
+ _PcdName = FfsFile.NameGuid.lstrip("PCD(").rstrip(")")\r
+ PcdFoundFlag = False\r
+ for Pa in self.AutoGenObjectList:\r
+ if not PcdFoundFlag:\r
+ for PcdItem in Pa.AllPcdList:\r
+ if (PcdItem.TokenSpaceGuidCName + "." + PcdItem.TokenCName) == _PcdName:\r
+ #\r
+ # First convert from CFormatGuid to GUID string\r
+ #\r
+ _PcdGuidString = GuidStructureStringToGuidString(PcdItem.DefaultValue)\r
+ \r
+ if not _PcdGuidString:\r
+ #\r
+ # Then try Byte array.\r
+ #\r
+ _PcdGuidString = GuidStructureByteArrayToGuidString(PcdItem.DefaultValue)\r
+ \r
+ if not _PcdGuidString:\r
+ #\r
+ # Not Byte array or CFormat GUID, raise error.\r
+ #\r
+ EdkLogger.error("build",\r
+ FORMAT_INVALID,\r
+ "The format of PCD value is incorrect. PCD: %s , Value: %s\n"%(_PcdName, PcdItem.DefaultValue),\r
+ ExtraData=self.FdfFile)\r
+ \r
+ if not _PcdGuidString.upper() in _GuidDict.keys(): \r
+ _GuidDict[_PcdGuidString.upper()] = FfsFile\r
+ PcdFoundFlag = True\r
+ break\r
+ else:\r
+ EdkLogger.error("build", \r
+ FORMAT_INVALID,\r
+ "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s"%(FfsFile.CurrentLineNum,\r
+ FfsFile.CurrentLineContent,\r
+ _GuidDict[_PcdGuidString.upper()].CurrentLineNum,\r
+ _GuidDict[_PcdGuidString.upper()].CurrentLineContent,\r
+ FfsFile.NameGuid.upper()),\r
+ ExtraData=self.FdfFile) \r
+ \r
+ if not FfsFile.NameGuid.upper() in _GuidDict.keys():\r
+ _GuidDict[FfsFile.NameGuid.upper()] = FfsFile\r
+ else:\r
+ #\r
+ # Two raw file GUID conflict.\r
+ #\r
+ EdkLogger.error("build", \r
+ FORMAT_INVALID,\r
+ "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s"%(FfsFile.CurrentLineNum,\r
+ FfsFile.CurrentLineContent,\r
+ _GuidDict[FfsFile.NameGuid.upper()].CurrentLineNum,\r
+ _GuidDict[FfsFile.NameGuid.upper()].CurrentLineContent,\r
+ FfsFile.NameGuid.upper()),\r
+ ExtraData=self.FdfFile)\r
+ \r
+\r
+ def _CheckPcdDefineAndType(self):\r
+ PcdTypeList = [\r
+ "FixedAtBuild", "PatchableInModule", "FeatureFlag",\r
+ "Dynamic", #"DynamicHii", "DynamicVpd",\r
+ "DynamicEx", # "DynamicExHii", "DynamicExVpd"\r
+ ]\r
+\r
+ # This dict store PCDs which are not used by any modules with specified arches\r
+ UnusedPcd = sdict()\r
+ for Pa in self.AutoGenObjectList:\r
+ # Key of DSC's Pcds dictionary is PcdCName, TokenSpaceGuid\r
+ for Pcd in Pa.Platform.Pcds:\r
+ PcdType = Pa.Platform.Pcds[Pcd].Type\r
+ \r
+ # If no PCD type, this PCD comes from FDF \r
+ if not PcdType:\r
+ continue\r
+ \r
+ # Try to remove Hii and Vpd suffix\r
+ if PcdType.startswith("DynamicEx"):\r
+ PcdType = "DynamicEx"\r
+ elif PcdType.startswith("Dynamic"):\r
+ PcdType = "Dynamic"\r
+ \r
+ for Package in Pa.PackageList:\r
+ # Key of DEC's Pcds dictionary is PcdCName, TokenSpaceGuid, PcdType\r
+ if (Pcd[0], Pcd[1], PcdType) in Package.Pcds:\r
+ break\r
+ for Type in PcdTypeList:\r
+ if (Pcd[0], Pcd[1], Type) in Package.Pcds:\r
+ EdkLogger.error(\r
+ 'build',\r
+ FORMAT_INVALID,\r
+ "Type [%s] of PCD [%s.%s] in DSC file doesn't match the type [%s] defined in DEC file." \\r
+ % (Pa.Platform.Pcds[Pcd].Type, Pcd[1], Pcd[0], Type),\r
+ ExtraData=None\r
+ )\r
+ return\r
+ else:\r
+ UnusedPcd.setdefault(Pcd, []).append(Pa.Arch)\r
+\r
+ for Pcd in UnusedPcd:\r
+ EdkLogger.warn(\r
+ 'build',\r
+ "The PCD was not specified by any INF module in the platform for the given architecture.\n"\r
+ "\tPCD: [%s.%s]\n\tPlatform: [%s]\n\tArch: %s"\r
+ % (Pcd[1], Pcd[0], os.path.basename(str(self.MetaFile)), str(UnusedPcd[Pcd])),\r
+ ExtraData=None\r
+ )\r
+\r
def __repr__(self):\r
return "%s [%s]" % (self.MetaFile, ", ".join(self.ArchList))\r
\r
# @return None\r
#\r
def _CheckAllPcdsTokenValueConflict(self):\r
- if len(self.BuildDatabase.WorkspaceDb.PackageList) >= 1:\r
- for Package in self.BuildDatabase.WorkspaceDb.PackageList:\r
+ for Pa in self.AutoGenObjectList:\r
+ for Package in Pa.PackageList:\r
PcdList = Package.Pcds.values()\r
PcdList.sort(lambda x, y: cmp(x.TokenValue, y.TokenValue)) \r
Count = 0\r
for Pa in self.AutoGenObjectList:\r
Pa.CreateCodeFile(CreateDepsCodeFile)\r
\r
+ ## Create AsBuilt INF file the platform\r
+ #\r
+ def CreateAsBuiltInf(self):\r
+ return\r
+\r
Name = property(_GetName)\r
Guid = property(_GetGuid)\r
Version = property(_GetVersion)\r
if LibraryClass.startswith("NULL"):\r
Module.LibraryClasses[LibraryClass] = PlatformModule.LibraryClasses[LibraryClass]\r
\r
- # R9 module\r
+ # EdkII module\r
LibraryConsumerList = [Module]\r
Constructor = []\r
ConsumedByList = sdict()\r
\r
## Resolve library names to library modules\r
#\r
- # (for R8.x modules)\r
+ # (for Edk.x modules)\r
#\r
# @param Module The module from which the library names will be resolved\r
#\r
EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), self.Arch))\r
LibraryConsumerList = [Module]\r
\r
- # "CompilerStub" is a must for R8 modules\r
+ # "CompilerStub" is a must for Edk modules\r
if Module.Libraries:\r
Module.Libraries.append("CompilerStub")\r
LibraryList = []\r
self._DepexList = None\r
self._DepexExpressionList = None\r
self._BuildOption = None\r
+ self._BuildOptionIncPathList = None\r
self._BuildTargets = None\r
self._IntroBuildTargetList = None\r
self._FinalBuildTargetList = None\r
def _GetBaseName(self):\r
return self.Module.BaseName\r
\r
+ ## Return the module DxsFile if exist\r
+ def _GetDxsFile(self):\r
+ return self.Module.DxsFile\r
+\r
## Return the module SourceOverridePath\r
def _GetSourceOverridePath(self):\r
return self.Module.SourceOverridePath\r
def _GetModuleType(self):\r
return self.Module.ModuleType\r
\r
- ## Return the component type (for R8.x style of module)\r
+ ## Return the component type (for Edk.x style of module)\r
def _GetComponentType(self):\r
return self.Module.ComponentType\r
\r
def _GetDepexTokenList(self):\r
if self._DepexList == None:\r
self._DepexList = {}\r
- if self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:\r
+ if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:\r
return self._DepexList\r
\r
self._DepexList[self.ModuleType] = []\r
def _GetDepexExpressionTokenList(self):\r
if self._DepexExpressionList == None:\r
self._DepexExpressionList = {}\r
- if self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:\r
+ if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:\r
return self._DepexExpressionList\r
\r
self._DepexExpressionList[self.ModuleType] = ''\r
self._BuildOption = self.PlatformInfo.ApplyBuildOption(self.Module)\r
return self._BuildOption\r
\r
+ ## Get include path list from tool option for the module build\r
+ #\r
+ # @retval list The include path list\r
+ #\r
+ def _GetBuildOptionIncPathList(self):\r
+ if self._BuildOptionIncPathList == None:\r
+ #\r
+ # Regular expression for finding Include Directories, the difference between MSFT and INTEL/GCC\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
+ elif self.PlatformInfo.ToolChainFamily in ('INTEL', 'GCC'):\r
+ gBuildOptIncludePattern = re.compile(r"(?:.*?)-I[ \t]*([^ ]*)", re.MULTILINE|re.DOTALL)\r
+ \r
+ BuildOptionIncPathList = []\r
+ for Tool in ('CC', 'PP', 'VFRPP', 'ASLPP', 'ASLCC', 'APP', 'ASM'):\r
+ Attr = 'FLAGS'\r
+ try:\r
+ FlagOption = self.BuildOption[Tool][Attr]\r
+ except KeyError:\r
+ FlagOption = ''\r
+ \r
+ IncPathList = [NormPath(Path, self.Macros) for Path in gBuildOptIncludePattern.findall(FlagOption)]\r
+ #\r
+ # EDK II modules must not reference header files outside of the packages they depend on or \r
+ # within the module's directory tree. Report error if violation.\r
+ #\r
+ if self.AutoGenVersion >= 0x00010005 and len(IncPathList) > 0:\r
+ for Path in IncPathList:\r
+ if (Path not in self.IncludePathList) and (CommonPath([Path, self.MetaFile.Dir]) != self.MetaFile.Dir):\r
+ ErrMsg = "The include directory for the EDK II module in this line is invalid %s specified in %s FLAGS '%s'" % (Path, Tool, FlagOption) \r
+ EdkLogger.error("build", \r
+ PARAMETER_INVALID,\r
+ ExtraData = ErrMsg, \r
+ File = str(self.MetaFile))\r
+\r
+ \r
+ BuildOptionIncPathList += IncPathList\r
+ \r
+ self._BuildOptionIncPathList = BuildOptionIncPathList\r
+ \r
+ return self._BuildOptionIncPathList\r
+ \r
## Return a list of files which can be built from source\r
#\r
# What kind of files can be built is determined by build rules in\r
self._BuildTargets = {}\r
self._FileTypes = {}\r
\r
- #TRICK: call _GetSourceFileList to apply build rule for binary files\r
+ #TRICK: call _GetSourceFileList to apply build rule for source files\r
if self.SourceFileList:\r
pass\r
\r
#\r
def _GetAutoGenFileList(self):\r
UniStringAutoGenC = True\r
- UniStringBinBuffer = None\r
+ UniStringBinBuffer = StringIO()\r
if self.BuildType == 'UEFI_HII':\r
- UniStringBinBuffer = StringIO()\r
UniStringAutoGenC = False\r
if self._AutoGenFileList == None:\r
self._AutoGenFileList = {}\r
#\r
def _GetLibraryPcdList(self):\r
if self._LibraryPcdList == None:\r
- Pcds = {}\r
+ Pcds = sdict()\r
if not self.IsLibrary:\r
# get PCDs from dependent libraries\r
for Library in self.DependentLibraryList:\r
for Inc in self.Module.Includes:\r
if Inc not in self._IncludePathList:\r
self._IncludePathList.append(Inc)\r
- # for r8 modules\r
+ # for Edk modules\r
Inc = path.join(Inc, self.Arch.capitalize())\r
if os.path.exists(Inc) and Inc not in self._IncludePathList:\r
self._IncludePathList.append(Inc)\r
- # r8 module needs to put DEBUG_DIR at the end of search path and not to use SOURCE_DIR all the time\r
+ # Edk module needs to put DEBUG_DIR at the end of search path and not to use SOURCE_DIR all the time\r
self._IncludePathList.append(self.DebugDir)\r
else:\r
self._IncludePathList.append(self.MetaFile.Dir)\r
\r
for File in self.AutoGenFileList:\r
if GenC.Generate(File.Path, self.AutoGenFileList[File], File.IsBinary):\r
- #Ignore R8 AutoGen.c\r
+ #Ignore Edk AutoGen.c\r
if self.AutoGenVersion < 0x00010005 and File.Name == 'AutoGen.c':\r
continue\r
\r
ProtocolList = property(_GetProtocolList)\r
PpiList = property(_GetPpiList)\r
DepexList = property(_GetDepexTokenList)\r
+ DxsFile = property(_GetDxsFile)\r
DepexExpressionList = property(_GetDepexExpressionTokenList)\r
BuildOption = property(_GetModuleBuildOption)\r
+ BuildOptionIncPathList = property(_GetBuildOptionIncPathList)\r
BuildCommand = property(_GetBuildCommand)\r
\r
# This acts like the main() function for the script, unless it is 'import'ed into another script.\r