diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-09-11 03:14:43 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-09-11 03:14:43 +0000 |
commit | fd171542e0aa89ac12a09d79608173f48019b14b (patch) | |
tree | b4e1320ab3bc1cb59355f9fcbc361f84ae0c4f0a /BaseTools/Source/Python/Workspace | |
parent | f22911b49e8be58d364f9e21f5af6bd3f0513cf7 (diff) | |
download | edk2-platforms-fd171542e0aa89ac12a09d79608173f48019b14b.tar.xz |
Sync basetools' source and binary files with r1707 of the basetools project.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9257 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/Workspace')
-rw-r--r-- | BaseTools/Source/Python/Workspace/MetaFileParser.py | 20 | ||||
-rw-r--r-- | BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 156 |
2 files changed, 110 insertions, 66 deletions
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 294237daee..40eb82656d 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -16,6 +16,7 @@ # import os import time +import copy import Common.EdkLogger as EdkLogger from CommonDataClass.DataClass import * @@ -55,7 +56,7 @@ class MetaFileParser(object): self._FileType = FileType self.MetaFile = FilePath self._FileDir = os.path.dirname(self.MetaFile) - self._Macros = {} + self._Macros = copy.copy(Macros) # for recursive parsing self._Owner = Owner @@ -87,7 +88,9 @@ class MetaFileParser(object): ## Set parsing complete flag in both class and table def _Done(self): self._Finished = True - self._Table.SetEndFlag() + ## Do not set end flag when processing included files + if self._From == -1: + self._Table.SetEndFlag() ## Return the table containg parsed data # @@ -208,11 +211,14 @@ class MetaFileParser(object): if TokenList[0] == '': EdkLogger.error('Parser', FORMAT_INVALID, "No macro name given", ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) - if len(TokenList) == 1: - self._Macros[TokenList[0]] = '' - else: - # keep the macro definition for later use - self._Macros[TokenList[0]] = ReplaceMacro(TokenList[1], self._Macros, False) + + # Macros defined in the command line override ones defined in the meta-data file + if not TokenList[0] in self._Macros: + if len(TokenList) == 1: + self._Macros[TokenList[0]] = '' + else: + # keep the macro definition for later use + self._Macros[TokenList[0]] = ReplaceMacro(TokenList[1], self._Macros, False) return TokenList[0], self._Macros[TokenList[0]] 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): |