]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/MetaFileTable.py
BaseTools: support private package definition
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / MetaFileTable.py
index 088a118de1a1e609864cd9cd99669984d5ded393..ab1807046e49b25087f7105139741b6c8253319d 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, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2016, 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
@@ -17,6 +17,7 @@
 import uuid\r
 \r
 import Common.EdkLogger as EdkLogger\r
+from Common.BuildToolError import FORMAT_INVALID\r
 \r
 from MetaDataTable import Table, TableFile\r
 from MetaDataTable import ConvertToSqlString\r
@@ -134,7 +135,7 @@ class ModuleTable(MetaFileTable):
     #\r
     # @retval:       A recordSet of all found records \r
     #\r
-    def Query(self, Model, Arch=None, Platform=None):\r
+    def Query(self, Model, Arch=None, Platform=None, BelongsToItem=None):\r
         ConditionString = "Model=%s AND Enabled>=0" % Model\r
         ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"\r
 \r
@@ -142,6 +143,8 @@ class ModuleTable(MetaFileTable):
             ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch\r
         if Platform != None and Platform != 'COMMON':\r
             ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Platform\r
+        if BelongsToItem != None:\r
+            ConditionString += " AND BelongsToItem=%s" % BelongsToItem\r
 \r
         SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)\r
         return self.Exec(SqlCommand)\r
@@ -215,7 +218,7 @@ 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
             ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch\r
@@ -223,6 +226,41 @@ class PackageTable(MetaFileTable):
         SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)\r
         return self.Exec(SqlCommand)\r
 \r
+    def GetValidExpression(self, TokenSpaceGuid, PcdCName):\r
+        SqlCommand = "select Value1,StartLine from %s WHERE Value2='%s' and Value3='%s'" % (self.Table, TokenSpaceGuid, PcdCName)\r
+        self.Cur.execute(SqlCommand)\r
+        validateranges = []\r
+        validlists = []\r
+        expressions = []\r
+        try:\r
+            for row in self.Cur:\r
+                comment = row[0]\r
+                \r
+                LineNum = row[1]\r
+                comment = comment.strip("#")\r
+                comment = comment.strip()\r
+                oricomment = comment\r
+                if comment.startswith("@ValidRange"):\r
+                    comment = comment.replace("@ValidRange", "", 1)\r
+                    validateranges.append(comment.split("|")[1].strip())\r
+                if comment.startswith("@ValidList"):\r
+                    comment = comment.replace("@ValidList", "", 1)\r
+                    validlists.append(comment.split("|")[1].strip())\r
+                if comment.startswith("@Expression"):\r
+                    comment = comment.replace("@Expression", "", 1)\r
+                    expressions.append(comment.split("|")[1].strip())\r
+        except Exception, Exc:\r
+            ValidType = ""\r
+            if oricomment.startswith("@ValidRange"):\r
+                ValidType = "@ValidRange"\r
+            if oricomment.startswith("@ValidList"):\r
+                ValidType = "@ValidList"\r
+            if oricomment.startswith("@Expression"):\r
+                ValidType = "@Expression"\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "The syntax for %s of PCD %s.%s is incorrect" % (ValidType,TokenSpaceGuid, PcdCName),\r
+                            ExtraData=oricomment,File=self.MetaFile, Line=LineNum)\r
+            return set(), set(), set()\r
+        return set(validateranges), set(validlists), set(expressions)\r
 ## Python class representation of table storing platform data\r
 class PlatformTable(MetaFileTable):\r
     _COLUMN_ = '''\r