X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FWorkspace%2FWorkspaceDatabase.py;h=348d219aa9efd30907bbf6ef9c74a0e238d3049b;hp=df0fa81ebb7d3bf72260afd63da64afa461f08bf;hb=fd171542e0aa89ac12a09d79608173f48019b14b;hpb=f22911b49e8be58d364f9e21f5af6bd3f0513cf7 diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index df0fa81ebb..348d219aa9 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -17,6 +17,7 @@ import sqlite3 import os import os.path +import pickle import Common.EdkLogger as EdkLogger import Common.GlobalData as GlobalData @@ -24,6 +25,7 @@ import Common.GlobalData as GlobalData from Common.String import * from Common.DataType import * from Common.Misc import * +from types import * from CommonDataClass.CommonClass import SkuInfoClass @@ -1109,6 +1111,7 @@ class InfBuildData(ModuleBuildClassObject): "BS_DRIVER" : "DXE_DRIVER", "RT_DRIVER" : "DXE_RUNTIME_DRIVER", "SAL_RT_DRIVER" : "DXE_SAL_DRIVER", + "SMM_DRIVER" : "SMM_DRIVER", # "BS_DRIVER" : "DXE_SMM_DRIVER", # "BS_DRIVER" : "UEFI_DRIVER", "APPLICATION" : "UEFI_APPLICATION", @@ -2059,11 +2062,11 @@ class WorkspaceDatabase(object): if DbPath != ':memory:': DbDir = os.path.split(DbPath)[0] if not os.path.exists(DbDir): - os.makedirs(DbDir) - - # remove db file in case inconsistency between db and file in file system - if self._CheckWhetherDbNeedRenew(RenewDb, DbPath): - os.remove(DbPath) + os.makedirs(DbDir) + + # remove db file in case inconsistency between db and file in file system + if self._CheckWhetherDbNeedRenew(RenewDb, DbPath): + os.remove(DbPath) # create db with optimized parameters self.Conn = sqlite3.connect(DbPath, isolation_level='DEFERRED') @@ -2084,60 +2087,95 @@ class WorkspaceDatabase(object): # conversion object for build or file format conversion purpose self.BuildObject = WorkspaceDatabase.BuildObjectFactory(self) self.TransformObject = WorkspaceDatabase.TransformObjectFactory(self) - - ## Check whether workspace database need to be renew. - # The renew reason maybe: - # 1) If user force to renew; - # 2) If user do not force renew, and - # a) If the time of last modified python source is newer than database file; - # b) If the time of last modified frozen executable file is newer than database file; - # - # @param force User force renew database - # @param DbPath The absolute path of workspace database file - # - # @return Bool value for whether need renew workspace databse - # - def _CheckWhetherDbNeedRenew (self, force, DbPath): - # if database does not exist, we need do nothing - if not os.path.exists(DbPath): return False - - # if user force to renew database, then not check whether database is out of date - if force: return True - - # - # Check the time of last modified source file or build.exe - # if is newer than time of database, then database need to be re-created. - # - timeOfToolModified = 0 - if hasattr(sys, "frozen"): - exePath = os.path.abspath(sys.executable) - timeOfToolModified = os.stat(exePath).st_mtime - else: - curPath = os.path.dirname(__file__) # curPath is the path of WorkspaceDatabase.py - rootPath = os.path.split(curPath)[0] # rootPath is root path of python source, such as /BaseTools/Source/Python - if rootPath == "" or rootPath == None: - EdkLogger.verbose("\nFail to find the root path of build.exe or python sources, so can not \ -determine whether database file is out of date!\n") - - # walk the root path of source or build's binary to get the time last modified. - - for root, dirs, files in os.walk (rootPath): - for dir in dirs: - # bypass source control folder - if dir.lower() in [".svn", "_svn", "cvs"]: - dirs.remove(dir) - - for file in files: - ext = os.path.splitext(file)[1] - if ext.lower() == ".py": # only check .py files - fd = os.stat(os.path.join(root, file)) - if timeOfToolModified < fd.st_mtime: - timeOfToolModified = fd.st_mtime - if timeOfToolModified > os.stat(DbPath).st_mtime: - EdkLogger.verbose("\nWorkspace database is out of data!") - return True - - return False + + ## Check whether workspace database need to be renew. + # The renew reason maybe: + # 1) If user force to renew; + # 2) If user do not force renew, and + # a) If the time of last modified python source is newer than database file; + # b) If the time of last modified frozen executable file is newer than database file; + # + # @param force User force renew database + # @param DbPath The absolute path of workspace database file + # + # @return Bool value for whether need renew workspace databse + # + def _CheckWhetherDbNeedRenew (self, force, DbPath): + DbDir = os.path.split(DbPath)[0] + MacroFilePath = os.path.normpath(os.path.join(DbDir, "build.mac")) + MacroMatch = False + if os.path.exists(MacroFilePath) and os.path.isfile(MacroFilePath): + LastMacros = None + try: + f = open(MacroFilePath,'r') + LastMacros = pickle.load(f) + f.close() + except IOError: + pass + except: + f.close() + + if LastMacros != None and type(LastMacros) is DictType: + if LastMacros == self._GlobalMacros: + MacroMatch = True + for Macro in LastMacros.keys(): + if not (Macro in self._GlobalMacros and LastMacros[Macro] == self._GlobalMacros[Macro]): + MacroMatch = False; + break; + + if not MacroMatch: + # save command line macros to file + try: + f = open(MacroFilePath,'w') + pickle.dump(self._GlobalMacros, f, 2) + f.close() + except IOError: + pass + except: + f.close() + + force = True + + # if database does not exist, we need do nothing + if not os.path.exists(DbPath): return False + + # if user force to renew database, then not check whether database is out of date + if force: return True + + # + # Check the time of last modified source file or build.exe + # if is newer than time of database, then database need to be re-created. + # + timeOfToolModified = 0 + if hasattr(sys, "frozen"): + exePath = os.path.abspath(sys.executable) + timeOfToolModified = os.stat(exePath).st_mtime + else: + curPath = os.path.dirname(__file__) # curPath is the path of WorkspaceDatabase.py + rootPath = os.path.split(curPath)[0] # rootPath is root path of python source, such as /BaseTools/Source/Python + if rootPath == "" or rootPath == None: + EdkLogger.verbose("\nFail to find the root path of build.exe or python sources, so can not \ +determine whether database file is out of date!\n") + + # walk the root path of source or build's binary to get the time last modified. + + for root, dirs, files in os.walk (rootPath): + for dir in dirs: + # bypass source control folder + if dir.lower() in [".svn", "_svn", "cvs"]: + dirs.remove(dir) + + for file in files: + ext = os.path.splitext(file)[1] + if ext.lower() == ".py": # only check .py files + fd = os.stat(os.path.join(root, file)) + if timeOfToolModified < fd.st_mtime: + timeOfToolModified = fd.st_mtime + if timeOfToolModified > os.stat(DbPath).st_mtime: + EdkLogger.verbose("\nWorkspace database is out of data!") + return True + + return False ## Initialize build database def InitDatabase(self):