def __init__(self): self.StartTime = time.time() self.PrintRunTime = False self.PrintRunStatus = False self.RunStatus = '' # # Check environment valiable 'WORKSPACE' # if os.environ.get('WORKSPACE') == None: print 'ERROR: WORKSPACE not defined. Please run EdkSetup from the EDK II install directory.' return False self.CurrentWorkingDir = os.getcwd() self.WorkspaceDir = os.path.realpath(os.environ.get('WORKSPACE')) (Drive, Path) = os.path.splitdrive(self.WorkspaceDir) if Drive == '': (Drive, CwdPath) = os.path.splitdrive(self.CurrentWorkingDir) if Drive != '': self.WorkspaceDir = Drive + Path else: self.WorkspaceDir = Drive.upper() + Path self.WorkspaceRelativeWorkingDir = self.WorkspaceRelativePath( self.CurrentWorkingDir) try: # # Load TianoCoreOrgLogo, used for GUI tool # self.Icon = wx.Icon( self.WorkspaceFile('tools/Python/TianoCoreOrgLogo.gif'), wx.BITMAP_TYPE_GIF) except: self.Icon = None self.Verbose = False for Arg in sys.argv: if Arg.lower() == '-v': self.Verbose = True
def __init__(self): self.StartTime = time.time() self.PrintRunTime = False self.PrintRunStatus = False self.RunStatus = '' # # Check environment valiable 'WORKSPACE' # if os.environ.get('WORKSPACE') == None: print 'ERROR: WORKSPACE not defined. Please run EdkSetup from the EDK II install directory.' return False self.CurrentWorkingDir = os.getcwd() self.WorkspaceDir = os.path.realpath(os.environ.get('WORKSPACE')) (Drive, Path) = os.path.splitdrive(self.WorkspaceDir) if Drive == '': (Drive, CwdPath) = os.path.splitdrive(self.CurrentWorkingDir) if Drive != '': self.WorkspaceDir = Drive + Path else: self.WorkspaceDir = Drive.upper() + Path self.WorkspaceRelativeWorkingDir = self.WorkspaceRelativePath (self.CurrentWorkingDir) try: # # Load TianoCoreOrgLogo, used for GUI tool # self.Icon = wx.Icon(self.WorkspaceFile('tools/Python/TianoCoreOrgLogo.gif'), wx.BITMAP_TYPE_GIF) except: self.Icon = None self.Verbose = False for Arg in sys.argv: if Arg.lower() == '-v': self.Verbose = True
def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None, GuidHdrLen=None, GuidAttr=[], Ui=None, Ver=None, InputAlign=[], BuildNumber=None, DummyFile=None, IsMakefile=False): Cmd = ["GenSec"] if Type: Cmd += ("-s", Type) if CompressionType: Cmd += ("-c", CompressionType) if Guid: Cmd += ("-g", Guid) if DummyFile: Cmd += ("--dummy", DummyFile) if GuidHdrLen: Cmd += ("-l", GuidHdrLen) #Add each guided attribute for Attr in GuidAttr: Cmd += ("-r", Attr) #Section Align is only for dummy section without section type for SecAlign in InputAlign: Cmd += ("--sectionalign", SecAlign) CommandFile = Output + '.txt' if Ui: if IsMakefile: if Ui == "$(MODULE_NAME)": Cmd += ('-n', Ui) else: Cmd += ("-n", '"' + Ui + '"') Cmd += ("-o", Output) if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList: GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip()) else: SectionData = array('B', [0, 0, 0, 0]) SectionData.fromlist(array('B',Ui.encode('utf-16-le')).tolist()) SectionData.append(0) SectionData.append(0) Len = len(SectionData) GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15) DirName = os.path.dirname(Output) if not CreateDirectory(DirName): EdkLogger.error(None, FILE_CREATE_FAILURE, "Could not create directory %s" % DirName) else: if DirName == '': DirName = os.getcwd() if not os.access(DirName, os.W_OK): EdkLogger.error(None, PERMISSION_FAILURE, "Do not have write permission on directory %s" % DirName) try: with open(Output, "wb") as Fd: SectionData.tofile(Fd) Fd.flush() except IOError as X: EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData='IOError %s' % X) elif Ver: Cmd += ("-n", Ver) if BuildNumber: Cmd += ("-j", BuildNumber) Cmd += ("-o", Output) SaveFileOnChange(CommandFile, ' '.join(Cmd), False) if IsMakefile: if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList: GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip()) else: if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]): return GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section") else: Cmd += ("-o", Output) Cmd += Input SaveFileOnChange(CommandFile, ' '.join(Cmd), False) if IsMakefile: if sys.platform == "win32": Cmd = ['if', 'exist', Input[0]] + Cmd else: Cmd = ['-test', '-e', Input[0], "&&"] + Cmd if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdList: GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).strip()) elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [CommandFile]): GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input)) GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section") if (os.path.getsize(Output) >= GenFdsGlobalVariable.LARGE_FILE_SIZE and GenFdsGlobalVariable.LargeFileInFvFlags): GenFdsGlobalVariable.LargeFileInFvFlags[-1] = True