X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FWorkspace%2FWorkspaceDatabase.py;h=2e6c68e33aaef2a1961c1a02b4589f9d61c88ba8;hp=8252a3180d9512d494c445cbe0d222bd18131c86;hb=2a29017e3e305a10ee1003354c0d0c037923341d;hpb=a0a2cd1ea6933bdd54165b8e9a403e7e7f492822 diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index 8252a3180d..2e6c68e33a 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -1,7 +1,8 @@ ## @file # This file is used to create a database used by build tool # -# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
+# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -21,6 +22,7 @@ import uuid import Common.EdkLogger as EdkLogger import Common.GlobalData as GlobalData +from Common.MultipleWorkspace import MultipleWorkspace as mws from Common.String import * from Common.DataType import * @@ -35,8 +37,11 @@ from MetaFileParser import * from BuildClassObject import * from WorkspaceCommon import GetDeclaredPcd from Common.Misc import AnalyzeDscPcd +from Common.Misc import ProcessDuplicatedInf import re from Common.Parsing import IsValidWord +from Common.VariableAttributes import VariableAttributes +import Common.GlobalData as GlobalData ## Platform build information from DSC file # @@ -103,6 +108,7 @@ class DscBuildData(PlatformBuildClassObject): self._Target = Target self._Toolchain = Toolchain self._Clear() + self._HandleOverridePath() ## XXX[key] = value def __setitem__(self, key, value): @@ -128,8 +134,12 @@ class DscBuildData(PlatformBuildClassObject): self._BuildTargets = None self._SkuName = None self._SkuIdentifier = None + self._AvilableSkuIds = None self._PcdInfoFlag = None + self._VarCheckFlag = None self._FlashDefinition = None + self._Prebuild = None + self._Postbuild = None self._BuildNumber = None self._MakefileName = None self._BsBaseAddress = None @@ -141,12 +151,34 @@ class DscBuildData(PlatformBuildClassObject): self._Pcds = None self._DecPcds = None self._BuildOptions = None + self._ModuleTypeOptions = None self._LoadFixAddress = None self._RFCLanguages = None self._ISOLanguages = None self._VpdToolGuid = None self.__Macros = None + + ## handle Override Path of Module + def _HandleOverridePath(self): + RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch] + Macros = self._Macros + Macros["EDK_SOURCE"] = GlobalData.gEcpSource + for Record in RecordList: + ModuleId = Record[5] + LineNo = Record[6] + ModuleFile = PathClass(NormPath(Record[0]), GlobalData.gWorkspace, Arch=self._Arch) + RecordList = self._RawData[MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH, self._Arch, None, ModuleId] + if RecordList != []: + SourceOverridePath = mws.join(GlobalData.gWorkspace, NormPath(RecordList[0][0])) + + # Check if the source override path exists + if not os.path.isdir(SourceOverridePath): + EdkLogger.error('build', FILE_NOT_FOUND, Message='Source override path does not exist:', File=self.MetaFile, ExtraData=SourceOverridePath, Line=LineNo) + + #Add to GlobalData Variables + GlobalData.gOverrideDir[ModuleFile.Key] = SourceOverridePath + ## Get current effective macros def _GetMacros(self): if self.__Macros == None: @@ -198,6 +230,10 @@ class DscBuildData(PlatformBuildClassObject): if ErrorCode != 0: EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=Record[-1], ExtraData=ErrorInfo) + elif Name == TAB_DSC_PREBUILD: + self._Prebuild = PathClass(NormPath(Record[2], self._Macros), GlobalData.gWorkspace) + elif Name == TAB_DSC_POSTBUILD: + self._Postbuild = PathClass(NormPath(Record[2], self._Macros), GlobalData.gWorkspace) elif Name == TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES: self._SupArchList = GetSplitValueList(Record[2], TAB_VALUE_SPLIT) elif Name == TAB_DSC_DEFINES_BUILD_TARGETS: @@ -206,8 +242,11 @@ class DscBuildData(PlatformBuildClassObject): if self._SkuName == None: self._SkuName = Record[2] self._SkuIdentifier = Record[2] + self._AvilableSkuIds = Record[2] elif Name == TAB_DSC_DEFINES_PCD_INFO_GENERATION: self._PcdInfoFlag = Record[2] + elif Name == TAB_DSC_DEFINES_PCD_VAR_CHECK_GENERATION: + self._VarCheckFlag = Record[2] elif Name == TAB_FIX_LOAD_TOP_MEMORY_ADDRESS: try: self._LoadFixAddress = int (Record[2], 0) @@ -327,7 +366,17 @@ class DscBuildData(PlatformBuildClassObject): return True else: return False - + def _GetVarCheckFlag(self): + if self._VarCheckFlag == None or self._VarCheckFlag.upper() == 'FALSE': + return False + elif self._VarCheckFlag.upper() == 'TRUE': + return True + else: + return False + def _GetAviableSkuIds(self): + if self._AvilableSkuIds: + return self._AvilableSkuIds + return self.SkuIdentifier def _GetSkuIdentifier(self): if self._SkuName: return self._SkuName @@ -357,6 +406,22 @@ class DscBuildData(PlatformBuildClassObject): self._FlashDefinition = '' return self._FlashDefinition + def _GetPrebuild(self): + if self._Prebuild == None: + if self._Header == None: + self._GetHeaderInfo() + if self._Prebuild == None: + self._Prebuild = '' + return self._Prebuild + + def _GetPostbuild(self): + if self._Postbuild == None: + if self._Header == None: + self._GetHeaderInfo() + if self._Postbuild == None: + self._Postbuild = '' + return self._Postbuild + ## Retrieve FLASH_DEFINITION def _GetBuildNumber(self): if self._BuildNumber == None: @@ -478,6 +543,14 @@ class DscBuildData(PlatformBuildClassObject): Macros = self._Macros Macros["EDK_SOURCE"] = GlobalData.gEcpSource for Record in RecordList: + DuplicatedFile = False + + # process only records COMMON and self.Arch + SectionArch = Record[3].upper() + if SectionArch != 'COMMON': + if SectionArch != self.Arch: + continue + ModuleFile = PathClass(NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch=self._Arch) ModuleId = Record[5] LineNo = Record[6] @@ -490,23 +563,11 @@ class DscBuildData(PlatformBuildClassObject): # Check duplication # If arch is COMMON, no duplicate module is checked since all modules in all component sections are selected if self._Arch != 'COMMON' and ModuleFile in self._Modules: - EdkLogger.error('build', FILE_DUPLICATED, File=self.MetaFile, ExtraData=str(ModuleFile), Line=LineNo) + DuplicatedFile = True Module = ModuleBuildClassObject() Module.MetaFile = ModuleFile - # get module override path - RecordList = self._RawData[MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH, self._Arch, None, ModuleId] - if RecordList != []: - Module.SourceOverridePath = os.path.join(GlobalData.gWorkspace, NormPath(RecordList[0][0], Macros)) - - # Check if the source override path exists - if not os.path.isdir(Module.SourceOverridePath): - EdkLogger.error('build', FILE_NOT_FOUND, Message = 'Source override path does not exist:', File=self.MetaFile, ExtraData=Module.SourceOverridePath, Line=LineNo) - - #Add to GlobalData Variables - GlobalData.gOverrideDir[ModuleFile.Key] = Module.SourceOverridePath - # get module private library instance RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch, None, ModuleId] for Record in RecordList: @@ -563,6 +624,16 @@ class DscBuildData(PlatformBuildClassObject): OptionString = Module.BuildOptions[ToolChainFamily, ToolChain] Module.BuildOptions[ToolChainFamily, ToolChain] = OptionString + " " + Option + RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, None, ModuleId] + if DuplicatedFile and not RecordList: + EdkLogger.error('build', FILE_DUPLICATED, File=self.MetaFile, ExtraData=str(ModuleFile), Line=LineNo) + if RecordList: + if len(RecordList) != 1: + EdkLogger.error('build', OPTION_UNKNOWN, 'Only FILE_GUID can be listed in section.', + File=self.MetaFile, ExtraData=str(ModuleFile), Line=LineNo) + ModuleFile = ProcessDuplicatedInf(ModuleFile, RecordList[0][2], GlobalData.gWorkspace) + ModuleFile.Arch = self._Arch + self._Modules[ModuleFile] = Module return self._Modules @@ -641,9 +712,26 @@ class DscBuildData(PlatformBuildClassObject): def _ValidatePcd(self, PcdCName, TokenSpaceGuid, Setting, PcdType, LineNo): if self._DecPcds == None: self._DecPcds = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain) + FdfInfList = [] + if GlobalData.gFdfParser: + FdfInfList = GlobalData.gFdfParser.Profile.InfList + + PkgSet = set() + for Inf in FdfInfList: + ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch=self._Arch) + if ModuleFile in self._Modules: + continue + ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain] + PkgSet.update(ModuleData.Packages) + DecPcds = {} + for Pkg in PkgSet: + for Pcd in Pkg.Pcds: + DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd] + self._DecPcds.update(DecPcds) + if (PcdCName, TokenSpaceGuid) not in self._DecPcds: EdkLogger.error('build', PARSER_ERROR, - "Pcd (%s.%s) defined in DSC is not declared in DEC files." % (TokenSpaceGuid, PcdCName), + "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (TokenSpaceGuid, PcdCName, self._Arch), File=self.MetaFile, Line=LineNo) ValueList, IsValid, Index = AnalyzeDscPcd(Setting, PcdType, self._DecPcds[PcdCName, TokenSpaceGuid].DatumType) if not IsValid and PcdType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]: @@ -698,19 +786,38 @@ class DscBuildData(PlatformBuildClassObject): if self._BuildOptions == None: self._BuildOptions = sdict() # - # Retrieve build option for EDKII style module + # Retrieve build option for EDKII and EDK style module # - RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, EDKII_NAME] - for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4 in RecordList: - self._BuildOptions[ToolChainFamily, ToolChain, EDKII_NAME] = Option - # - # Retrieve build option for EDK style module - # - RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, EDK_NAME] - for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4 in RecordList: - self._BuildOptions[ToolChainFamily, ToolChain, EDK_NAME] = Option + for CodeBase in (EDKII_NAME, EDK_NAME): + RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, CodeBase] + for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4 in RecordList: + CurKey = (ToolChainFamily, ToolChain, CodeBase) + # + # Only flags can be appended + # + if CurKey not in self._BuildOptions or not ToolChain.endswith('_FLAGS') or Option.startswith('='): + self._BuildOptions[CurKey] = Option + else: + self._BuildOptions[CurKey] += ' ' + Option return self._BuildOptions + def GetBuildOptionsByModuleType(self, Edk, ModuleType): + if self._ModuleTypeOptions == None: + self._ModuleTypeOptions = sdict() + if (Edk, ModuleType) not in self._ModuleTypeOptions: + options = sdict() + self._ModuleTypeOptions[Edk, ModuleType] = options + DriverType = '%s.%s' % (Edk, ModuleType) + RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, DriverType] + for ToolChainFamily, ToolChain, Option, Arch, Type, Dummy3, Dummy4 in RecordList: + if Type == DriverType: + Key = (ToolChainFamily, ToolChain, Edk) + if Key not in options or not ToolChain.endswith('_FLAGS') or Option.startswith('='): + options[Key] = Option + else: + options[Key] += ' ' + Option + return self._ModuleTypeOptions[Edk, ModuleType] + ## Retrieve non-dynamic PCD settings # # @param Type PCD type @@ -857,6 +964,17 @@ class DscBuildData(PlatformBuildClassObject): return Pcds + def CompareVarAttr(self, Attr1, Attr2): + if not Attr1 or not Attr2: # for empty string + return True + Attr1s = [attr.strip() for attr in Attr1.split(",")] + Attr1Set = set(Attr1s) + Attr2s = [attr.strip() for attr in Attr2.split(",")] + Attr2Set = set(Attr2s) + if Attr2Set == Attr1Set: + return True + else: + return False ## Retrieve dynamic HII PCD settings # # @param Type PCD type @@ -866,6 +984,7 @@ class DscBuildData(PlatformBuildClassObject): def _GetDynamicHiiPcd(self, Type): SkuObj = SkuClass(self.SkuIdentifier,self.SkuIds) + VariableAttrs = {} Pcds = sdict() # @@ -890,8 +1009,12 @@ class DscBuildData(PlatformBuildClassObject): Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid] if Setting == None: continue - VariableName, VariableGuid, VariableOffset, DefaultValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) + VariableName, VariableGuid, VariableOffset, DefaultValue, VarAttribute = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4) + rt, Msg = VariableAttributes.ValidateVarAttributes(VarAttribute) + if not rt: + EdkLogger.error("build", PCD_VARIABLE_ATTRIBUTES_ERROR, "Variable attributes settings for %s is incorrect.\n %s" % (".".join((TokenSpaceGuid, PcdCName)), Msg), + ExtraData = "[%s]" % VarAttribute) ExceedMax = False FormatCorrect = True if VariableOffset.isdigit(): @@ -914,8 +1037,14 @@ class DscBuildData(PlatformBuildClassObject): if ExceedMax: EdkLogger.error('Build', OPTION_VALUE_INVALID, "The variable offset value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid,PcdCName))) + if (VariableName, VariableGuid) not in VariableAttrs: + VariableAttrs[(VariableName, VariableGuid)] = VarAttribute + else: + if not self.CompareVarAttr(VariableAttrs[(VariableName, VariableGuid)], VarAttribute): + EdkLogger.error('Build', PCD_VARIABLE_ATTRIBUTES_CONFLICT_ERROR, "The variable %s.%s for DynamicHii PCDs has conflicting attributes [%s] and [%s] " % (VariableGuid, VariableName, VarAttribute, VariableAttrs[(VariableName, VariableGuid)])) - SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName], VariableName, VariableGuid, VariableOffset, DefaultValue) + SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName], VariableName, VariableGuid, VariableOffset, DefaultValue, VariableAttribute = VarAttribute) + pcdDecObject = self._DecPcds[PcdCName, TokenSpaceGuid] if (PcdCName,TokenSpaceGuid) in Pcds.keys(): pcdObject = Pcds[PcdCName,TokenSpaceGuid] pcdObject.SkuInfoList[SkuName] = SkuInfo @@ -930,7 +1059,10 @@ class DscBuildData(PlatformBuildClassObject): '', {SkuName : SkuInfo}, False, - None + None, + pcdDecObject.validateranges, + pcdDecObject.validlists, + pcdDecObject.expressions ) @@ -1035,7 +1167,7 @@ class DscBuildData(PlatformBuildClassObject): TokenSpaceGuid, self._PCD_TYPE_STRING_[Type], '', - '', + InitialValue, '', MaxDatumSize, {SkuName : SkuInfo}, @@ -1101,8 +1233,12 @@ class DscBuildData(PlatformBuildClassObject): BuildTargets = property(_GetBuildTarget) SkuName = property(_GetSkuName, _SetSkuName) SkuIdentifier = property(_GetSkuIdentifier) + AvilableSkuIds = property(_GetAviableSkuIds) PcdInfoFlag = property(_GetPcdInfoFlag) + VarCheckFlag = property(_GetVarCheckFlag) FlashDefinition = property(_GetFdfFile) + Prebuild = property(_GetPrebuild) + Postbuild = property(_GetPostbuild) BuildNumber = property(_GetBuildNumber) MakefileName = property(_GetMakefileName) BsBaseAddress = property(_GetBsBaseAddress) @@ -1421,6 +1557,7 @@ class DecBuildData(PackageBuildClassObject): DefaultValue, DatumType, TokenNumber = AnalyzePcdData(Setting) + validateranges, validlists, expressions = self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName) Pcds[PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type]] = PcdClassObject( PcdCName, TokenSpaceGuid, @@ -1431,7 +1568,10 @@ class DecBuildData(PackageBuildClassObject): '', {}, False, - None + None, + list(validateranges), + list(validlists), + list(expressions) ) return Pcds @@ -1676,6 +1816,9 @@ class InfBuildData(ModuleBuildClassObject): # items defined _PROPERTY_ don't need additional processing if Name in self: self[Name] = Value + if self._Defs == None: + self._Defs = sdict() + self._Defs[Name] = Value # some special items in [Defines] section need special treatment elif Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION', 'EDK_RELEASE_VERSION', 'PI_SPECIFICATION_VERSION'): if Name in ('EFI_SPECIFICATION_VERSION', 'UEFI_SPECIFICATION_VERSION'): @@ -1752,11 +1895,11 @@ class InfBuildData(ModuleBuildClassObject): LineNo = Record[6] break EdkLogger.error("build", FORMAT_NOT_SUPPORTED, - "MODULE_TYPE %s is not supported for EDK II, valid values are:\n %s" % (self._ModuleType,' '.join(l for l in SUP_MODULE_LIST)), + "MODULE_TYPE %s is not supported for EDK II, valid values are:\n %s" % (self._ModuleType, ' '.join(l for l in SUP_MODULE_LIST)), File=self.MetaFile, Line=LineNo) if (self._Specification == None) or (not 'PI_SPECIFICATION_VERSION' in self._Specification) or (int(self._Specification['PI_SPECIFICATION_VERSION'], 16) < 0x0001000A): if self._ModuleType == SUP_MODULE_SMM_CORE: - EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=self.MetaFile) + EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=self.MetaFile) if self._Defs and 'PCI_DEVICE_ID' in self._Defs and 'PCI_VENDOR_ID' in self._Defs \ and 'PCI_CLASS_CODE' in self._Defs: self._BuildType = 'UEFI_OPTIONROM' @@ -1765,7 +1908,7 @@ class InfBuildData(ModuleBuildClassObject): self._BuildType = 'UEFI_HII' else: self._BuildType = self._ModuleType.upper() - + if self._DxsFile: File = PathClass(NormPath(self._DxsFile), self._ModuleDir, Arch=self._Arch) # check the file validation @@ -1780,7 +1923,7 @@ class InfBuildData(ModuleBuildClassObject): if not self._ComponentType: EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "COMPONENT_TYPE is not given", File=self.MetaFile) - self._BuildType = self._ComponentType.upper() + self._BuildType = self._ComponentType.upper() if self._ComponentType in self._MODULE_TYPE_: self._ModuleType = self._MODULE_TYPE_[self._ComponentType] if self._ComponentType == 'LIBRARY': @@ -1790,7 +1933,7 @@ class InfBuildData(ModuleBuildClassObject): Macros["EDK_SOURCE"] = GlobalData.gEcpSource Macros['PROCESSOR'] = self._Arch RecordList = self._RawData[MODEL_META_DATA_NMAKE, self._Arch, self._Platform] - for Name,Value,Dummy,Arch,Platform,ID,LineNo in RecordList: + for Name, Value, Dummy, Arch, Platform, ID, LineNo in RecordList: Value = ReplaceMacro(Value, Macros, True) if Name == "IMAGE_ENTRY_POINT": if self._ModuleEntryPointList == None: @@ -1844,7 +1987,13 @@ class InfBuildData(ModuleBuildClassObject): RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, self._Platform] for Record in RecordList: if Record[1] == TAB_INF_DEFINES_INF_VERSION: - self._AutoGenVersion = int(Record[2], 0) + if '.' in Record[2]: + ValueList = Record[2].split('.') + Major = '%04o' % int(ValueList[0], 0) + Minor = '%04o' % int(ValueList[1], 0) + self._AutoGenVersion = int('0x' + Major + Minor, 0) + else: + self._AutoGenVersion = int(Record[2], 0) break if self._AutoGenVersion == None: self._AutoGenVersion = 0x00010000 @@ -1903,7 +2052,7 @@ class InfBuildData(ModuleBuildClassObject): if self._Header_ == None: self._GetHeaderInfo() if self._Guid == None: - self._Guid = '00000000-0000-0000-000000000000' + self._Guid = '00000000-0000-0000-0000-000000000000' return self._Guid ## Retrieve module version @@ -2051,6 +2200,11 @@ class InfBuildData(ModuleBuildClassObject): return False ## Retrieve source files def _GetSourceFiles(self): + #Ignore all source files in a binary build mode + if GlobalData.gIgnoreSource: + self._Sources = [] + return self._Sources + if self._Sources == None: self._Sources = [] RecordList = self._RawData[MODEL_EFI_SOURCE_FILE, self._Arch, self._Platform] @@ -2064,8 +2218,11 @@ class InfBuildData(ModuleBuildClassObject): if self.AutoGenVersion < 0x00010005: Macros["EDK_SOURCE"] = GlobalData.gEcpSource Macros['PROCESSOR'] = self._Arch + SourceFile = NormPath(Record[0], Macros) + if SourceFile[0] == os.path.sep: + SourceFile = mws.join(GlobalData.gWorkspace, SourceFile[1:]) # old module source files (Edk) - File = PathClass(NormPath(Record[0], Macros), self._ModuleDir, self._SourceOverridePath, + File = PathClass(SourceFile, self._ModuleDir, self._SourceOverridePath, '', False, self._Arch, ToolChainFamily, '', TagName, ToolCode) # check the file validation ErrorCode, ErrorInfo = File.Validate(CaseSensitive=False) @@ -2228,10 +2385,21 @@ class InfBuildData(ModuleBuildClassObject): if File[0] == '.': File = os.path.join(self._ModuleDir, File) else: - File = os.path.join(GlobalData.gWorkspace, File) + File = mws.join(GlobalData.gWorkspace, File) File = RealPath(os.path.normpath(File)) if File: self._Includes.append(File) + if not File and Record[0].find('EFI_SOURCE') > -1: + # tricky to regard WorkSpace as EFI_SOURCE + Macros['EFI_SOURCE'] = GlobalData.gWorkspace + File = NormPath(Record[0], Macros) + if File[0] == '.': + File = os.path.join(self._ModuleDir, File) + else: + File = os.path.join(GlobalData.gWorkspace, File) + File = RealPath(os.path.normpath(File)) + if File: + self._Includes.append(File) return self._Includes ## Retrieve packages this module depends on @@ -2278,7 +2446,7 @@ class InfBuildData(ModuleBuildClassObject): ToolChainFamily = Record[0] ToolChain = Record[1] Option = Record[2] - if (ToolChainFamily, ToolChain) not in self._BuildOptions: + if (ToolChainFamily, ToolChain) not in self._BuildOptions or Option.startswith('='): self._BuildOptions[ToolChainFamily, ToolChain] = Option else: # concatenate the option string if they're for the same tool @@ -2304,6 +2472,13 @@ class InfBuildData(ModuleBuildClassObject): EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "No [Depex] section or no valid expression in [Depex] section for [%s] module" \ % self.ModuleType, File=self.MetaFile) + if len(RecordList) != 0 and self.ModuleType == 'USER_DEFINED': + for Record in RecordList: + if Record[4] not in ['PEIM', 'DXE_DRIVER', 'DXE_SMM_DRIVER']: + EdkLogger.error('build', FORMAT_INVALID, + "'%s' module must specify the type of [Depex] section" % self.ModuleType, + File=self.MetaFile) + Depex = sdict() for Record in RecordList: DepexStr = ReplaceMacro(Record[0], self._Macros, False) @@ -2388,6 +2563,7 @@ class InfBuildData(ModuleBuildClassObject): # resolve PCD type, value, datum info, etc. by getting its definition from package for PcdCName, TokenSpaceGuid in PcdList: + PcdRealName = PcdCName Setting, LineNo = PcdDict[self._Arch, self.Platform, PcdCName, TokenSpaceGuid] if Setting == None: continue @@ -2409,6 +2585,27 @@ class InfBuildData(ModuleBuildClassObject): # Patch PCD: TokenSpace.PcdCName|Value|Offset Pcd.Offset = ValueList[1] + if (PcdRealName, TokenSpaceGuid) in GlobalData.MixedPcd: + for Package in self.Packages: + for key in Package.Pcds: + if (Package.Pcds[key].TokenCName, Package.Pcds[key].TokenSpaceGuidCName) == (PcdRealName, TokenSpaceGuid): + for item in GlobalData.MixedPcd[(PcdRealName, TokenSpaceGuid)]: + Pcd_Type = item[0].split('_')[-1] + if Pcd_Type == Package.Pcds[key].Type: + Value = Package.Pcds[key] + Value.TokenCName = Package.Pcds[key].TokenCName + '_' + Pcd_Type + if len(key) == 2: + newkey = (Value.TokenCName, key[1]) + elif len(key) == 3: + newkey = (Value.TokenCName, key[1], key[2]) + del Package.Pcds[key] + Package.Pcds[newkey] = Value + break + else: + pass + else: + pass + # get necessary info from package declaring this PCD for Package in self.Packages: # @@ -2422,11 +2619,32 @@ class InfBuildData(ModuleBuildClassObject): if Type == MODEL_PCD_DYNAMIC: Pcd.Pending = True for T in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]: - if (PcdCName, TokenSpaceGuid, T) in Package.Pcds: - PcdType = T + if (PcdRealName, TokenSpaceGuid) in GlobalData.MixedPcd: + for item in GlobalData.MixedPcd[(PcdRealName, TokenSpaceGuid)]: + if str(item[0]).endswith(T) and (item[0], item[1], T) in Package.Pcds: + PcdType = T + PcdCName = item[0] + break + else: + pass break + else: + if (PcdRealName, TokenSpaceGuid, T) in Package.Pcds: + PcdType = T + break + else: Pcd.Pending = False + if (PcdRealName, TokenSpaceGuid) in GlobalData.MixedPcd: + for item in GlobalData.MixedPcd[(PcdRealName, TokenSpaceGuid)]: + Pcd_Type = item[0].split('_')[-1] + if Pcd_Type == PcdType: + PcdCName = item[0] + break + else: + pass + else: + pass if (PcdCName, TokenSpaceGuid, PcdType) in Package.Pcds: PcdInPackage = Package.Pcds[PcdCName, TokenSpaceGuid, PcdType] @@ -2440,8 +2658,8 @@ class InfBuildData(ModuleBuildClassObject): EdkLogger.error( 'build', FORMAT_INVALID, - "No TokenValue for PCD [%s.%s] in [%s]!" % (TokenSpaceGuid, PcdCName, str(Package)), - File =self.MetaFile, Line=LineNo, + "No TokenValue for PCD [%s.%s] in [%s]!" % (TokenSpaceGuid, PcdRealName, str(Package)), + File=self.MetaFile, Line=LineNo, ExtraData=None ) # @@ -2453,8 +2671,8 @@ class InfBuildData(ModuleBuildClassObject): EdkLogger.error( 'build', FORMAT_INVALID, - "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid:" % (Pcd.TokenValue, TokenSpaceGuid, PcdCName, str(Package)), - File =self.MetaFile, Line=LineNo, + "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid:" % (Pcd.TokenValue, TokenSpaceGuid, PcdRealName, str(Package)), + File=self.MetaFile, Line=LineNo, ExtraData=None ) @@ -2468,19 +2686,19 @@ class InfBuildData(ModuleBuildClassObject): EdkLogger.error( 'build', FORMAT_INVALID, - "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid, as a decimal it should between: 0 - 4294967295!"% (Pcd.TokenValue, TokenSpaceGuid, PcdCName, str(Package)), - File =self.MetaFile, Line=LineNo, + "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid, as a decimal it should between: 0 - 4294967295!" % (Pcd.TokenValue, TokenSpaceGuid, PcdRealName, str(Package)), + File=self.MetaFile, Line=LineNo, ExtraData=None - ) + ) except: EdkLogger.error( 'build', FORMAT_INVALID, - "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid, it should be hexadecimal or decimal!"% (Pcd.TokenValue, TokenSpaceGuid, PcdCName, str(Package)), - File =self.MetaFile, Line=LineNo, + "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid, it should be hexadecimal or decimal!" % (Pcd.TokenValue, TokenSpaceGuid, PcdRealName, str(Package)), + File=self.MetaFile, Line=LineNo, ExtraData=None ) - + Pcd.DatumType = PcdInPackage.DatumType Pcd.MaxDatumSize = PcdInPackage.MaxDatumSize Pcd.InfDefaultValue = Pcd.DefaultValue @@ -2491,8 +2709,8 @@ class InfBuildData(ModuleBuildClassObject): EdkLogger.error( 'build', FORMAT_INVALID, - "PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid, PcdCName, self.MetaFile), - File =self.MetaFile, Line=LineNo, + "PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid, PcdRealName, self.MetaFile), + File=self.MetaFile, Line=LineNo, ExtraData="\t%s" % '\n\t'.join([str(P) for P in self.Packages]) ) Pcds[PcdCName, TokenSpaceGuid] = Pcd @@ -2565,8 +2783,6 @@ class InfBuildData(ModuleBuildClassObject): # class WorkspaceDatabase(object): - # default database file path - _DB_PATH_ = "Conf/.cache/build.db" # # internal class used for call corresponding file parser and caching the result @@ -2677,7 +2893,7 @@ class WorkspaceDatabase(object): def __init__(self, DbPath, RenewDb=False): self._DbClosedFlag = False if not DbPath: - DbPath = os.path.normpath(os.path.join(GlobalData.gWorkspace, self._DB_PATH_)) + DbPath = os.path.normpath(mws.join(GlobalData.gWorkspace, 'Conf', GlobalData.gDatabasePath)) # don't create necessary path for db in memory if DbPath != ':memory:': @@ -2805,7 +3021,7 @@ determine whether database file is out of date!\n") ## Summarize all packages in the database def GetPackageList(self, Platform, Arch, TargetName, ToolChainTag): self.Platform = Platform - PackageList =[] + PackageList = [] Pa = self.BuildObject[self.Platform, 'COMMON'] # # Get Package related to Modules @@ -2822,8 +3038,8 @@ determine whether database file is out of date!\n") LibObj = self.BuildObject[Lib, Arch, TargetName, ToolChainTag] for Package in LibObj.Packages: if Package not in PackageList: - PackageList.append(Package) - + PackageList.append(Package) + return PackageList ## Summarize all platforms in the database @@ -2838,6 +3054,12 @@ determine whether database file is out of date!\n") PlatformList.append(Platform) return PlatformList + def _MapPlatform(self, Dscfile): + Platform = self.BuildObject[PathClass(Dscfile), 'COMMON'] + if Platform == None: + EdkLogger.error('build', PARSER_ERROR, "Failed to parser DSC file: %s" % Dscfile) + return Platform + PlatformList = property(_GetPlatformList) ##