def LoadFvInfo(self): EdkLogger.quiet("Parsing FV file ... ") EotGlobalData.gFV = MultipleFv(EotGlobalData.gFV_FILE) EotGlobalData.gFV.Dispatch(EotGlobalData.gDb) for Protocol in EotGlobalData.gProtocolList: EotGlobalData.gOP_UN_MATCHED_IN_LIBRARY_CALLING.write('%s\n' %Protocol)
def LoadFvInfo(self): EdkLogger.quiet("Parsing FV file ... ") EotGlobalData.gFV = MultipleFv(EotGlobalData.gFV_FILE) EotGlobalData.gFV.Dispatch(EotGlobalData.gDb) for Protocol in EotGlobalData.gProtocolList: EotGlobalData.gOP_UN_MATCHED_IN_LIBRARY_CALLING.write("%s\n" % Protocol)
def BuildDatabase(self, SpeciDirs=None): # Clean report table EccGlobalData.gDb.TblReport.Drop() EccGlobalData.gDb.TblReport.Create() # Build database if self.IsInit: if self.ScanMetaData: EdkLogger.quiet("Building database for Meta Data File ...") self.BuildMetaDataFileDatabase(SpeciDirs) if self.ScanSourceCode: EdkLogger.quiet("Building database for Meta Data File Done!") if SpeciDirs == None: c.CollectSourceCodeDataIntoDB(EccGlobalData.gTarget) else: for specificDir in SpeciDirs: c.CollectSourceCodeDataIntoDB( os.path.join(EccGlobalData.gTarget, specificDir)) EccGlobalData.gIdentifierTableList = GetTableList( (MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EccGlobalData.gDb) EccGlobalData.gCFileList = GetFileList(MODEL_FILE_C, EccGlobalData.gDb) EccGlobalData.gHFileList = GetFileList(MODEL_FILE_H, EccGlobalData.gDb) EccGlobalData.gUFileList = GetFileList(MODEL_FILE_UNI, EccGlobalData.gDb)
def Main(): try: EdkLogger.Initialize() CommandOptions, InputFile = Options() if CommandOptions.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(CommandOptions.LogLevel + 1) else: EdkLogger.SetLevel(CommandOptions.LogLevel) except FatalError as X: return 1 try: if CommandOptions.FileType == "Vfr": if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext( InputFile)[0] + '.iii' TrimPreprocessedVfr(InputFile, CommandOptions.OutputFile) elif CommandOptions.FileType == "Asl": if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext( InputFile)[0] + '.iii' TrimAslFile(InputFile, CommandOptions.OutputFile, CommandOptions.IncludePathFile) elif CommandOptions.FileType == "EdkSourceCode": TrimEdkSources(InputFile, CommandOptions.OutputFile) elif CommandOptions.FileType == "VfrOffsetBin": GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.DebugDir, CommandOptions.OutputFile) else: if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext( InputFile)[0] + '.iii' TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex, CommandOptions.TrimLong) except FatalError as X: import platform import traceback if CommandOptions is not None and CommandOptions.LogLevel <= EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) return 1 except: import traceback import platform EdkLogger.error( "\nTrim", CODE_ERROR, "Unknown fatal error when trimming [%s]" % InputFile, ExtraData= "\n(Please send email to [email protected] for help, attaching following call stack trace!)\n", RaiseError=False) EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) return 1 return 0
def ToCSV(self, Filename = 'Report.csv'): try: File = open(Filename, 'w+') File.write("""No, Error Code, Error Message, File, LineNo, Other Error Message\n""") RecordSet = self.Query() Index = 0 for Record in RecordSet: Index = Index + 1 ErrorID = Record[1] OtherMsg = Record[2] BelongsToTable = Record[3] BelongsToItem = Record[4] IsCorrected = Record[5] SqlCommand = '' if BelongsToTable == 'File': SqlCommand = """select 1, FullPath from %s where ID = %s """ % (BelongsToTable, BelongsToItem) else: SqlCommand = """select A.StartLine, B.FullPath from %s as A, File as B where A.ID = %s and B.ID = A.BelongsToFile """ % (BelongsToTable, BelongsToItem) NewRecord = self.Exec(SqlCommand) if NewRecord != []: File.write("""%s,%s,"%s",%s,%s,"%s"\n""" % (Index, ErrorID, EccToolError.gEccErrorMessage[ErrorID], NewRecord[0][1], NewRecord[0][0], OtherMsg)) EdkLogger.quiet("%s(%s): [%s]%s %s" % (NewRecord[0][1], NewRecord[0][0], ErrorID, EccToolError.gEccErrorMessage[ErrorID], OtherMsg)) File.close() except IOError: NewFilename = 'Report_' + time.strftime("%Y%m%d_%H%M%S.csv", time.localtime()) EdkLogger.warn("ECC", "The report file %s is locked by other progress, use %s instead!" % (Filename, NewFilename)) self.ToCSV(NewFilename)
def ToCSV(self, Filename='Report.csv'): try: File = open(Filename, 'w+') File.write("""No, Error Code, Error Message, File, LineNo, Other Error Message\n""") RecordSet = self.Query() Index = 0 for Record in RecordSet: Index = Index + 1 ErrorID = Record[1] OtherMsg = Record[2] BelongsToTable = Record[3] BelongsToItem = Record[4] IsCorrected = Record[5] SqlCommand = '' if BelongsToTable == 'File': SqlCommand = """select 1, FullPath from %s where ID = %s """ % (BelongsToTable, BelongsToItem) else: SqlCommand = """select A.StartLine, B.FullPath from %s as A, File as B where A.ID = %s and B.ID = A.BelongsToFile """ % (BelongsToTable, BelongsToItem) NewRecord = self.Exec(SqlCommand) if NewRecord != []: File.write("""%s,%s,"%s",%s,%s,"%s"\n""" % (Index, ErrorID, EccToolError.gEccErrorMessage[ErrorID], NewRecord[0][1], NewRecord[0][0], OtherMsg)) EdkLogger.quiet("%s(%s): [%s]%s %s" % (NewRecord[0][1], NewRecord[0][0], ErrorID, EccToolError.gEccErrorMessage[ErrorID], OtherMsg)) File.close() except IOError: NewFilename = 'Report_' + time.strftime("%Y%m%d_%H%M%S.csv", time.localtime()) EdkLogger.warn("ECC", "The report file %s is locked by other progress, use %s instead!" % (Filename, NewFilename)) self.ToCSV(NewFilename)
def ParseOption(self): EdkLogger.quiet("Loading ECC configuration ... done") (Options, Target) = self.EccOptionParser() if Options.Workspace: os.environ["WORKSPACE"] = Options.Workspace # Check workspace envirnoment if "WORKSPACE" not in os.environ: EdkLogger.error("ECC", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found", ExtraData="WORKSPACE") else: EccGlobalData.gWorkspace = os.path.normpath(os.getenv("WORKSPACE")) if not os.path.exists(EccGlobalData.gWorkspace): EdkLogger.error("ECC", BuildToolError.FILE_NOT_FOUND, ExtraData="WORKSPACE = %s" % EccGlobalData.gWorkspace) os.environ["WORKSPACE"] = EccGlobalData.gWorkspace # Set log level self.SetLogLevel(Options) # Set other options if Options.ConfigFile != None: self.ConfigFile = Options.ConfigFile if Options.OutputFile != None: self.OutputFile = Options.OutputFile if Options.ReportFile != None: self.ReportFile = Options.ReportFile if Options.ExceptionFile != None: self.ExceptionFile = Options.ExceptionFile if Options.Target != None: if not os.path.isdir(Options.Target): EdkLogger.error("ECC", BuildToolError.OPTION_VALUE_INVALID, ExtraData="Target [%s] does NOT exist" % Options.Target) else: EccGlobalData.gTarget = self.GetRealPathCase( os.path.normpath(Options.Target)) else: EdkLogger.warn( "Ecc", EdkLogger.ECC_ERROR, "The target source tree was not specified, using current WORKSPACE instead!" ) EccGlobalData.gTarget = os.path.normpath(os.getenv("WORKSPACE")) if Options.keepdatabase != None: self.IsInit = False if Options.metadata != None and Options.sourcecode != None: EdkLogger.error( "ECC", BuildToolError.OPTION_CONFLICT, ExtraData="-m and -s can't be specified at one time") if Options.metadata != None: self.ScanSourceCode = False if Options.sourcecode != None: self.ScanMetaData = False
def GenerateReportDatabase(self): EdkLogger.quiet("Generating the cross-reference table of GUID for Ppi/Protocol ... ") # Update Protocol/Ppi Guid SqlCommand = """select DISTINCT GuidName from Report""" RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand) for Record in RecordSet: GuidName = Record[0] GuidMacro = '' GuidMacro2 = '' GuidValue = '' # Find value for hardcode guid macro if GuidName in EotGlobalData.gGuidMacroDict: GuidMacro = EotGlobalData.gGuidMacroDict[GuidName][0] GuidValue = EotGlobalData.gGuidMacroDict[GuidName][1] SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName) EotGlobalData.gDb.TblReport.Exec(SqlCommand) continue # Find guid value defined in Dec file if GuidName in EotGlobalData.gGuidDict: GuidValue = EotGlobalData.gGuidDict[GuidName] SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName) EotGlobalData.gDb.TblReport.Exec(SqlCommand) continue # Search defined Macros for guid name SqlCommand ="""select DISTINCT Value, Modifier from Query where Name like '%s'""" % GuidName GuidMacroSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand) # Ignore NULL result if not GuidMacroSet: continue GuidMacro = GuidMacroSet[0][0].strip() if not GuidMacro: continue # Find Guid value of Guid Macro SqlCommand ="""select DISTINCT Value from Query2 where Value like '%%%s%%' and Model = %s""" % (GuidMacro, MODEL_IDENTIFIER_MACRO_DEFINE) GuidValueSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand) if GuidValueSet != []: GuidValue = GuidValueSet[0][0] GuidValue = GuidValue[GuidValue.find(GuidMacro) + len(GuidMacro) :] GuidValue = GuidValue.lower().replace('\\', '').replace('\r', '').replace('\n', '').replace('l', '').strip() GuidValue = GuidStructureStringToGuidString(GuidValue) SqlCommand = """update Report set GuidMacro = '%s', GuidValue = '%s' where GuidName = '%s'""" %(GuidMacro, GuidValue, GuidName) EotGlobalData.gDb.TblReport.Exec(SqlCommand) continue # Update Hard Coded Ppi/Protocol SqlCommand = """select DISTINCT GuidValue, ItemType from Report where ModuleID = -2 and ItemMode = 'Produced'""" RecordSet = EotGlobalData.gDb.TblReport.Exec(SqlCommand) for Record in RecordSet: if Record[1] == 'Ppi': EotGlobalData.gPpiList[Record[0].lower()] = -2 if Record[1] == 'Protocol': EotGlobalData.gProtocolList[Record[0].lower()] = -2
def GenerateSourceFileList(self, SourceFileList, IncludeFileList): EdkLogger.quiet("Generating source files list ... ") mSourceFileList = [] mInfFileList = [] mDecFileList = [] mFileList = {} mCurrentInfFile = '' mCurrentSourceFileList = [] if SourceFileList: sfl = open(SourceFileList, 'rb') for line in sfl: line = os.path.normpath( os.path.join(EotGlobalData.gWORKSPACE, line.strip())) if line[-2:].upper() == '.C' or line[-2:].upper() == '.H': if line not in mCurrentSourceFileList: mCurrentSourceFileList.append(line) mSourceFileList.append(line) EotGlobalData.gOP_SOURCE_FILES.write('%s\n' % line) if line[-4:].upper() == '.INF': if mCurrentInfFile != '': mFileList[mCurrentInfFile] = mCurrentSourceFileList mCurrentSourceFileList = [] mCurrentInfFile = os.path.normpath( os.path.join(EotGlobalData.gWORKSPACE, line)) EotGlobalData.gOP_INF.write('%s\n' % mCurrentInfFile) if mCurrentInfFile not in mFileList: mFileList[mCurrentInfFile] = mCurrentSourceFileList # Get all include files from packages if IncludeFileList: ifl = open(IncludeFileList, 'rb') for line in ifl: if not line.strip(): continue newline = os.path.normpath( os.path.join(EotGlobalData.gWORKSPACE, line.strip())) for Root, Dirs, Files in os.walk(str(newline)): for File in Files: FullPath = os.path.normpath(os.path.join(Root, File)) if FullPath not in mSourceFileList and File[-2:].upper( ) == '.H': mSourceFileList.append(FullPath) EotGlobalData.gOP_SOURCE_FILES.write('%s\n' % FullPath) if FullPath not in mDecFileList and File.upper().find( '.DEC') > -1: mDecFileList.append(FullPath) EotGlobalData.gSOURCE_FILES = mSourceFileList EotGlobalData.gOP_SOURCE_FILES.close() EotGlobalData.gINF_FILES = mFileList EotGlobalData.gOP_INF.close() EotGlobalData.gDEC_FILES = mDecFileList
def GenerateQueryTable(self): EdkLogger.quiet("Generating temp query table for analysis ... ") for Identifier in EotGlobalData.gIdentifierTableList: SqlCommand = """insert into Query (Name, Modifier, Value, Model) select Name, Modifier, Value, Model from %s where (Model = %s or Model = %s)""" \ % (Identifier[0], MODEL_IDENTIFIER_VARIABLE, MODEL_IDENTIFIER_ASSIGNMENT_EXPRESSION) EotGlobalData.gDb.TblReport.Exec(SqlCommand) SqlCommand = """insert into Query2 (Name, Modifier, Value, Model) select Name, Modifier, Value, Model from %s where Model = %s""" \ % (Identifier[0], MODEL_IDENTIFIER_MACRO_DEFINE) EotGlobalData.gDb.TblReport.Exec(SqlCommand)
def ParseOption(self): EdkLogger.quiet("Loading ECC configuration ... done") (Options, Target) = self.EccOptionParser() if Options.Workspace: os.environ["WORKSPACE"] = Options.Workspace # Check workspace envirnoment if "WORKSPACE" not in os.environ: EdkLogger.error( "ECC", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found", ExtraData="WORKSPACE" ) else: EccGlobalData.gWorkspace = os.path.normpath(os.getenv("WORKSPACE")) if not os.path.exists(EccGlobalData.gWorkspace): EdkLogger.error( "ECC", BuildToolError.FILE_NOT_FOUND, ExtraData="WORKSPACE = %s" % EccGlobalData.gWorkspace ) os.environ["WORKSPACE"] = EccGlobalData.gWorkspace # Set log level self.SetLogLevel(Options) # Set other options if Options.ConfigFile != None: self.ConfigFile = Options.ConfigFile if Options.OutputFile != None: self.OutputFile = Options.OutputFile if Options.ReportFile != None: self.ReportFile = Options.ReportFile if Options.ExceptionFile != None: self.ExceptionFile = Options.ExceptionFile if Options.Target != None: if not os.path.isdir(Options.Target): EdkLogger.error( "ECC", BuildToolError.OPTION_VALUE_INVALID, ExtraData="Target [%s] does NOT exist" % Options.Target ) else: EccGlobalData.gTarget = self.GetRealPathCase(os.path.normpath(Options.Target)) else: EdkLogger.warn( "Ecc", EdkLogger.ECC_ERROR, "The target source tree was not specified, using current WORKSPACE instead!" ) EccGlobalData.gTarget = os.path.normpath(os.getenv("WORKSPACE")) if Options.keepdatabase != None: self.IsInit = False if Options.metadata != None and Options.sourcecode != None: EdkLogger.error("ECC", BuildToolError.OPTION_CONFLICT, ExtraData="-m and -s can't be specified at one time") if Options.metadata != None: self.ScanSourceCode = False if Options.sourcecode != None: self.ScanMetaData = False if Options.folders != None: self.OnlyScan = True
def BuildDatabase(self): # Clean report table EotGlobalData.gDb.TblReport.Drop() EotGlobalData.gDb.TblReport.Create() # Build database if self.IsInit: self.BuildMetaDataFileDatabase(EotGlobalData.gINF_FILES) EdkLogger.quiet("Building database for source code ...") c.CreateCCodeDB(EotGlobalData.gSOURCE_FILES) EdkLogger.quiet("Building database for source code done!") EotGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EotGlobalData.gDb)
def BuildDatabase(self): # Clean report table EotGlobalData.gDb.TblReport.Drop() EotGlobalData.gDb.TblReport.Create() # Build database if self.IsInit: self.BuildMetaDataFileDatabase(EotGlobalData.gINF_FILES) EdkLogger.quiet("Building database for source code ...") c.CreateCCodeDB(EotGlobalData.gSOURCE_FILES) EdkLogger.quiet("Building database for source code done!") EotGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), "Identifier", EotGlobalData.gDb)
def GenerateSourceFileList(self, SourceFileList, IncludeFileList): EdkLogger.quiet("Generating source files list ... ") mSourceFileList = [] mInfFileList = [] mDecFileList = [] mFileList = {} mCurrentInfFile = "" mCurrentSourceFileList = [] if SourceFileList: sfl = open(SourceFileList, "rb") for line in sfl: line = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip())) if line[-2:].upper() == ".C" or line[-2:].upper() == ".H": if line not in mCurrentSourceFileList: mCurrentSourceFileList.append(line) mSourceFileList.append(line) EotGlobalData.gOP_SOURCE_FILES.write("%s\n" % line) if line[-4:].upper() == ".INF": if mCurrentInfFile != "": mFileList[mCurrentInfFile] = mCurrentSourceFileList mCurrentSourceFileList = [] mCurrentInfFile = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line)) EotGlobalData.gOP_INF.write("%s\n" % mCurrentInfFile) if mCurrentInfFile not in mFileList: mFileList[mCurrentInfFile] = mCurrentSourceFileList # Get all include files from packages if IncludeFileList: ifl = open(IncludeFileList, "rb") for line in ifl: if not line.strip(): continue newline = os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, line.strip())) for Root, Dirs, Files in os.walk(str(newline)): for File in Files: FullPath = os.path.normpath(os.path.join(Root, File)) if FullPath not in mSourceFileList and File[-2:].upper() == ".H": mSourceFileList.append(FullPath) EotGlobalData.gOP_SOURCE_FILES.write("%s\n" % FullPath) if FullPath not in mDecFileList and File.upper().find(".DEC") > -1: mDecFileList.append(FullPath) EotGlobalData.gSOURCE_FILES = mSourceFileList EotGlobalData.gOP_SOURCE_FILES.close() EotGlobalData.gINF_FILES = mFileList EotGlobalData.gOP_INF.close() EotGlobalData.gDEC_FILES = mDecFileList
def BuildDatabase(self): # Clean report table EccGlobalData.gDb.TblReport.Drop() EccGlobalData.gDb.TblReport.Create() # Build database if self.IsInit: if self.ScanSourceCode: EdkLogger.quiet("Building database for source code ...") c.CollectSourceCodeDataIntoDB(EccGlobalData.gTarget) if self.ScanMetaData: EdkLogger.quiet("Building database for source code done!") self.BuildMetaDataFileDatabase() EccGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EccGlobalData.gDb)
def Main(): try: EdkLogger.Initialize() CommandOptions, InputFile = Options() if CommandOptions.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(CommandOptions.LogLevel + 1) else: EdkLogger.SetLevel(CommandOptions.LogLevel) except FatalError as X: return 1 try: if CommandOptions.FileType == "Vfr": if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii' TrimPreprocessedVfr(InputFile, CommandOptions.OutputFile) elif CommandOptions.FileType == "Asl": if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii' TrimAslFile(InputFile, CommandOptions.OutputFile, CommandOptions.IncludePathFile) elif CommandOptions.FileType == "EdkSourceCode": TrimEdkSources(InputFile, CommandOptions.OutputFile) elif CommandOptions.FileType == "VfrOffsetBin": GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.DebugDir, CommandOptions.OutputFile) else : if CommandOptions.OutputFile is None: CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii' TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex, CommandOptions.TrimLong) except FatalError as X: import platform import traceback if CommandOptions is not None and CommandOptions.LogLevel <= EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) return 1 except: import traceback import platform EdkLogger.error( "\nTrim", CODE_ERROR, "Unknown fatal error when trimming [%s]" % InputFile, ExtraData="\n(Please send email to [email protected] for help, attaching following call stack trace!)\n", RaiseError=False ) EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) return 1 return 0
def BuildDatabase(self): # Clean report table EccGlobalData.gDb.TblReport.Drop() EccGlobalData.gDb.TblReport.Create() # Build database if self.IsInit: if self.ScanSourceCode: EdkLogger.quiet("Building database for source code ...") c.CollectSourceCodeDataIntoDB(EccGlobalData.gTarget) if self.ScanMetaData: EdkLogger.quiet("Building database for source code done!") self.BuildMetaDataFileDatabase() EccGlobalData.gIdentifierTableList = GetTableList( (MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EccGlobalData.gDb)
def BuildDatabase(self, SpeciDirs = None): # Clean report table EccGlobalData.gDb.TblReport.Drop() EccGlobalData.gDb.TblReport.Create() # Build database if self.IsInit: if self.ScanMetaData: EdkLogger.quiet("Building database for Meta Data File ...") self.BuildMetaDataFileDatabase(SpeciDirs) if self.ScanSourceCode: EdkLogger.quiet("Building database for Meta Data File Done!") if SpeciDirs == None: c.CollectSourceCodeDataIntoDB(EccGlobalData.gTarget) else: for specificDir in SpeciDirs: c.CollectSourceCodeDataIntoDB(os.path.join(EccGlobalData.gTarget, specificDir)) EccGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EccGlobalData.gDb) EccGlobalData.gCFileList = GetFileList(MODEL_FILE_C, EccGlobalData.gDb) EccGlobalData.gHFileList = GetFileList(MODEL_FILE_H, EccGlobalData.gDb)
def BuildMetaDataFileDatabase(self, Inf_Files): EdkLogger.quiet("Building database for meta data files ...") for InfFile in Inf_Files: EdkLogger.quiet("Parsing %s ..." % str(InfFile)) EdkInfParser(InfFile, EotGlobalData.gDb, Inf_Files[InfFile], '') EotGlobalData.gDb.Conn.commit() EdkLogger.quiet("Building database for meta data files done!")
def BuildMetaDataFileDatabase(self, Inf_Files): EdkLogger.quiet("Building database for meta data files ...") for InfFile in Inf_Files: EdkLogger.quiet("Parsing %s ..." % str(InfFile)) EdkInfParser(InfFile, EotGlobalData.gDb, Inf_Files[InfFile], "") EotGlobalData.gDb.Conn.commit() EdkLogger.quiet("Building database for meta data files done!")
def Main(): EdkLogger.Initialize() Option, Input = GetOptions() # Set log level if Option.quiet: EdkLogger.SetLevel(EdkLogger.QUIET) elif Option.verbose: EdkLogger.SetLevel(EdkLogger.VERBOSE) elif Option.debug is not None: EdkLogger.SetLevel(Option.debug + 1) else: EdkLogger.SetLevel(EdkLogger.INFO) try: if Option.ModuleType is None or Option.ModuleType not in gType2Phase: EdkLogger.error("GenDepex", OPTION_MISSING, "Module type is not specified or supported") DxsFile = '' if len(Input) > 0 and Option.Expression == "": DxsFile = Input[0] DxsString = open(DxsFile, 'r').read().replace("\n", " ").replace("\r", " ") DxsString = gStartClosePattern.sub("\\1", DxsString) elif Option.Expression != "": if Option.Expression[0] == '"': DxsString = Option.Expression[1:-1] else: DxsString = Option.Expression else: EdkLogger.error("GenDepex", OPTION_MISSING, "No expression string or file given") Dpx = DependencyExpression(DxsString, Option.ModuleType, Option.Optimize) if Option.OutputFile is not None: FileChangeFlag = Dpx.Generate(Option.OutputFile) if not FileChangeFlag and DxsFile: # # Touch the output file if its time stamp is older than the original # DXS file to avoid re-invoke this tool for the dependency check in build rule. # if os.stat(DxsFile)[8] > os.stat(Option.OutputFile)[8]: os.utime(Option.OutputFile, None) else: Dpx.Generate() except BaseException as X: EdkLogger.quiet("") if Option is not None and Option.debug is not None: EdkLogger.quiet(traceback.format_exc()) else: EdkLogger.quiet(str(X)) return 1 return 0
def Main(): EdkLogger.Initialize() Option, Input = GetOptions() # Set log level if Option.quiet: EdkLogger.SetLevel(EdkLogger.QUIET) elif Option.verbose: EdkLogger.SetLevel(EdkLogger.VERBOSE) elif Option.debug != None: EdkLogger.SetLevel(Option.debug + 1) else: EdkLogger.SetLevel(EdkLogger.INFO) try: if Option.ModuleType == None or Option.ModuleType not in gType2Phase: EdkLogger.error("GenDepex", OPTION_MISSING, "Module type is not specified or supported") DxsFile = '' if len(Input) > 0 and Option.Expression == "": DxsFile = Input[0] DxsString = open(DxsFile, 'r').read().replace("\n", " ").replace("\r", " ") DxsString = gStartClosePattern.sub("\\1", DxsString) elif Option.Expression != "": if Option.Expression[0] == '"': DxsString = Option.Expression[1:-1] else: DxsString = Option.Expression else: EdkLogger.error("GenDepex", OPTION_MISSING, "No expression string or file given") Dpx = DependencyExpression(DxsString, Option.ModuleType, Option.Optimize) if Option.OutputFile != None: Dpx.Generate(Option.OutputFile) else: Dpx.Generate() except BaseException, X: EdkLogger.quiet("") if Option != None and Option.debug != None: EdkLogger.quiet(traceback.format_exc()) else: EdkLogger.quiet(str(X)) return 1
def Main(): EdkLogger.Initialize() Options = None DistFileName = 'dist.pkg' ContentFileName = 'content.zip' DistFile, ContentZipFile, UnpackDir = None, None, None Options = MyOptionParser() try: if Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(Options.LogLevel + 1) else: EdkLogger.SetLevel(Options.LogLevel) CheckEnvVariable() WorkspaceDir = os.environ["WORKSPACE"] if not Options.PackageFile: EdkLogger.error("InstallPkg", OPTION_NOT_SUPPORTED, ExtraData="Must specify one distribution package") # unzip dist.pkg file EdkLogger.quiet("Unzipping and parsing distribution package XML file ... ") DistFile = PackageFile(Options.PackageFile) UnpackDir = os.path.normpath(os.path.join(WorkspaceDir, ".tmp")) DistPkgFile = DistFile.UnpackFile(DistFileName, os.path.normpath(os.path.join(UnpackDir, DistFileName))) if not DistPkgFile: EdkLogger.error("InstallPkg", FILE_NOT_FOUND, "File [%s] is broken in distribution package" %DistFileName) # Generate distpkg DistPkgObj = DistributionPackageXml() DistPkg = DistPkgObj.FromXml(DistPkgFile) # prepare check dependency Db = IpiDatabase(os.path.normpath(os.path.join(WorkspaceDir, "Conf/DistributionPackageDatabase.db"))) Db.InitDatabase() Dep = DependencyRules(Db) # Check distribution package exist if Dep.CheckDpExists(DistPkg.Header.Guid, DistPkg.Header.Version): EdkLogger.error("InstallPkg", UNKNOWN_ERROR, "This distribution package has been installed", ExtraData=DistPkg.Header.Name) # unzip contents.zip file ContentFile = DistFile.UnpackFile(ContentFileName, os.path.normpath(os.path.join(UnpackDir, ContentFileName))) ContentZipFile = PackageFile(ContentFile) if not ContentFile: EdkLogger.error("InstallPkg", FILE_NOT_FOUND, "File [%s] is broken in distribution package" %ContentFileName) # verify MD5 signature Md5Sigature = md5.new(open(ContentFile).read()) if DistPkg.Header.Signature != Md5Sigature.hexdigest(): EdkLogger.error("InstallPkg", FILE_CHECKSUM_FAILURE, ExtraData=ContentFile) # Check package exist and install for Guid,Version,Path in DistPkg.PackageSurfaceArea: PackagePath = os.path.dirname(Path) NewPackagePath = PackagePath Package = DistPkg.PackageSurfaceArea[Guid,Version,Path] EdkLogger.info("Installing package ... %s" % Package.PackageHeader.Name) if Dep.CheckPackageExists(Guid, Version): EdkLogger.quiet("Package [%s] has been installed" %Path) NewPackagePath = InstallNewPackage(WorkspaceDir, PackagePath) Package.FileList = [] for Item in Package.MiscFiles.Files: FromFile = os.path.join(PackagePath, Item.Filename) ToFile = os.path.normpath(os.path.join(WorkspaceDir, NewPackagePath, Item.Filename)) ContentZipFile.UnpackFile(FromFile, ToFile) Package.FileList.append(ToFile) # Update package Package.PackageHeader.CombinePath = Package.PackageHeader.CombinePath.replace(PackagePath, NewPackagePath, 1) # Update modules of package Module = None for ModuleGuid, ModuleVersion, ModulePath in Package.Modules: Module = Package.Modules[ModuleGuid, ModuleVersion, ModulePath] NewModulePath = ModulePath.replace(PackagePath, NewPackagePath, 1) del Package.Modules[ModuleGuid, ModuleVersion, ModulePath] Package.Modules[ModuleGuid, ModuleVersion, NewModulePath] = Module del DistPkg.PackageSurfaceArea[Guid,Version,Path] DistPkg.PackageSurfaceArea[Guid,Version,Package.PackageHeader.CombinePath] = Package # SaveFileOnChange(os.path.join(Options.InstallDir, ModulePath, Module.Header.Name, ".inf"), Inf.ModuleToInf(Module), False) # EdkLogger.info("Installing package ... %s" % Package.Header.Name) # shutil.copytree(os.path.join(ContentFileDir, Path), Options.InstallDir) # SaveFileOnChange(os.path.join(Options.InstallDir, Path, Package.Header.Name, ".dec"), Dec.PackageToDec(Package), False) # Check module exist and install Module = None for Guid,Version,Path in DistPkg.ModuleSurfaceArea: ModulePath = os.path.dirname(Path) NewModulePath = ModulePath Module = DistPkg.ModuleSurfaceArea[Guid,Version,Path] EdkLogger.info("Installing module ... %s" % Module.ModuleHeader.Name) if Dep.CheckModuleExists(Guid, Version): EdkLogger.quiet("Module [%s] has been installed" %Path) NewModulePath = InstallNewPackage(WorkspaceDir, ModulePath) Module.FileList = [] for Item in Module.MiscFiles.Files: ModulePath = ModulePath[os.path.normpath(ModulePath).rfind(os.path.normpath('/'))+1:] FromFile = os.path.join(ModulePath, Item.Filename) ToFile = os.path.normpath(os.path.join(WorkspaceDir, NewModulePath, Item.Filename)) ContentZipFile.UnpackFile(FromFile, ToFile) Module.FileList.append(ToFile) # EdkLogger.info("Installing module ... %s" % Module.Header.Name) # shutil.copytree(os.path.join(ContentFileDir, Path), Options.InstallDir) # SaveFileOnChange(os.path.join(Options.InstallDir, Path, Module.Header.Name, ".inf"), Inf.ModuleToInf(Module), False) # Update module Module.ModuleHeader.CombinePath = Module.ModuleHeader.CombinePath.replace(os.path.dirname(Path), NewModulePath, 1) del DistPkg.ModuleSurfaceArea[Guid,Version,Path] DistPkg.ModuleSurfaceArea[Guid,Version,Module.ModuleHeader.CombinePath] = Module # # # for Guid,Version,Path in DistPkg.PackageSurfaceArea: # print Guid,Version,Path # for item in DistPkg.PackageSurfaceArea[Guid,Version,Path].FileList: # print item # for Guid,Version,Path in DistPkg.ModuleSurfaceArea: # print Guid,Version,Path # for item in DistPkg.ModuleSurfaceArea[Guid,Version,Path].FileList: # print item if Options.Tools: EdkLogger.info("Installing tools ... ") for File in DistPkg.Tools.Files: FromFile = File.Filename ToFile = InstallNewFile(WorkspaceDir, FromFile) ContentZipFile.UnpackFile(FromFile, ToFile) if Options.MiscFiles: EdkLogger.info("Installing misc files ... ") for File in DistPkg.MiscellaneousFiles.Files: FromFile = File.Filename ToFile = InstallNewFile(WorkspaceDir, FromFile) ContentZipFile.UnpackFile(FromFile, ToFile) # update database EdkLogger.quiet("Update Distribution Package Database ...") Db.AddDPObject(DistPkg) except FatalError, X: if Options and Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) ReturnCode = X.args[0]
def __init__( self, CommandLineOption=True, IsInit=True, SourceFileList=None, IncludeDirList=None, DecFileList=None, GuidList=None, LogFile=None, FvFileList="", MapFileList="", Report="Report.html", Dispatch=None, ): # Version and Copyright self.VersionNumber = "0.02" + " " + gBUILD_VERSION self.Version = "%prog Version " + self.VersionNumber self.Copyright = "Copyright (c) 2008 - 2010, Intel Corporation All rights reserved." self.Report = Report self.IsInit = IsInit self.SourceFileList = SourceFileList self.IncludeDirList = IncludeDirList self.DecFileList = DecFileList self.GuidList = GuidList self.LogFile = LogFile self.FvFileList = FvFileList self.MapFileList = MapFileList self.Dispatch = Dispatch # Check workspace environment if "EFI_SOURCE" not in os.environ: if "EDK_SOURCE" not in os.environ: pass else: EotGlobalData.gEDK_SOURCE = os.path.normpath(os.getenv("EDK_SOURCE")) else: EotGlobalData.gEFI_SOURCE = os.path.normpath(os.getenv("EFI_SOURCE")) EotGlobalData.gEDK_SOURCE = os.path.join(EotGlobalData.gEFI_SOURCE, "Edk") if "WORKSPACE" not in os.environ: EdkLogger.error( "EOT", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found", ExtraData="WORKSPACE" ) else: EotGlobalData.gWORKSPACE = os.path.normpath(os.getenv("WORKSPACE")) EotGlobalData.gMACRO["WORKSPACE"] = EotGlobalData.gWORKSPACE EotGlobalData.gMACRO["EFI_SOURCE"] = EotGlobalData.gEFI_SOURCE EotGlobalData.gMACRO["EDK_SOURCE"] = EotGlobalData.gEDK_SOURCE # Parse the options and args if CommandLineOption: self.ParseOption() if self.FvFileList: for FvFile in GetSplitValueList(self.FvFileList, " "): FvFile = os.path.normpath(FvFile) if not os.path.isfile(FvFile): EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % FvFile) EotGlobalData.gFV_FILE.append(FvFile) else: EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "The fv file list of target platform was not specified") if self.MapFileList: for MapFile in GetSplitValueList(self.MapFileList, " "): MapFile = os.path.normpath(MapFile) if not os.path.isfile(MapFile): EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % MapFile) EotGlobalData.gMAP_FILE.append(MapFile) # Generate source file list self.GenerateSourceFileList(self.SourceFileList, self.IncludeDirList) # Generate guid list of dec file list self.ParseDecFile(self.DecFileList) # Generate guid list from GUID list file self.ParseGuidList(self.GuidList) # Init Eot database EotGlobalData.gDb = Database.Database(Database.DATABASE_PATH) EotGlobalData.gDb.InitDatabase(self.IsInit) # Build ECC database self.BuildDatabase() # Parse Ppi/Protocol self.ParseExecutionOrder() # Merge Identifier tables self.GenerateQueryTable() # Generate report database self.GenerateReportDatabase() # Load Fv Info self.LoadFvInfo() # Load Map Info self.LoadMapInfo() # Generate Report self.GenerateReport() # Convert log file self.ConvertLogFile(self.LogFile) # DONE EdkLogger.quiet("EOT FINISHED!") # Close Database EotGlobalData.gDb.Close()
def BuildMetaDataFileDatabase(self, SpecificDirs = None): ScanFolders = [] if SpecificDirs is None: ScanFolders.append(EccGlobalData.gTarget) else: for specificDir in SpecificDirs: ScanFolders.append(os.path.join(EccGlobalData.gTarget, specificDir)) EdkLogger.quiet("Building database for meta data files ...") Op = open(EccGlobalData.gConfig.MetaDataFileCheckPathOfGenerateFileList, 'w+') #SkipDirs = Read from config file SkipDirs = EccGlobalData.gConfig.SkipDirList SkipDirString = '|'.join(SkipDirs) # p = re.compile(r'.*[\\/](?:%s)[\\/]?.*' % SkipDirString) p = re.compile(r'.*[\\/](?:%s^\S)[\\/]?.*' % SkipDirString) for scanFolder in ScanFolders: for Root, Dirs, Files in os.walk(scanFolder): if p.match(Root.upper()): continue for Dir in Dirs: Dirname = os.path.join(Root, Dir) if os.path.islink(Dirname): Dirname = os.path.realpath(Dirname) if os.path.isdir(Dirname): # symlinks to directories are treated as directories Dirs.remove(Dir) Dirs.append(Dirname) for File in Files: if len(File) > 4 and File[-4:].upper() == ".DEC": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) #Dec(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) self.MetaFile = DecParser(Filename, MODEL_FILE_DEC, EccGlobalData.gDb.TblDec) self.MetaFile.Start() continue if len(File) > 4 and File[-4:].upper() == ".DSC": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) #Dsc(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) self.MetaFile = DscParser(PathClass(Filename, Root), MODEL_FILE_DSC, MetaFileStorage(EccGlobalData.gDb.TblDsc.Cur, Filename, MODEL_FILE_DSC, True)) # always do post-process, in case of macros change self.MetaFile.DoPostProcess() self.MetaFile.Start() self.MetaFile._PostProcess() continue if len(File) > 4 and File[-4:].upper() == ".INF": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) #Inf(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) self.MetaFile = InfParser(Filename, MODEL_FILE_INF, EccGlobalData.gDb.TblInf) self.MetaFile.Start() continue if len(File) > 4 and File[-4:].upper() == ".FDF": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) Fdf(Filename, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) continue if len(File) > 4 and File[-4:].upper() == ".UNI": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) FileID = EccGlobalData.gDb.TblFile.InsertFile(Filename, MODEL_FILE_UNI) EccGlobalData.gDb.TblReport.UpdateBelongsToItemByFile(FileID, File) continue Op.close() # Commit to database EccGlobalData.gDb.Conn.commit() EdkLogger.quiet("Building database for meta data files done!")
def GenFdsApi(FdsCommandDict, WorkSpaceDataBase=None): global Workspace Workspace = "" ArchList = None ReturnCode = 0 try: if FdsCommandDict.get("verbose"): EdkLogger.SetLevel(EdkLogger.VERBOSE) GenFdsGlobalVariable.VerboseMode = True if FdsCommandDict.get("FixedAddress"): GenFdsGlobalVariable.FixedLoadAddress = True if FdsCommandDict.get("quiet"): EdkLogger.SetLevel(EdkLogger.QUIET) if FdsCommandDict.get("debug"): EdkLogger.SetLevel(FdsCommandDict.get("debug") + 1) GenFdsGlobalVariable.DebugLevel = FdsCommandDict.get("debug") else: EdkLogger.SetLevel(EdkLogger.INFO) if not FdsCommandDict.get("Workspace",os.environ.get('WORKSPACE')): EdkLogger.error("GenFds", OPTION_MISSING, "WORKSPACE not defined", ExtraData="Please use '-w' switch to pass it or set the WORKSPACE environment variable.") elif not os.path.exists(FdsCommandDict.get("Workspace",os.environ.get('WORKSPACE'))): EdkLogger.error("GenFds", PARAMETER_INVALID, "WORKSPACE is invalid", ExtraData="Please use '-w' switch to pass it or set the WORKSPACE environment variable.") else: Workspace = os.path.normcase(FdsCommandDict.get("Workspace",os.environ.get('WORKSPACE'))) GenFdsGlobalVariable.WorkSpaceDir = Workspace if 'EDK_SOURCE' in os.environ: GenFdsGlobalVariable.EdkSourceDir = os.path.normcase(os.environ['EDK_SOURCE']) if FdsCommandDict.get("debug"): GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace) if FdsCommandDict.get("GenfdsMultiThread"): GenFdsGlobalVariable.EnableGenfdsMultiThread = True os.chdir(GenFdsGlobalVariable.WorkSpaceDir) # set multiple workspace PackagesPath = os.getenv("PACKAGES_PATH") mws.setWs(GenFdsGlobalVariable.WorkSpaceDir, PackagesPath) if FdsCommandDict.get("fdf_file"): FdfFilename = FdsCommandDict.get("fdf_file")[0].Path FdfFilename = GenFdsGlobalVariable.ReplaceWorkspaceMacro(FdfFilename) if FdfFilename[0:2] == '..': FdfFilename = os.path.realpath(FdfFilename) if not os.path.isabs(FdfFilename): FdfFilename = mws.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename) if not os.path.exists(FdfFilename): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=FdfFilename) GenFdsGlobalVariable.FdfFile = FdfFilename GenFdsGlobalVariable.FdfFileTimeStamp = os.path.getmtime(FdfFilename) else: EdkLogger.error("GenFds", OPTION_MISSING, "Missing FDF filename") if FdsCommandDict.get("build_target"): GenFdsGlobalVariable.TargetName = FdsCommandDict.get("build_target") if FdsCommandDict.get("toolchain_tag"): GenFdsGlobalVariable.ToolChainTag = FdsCommandDict.get("toolchain_tag") if FdsCommandDict.get("active_platform"): ActivePlatform = FdsCommandDict.get("active_platform") ActivePlatform = GenFdsGlobalVariable.ReplaceWorkspaceMacro(ActivePlatform) if ActivePlatform[0:2] == '..': ActivePlatform = os.path.realpath(ActivePlatform) if not os.path.isabs (ActivePlatform): ActivePlatform = mws.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform) if not os.path.exists(ActivePlatform): EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!") else: EdkLogger.error("GenFds", OPTION_MISSING, "Missing active platform") GlobalData.BuildOptionPcd = FdsCommandDict.get("OptionPcd") if FdsCommandDict.get("OptionPcd") else {} GenFdsGlobalVariable.ActivePlatform = PathClass(NormPath(ActivePlatform)) if FdsCommandDict.get("conf_directory"): # Get alternate Conf location, if it is absolute, then just use the absolute directory name ConfDirectoryPath = os.path.normpath(FdsCommandDict.get("conf_directory")) if ConfDirectoryPath.startswith('"'): ConfDirectoryPath = ConfDirectoryPath[1:] if ConfDirectoryPath.endswith('"'): ConfDirectoryPath = ConfDirectoryPath[:-1] if not os.path.isabs(ConfDirectoryPath): # Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf ConfDirectoryPath = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath) else: if "CONF_PATH" in os.environ: ConfDirectoryPath = os.path.normcase(os.environ["CONF_PATH"]) else: # Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf ConfDirectoryPath = mws.join(GenFdsGlobalVariable.WorkSpaceDir, 'Conf') GenFdsGlobalVariable.ConfDir = ConfDirectoryPath if not GlobalData.gConfDirectory: GlobalData.gConfDirectory = GenFdsGlobalVariable.ConfDir BuildConfigurationFile = os.path.normpath(os.path.join(ConfDirectoryPath, "target.txt")) if os.path.isfile(BuildConfigurationFile) == True: TargetTxt = TargetTxtClassObject() TargetTxt.LoadTargetTxtFile(BuildConfigurationFile) # if no build target given in command line, get it from target.txt if not GenFdsGlobalVariable.TargetName: BuildTargetList = TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_TARGET] if len(BuildTargetList) != 1: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, ExtraData="Only allows one instance for Target.") GenFdsGlobalVariable.TargetName = BuildTargetList[0] # if no tool chain given in command line, get it from target.txt if not GenFdsGlobalVariable.ToolChainTag: ToolChainList = TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_TOOL_CHAIN_TAG] if ToolChainList is None or len(ToolChainList) == 0: EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE, ExtraData="No toolchain given. Don't know how to build.") if len(ToolChainList) != 1: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, ExtraData="Only allows one instance for ToolChain.") GenFdsGlobalVariable.ToolChainTag = ToolChainList[0] else: EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=BuildConfigurationFile) #Set global flag for build mode GlobalData.gIgnoreSource = FdsCommandDict.get("IgnoreSources") if FdsCommandDict.get("macro"): for Pair in FdsCommandDict.get("macro"): if Pair.startswith('"'): Pair = Pair[1:] if Pair.endswith('"'): Pair = Pair[:-1] List = Pair.split('=') if len(List) == 2: if not List[1].strip(): EdkLogger.error("GenFds", OPTION_VALUE_INVALID, ExtraData="No Value given for Macro %s" %List[0]) if List[0].strip() == "EFI_SOURCE": GlobalData.gEfiSource = List[1].strip() GlobalData.gGlobalDefines["EFI_SOURCE"] = GlobalData.gEfiSource continue elif List[0].strip() == "EDK_SOURCE": GlobalData.gEdkSource = List[1].strip() GlobalData.gGlobalDefines["EDK_SOURCE"] = GlobalData.gEdkSource continue elif List[0].strip() in ["WORKSPACE", "TARGET", "TOOLCHAIN"]: GlobalData.gGlobalDefines[List[0].strip()] = List[1].strip() else: GlobalData.gCommandLineDefines[List[0].strip()] = List[1].strip() else: GlobalData.gCommandLineDefines[List[0].strip()] = "TRUE" os.environ["WORKSPACE"] = Workspace # Use the -t and -b option as gGlobalDefines's TOOLCHAIN and TARGET if they are not defined if "TARGET" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines["TARGET"] = GenFdsGlobalVariable.TargetName if "TOOLCHAIN" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines["TOOLCHAIN"] = GenFdsGlobalVariable.ToolChainTag if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines['TOOL_CHAIN_TAG'] = GenFdsGlobalVariable.ToolChainTag """call Workspace build create database""" GlobalData.gDatabasePath = os.path.normpath(os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath)) if WorkSpaceDataBase: BuildWorkSpace = WorkSpaceDataBase else: BuildWorkSpace = WorkspaceDatabase() # # Get files real name in workspace dir # GlobalData.gAllFiles = DirCache(Workspace) GlobalData.gWorkspace = Workspace if FdsCommandDict.get("build_architecture_list"): ArchList = FdsCommandDict.get("build_architecture_list").split(',') else: ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, FdsCommandDict.get("build_target"), FdsCommandDict.get("toolchain_tag")].SupArchList TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, FdsCommandDict.get("build_target"), FdsCommandDict.get("toolchain_tag")].SupArchList) & set(ArchList) if len(TargetArchList) == 0: EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, TAB_COMMON].SupArchList))) for Arch in ArchList: GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, FdsCommandDict.get("build_target"), FdsCommandDict.get("toolchain_tag")].OutputDirectory) # assign platform name based on last entry in ArchList GenFdsGlobalVariable.PlatformName = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, ArchList[-1], FdsCommandDict.get("build_target"), FdsCommandDict.get("toolchain_tag")].PlatformName if FdsCommandDict.get("platform_build_directory"): OutputDirFromCommandLine = GenFdsGlobalVariable.ReplaceWorkspaceMacro(FdsCommandDict.get("platform_build_directory")) if not os.path.isabs (OutputDirFromCommandLine): OutputDirFromCommandLine = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, OutputDirFromCommandLine) for Arch in ArchList: GenFdsGlobalVariable.OutputDirDict[Arch] = OutputDirFromCommandLine else: for Arch in ArchList: GenFdsGlobalVariable.OutputDirDict[Arch] = os.path.join(GenFdsGlobalVariable.OutputDirFromDscDict[Arch], GenFdsGlobalVariable.TargetName + '_' + GenFdsGlobalVariable.ToolChainTag) for Key in GenFdsGlobalVariable.OutputDirDict: OutputDir = GenFdsGlobalVariable.OutputDirDict[Key] if OutputDir[0:2] == '..': OutputDir = os.path.realpath(OutputDir) if OutputDir[1] != ':': OutputDir = os.path.join (GenFdsGlobalVariable.WorkSpaceDir, OutputDir) if not os.path.exists(OutputDir): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=OutputDir) GenFdsGlobalVariable.OutputDirDict[Key] = OutputDir """ Parse Fdf file, has to place after build Workspace as FDF may contain macros from DSC file """ if WorkSpaceDataBase: FdfParserObj = GlobalData.gFdfParser else: FdfParserObj = FdfParser(FdfFilename) FdfParserObj.ParseFile() if FdfParserObj.CycleReferenceCheck(): EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file") if FdsCommandDict.get("fd"): if FdsCommandDict.get("fd")[0].upper() in FdfParserObj.Profile.FdDict: GenFds.OnlyGenerateThisFd = FdsCommandDict.get("fd")[0] else: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, "No such an FD in FDF file: %s" % FdsCommandDict.get("fd")[0]) if FdsCommandDict.get("fv"): if FdsCommandDict.get("fv")[0].upper() in FdfParserObj.Profile.FvDict: GenFds.OnlyGenerateThisFv = FdsCommandDict.get("fv")[0] else: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, "No such an FV in FDF file: %s" % FdsCommandDict.get("fv")[0]) if FdsCommandDict.get("cap"): if FdsCommandDict.get("cap")[0].upper() in FdfParserObj.Profile.CapsuleDict: GenFds.OnlyGenerateThisCap = FdsCommandDict.get("cap")[0] else: EdkLogger.error("GenFds", OPTION_VALUE_INVALID, "No such a Capsule in FDF file: %s" % FdsCommandDict.get("cap")[0]) GenFdsGlobalVariable.WorkSpace = BuildWorkSpace if ArchList: GenFdsGlobalVariable.ArchList = ArchList # Dsc Build Data will handle Pcd Settings from CommandLine. """Modify images from build output if the feature of loading driver at fixed address is on.""" if GenFdsGlobalVariable.FixedLoadAddress: GenFds.PreprocessImage(BuildWorkSpace, GenFdsGlobalVariable.ActivePlatform) # Record the FV Region info that may specific in the FD if FdfParserObj.Profile.FvDict and FdfParserObj.Profile.FdDict: for FvObj in FdfParserObj.Profile.FvDict.values(): for FdObj in FdfParserObj.Profile.FdDict.values(): for RegionObj in FdObj.RegionList: if RegionObj.RegionType != BINARY_FILE_TYPE_FV: continue for RegionData in RegionObj.RegionDataList: if FvObj.UiFvName.upper() == RegionData.upper(): if FvObj.FvRegionInFD: if FvObj.FvRegionInFD != RegionObj.Size: EdkLogger.error("GenFds", FORMAT_INVALID, "The FV %s's region is specified in multiple FD with different value." %FvObj.UiFvName) else: FvObj.FvRegionInFD = RegionObj.Size RegionObj.BlockInfoOfRegion(FdObj.BlockSizeList, FvObj) """Call GenFds""" GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) """Generate GUID cross reference file""" GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList, FdfParserObj) """Display FV space info.""" GenFds.DisplayFvSpaceInfo(FdfParserObj) except Warning as X: EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError=False) ReturnCode = FORMAT_INVALID except FatalError as X: if FdsCommandDict.get("debug") is not None: import traceback EdkLogger.quiet(traceback.format_exc()) ReturnCode = X.args[0] except: import traceback EdkLogger.error( "\nPython", CODE_ERROR, "Tools code failure", ExtraData="Please send email to [email protected] for help, attaching following call stack trace!\n", RaiseError=False ) EdkLogger.quiet(traceback.format_exc()) ReturnCode = CODE_ERROR finally: ClearDuplicatedInf() return ReturnCode
"""Call GenFds""" GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) """Generate GUID cross reference file""" GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList) """Display FV space info.""" GenFds.DisplayFvSpaceInfo(FdfParserObj) except FdfParser.Warning, X: EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError = False) ReturnCode = FORMAT_INVALID except FatalError, X: if Options.debug != None: import traceback EdkLogger.quiet(traceback.format_exc()) ReturnCode = X.args[0] except: import traceback EdkLogger.error( "\nPython", CODE_ERROR, "Tools code failure", ExtraData="Please send email to [email protected] for help, attaching following call stack trace!\n", RaiseError=False ) EdkLogger.quiet(traceback.format_exc()) ReturnCode = CODE_ERROR return ReturnCode gParamCheck = []
def GenReport(self): EdkLogger.quiet("Generating report ...") EccGlobalData.gDb.TblReport.ToCSV(self.ReportFile) EdkLogger.quiet("Generating report done!")
def BuildMetaDataFileDatabase(self, SpecificDirs = None): ScanFolders = [] if SpecificDirs == None: ScanFolders.append(EccGlobalData.gTarget) else: for specificDir in SpecificDirs: ScanFolders.append(os.path.join(EccGlobalData.gTarget, specificDir)) EdkLogger.quiet("Building database for meta data files ...") Op = open(EccGlobalData.gConfig.MetaDataFileCheckPathOfGenerateFileList, 'w+') #SkipDirs = Read from config file SkipDirs = EccGlobalData.gConfig.SkipDirList SkipDirString = string.join(SkipDirs, '|') # p = re.compile(r'.*[\\/](?:%s)[\\/]?.*' % SkipDirString) p = re.compile(r'.*[\\/](?:%s^\S)[\\/]?.*' % SkipDirString) for scanFolder in ScanFolders: for Root, Dirs, Files in os.walk(scanFolder): if p.match(Root.upper()): continue for Dir in Dirs: Dirname = os.path.join(Root, Dir) if os.path.islink(Dirname): Dirname = os.path.realpath(Dirname) if os.path.isdir(Dirname): # symlinks to directories are treated as directories Dirs.remove(Dir) Dirs.append(Dirname) for File in Files: if len(File) > 4 and File[-4:].upper() == ".DEC": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) #Dec(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) self.MetaFile = DecParser(Filename, MODEL_FILE_DEC, EccGlobalData.gDb.TblDec) self.MetaFile.Start() continue if len(File) > 4 and File[-4:].upper() == ".DSC": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) #Dsc(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) self.MetaFile = DscParser(PathClass(Filename, Root), MODEL_FILE_DSC, MetaFileStorage(EccGlobalData.gDb.TblDsc.Cur, Filename, MODEL_FILE_DSC, True)) # alwasy do post-process, in case of macros change self.MetaFile.DoPostProcess() self.MetaFile.Start() self.MetaFile._PostProcess() continue if len(File) > 4 and File[-4:].upper() == ".INF": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) #Inf(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) self.MetaFile = InfParser(Filename, MODEL_FILE_INF, EccGlobalData.gDb.TblInf) self.MetaFile.Start() continue if len(File) > 4 and File[-4:].upper() == ".FDF": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) Fdf(Filename, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) continue if len(File) > 4 and File[-4:].upper() == ".UNI": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) EccGlobalData.gDb.TblFile.InsertFile(Filename, MODEL_FILE_UNI) continue Op.close() # Commit to database EccGlobalData.gDb.Conn.commit() EdkLogger.quiet("Building database for meta data files done!")
def LoadMapInfo(self): if EotGlobalData.gMAP_FILE != []: EdkLogger.quiet("Parsing Map file ... ") EotGlobalData.gMap = ParseMapFile(EotGlobalData.gMAP_FILE)
def Main(): EdkLogger.Initialize() Options = MyOptionParser() try: if not Options.PackageGuid and not Options.PackageVersion: EdkLogger.error("RmPkg", OPTION_MISSING, ExtraData="The GUID and Version of distribution package must be specified") if Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(Options.LogLevel + 1) else: EdkLogger.SetLevel(Options.LogLevel) CheckEnvVariable() WorkspaceDir = os.environ["WORKSPACE"] # Prepare check dependency Db = IpiDatabase(os.path.normpath(os.path.join(WorkspaceDir, "Conf/DistributionPackageDatabase.db"))) Db.InitDatabase() Dep = DependencyRules(Db) Guid = Options.PackageGuid Version = Options.PackageVersion # Check Dp existing if not Dep.CheckDpExists(Guid, Version): EdkLogger.error("RmPkg", UNKNOWN_ERROR, "This distribution package are not installed!") # Check Dp depex if not Dep.CheckDpDepexForRemove(Guid, Version): print "Some packages/modules are depending on this distribution package, do you really want to remove it?" print "Press Y to delete all files or press other keys to quit:" Input = Input = sys.stdin.readline() Input = Input.replace('\r', '').replace('\n', '') if Input.upper() != 'Y': EdkLogger.error("RmPkg", UNKNOWN_ERROR, "User interrupt") # Remove all files if not Options.Yes: print "All files of the distribution package will be removed, do you want to continue?" print "Press Y to remove all files or press other keys to quit:" Input = Input = sys.stdin.readline() Input = Input.replace('\r', '').replace('\n', '') if Input.upper() != 'Y': EdkLogger.error("RmPkg", UNKNOWN_ERROR, "User interrupt") # Remove all files MissingFileList = [] for Item in Db.GetDpFileList(Guid, Version): if os.path.isfile(Item): print "Removing file [%s] ..." % Item os.remove(Item) else: MissingFileList.append(Item) # Remove all empty dirs of package for Item in Db.GetPackageListFromDp(Guid, Version): Dir = os.path.dirname(Item[2]) RemoveEmptyDirs(Dir) # Remove all empty dirs of module for Item in Db.GetStandaloneModuleInstallPathListFromDp(Guid, Version): Dir = os.path.dirname(Item) RemoveEmptyDirs(Dir) # update database EdkLogger.quiet("Update Distribution Package Database ...") Db.RemoveDpObj(Guid, Version) EdkLogger.quiet("DONE") except FatalError, X: if Options and Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) ReturnCode = X.args[0]
FromFile = File.Filename ToFile = InstallNewFile(WorkspaceDir, FromFile) ContentZipFile.UnpackFile(FromFile, ToFile) # update database EdkLogger.quiet("Update Distribution Package Database ...") Db.AddDPObject(DistPkg) except FatalError, X: if Options and Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) ReturnCode = X.args[0] except KeyboardInterrupt: ReturnCode = ABORT_ERROR if Options and Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) except: EdkLogger.error( "\nInstallPkg", CODE_ERROR, "Unknown fatal error when installing [%s]" % Options.PackageFile, ExtraData="\n(Please send email to [email protected] for help, attaching following call stack trace!)\n", RaiseError=False ) EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) ReturnCode = CODE_ERROR finally: EdkLogger.quiet("Removing temp files ... ") if DistFile: DistFile.Close() if ContentZipFile:
def Main(): EdkLogger.Initialize() Options = MyOptionParser() try: if Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(Options.LogLevel + 1) else: EdkLogger.SetLevel(Options.LogLevel) CheckEnvVariable() WorkspaceDir = os.environ["WORKSPACE"] # Init DistributionFile if not Options.DistributionFile: Options.DistributionFile = "DistributionPackage.zip" # Check Tools Dir if Options.ToolsDir: if not os.path.isdir(os.path.normpath(os.path.join(WorkspaceDir, Options.ToolsDir))): EdkLogger.error( "\nMkPkg", FILE_NOT_FOUND, "Tools directory [%s] not found" % Options.ToolsDir ) # Check misc files if Options.MiscFiles: for Item in Options.MiscFiles: FullPath = os.path.normpath(os.path.join(WorkspaceDir, Item)) if not os.path.isfile(FullPath): EdkLogger.error( "\nMkPkg", FILE_NOT_FOUND, "Misc file [%s] not found" % Item ) #Check package file existing and valid if Options.PackageFileList: for Item in Options.PackageFileList: (Name, Ext) = os.path.splitext(Item) if Ext.upper() != '.DEC': EdkLogger.error( "\nMkPkg", OPTION_VALUE_INVALID, "[%s] is not a valid package name" % Item ) Path = os.path.normpath(os.path.join(WorkspaceDir, Item)) if not os.path.exists(Path): EdkLogger.error( "\nMkPkg", FILE_NOT_FOUND, "[%s] not found" % Item ) #Check module file existing and valid if Options.ModuleFileList: for Item in Options.ModuleFileList: (Name, Ext) = os.path.splitext(Item) if Ext.upper() != '.INF': EdkLogger.error( "\nMkPkg", OPTION_VALUE_INVALID, "[%s] is not a valid module name" % Item ) Path = os.path.normpath(os.path.join(WorkspaceDir, Item)) if not os.path.exists(Path): EdkLogger.error( "\nMkPkg", FILE_NOT_FOUND, "[%s] not found" % Item ) ContentFile = PackageFile("content.zip", "w") DistPkg = DistributionPackageClass() DistPkg.GetDistributionPackage(WorkspaceDir, Options.PackageFileList, Options.ModuleFileList) DistPkgXml = DistributionPackageXml() for Item in DistPkg.PackageSurfaceArea: ContentFile.Pack(os.path.dirname(os.path.normpath(os.path.join(WorkspaceDir,Item[2])))) for Item in DistPkg.ModuleSurfaceArea: ContentFile.Pack(os.path.dirname(os.path.normpath(os.path.join(WorkspaceDir,Item[2])))) # Add tools files and information if Options.ToolsDir: ToolsFiles = MiscFileClass() ToolsRoot = os.path.normpath(os.path.join(WorkspaceDir, Options.ToolsDir)) ContentFile.Pack(ToolsRoot) ToolsFileList = GetFiles(ToolsRoot, ['CVS', '.svn']) for Item in ToolsFileList: OriPath = Item[len(WorkspaceDir)+1:] FileObj = FileClass() FileObj.Filename = OriPath (Name, Ext) = os.path.splitext(OriPath) if Ext.upper() in ['EXE', 'COM', 'EFI']: FileObj.Executable = 'True' ToolsFiles.Files.append(FileObj) DistPkg.Tools = ToolsFiles # Add misc files and information if Options.MiscFiles: MiscFiles = MiscFileClass() for Item in Options.MiscFiles: ContentFile.PackFile(Item) FileObj = FileClass() FileObj.Filename = Item (Name, Ext) = os.path.splitext(Item) if Ext.upper() in ['EXE', 'COM', 'EFI']: FileObj.Executable = 'True' MiscFiles.Files.append(FileObj) DistPkg.MiscellaneousFiles = MiscFiles print "Compressing Distribution Package File ..." ContentFile.Close() # Add temp distribution header if Options.TemplateFile: TempXML = DistributionPackageXml() DistPkg.Header = TempXML.FromXml(Options.TemplateFile).Header # Add init dp information else: DistPkg.Header.Name = 'Distribution Package' DistPkg.Header.Guid = str(uuid.uuid4()) DistPkg.Header.Version = '1.0' # Add Md5Sigature Md5Sigature = md5.new(open(str(ContentFile)).read()) DistPkg.Header.Signature = Md5Sigature.hexdigest() # Add current Date DistPkg.Header.Date = str(time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime())) # Finish final dp file DistPkgFile = PackageFile(Options.DistributionFile, "w") DistPkgFile.PackFile(str(ContentFile)) DistPkgFile.PackData(DistPkgXml.ToXml(DistPkg), "dist.pkg") DistPkgFile.Close() print "DONE" except FatalError, X: if Options and Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) ReturnCode = X.args[0]
def main(): global Options Options = myOptionParser() global Workspace Workspace = "" ArchList = None ReturnCode = 0 EdkLogger.Initialize() try: if Options.verbose is not None: EdkLogger.SetLevel(EdkLogger.VERBOSE) GenFdsGlobalVariable.VerboseMode = True if Options.FixedAddress is not None: GenFdsGlobalVariable.FixedLoadAddress = True if Options.quiet is not None: EdkLogger.SetLevel(EdkLogger.QUIET) if Options.debug is not None: EdkLogger.SetLevel(Options.debug + 1) GenFdsGlobalVariable.DebugLevel = Options.debug else: EdkLogger.SetLevel(EdkLogger.INFO) if (Options.Workspace is None): EdkLogger.error( "GenFds", OPTION_MISSING, "WORKSPACE not defined", ExtraData= "Please use '-w' switch to pass it or set the WORKSPACE environment variable." ) elif not os.path.exists(Options.Workspace): EdkLogger.error( "GenFds", PARAMETER_INVALID, "WORKSPACE is invalid", ExtraData= "Please use '-w' switch to pass it or set the WORKSPACE environment variable." ) else: Workspace = os.path.normcase(Options.Workspace) GenFdsGlobalVariable.WorkSpaceDir = Workspace if 'EDK_SOURCE' in os.environ: GenFdsGlobalVariable.EdkSourceDir = os.path.normcase( os.environ['EDK_SOURCE']) if (Options.debug): GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Workspace) if Options.GenfdsMultiThread: GenFdsGlobalVariable.EnableGenfdsMultiThread = True os.chdir(GenFdsGlobalVariable.WorkSpaceDir) # set multiple workspace PackagesPath = os.getenv("PACKAGES_PATH") mws.setWs(GenFdsGlobalVariable.WorkSpaceDir, PackagesPath) if (Options.filename): FdfFilename = Options.filename FdfFilename = GenFdsGlobalVariable.ReplaceWorkspaceMacro( FdfFilename) if FdfFilename[0:2] == '..': FdfFilename = os.path.realpath(FdfFilename) if not os.path.isabs(FdfFilename): FdfFilename = mws.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename) if not os.path.exists(FdfFilename): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=FdfFilename) GenFdsGlobalVariable.FdfFile = FdfFilename GenFdsGlobalVariable.FdfFileTimeStamp = os.path.getmtime( FdfFilename) else: EdkLogger.error("GenFds", OPTION_MISSING, "Missing FDF filename") if (Options.BuildTarget): GenFdsGlobalVariable.TargetName = Options.BuildTarget if (Options.ToolChain): GenFdsGlobalVariable.ToolChainTag = Options.ToolChain if (Options.activePlatform): ActivePlatform = Options.activePlatform ActivePlatform = GenFdsGlobalVariable.ReplaceWorkspaceMacro( ActivePlatform) if ActivePlatform[0:2] == '..': ActivePlatform = os.path.realpath(ActivePlatform) if not os.path.isabs(ActivePlatform): ActivePlatform = mws.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform) if not os.path.exists(ActivePlatform): EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!") else: EdkLogger.error("GenFds", OPTION_MISSING, "Missing active platform") GlobalData.BuildOptionPcd = Options.OptionPcd if Options.OptionPcd else {} GenFdsGlobalVariable.ActivePlatform = PathClass( NormPath(ActivePlatform)) if (Options.ConfDirectory): # Get alternate Conf location, if it is absolute, then just use the absolute directory name ConfDirectoryPath = os.path.normpath(Options.ConfDirectory) if ConfDirectoryPath.startswith('"'): ConfDirectoryPath = ConfDirectoryPath[1:] if ConfDirectoryPath.endswith('"'): ConfDirectoryPath = ConfDirectoryPath[:-1] if not os.path.isabs(ConfDirectoryPath): # Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE # This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf ConfDirectoryPath = os.path.join( GenFdsGlobalVariable.WorkSpaceDir, ConfDirectoryPath) else: if "CONF_PATH" in os.environ: ConfDirectoryPath = os.path.normcase(os.environ["CONF_PATH"]) else: # Get standard WORKSPACE/Conf, use the absolute path to the WORKSPACE/Conf ConfDirectoryPath = mws.join(GenFdsGlobalVariable.WorkSpaceDir, 'Conf') GenFdsGlobalVariable.ConfDir = ConfDirectoryPath if not GlobalData.gConfDirectory: GlobalData.gConfDirectory = GenFdsGlobalVariable.ConfDir BuildConfigurationFile = os.path.normpath( os.path.join(ConfDirectoryPath, "target.txt")) if os.path.isfile(BuildConfigurationFile) == True: TargetTxt = TargetTxtClassObject.TargetTxtClassObject() TargetTxt.LoadTargetTxtFile(BuildConfigurationFile) # if no build target given in command line, get it from target.txt if not GenFdsGlobalVariable.TargetName: BuildTargetList = TargetTxt.TargetTxtDictionary[ DataType.TAB_TAT_DEFINES_TARGET] if len(BuildTargetList) != 1: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, ExtraData="Only allows one instance for Target.") GenFdsGlobalVariable.TargetName = BuildTargetList[0] # if no tool chain given in command line, get it from target.txt if not GenFdsGlobalVariable.ToolChainTag: ToolChainList = TargetTxt.TargetTxtDictionary[ DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG] if ToolChainList is None or len(ToolChainList) == 0: EdkLogger.error( "GenFds", RESOURCE_NOT_AVAILABLE, ExtraData="No toolchain given. Don't know how to build." ) if len(ToolChainList) != 1: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, ExtraData="Only allows one instance for ToolChain.") GenFdsGlobalVariable.ToolChainTag = ToolChainList[0] else: EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=BuildConfigurationFile) #Set global flag for build mode GlobalData.gIgnoreSource = Options.IgnoreSources if Options.Macros: for Pair in Options.Macros: if Pair.startswith('"'): Pair = Pair[1:] if Pair.endswith('"'): Pair = Pair[:-1] List = Pair.split('=') if len(List) == 2: if not List[1].strip(): EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, ExtraData="No Value given for Macro %s" % List[0]) if List[0].strip() == "EFI_SOURCE": GlobalData.gEfiSource = List[1].strip() GlobalData.gGlobalDefines[ "EFI_SOURCE"] = GlobalData.gEfiSource continue elif List[0].strip() == "EDK_SOURCE": GlobalData.gEdkSource = List[1].strip() GlobalData.gGlobalDefines[ "EDK_SOURCE"] = GlobalData.gEdkSource continue elif List[0].strip() in [ "WORKSPACE", "TARGET", "TOOLCHAIN" ]: GlobalData.gGlobalDefines[ List[0].strip()] = List[1].strip() else: GlobalData.gCommandLineDefines[ List[0].strip()] = List[1].strip() else: GlobalData.gCommandLineDefines[List[0].strip()] = "TRUE" os.environ["WORKSPACE"] = Workspace # Use the -t and -b option as gGlobalDefines's TOOLCHAIN and TARGET if they are not defined if "TARGET" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines[ "TARGET"] = GenFdsGlobalVariable.TargetName if "TOOLCHAIN" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines[ "TOOLCHAIN"] = GenFdsGlobalVariable.ToolChainTag if "TOOL_CHAIN_TAG" not in GlobalData.gGlobalDefines: GlobalData.gGlobalDefines[ 'TOOL_CHAIN_TAG'] = GenFdsGlobalVariable.ToolChainTag """call Workspace build create database""" GlobalData.gDatabasePath = os.path.normpath( os.path.join(ConfDirectoryPath, GlobalData.gDatabasePath)) BuildWorkSpace = WorkspaceDatabase(GlobalData.gDatabasePath) BuildWorkSpace.InitDatabase() # # Get files real name in workspace dir # GlobalData.gAllFiles = DirCache(Workspace) GlobalData.gWorkspace = Workspace if (Options.archList): ArchList = Options.archList.split(',') else: # EdkLogger.error("GenFds", OPTION_MISSING, "Missing build ARCH") ArchList = BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList TargetArchList = set(BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, TAB_COMMON, Options.BuildTarget, Options.ToolChain].SupArchList) & set(ArchList) if len(TargetArchList) == 0: EdkLogger.error( "GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, TAB_COMMON].SupArchList))) for Arch in ArchList: GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath( BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].OutputDirectory) GenFdsGlobalVariable.PlatformName = BuildWorkSpace.BuildObject[ GenFdsGlobalVariable.ActivePlatform, Arch, Options.BuildTarget, Options.ToolChain].PlatformName if (Options.outputDir): OutputDirFromCommandLine = GenFdsGlobalVariable.ReplaceWorkspaceMacro( Options.outputDir) if not os.path.isabs(OutputDirFromCommandLine): OutputDirFromCommandLine = os.path.join( GenFdsGlobalVariable.WorkSpaceDir, OutputDirFromCommandLine) for Arch in ArchList: GenFdsGlobalVariable.OutputDirDict[ Arch] = OutputDirFromCommandLine else: for Arch in ArchList: GenFdsGlobalVariable.OutputDirDict[Arch] = os.path.join( GenFdsGlobalVariable.OutputDirFromDscDict[Arch], GenFdsGlobalVariable.TargetName + '_' + GenFdsGlobalVariable.ToolChainTag) for Key in GenFdsGlobalVariable.OutputDirDict: OutputDir = GenFdsGlobalVariable.OutputDirDict[Key] if OutputDir[0:2] == '..': OutputDir = os.path.realpath(OutputDir) if OutputDir[1] != ':': OutputDir = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, OutputDir) if not os.path.exists(OutputDir): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=OutputDir) GenFdsGlobalVariable.OutputDirDict[Key] = OutputDir """ Parse Fdf file, has to place after build Workspace as FDF may contain macros from DSC file """ FdfParserObj = FdfParser.FdfParser(FdfFilename) FdfParserObj.ParseFile() if FdfParserObj.CycleReferenceCheck(): EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file") if (Options.uiFdName): if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict: GenFds.OnlyGenerateThisFd = Options.uiFdName else: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, "No such an FD in FDF file: %s" % Options.uiFdName) if (Options.uiFvName): if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict: GenFds.OnlyGenerateThisFv = Options.uiFvName else: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, "No such an FV in FDF file: %s" % Options.uiFvName) if (Options.uiCapName): if Options.uiCapName.upper() in FdfParserObj.Profile.CapsuleDict: GenFds.OnlyGenerateThisCap = Options.uiCapName else: EdkLogger.error( "GenFds", OPTION_VALUE_INVALID, "No such a Capsule in FDF file: %s" % Options.uiCapName) GenFdsGlobalVariable.WorkSpace = BuildWorkSpace if ArchList is not None: GenFdsGlobalVariable.ArchList = ArchList # Dsc Build Data will handle Pcd Settings from CommandLine. """Modify images from build output if the feature of loading driver at fixed address is on.""" if GenFdsGlobalVariable.FixedLoadAddress: GenFds.PreprocessImage(BuildWorkSpace, GenFdsGlobalVariable.ActivePlatform) # Record the FV Region info that may specific in the FD if FdfParserObj.Profile.FvDict and FdfParserObj.Profile.FdDict: for Fv in FdfParserObj.Profile.FvDict: FvObj = FdfParserObj.Profile.FvDict[Fv] for Fd in FdfParserObj.Profile.FdDict: FdObj = FdfParserObj.Profile.FdDict[Fd] for RegionObj in FdObj.RegionList: if RegionObj.RegionType != BINARY_FILE_TYPE_FV: continue for RegionData in RegionObj.RegionDataList: if FvObj.UiFvName.upper() == RegionData.upper(): if FvObj.FvRegionInFD: if FvObj.FvRegionInFD != RegionObj.Size: EdkLogger.error( "GenFds", FORMAT_INVALID, "The FV %s's region is specified in multiple FD with different value." % FvObj.UiFvName) else: FvObj.FvRegionInFD = RegionObj.Size RegionObj.BlockInfoOfRegion( FdObj.BlockSizeList, FvObj) """Call GenFds""" GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList) """Generate GUID cross reference file""" GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList, FdfParserObj) """Display FV space info.""" GenFds.DisplayFvSpaceInfo(FdfParserObj) except FdfParser.Warning as X: EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError=False) ReturnCode = FORMAT_INVALID except FatalError as X: if Options.debug is not None: import traceback EdkLogger.quiet(traceback.format_exc()) ReturnCode = X.args[0] except: import traceback EdkLogger.error( "\nPython", CODE_ERROR, "Tools code failure", ExtraData= "Please send email to [email protected] for help, attaching following call stack trace!\n", RaiseError=False) EdkLogger.quiet(traceback.format_exc()) ReturnCode = CODE_ERROR finally: ClearDuplicatedInf() return ReturnCode
def __init__(self, CommandLineOption=True, IsInit=True, SourceFileList=None, \ IncludeDirList=None, DecFileList=None, GuidList=None, LogFile=None, FvFileList="", MapFileList="", Report='Report.html', Dispatch=None): # Version and Copyright self.VersionNumber = ("0.02" + " " + gBUILD_VERSION) self.Version = "%prog Version " + self.VersionNumber self.Copyright = "Copyright (c) 2008 - 2010, Intel Corporation All rights reserved." self.Report = Report self.IsInit = IsInit self.SourceFileList = SourceFileList self.IncludeDirList = IncludeDirList self.DecFileList = DecFileList self.GuidList = GuidList self.LogFile = LogFile self.FvFileList = FvFileList self.MapFileList = MapFileList self.Dispatch = Dispatch # Check workspace environment if "EFI_SOURCE" not in os.environ: if "EDK_SOURCE" not in os.environ: pass else: EotGlobalData.gEDK_SOURCE = os.path.normpath( os.getenv("EDK_SOURCE")) else: EotGlobalData.gEFI_SOURCE = os.path.normpath( os.getenv("EFI_SOURCE")) EotGlobalData.gEDK_SOURCE = os.path.join(EotGlobalData.gEFI_SOURCE, 'Edk') if "WORKSPACE" not in os.environ: EdkLogger.error("EOT", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found", ExtraData="WORKSPACE") else: EotGlobalData.gWORKSPACE = os.path.normpath(os.getenv("WORKSPACE")) EotGlobalData.gMACRO['WORKSPACE'] = EotGlobalData.gWORKSPACE EotGlobalData.gMACRO['EFI_SOURCE'] = EotGlobalData.gEFI_SOURCE EotGlobalData.gMACRO['EDK_SOURCE'] = EotGlobalData.gEDK_SOURCE # Parse the options and args if CommandLineOption: self.ParseOption() if self.FvFileList: for FvFile in GetSplitValueList(self.FvFileList, ' '): FvFile = os.path.normpath(FvFile) if not os.path.isfile(FvFile): EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % FvFile) EotGlobalData.gFV_FILE.append(FvFile) else: EdkLogger.error( "Eot", EdkLogger.EOT_ERROR, "The fv file list of target platform was not specified") if self.MapFileList: for MapFile in GetSplitValueList(self.MapFileList, ' '): MapFile = os.path.normpath(MapFile) if not os.path.isfile(MapFile): EdkLogger.error("Eot", EdkLogger.EOT_ERROR, "Can not find file %s " % MapFile) EotGlobalData.gMAP_FILE.append(MapFile) # Generate source file list self.GenerateSourceFileList(self.SourceFileList, self.IncludeDirList) # Generate guid list of dec file list self.ParseDecFile(self.DecFileList) # Generate guid list from GUID list file self.ParseGuidList(self.GuidList) # Init Eot database EotGlobalData.gDb = Database.Database(Database.DATABASE_PATH) EotGlobalData.gDb.InitDatabase(self.IsInit) # Build ECC database self.BuildDatabase() # Parse Ppi/Protocol self.ParseExecutionOrder() # Merge Identifier tables self.GenerateQueryTable() # Generate report database self.GenerateReportDatabase() # Load Fv Info self.LoadFvInfo() # Load Map Info self.LoadMapInfo() # Generate Report self.GenerateReport() # Convert log file self.ConvertLogFile(self.LogFile) # DONE EdkLogger.quiet("EOT FINISHED!") # Close Database EotGlobalData.gDb.Close()
def GenerateReport(self): EdkLogger.quiet("Generating report file ... ") Rep = Report(self.Report, EotGlobalData.gFV, self.Dispatch) Rep.GenerateReport()
create a log file, or output a log message.""") Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.") Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\ "including library instances selected, final dependency expression, "\ "and warning messages, etc.") Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.") Parser.add_option("-w", "--workspace", action="store", type="string", dest='Workspace', help="Specify workspace.") Parser.add_option("-f", "--folders", action="store_true", type=None, help="Only scanning specified folders which are recorded in config.ini file.") (Opt, Args)=Parser.parse_args() return (Opt, Args) ## # # This acts like the main() function for the script, unless it is 'import'ed into another # script. # if __name__ == '__main__': # Initialize log system EdkLogger.Initialize() EdkLogger.IsRaiseError = False EdkLogger.quiet(time.strftime("%H:%M:%S, %b.%d %Y ", time.localtime()) + "[00:00]" + "\n") StartTime = time.clock() Ecc = Ecc() FinishTime = time.clock() BuildDuration = time.strftime("%M:%S", time.gmtime(int(round(FinishTime - StartTime)))) EdkLogger.quiet("\n%s [%s]" % (time.strftime("%H:%M:%S, %b.%d %Y", time.localtime()), BuildDuration))
def Check(self): EdkLogger.quiet("Checking ...") EccCheck = Check() EccCheck.Check() EdkLogger.quiet("Checking done!")
def Main(): EdkLogger.Initialize() Options = MyOptionParser() try: if not Options.PackageGuid and not Options.PackageVersion: EdkLogger.error( "RmPkg", OPTION_MISSING, ExtraData= "The GUID and Version of distribution package must be specified" ) if Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(Options.LogLevel + 1) else: EdkLogger.SetLevel(Options.LogLevel) CheckEnvVariable() WorkspaceDir = os.environ["WORKSPACE"] # Prepare check dependency Db = IpiDatabase( os.path.normpath( os.path.join(WorkspaceDir, "Conf/DistributionPackageDatabase.db"))) Db.InitDatabase() Dep = DependencyRules(Db) Guid = Options.PackageGuid Version = Options.PackageVersion # Check Dp existing if not Dep.CheckDpExists(Guid, Version): EdkLogger.error("RmPkg", UNKNOWN_ERROR, "This distribution package are not installed!") # Check Dp depex if not Dep.CheckDpDepexForRemove(Guid, Version): print "Some packages/modules are depending on this distribution package, do you really want to remove it?" print "Press Y to delete all files or press other keys to quit:" Input = Input = sys.stdin.readline() Input = Input.replace('\r', '').replace('\n', '') if Input.upper() != 'Y': EdkLogger.error("RmPkg", UNKNOWN_ERROR, "User interrupt") # Remove all files if not Options.Yes: print "All files of the distribution package will be removed, do you want to continue?" print "Press Y to remove all files or press other keys to quit:" Input = Input = sys.stdin.readline() Input = Input.replace('\r', '').replace('\n', '') if Input.upper() != 'Y': EdkLogger.error("RmPkg", UNKNOWN_ERROR, "User interrupt") # Remove all files MissingFileList = [] for Item in Db.GetDpFileList(Guid, Version): if os.path.isfile(Item): print "Removing file [%s] ..." % Item os.remove(Item) else: MissingFileList.append(Item) # Remove all empty dirs of package for Item in Db.GetPackageListFromDp(Guid, Version): Dir = os.path.dirname(Item[2]) RemoveEmptyDirs(Dir) # Remove all empty dirs of module for Item in Db.GetStandaloneModuleInstallPathListFromDp(Guid, Version): Dir = os.path.dirname(Item) RemoveEmptyDirs(Dir) # update database EdkLogger.quiet("Update Distribution Package Database ...") Db.RemoveDpObj(Guid, Version) EdkLogger.quiet("DONE") except FatalError, X: if Options and Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) ReturnCode = X.args[0]
TrimPreprocessedVfr(InputFile, CommandOptions.OutputFile) elif CommandOptions.FileType == "Asl": if CommandOptions.OutputFile == None: CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii' TrimAslFile(InputFile, CommandOptions.OutputFile, CommandOptions.IncludePathFile) elif CommandOptions.FileType == "EdkSourceCode": TrimEdkSources(InputFile, CommandOptions.OutputFile) else : if CommandOptions.OutputFile == None: CommandOptions.OutputFile = os.path.splitext(InputFile)[0] + '.iii' TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, CommandOptions.ConvertHex, CommandOptions.TrimLong) except FatalError, X: import platform import traceback if CommandOptions != None and CommandOptions.LogLevel <= EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) return 1 except: import traceback import platform EdkLogger.error( "\nTrim", CODE_ERROR, "Unknown fatal error when trimming [%s]" % InputFile, ExtraData="\n(Please send email to [email protected] for help, attaching following call stack trace!)\n", RaiseError=False ) EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) return 1 return 0
GenFds.GenerateGuidXRefFile(BuildWorkSpace, ArchList) """Display FV space info.""" GenFds.DisplayFvSpaceInfo(FdfParserObj) except FdfParser.Warning, X: EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError=False) ReturnCode = FORMAT_INVALID except FatalError, X: if Options.debug != None: import traceback EdkLogger.quiet(traceback.format_exc()) ReturnCode = X.args[0] except: import traceback EdkLogger.error( "\nPython", CODE_ERROR, "Tools code failure", ExtraData= "Please send email to [email protected] for help, attaching following call stack trace!\n", RaiseError=False) EdkLogger.quiet(traceback.format_exc()) ReturnCode = CODE_ERROR finally: ClearDuplicatedInf() return ReturnCode
def BuildMetaDataFileDatabase(self): EdkLogger.quiet("Building database for meta data files ...") Op = open(EccGlobalData.gConfig.MetaDataFileCheckPathOfGenerateFileList, 'w+') #SkipDirs = Read from config file SkipDirs = EccGlobalData.gConfig.SkipDirList SkipDirString = string.join(SkipDirs, '|') p = re.compile(r'.*[\\/](?:%s)[\\/]?.*' % SkipDirString) for Root, Dirs, Files in os.walk(EccGlobalData.gTarget): if p.match(Root.upper()): continue for Dir in Dirs: Dirname = os.path.join(Root, Dir) if os.path.islink(Dirname): Dirname = os.path.realpath(Dirname) if os.path.isdir(Dirname): # symlinks to directories are treated as directories Dirs.remove(Dir) Dirs.append(Dirname) for File in Files: if len(File) > 4 and File[-4:].upper() == ".DEC": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) Dec(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) continue if len(File) > 4 and File[-4:].upper() == ".DSC": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) Dsc(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) continue if len(File) > 4 and File[-4:].upper() == ".INF": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) Inf(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) continue if len(File) > 4 and File[-4:].upper() == ".FDF": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) Fdf(Filename, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) continue Op.close() # Commit to database EccGlobalData.gDb.Conn.commit() EdkLogger.quiet("Building database for meta data files done!")
standard output. If no modifications were made, then do not create a log file, or output a log message.""") Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.") Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\ "including library instances selected, final dependency expression, "\ "and warning messages, etc.") Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.") Parser.add_option("-w", "--workspace", action="store", type="string", dest='Workspace', help="Specify workspace.") Parser.add_option("-f", "--folders", action="store_true", type=None, help="Only scanning specified folders which are recorded in config.ini file.") (Opt, Args)=Parser.parse_args() return (Opt, Args) ## # # This acts like the main() function for the script, unless it is 'import'ed into another # script. # if __name__ == '__main__': # Initialize log system EdkLogger.Initialize() EdkLogger.IsRaiseError = False StartTime = time.perf_counter() Ecc = Ecc() FinishTime = time.perf_counter() BuildDuration = time.strftime("%M:%S", time.gmtime(int(round(FinishTime - StartTime)))) EdkLogger.quiet("\n%s [%s]" % (time.strftime("%H:%M:%S, %b.%d %Y", time.localtime()), BuildDuration))
def ParseExecutionOrder(self): EdkLogger.quiet("Searching Ppi/Protocol ... ") for Identifier in EotGlobalData.gIdentifierTableList: ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, Enabled = \ -1, '', '', -1, '', '', '', '', '', '', '', '', 0 SourceFileID = Identifier[0].replace('Identifier', '') SourceFileFullPath = Identifier[1] Identifier = Identifier[0] # Find Ppis ItemMode = 'Produced' SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \ % (Identifier, '.InstallPpi', '->InstallPpi', 'PeiInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING) SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode) ItemMode = 'Produced' SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \ % (Identifier, '.ReInstallPpi', '->ReInstallPpi', MODEL_IDENTIFIER_FUNCTION_CALLING) SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2) SearchPpiCallFunction(Identifier, SourceFileID, SourceFileFullPath, ItemMode) ItemMode = 'Consumed' SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \ % (Identifier, '.LocatePpi', '->LocatePpi', MODEL_IDENTIFIER_FUNCTION_CALLING) SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode) SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Ppi', ItemMode) ItemMode = 'Callback' SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \ % (Identifier, '.NotifyPpi', '->NotifyPpi', MODEL_IDENTIFIER_FUNCTION_CALLING) SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode) # Find Procotols ItemMode = 'Produced' SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \ % (Identifier, '.InstallProtocolInterface', '.ReInstallProtocolInterface', '->InstallProtocolInterface', '->ReInstallProtocolInterface', MODEL_IDENTIFIER_FUNCTION_CALLING) SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1) SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \ % (Identifier, '.InstallMultipleProtocolInterfaces', '->InstallMultipleProtocolInterfaces', MODEL_IDENTIFIER_FUNCTION_CALLING) SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2) SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode) ItemMode = 'Consumed' SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \ % (Identifier, '.LocateProtocol', '->LocateProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING) SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0) SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \ % (Identifier, '.HandleProtocol', '->HandleProtocol', MODEL_IDENTIFIER_FUNCTION_CALLING) SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1) SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode) ItemMode = 'Callback' SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" \ % (Identifier, '.RegisterProtocolNotify', '->RegisterProtocolNotify', MODEL_IDENTIFIER_FUNCTION_CALLING) SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0) SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, 'Protocol', ItemMode) # Hard Code EotGlobalData.gDb.TblReport.Insert( -2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiSecPlatformInformationPpiGuid', '', '', '', 0) EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gEfiNtLoadAsDllPpiGuid', '', '', '', 0) EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtPeiLoadFileGuid', '', '', '', 0) EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtAutoScanPpiGuid', '', '', '', 0) EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gNtFwhPpiGuid', '', '', '', 0) EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiNtThunkPpiGuid', '', '', '', 0) EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiPlatformTypePpiGuid', '', '', '', 0) EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiFrequencySelectionCpuPpiGuid', '', '', '', 0) EotGlobalData.gDb.TblReport.Insert(-2, '', '', -1, '', '', 'Ppi', 'Produced', 'gPeiCachePpiGuid', '', '', '', 0) EotGlobalData.gDb.Conn.commit()
def ParseExecutionOrder(self): EdkLogger.quiet("Searching Ppi/Protocol ... ") for Identifier in EotGlobalData.gIdentifierTableList: ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFullPath, ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, Enabled = ( -1, "", "", -1, "", "", "", "", "", "", "", "", 0, ) SourceFileID = Identifier[0].replace("Identifier", "") SourceFileFullPath = Identifier[1] Identifier = Identifier[0] # Find Ppis ItemMode = "Produced" SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" % ( Identifier, ".InstallPpi", "->InstallPpi", "PeiInstallPpi", MODEL_IDENTIFIER_FUNCTION_CALLING, ) SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode) ItemMode = "Produced" SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" % ( Identifier, ".ReInstallPpi", "->ReInstallPpi", MODEL_IDENTIFIER_FUNCTION_CALLING, ) SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2) SearchPpiCallFunction(Identifier, SourceFileID, SourceFileFullPath, ItemMode) ItemMode = "Consumed" SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" % ( Identifier, ".LocatePpi", "->LocatePpi", MODEL_IDENTIFIER_FUNCTION_CALLING, ) SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode) SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, "Ppi", ItemMode) ItemMode = "Callback" SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" % ( Identifier, ".NotifyPpi", "->NotifyPpi", MODEL_IDENTIFIER_FUNCTION_CALLING, ) SearchPpi(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode) # Find Procotols ItemMode = "Produced" SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" % ( Identifier, ".InstallProtocolInterface", ".ReInstallProtocolInterface", "->InstallProtocolInterface", "->ReInstallProtocolInterface", MODEL_IDENTIFIER_FUNCTION_CALLING, ) SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1) SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" % ( Identifier, ".InstallMultipleProtocolInterfaces", "->InstallMultipleProtocolInterfaces", MODEL_IDENTIFIER_FUNCTION_CALLING, ) SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 2) SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, "Protocol", ItemMode) ItemMode = "Consumed" SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" % ( Identifier, ".LocateProtocol", "->LocateProtocol", MODEL_IDENTIFIER_FUNCTION_CALLING, ) SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0) SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" % ( Identifier, ".HandleProtocol", "->HandleProtocol", MODEL_IDENTIFIER_FUNCTION_CALLING, ) SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 1) SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, "Protocol", ItemMode) ItemMode = "Callback" SqlCommand = """select Value, Name, BelongsToFile, StartLine, EndLine from %s where (Name like '%%%s%%' or Name like '%%%s%%') and Model = %s""" % ( Identifier, ".RegisterProtocolNotify", "->RegisterProtocolNotify", MODEL_IDENTIFIER_FUNCTION_CALLING, ) SearchProtocols(SqlCommand, Identifier, SourceFileID, SourceFileFullPath, ItemMode, 0) SearchFunctionCalling(Identifier, SourceFileID, SourceFileFullPath, "Protocol", ItemMode) # Hard Code EotGlobalData.gDb.TblReport.Insert( -2, "", "", -1, "", "", "Ppi", "Produced", "gEfiSecPlatformInformationPpiGuid", "", "", "", 0 ) EotGlobalData.gDb.TblReport.Insert( -2, "", "", -1, "", "", "Ppi", "Produced", "gEfiNtLoadAsDllPpiGuid", "", "", "", 0 ) EotGlobalData.gDb.TblReport.Insert( -2, "", "", -1, "", "", "Ppi", "Produced", "gNtPeiLoadFileGuid", "", "", "", 0 ) EotGlobalData.gDb.TblReport.Insert( -2, "", "", -1, "", "", "Ppi", "Produced", "gPeiNtAutoScanPpiGuid", "", "", "", 0 ) EotGlobalData.gDb.TblReport.Insert(-2, "", "", -1, "", "", "Ppi", "Produced", "gNtFwhPpiGuid", "", "", "", 0) EotGlobalData.gDb.TblReport.Insert( -2, "", "", -1, "", "", "Ppi", "Produced", "gPeiNtThunkPpiGuid", "", "", "", 0 ) EotGlobalData.gDb.TblReport.Insert( -2, "", "", -1, "", "", "Ppi", "Produced", "gPeiPlatformTypePpiGuid", "", "", "", 0 ) EotGlobalData.gDb.TblReport.Insert( -2, "", "", -1, "", "", "Ppi", "Produced", "gPeiFrequencySelectionCpuPpiGuid", "", "", "", 0 ) EotGlobalData.gDb.TblReport.Insert(-2, "", "", -1, "", "", "Ppi", "Produced", "gPeiCachePpiGuid", "", "", "", 0) EotGlobalData.gDb.Conn.commit()
def BuildMetaDataFileDatabase(self): EdkLogger.quiet("Building database for meta data files ...") Op = open( EccGlobalData.gConfig.MetaDataFileCheckPathOfGenerateFileList, 'w+') #SkipDirs = Read from config file SkipDirs = EccGlobalData.gConfig.SkipDirList SkipDirString = string.join(SkipDirs, '|') p = re.compile(r'.*[\\/](?:%s)[\\/]?.*' % SkipDirString) for Root, Dirs, Files in os.walk(EccGlobalData.gTarget): if p.match(Root.upper()): continue for Dir in Dirs: Dirname = os.path.join(Root, Dir) if os.path.islink(Dirname): Dirname = os.path.realpath(Dirname) if os.path.isdir(Dirname): # symlinks to directories are treated as directories Dirs.remove(Dir) Dirs.append(Dirname) for File in Files: if len(File) > 4 and File[-4:].upper() == ".DEC": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) Dec(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) continue if len(File) > 4 and File[-4:].upper() == ".DSC": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) Dsc(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) continue if len(File) > 4 and File[-4:].upper() == ".INF": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) Inf(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) continue if len(File) > 4 and File[-4:].upper() == ".FDF": Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) Fdf(Filename, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) continue Op.close() # Commit to database EccGlobalData.gDb.Conn.commit() EdkLogger.quiet("Building database for meta data files done!")
def QuietLogger (msg): EdkLogger.quiet(msg)
def Main(): EdkLogger.Initialize() Options = MyOptionParser() try: if Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.SetLevel(Options.LogLevel + 1) else: EdkLogger.SetLevel(Options.LogLevel) CheckEnvVariable() WorkspaceDir = os.environ["WORKSPACE"] # Init DistributionFile if not Options.DistributionFile: Options.DistributionFile = "DistributionPackage.zip" # Check Tools Dir if Options.ToolsDir: if not os.path.isdir( os.path.normpath( os.path.join(WorkspaceDir, Options.ToolsDir))): EdkLogger.error( "\nMkPkg", FILE_NOT_FOUND, "Tools directory [%s] not found" % Options.ToolsDir) # Check misc files if Options.MiscFiles: for Item in Options.MiscFiles: FullPath = os.path.normpath(os.path.join(WorkspaceDir, Item)) if not os.path.isfile(FullPath): EdkLogger.error("\nMkPkg", FILE_NOT_FOUND, "Misc file [%s] not found" % Item) #Check package file existing and valid if Options.PackageFileList: for Item in Options.PackageFileList: (Name, Ext) = os.path.splitext(Item) if Ext.upper() != '.DEC': EdkLogger.error("\nMkPkg", OPTION_VALUE_INVALID, "[%s] is not a valid package name" % Item) Path = os.path.normpath(os.path.join(WorkspaceDir, Item)) if not os.path.exists(Path): EdkLogger.error("\nMkPkg", FILE_NOT_FOUND, "[%s] not found" % Item) #Check module file existing and valid if Options.ModuleFileList: for Item in Options.ModuleFileList: (Name, Ext) = os.path.splitext(Item) if Ext.upper() != '.INF': EdkLogger.error("\nMkPkg", OPTION_VALUE_INVALID, "[%s] is not a valid module name" % Item) Path = os.path.normpath(os.path.join(WorkspaceDir, Item)) if not os.path.exists(Path): EdkLogger.error("\nMkPkg", FILE_NOT_FOUND, "[%s] not found" % Item) ContentFile = PackageFile("content.zip", "w") DistPkg = DistributionPackageClass() DistPkg.GetDistributionPackage(WorkspaceDir, Options.PackageFileList, Options.ModuleFileList) DistPkgXml = DistributionPackageXml() for Item in DistPkg.PackageSurfaceArea: ContentFile.Pack( os.path.dirname( os.path.normpath(os.path.join(WorkspaceDir, Item[2])))) for Item in DistPkg.ModuleSurfaceArea: ContentFile.Pack( os.path.dirname( os.path.normpath(os.path.join(WorkspaceDir, Item[2])))) # Add tools files and information if Options.ToolsDir: ToolsFiles = MiscFileClass() ToolsRoot = os.path.normpath( os.path.join(WorkspaceDir, Options.ToolsDir)) ContentFile.Pack(ToolsRoot) ToolsFileList = GetFiles(ToolsRoot, ['CVS', '.svn']) for Item in ToolsFileList: OriPath = Item[len(WorkspaceDir) + 1:] FileObj = FileClass() FileObj.Filename = OriPath (Name, Ext) = os.path.splitext(OriPath) if Ext.upper() in ['EXE', 'COM', 'EFI']: FileObj.Executable = 'True' ToolsFiles.Files.append(FileObj) DistPkg.Tools = ToolsFiles # Add misc files and information if Options.MiscFiles: MiscFiles = MiscFileClass() for Item in Options.MiscFiles: ContentFile.PackFile(Item) FileObj = FileClass() FileObj.Filename = Item (Name, Ext) = os.path.splitext(Item) if Ext.upper() in ['EXE', 'COM', 'EFI']: FileObj.Executable = 'True' MiscFiles.Files.append(FileObj) DistPkg.MiscellaneousFiles = MiscFiles print "Compressing Distribution Package File ..." ContentFile.Close() # Add temp distribution header if Options.TemplateFile: TempXML = DistributionPackageXml() DistPkg.Header = TempXML.FromXml(Options.TemplateFile).Header # Add init dp information else: DistPkg.Header.Name = 'Distribution Package' DistPkg.Header.Guid = str(uuid.uuid4()) DistPkg.Header.Version = '1.0' # Add Md5Sigature Md5Sigature = md5.new(open(str(ContentFile)).read()) DistPkg.Header.Signature = Md5Sigature.hexdigest() # Add current Date DistPkg.Header.Date = str( time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime())) # Finish final dp file DistPkgFile = PackageFile(Options.DistributionFile, "w") DistPkgFile.PackFile(str(ContentFile)) DistPkgFile.PackData(DistPkgXml.ToXml(DistPkg), "dist.pkg") DistPkgFile.Close() print "DONE" except FatalError, X: if Options and Options.LogLevel < EdkLogger.DEBUG_9: EdkLogger.quiet("(Python %s on %s) " % (platform.python_version(), sys.platform) + traceback.format_exc()) ReturnCode = X.args[0]