def CheckDpDepexForReplace(self, OrigDpGuid, OrigDpVersion, NewDpPkgList): Replaceable = True DependModuleList = [] WsModuleList = self.WsModuleList # # remove modules that included in current DP # List of item (FilePath) DpModuleList = self.IpiDb.GetDpModuleList(OrigDpGuid, OrigDpVersion) for Module in DpModuleList: if Module in WsModuleList: WsModuleList.remove(Module) else: Logger.Warn("UPT\n", ST.ERR_MODULE_NOT_INSTALLED % Module) OtherPkgList = NewDpPkgList # # get packages in current Dp and find the install path # List of item (PkgGuid, PkgVersion, InstallPath) DpPackageList = self.IpiDb.GetPackageListFromDp( OrigDpGuid, OrigDpVersion) DpPackagePathList = [] WorkSP = GlobalData.gWORKSPACE for (PkgName, PkgGuid, PkgVersion, DecFile) in self.WsPkgList: if PkgName: pass DecPath = dirname(DecFile) if DecPath.find(WorkSP) > -1: InstallPath = GetRelativePath(DecPath, WorkSP) DecFileRelaPath = GetRelativePath(DecFile, WorkSP) else: InstallPath = DecPath DecFileRelaPath = DecFile if (PkgGuid, PkgVersion, InstallPath) in DpPackageList: DpPackagePathList.append(DecFileRelaPath) DpPackageList.remove((PkgGuid, PkgVersion, InstallPath)) else: OtherPkgList.append((PkgGuid, PkgVersion)) # # the left items in DpPackageList are the packages that installed but not found anymore # for (PkgGuid, PkgVersion, InstallPath) in DpPackageList: Logger.Warn( "UPT", ST.WARN_INSTALLED_PACKAGE_NOT_FOUND % (PkgGuid, PkgVersion, InstallPath)) # # check modules to see if it can be satisfied by package not belong to removed DP # for Module in WsModuleList: if (not VerifyReplaceModuleDep(Module, DpPackagePathList, OtherPkgList)): Replaceable = False DependModuleList.append(Module) return (Replaceable, DependModuleList)
def LoadDecFile(self, Filename): # # Insert a record for file # Filename = NormPath(Filename) (Path, Name) = os.path.split(Filename) self.SetFullPath(Filename) self.SetRelaPath(Path) self.SetFileName(Name) self.SetPackagePath(GetRelativePath(Path, self.WorkspaceDir)) self.SetCombinePath(GetRelativePath(Filename, self.WorkspaceDir)) self.DecParser = Dec(Filename)
def GenPackages(ModuleObject): Content = '' # # generate [Packages] section # NewSectionDict = Sdict() WorkspaceDir = GlobalData.gWORKSPACE for PackageDependency in ModuleObject.GetPackageDependencyList(): # # Generate generic comment # CommentStr = '' HelpText = PackageDependency.GetHelpText() if HelpText: HelpStr = HelpText.GetString() CommentStr = GenGenericCommentF(HelpStr) Statement = CommentStr Guid = PackageDependency.GetGuid() Version = PackageDependency.GetVersion() FFE = PackageDependency.GetFeatureFlag() Path = '' # # find package path/name # for PkgInfo in GlobalData.gWSPKG_LIST: if Guid == PkgInfo[1]: if (not Version) or (Version == PkgInfo[2]): Path = PkgInfo[3] break # # get relative path # RelaPath = GetRelativePath(Path, WorkspaceDir) Statement += RelaPath.replace('\\', '/') if FFE: Statement += '|' + FFE ArchList = PackageDependency.GetSupArchList() ArchList.sort() SortedArch = ' '.join(ArchList) if SortedArch in NewSectionDict: NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [ Statement ] else: NewSectionDict[SortedArch] = [Statement] Content += GenSection('Packages', NewSectionDict) return Content
def GenPackages(ModuleObject): Content = '' # # generate [Packages] section # NewSectionDict = Sdict() WorkspaceDir = GlobalData.gWORKSPACE for PackageDependency in ModuleObject.GetPackageDependencyList(): # # Generate generic comment # CommentStr = '' HelpText = PackageDependency.GetHelpText() if HelpText: HelpStr = HelpText.GetString() CommentStr = GenGenericCommentF(HelpStr) Statement = CommentStr Guid = PackageDependency.GetGuid() Version = PackageDependency.GetVersion() FFE = PackageDependency.GetFeatureFlag() Path = '' # # find package path/name # for PkgInfo in GlobalData.gWSPKG_LIST: if Guid == PkgInfo[1]: if (not Version) or (Version == PkgInfo[2]): Path = PkgInfo[3] break # # get relative path # RelaPath = GetRelativePath(Path, WorkspaceDir) Statement += RelaPath.replace('\\', '/') if FFE: Statement += '|' + FFE ArchList = PackageDependency.GetSupArchList() ArchList.sort() SortedArch = ' '.join(ArchList) if SortedArch in NewSectionDict: NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement] else: NewSectionDict[SortedArch] = [Statement] Content += GenSection('Packages', NewSectionDict) return Content
def _GenModuleHeader(self): Logger.Debug(2, "Generate ModuleHeader ...") # # Get all defines information form InfParser Object # RecordSet = self.Parser.InfDefSection.Defines # # Should only have one ArchString Item. # ArchString = RecordSet.keys()[0] ArchList = GetSplitValueList(ArchString, ' ') ArchList = ConvertArchList(ArchList) HasCalledFlag = False # # Get data from Sdict() # ValueList = RecordSet[ArchString] self.SetFileName(self.FileName) self.SetFullPath(self.FullPath) # # The INF's filename (without the directory path or the extension) # must be used for the value of the # ModuleSurfaceArea.Header.Name element # self.SetName(os.path.splitext(os.path.basename(self.FileName))[0]) self.WorkspaceDir = " " # # CombinePath and ModulePath # CombinePath = GetRelativePath(self.FullPath, self.WorkSpace) self.SetCombinePath(CombinePath) ModulePath = os.path.split(CombinePath)[0] ModuleRelativePath = ModulePath if self.GetPackagePath() != '': ModuleRelativePath = GetRelativePath(ModulePath, self.GetPackagePath()) self.SetModulePath(ModuleRelativePath) # # For Define Seciton Items. # DefineObj = ValueList # # Convert UEFI/PI version to decimal number # if DefineObj.GetUefiSpecificationVersion() != None: __UefiVersion = DefineObj.GetUefiSpecificationVersion().GetValue() __UefiVersion = ConvertVersionToDecimal(__UefiVersion) self.SetUefiSpecificationVersion(str(__UefiVersion)) if DefineObj.GetPiSpecificationVersion() != None: __PiVersion = DefineObj.GetPiSpecificationVersion().GetValue() __PiVersion = ConvertVersionToDecimal(__PiVersion) self.SetPiSpecificationVersion(str(__PiVersion)) SpecList = DefineObj.GetSpecification() NewSpecList = [] for SpecItem in SpecList: NewSpecList.append( (SpecItem[0], ConvertVersionToDecimal(SpecItem[1]))) self.SetSpecList(NewSpecList) # # must exist items in INF define section # MODULE_TYPE/BASE_NAME/INF_VERSION/FILE_GUID/VERSION_STRING # if DefineObj.GetModuleType() == None: Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("MODULE_TYPE"), File=self.FullPath) else: self.SetModuleType(DefineObj.GetModuleType().GetValue()) ModuleType = DefineObj.GetModuleType().GetValue() if ModuleType: # # Drivers and applications are not allowed to have a MODULE_TYPE of "BASE". Only # libraries are permitted to a have a MODULE_TYPE of "BASE". # if len(DefineObj.LibraryClass) == 0 and ModuleType == 'BASE': Logger.Error( "InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_MODULETYPE_INVALID, File=self.FullPath, Line=DefineObj.ModuleType.CurrentLine.LineNo, ExtraData=DefineObj.ModuleType.CurrentLine.LineString) self.LibModuleTypeList.append(ModuleType) if DefineObj.GetBaseName() == None: Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("BASE_NAME"), File=self.FullPath) else: self.SetBaseName(DefineObj.GetBaseName().GetValue()) if DefineObj.GetModuleUniFileName(): self.UniFileClassObject = UniFileClassObject( [PathClass(DefineObj.GetModuleUniFileName())]) else: self.UniFileClassObject = None if DefineObj.GetInfVersion() == None: Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("INF_VERSION"), File=self.FullPath) else: self.SetVersion(DefineObj.GetInfVersion().GetValue()) if DefineObj.GetFileGuid() == None: Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SECTION_MUST_ITEM_NOT_EXIST % ("FILE_GUID"), File=self.FullPath) else: self.SetGuid(DefineObj.GetFileGuid().GetValue()) if DefineObj.GetVersionString() == None: # # VERSION_STRING is missing from the [Defines] section, tools must assume that the module's version is 0. # self.SetVersion('0') else: # # Get version of INF # if DefineObj.GetVersionString().GetValue() != "": # # EDK2 inf # VersionString = DefineObj.GetVersionString().GetValue() if len(VersionString) > 0: VersionString = ConvertVersionToDecimal(VersionString) self.SetVersion(VersionString) else: # # EDK1 inf # Logger.Error("Parser", PARSER_ERROR, ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF, ExtraData=self.FullPath, RaiseError=Logger.IS_RAISE_ERROR) # # if there is Shadow, Should judge the MODULE_TYPE in # SEC, PEI_CORE and PEIM # if DefineObj.GetShadow(): ModuleTypeValue = DefineObj.GetModuleType().GetValue() if not (ModuleTypeValue == 'SEC' or ModuleTypeValue == 'PEI_CORE' or ModuleTypeValue == 'PEIM'): Logger.Error("InfParser", FORMAT_INVALID, ST.ERR_INF_PARSER_DEFINE_SHADOW_INVALID, File=self.FullPath) if DefineObj.GetPcdIsDriver() != None: self.SetPcdIsDriver(DefineObj.GetPcdIsDriver().GetValue()) # # LIBRARY_CLASS # self._GenModuleHeaderLibClass(DefineObj, ArchList) # # CUSTOM_MAKEFILE # self.CustomMakefile = DefineObj.GetCustomMakefile() # # Externs in Defines section # Only one define section, so just call once. # if not HasCalledFlag: self._GenModuleHeaderExterns(DefineObj) HasCalledFlag = True # # each module has only one module header # self.SetSupArchList(ArchList) # # Get Hob/BootMode/EventList information # self._GenSpecialComments() # # put all define statement into user-extension sections # DefinesDictNew = GenModuleHeaderUserExt(DefineObj, ArchString) if DefinesDictNew: UserExtension = CommonObject.UserExtensionObject() UserExtension.SetDefinesDict(DefinesDictNew) UserExtension.SetIdentifier('DefineModifiers') UserExtension.SetUserID('EDK2') self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension]) # # Get all meta-file header information # the record is list of items formated: # [LineValue, Arch, StartLine, ID, Third] # InfHeaderObj = self.Parser.InfHeader # # Put header information into POM object # if self.UniFileClassObject: Lang = DT.TAB_LANGUAGE_EN_X else: Lang = DT.TAB_LANGUAGE_EN_US if InfHeaderObj.GetAbstract(): self.SetAbstract((Lang, InfHeaderObj.GetAbstract())) if InfHeaderObj.GetDescription(): self.SetDescription((Lang, InfHeaderObj.GetDescription())) if InfHeaderObj.GetCopyright(): self.SetCopyright(('', InfHeaderObj.GetCopyright())) if InfHeaderObj.GetLicense(): self.SetLicense(('', InfHeaderObj.GetLicense())) # # Put Binary header information into POM object # InfBinaryHeaderObj = self.Parser.InfBinaryHeader if InfBinaryHeaderObj.GetAbstract(): self.SetBinaryHeaderAbstract( (Lang, InfBinaryHeaderObj.GetAbstract())) if InfBinaryHeaderObj.GetDescription(): self.SetBinaryHeaderDescription( (Lang, InfBinaryHeaderObj.GetDescription())) if InfBinaryHeaderObj.GetCopyright(): self.SetBinaryHeaderCopyright( ('', InfBinaryHeaderObj.GetCopyright())) if InfBinaryHeaderObj.GetLicense(): self.SetBinaryHeaderLicense(('', InfBinaryHeaderObj.GetLicense()))