]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
BaseTools: Use absolute import in Workspace
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / WorkspaceDatabase.py
index a3407d113e0f437dbb2b6a5af65cd65d1a3969d8..e2f373745fc0c370ee0bc82d7c1c042e7f56f7f4 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to create a database used by build tool\r
 #\r
-# Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 ##\r
 # Import Modules\r
 #\r
+from __future__ import absolute_import\r
 import sqlite3\r
-from Common.String import *\r
+from Common.StringUtils import *\r
 from Common.DataType import *\r
 from Common.Misc import *\r
 from types import *\r
 \r
-from MetaDataTable import *\r
-from MetaFileTable import *\r
-from MetaFileParser import *\r
+from .MetaDataTable import *\r
+from .MetaFileTable import *\r
+from .MetaFileParser import *\r
 \r
 from Workspace.DecBuildData import DecBuildData\r
 from Workspace.DscBuildData import DscBuildData\r
@@ -114,8 +115,8 @@ class WorkspaceDatabase(object):
 \r
             # get the parser ready for this file\r
             MetaFile = self._FILE_PARSER_[FileType](\r
-                                FilePath, \r
-                                FileType, \r
+                                FilePath,\r
+                                FileType,\r
                                 Arch,\r
                                 MetaFileStorage(self.WorkspaceDb.Cur, FilePath, FileType)\r
                                 )\r
@@ -162,7 +163,7 @@ class WorkspaceDatabase(object):
             # remove db file in case inconsistency between db and file in file system\r
             if self._CheckWhetherDbNeedRenew(RenewDb, DbPath):\r
                 os.remove(DbPath)\r
-        \r
+\r
         # create db with optimized parameters\r
         self.Conn = sqlite3.connect(DbPath, isolation_level='DEFERRED')\r
         self.Conn.execute("PRAGMA synchronous=OFF")\r
@@ -199,11 +200,11 @@ class WorkspaceDatabase(object):
     def _CheckWhetherDbNeedRenew (self, force, DbPath):\r
         # if database does not exist, we need do nothing\r
         if not os.path.exists(DbPath): return False\r
-            \r
+\r
         # if user force to renew database, then not check whether database is out of date\r
         if force: return True\r
-        \r
-        #    \r
+\r
+        #\r
         # Check the time of last modified source file or build.exe\r
         # if is newer than time of database, then database need to be re-created.\r
         #\r
@@ -214,18 +215,18 @@ class WorkspaceDatabase(object):
         else:\r
             curPath  = os.path.dirname(__file__) # curPath is the path of WorkspaceDatabase.py\r
             rootPath = os.path.split(curPath)[0] # rootPath is root path of python source, such as /BaseTools/Source/Python\r
-            if rootPath == "" or rootPath == None:\r
+            if rootPath == "" or rootPath is None:\r
                 EdkLogger.verbose("\nFail to find the root path of build.exe or python sources, so can not \\r
 determine whether database file is out of date!\n")\r
-        \r
+\r
             # walk the root path of source or build's binary to get the time last modified.\r
-        \r
+\r
             for root, dirs, files in os.walk (rootPath):\r
                 for dir in dirs:\r
-                    # bypass source control folder \r
+                    # bypass source control folder\r
                     if dir.lower() in [".svn", "_svn", "cvs"]:\r
                         dirs.remove(dir)\r
-                        \r
+\r
                 for file in files:\r
                     ext = os.path.splitext(file)[1]\r
                     if ext.lower() == ".py":            # only check .py files\r
@@ -235,9 +236,9 @@ determine whether database file is out of date!\n")
         if timeOfToolModified > os.stat(DbPath).st_mtime:\r
             EdkLogger.verbose("\nWorkspace database is out of data!")\r
             return True\r
-            \r
+\r
         return False\r
-            \r
+\r
     ## Initialize build database\r
     def InitDatabase(self):\r
         EdkLogger.verbose("\nInitialize build database started ...")\r
@@ -280,7 +281,7 @@ determine whether database file is out of date!\n")
     def GetPackageList(self, Platform, Arch, TargetName, ToolChainTag):\r
         self.Platform = Platform\r
         PackageList = []\r
-        Pa = self.BuildObject[self.Platform, Arch]\r
+        Pa = self.BuildObject[self.Platform, Arch, TargetName, ToolChainTag]\r
         #\r
         # Get Package related to Modules\r
         #\r
@@ -305,16 +306,16 @@ determine whether database file is out of date!\n")
         PlatformList = []\r
         for PlatformFile in self.TblFile.GetFileList(MODEL_FILE_DSC):\r
             try:\r
-                Platform = self.BuildObject[PathClass(PlatformFile), 'COMMON']\r
+                Platform = self.BuildObject[PathClass(PlatformFile), TAB_COMMON]\r
             except:\r
                 Platform = None\r
-            if Platform != None:\r
+            if Platform is not None:\r
                 PlatformList.append(Platform)\r
         return PlatformList\r
 \r
     def _MapPlatform(self, Dscfile):\r
-        Platform = self.BuildObject[PathClass(Dscfile), 'COMMON']\r
-        if Platform == None:\r
+        Platform = self.BuildObject[PathClass(Dscfile), TAB_COMMON]\r
+        if Platform is None:\r
             EdkLogger.error('build', PARSER_ERROR, "Failed to parser DSC file: %s" % Dscfile)\r
         return Platform\r
 \r