]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/MetaFileTable.py
BaseTools: use predefined constants instead of local strings
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / MetaFileTable.py
index 449e56efcc16408b89faafe41cbb8c906ca760da..3c8dae0e622faf550e8abb72a82eaa55b6e0444c 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to create/update/query/erase a meta file table\r
 #\r
-# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -23,6 +23,7 @@ from MetaDataTable import Table, TableFile
 from MetaDataTable import ConvertToSqlString\r
 from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \\r
                                       MODEL_FILE_OTHERS\r
+from Common.DataType import *\r
 \r
 class MetaFileTable(Table):\r
     # TRICK: use file ID as the part before '.'\r
@@ -108,7 +109,7 @@ class ModuleTable(MetaFileTable):
     # @param EndColumn:      EndColumn of a Inf item\r
     # @param Enabled:        If this item enabled\r
     #\r
-    def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON',\r
+    def Insert(self, Model, Value1, Value2, Value3, Scope1=TAB_ARCH_COMMON, Scope2=TAB_COMMON,\r
                BelongsToItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0):\r
         (Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))\r
         return Table.Insert(\r
@@ -139,11 +140,11 @@ class ModuleTable(MetaFileTable):
         ConditionString = "Model=%s AND Enabled>=0" % Model\r
         ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"\r
 \r
-        if Arch != None and Arch != 'COMMON':\r
+        if Arch is not None and Arch != TAB_ARCH_COMMON:\r
             ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch\r
-        if Platform != None and Platform != 'COMMON':\r
+        if Platform is not None and Platform != TAB_COMMON:\r
             ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Platform\r
-        if BelongsToItem != None:\r
+        if BelongsToItem is not None:\r
             ConditionString += " AND BelongsToItem=%s" % BelongsToItem\r
 \r
         SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)\r
@@ -190,7 +191,7 @@ class PackageTable(MetaFileTable):
     # @param EndColumn:      EndColumn of a Dec item\r
     # @param Enabled:        If this item enabled\r
     #\r
-    def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON',\r
+    def Insert(self, Model, Value1, Value2, Value3, Scope1=TAB_ARCH_COMMON, Scope2=TAB_COMMON,\r
                BelongsToItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0):\r
         (Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))\r
         return Table.Insert(\r
@@ -218,9 +219,9 @@ class PackageTable(MetaFileTable):
     #\r
     def Query(self, Model, Arch=None):\r
         ConditionString = "Model=%s AND Enabled>=0" % Model\r
-        ValueString = "Value1,Value2,Value3,Scope1,ID,StartLine"\r
+        ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"\r
 \r
-        if Arch != None and Arch != 'COMMON':\r
+        if Arch is not None and Arch != TAB_ARCH_COMMON:\r
             ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch\r
 \r
         SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)\r
@@ -271,6 +272,7 @@ class PlatformTable(MetaFileTable):
         Value3 TEXT,\r
         Scope1 TEXT,\r
         Scope2 TEXT,\r
+        Scope3 TEXT,\r
         BelongsToItem REAL NOT NULL,\r
         FromItem REAL NOT NULL,\r
         StartLine INTEGER NOT NULL,\r
@@ -280,7 +282,7 @@ class PlatformTable(MetaFileTable):
         Enabled INTEGER DEFAULT 0\r
         '''\r
     # used as table end flag, in case the changes to database is not committed to db file\r
-    _DUMMY_ = "-1, -1, '====', '====', '====', '====', '====', -1, -1, -1, -1, -1, -1, -1"\r
+    _DUMMY_ = "-1, -1, '====', '====', '====', '====', '====','====', -1, -1, -1, -1, -1, -1, -1"\r
 \r
     ## Constructor\r
     def __init__(self, Cursor, MetaFile, Temporary):\r
@@ -304,9 +306,9 @@ class PlatformTable(MetaFileTable):
     # @param EndColumn:      EndColumn of a Dsc item\r
     # @param Enabled:        If this item enabled\r
     #\r
-    def Insert(self, Model, Value1, Value2, Value3, Scope1='COMMON', Scope2='COMMON', BelongsToItem=-1, \r
+    def Insert(self, Model, Value1, Value2, Value3, Scope1=TAB_ARCH_COMMON, Scope2=TAB_COMMON, Scope3=TAB_DEFAULT_STORES_DEFAULT,BelongsToItem=-1,\r
                FromItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=1):\r
-        (Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))\r
+        (Value1, Value2, Value3, Scope1, Scope2,Scope3) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2,Scope3))\r
         return Table.Insert(\r
                         self, \r
                         Model, \r
@@ -315,6 +317,7 @@ class PlatformTable(MetaFileTable):
                         Value3, \r
                         Scope1, \r
                         Scope2,\r
+                        Scope3,\r
                         BelongsToItem, \r
                         FromItem,\r
                         StartLine, \r
@@ -336,19 +339,25 @@ class PlatformTable(MetaFileTable):
     #\r
     def Query(self, Model, Scope1=None, Scope2=None, BelongsToItem=None, FromItem=None):\r
         ConditionString = "Model=%s AND Enabled>0" % Model\r
-        ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"\r
+        ValueString = "Value1,Value2,Value3,Scope1,Scope2,Scope3,ID,StartLine"\r
 \r
-        if Scope1 != None and Scope1 != 'COMMON':\r
+        if Scope1 is not None and Scope1 != TAB_ARCH_COMMON:\r
             ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Scope1\r
-        if Scope2 != None and Scope2 != 'COMMON':\r
-            ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Scope2\r
+        if Scope2 is not None and Scope2 != TAB_COMMON:\r
+            # Cover the case that CodeBase is 'COMMON' for BuildOptions section\r
+            if '.' in Scope2:\r
+                Index = Scope2.index('.')\r
+                NewScope = TAB_COMMON + Scope2[Index:]\r
+                ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT' OR Scope2='%s')" % (Scope2, NewScope)\r
+            else:\r
+                ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Scope2\r
 \r
-        if BelongsToItem != None:\r
+        if BelongsToItem is not None:\r
             ConditionString += " AND BelongsToItem=%s" % BelongsToItem\r
         else:\r
             ConditionString += " AND BelongsToItem<0"\r
 \r
-        if FromItem != None:\r
+        if FromItem is not None:\r
             ConditionString += " AND FromItem=%s" % FromItem\r
 \r
         SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)\r