1. Fix tracker 200972
authorhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 4 Mar 2008 06:18:41 +0000 (06:18 +0000)
committerhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 4 Mar 2008 06:18:41 +0000 (06:18 +0000)
2. Add a switch in DEC/INF/DSC parser to decide whether update the records of database.

git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1044 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Common/DecClassObject.py
Source/Python/Common/DscClassObject.py
Source/Python/Common/InfClassObject.py
Source/Python/CommonDataClass/ModuleClass.py

index 587ff8e..f4ff414 100644 (file)
@@ -82,12 +82,13 @@ class DecObject(object):
 # @var KeyList:             To store value for KeyList, a list for all Keys used in Dec\r
 #\r
 class Dec(DecObject):\r
-    def __init__(self, Filename = None, IsMergeAllArches = False, IsToPackage = False, WorkspaceDir = None, Database = None, SupArchList = DataType.ARCH_LIST):\r
+    def __init__(self, Filename = None, IsToDatabase = False, IsToPackage = False, WorkspaceDir = None, Database = None, SupArchList = DataType.ARCH_LIST):\r
         self.Identification = Identification()\r
         self.Package = PackageClass()\r
         self.UserExtensions = ''\r
         self.WorkspaceDir = WorkspaceDir\r
         self.SupArchList = SupArchList\r
+        self.IsToDatabase = IsToDatabase\r
         \r
         self.Cur = Database.Cur\r
         self.TblFile = Database.TblFile\r
index ac2abb1..0da225b 100755 (executable)
@@ -91,11 +91,12 @@ class DscObject(object):
 class Dsc(DscObject):\r
     _NullClassIndex = 0\r
 \r
-    def __init__(self, Filename = None, IsMergeAllArches = False, IsToPlatform = False, WorkspaceDir = None, Database = None):\r
+    def __init__(self, Filename = None, IsToDatabase = False, IsToPlatform = False, WorkspaceDir = None, Database = None):\r
         self.Identification = Identification()\r
         self.Platform = PlatformClass()\r
         self.UserExtensions = ''\r
         self.WorkspaceDir = WorkspaceDir\r
+        self.IsToDatabase = IsToDatabase\r
 \r
         self.Cur = Database.Cur\r
         self.TblFile = Database.TblFile\r
@@ -280,9 +281,10 @@ class Dsc(DscObject):
                     #\r
                     # Update to Database\r
                     #\r
-                    #SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'\r
-                    #                where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(Family), ConvertToSqlString2(ToolChain), ConvertToSqlString2(Flag), Record[3])\r
-                    #self.TblDsc.Exec(SqlCommand)\r
+                    if self.IsToDatabase:\r
+                        SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'\r
+                                        where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(Family), ConvertToSqlString2(ToolChain), ConvertToSqlString2(Flag), Record[3])\r
+                        self.TblDsc.Exec(SqlCommand)\r
 \r
         for Key in BuildOptions.keys():\r
             BuildOption = BuildOptionClass(Key[0], Key[1], Key[2])\r
@@ -340,9 +342,10 @@ class Dsc(DscObject):
                         #\r
                         # Update to Database\r
                         #\r
-                        #SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'\r
-                        #                where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(List[0]), ConvertToSqlString2(List[1]), Record[3])\r
-                        #self.TblDsc.Exec(SqlCommand)\r
+                        if self.IsToDatabase:\r
+                            SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'\r
+                                            where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(List[0]), ConvertToSqlString2(List[1]), Record[3])\r
+                            self.TblDsc.Exec(SqlCommand)\r
     \r
     ## GenLibraries\r
     #\r
@@ -425,9 +428,10 @@ class Dsc(DscObject):
                     #\r
                     # Update to Database\r
                     #\r
-                    #SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'\r
-                    #                where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(LibClassName), ConvertToSqlString2(LibClassIns), ConvertToSqlString2(SupModelList), Record[3])\r
-                    #self.TblDsc.Exec(SqlCommand)\r
+                    if self.IsToDatabase:\r
+                        SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'\r
+                                        where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(LibClassName), ConvertToSqlString2(LibClassIns), ConvertToSqlString2(SupModelList), Record[3])\r
+                        self.TblDsc.Exec(SqlCommand)\r
 \r
         for Key in LibraryClasses.keys():\r
             Library = PlatformLibraryClass()\r
@@ -1378,7 +1382,7 @@ if __name__ == '__main__':
     Db = Database.Database(DATABASE_PATH)\r
     Db.InitDatabase()\r
     \r
-    P = Dsc(os.path.normpath(F), False, True, W, Db)\r
+    P = Dsc(os.path.normpath(F), True, True, W, Db)\r
     P.ShowPlatform()\r
     \r
     Db.Close()\r
index 799f9a8..b82122a 100755 (executable)
@@ -101,8 +101,8 @@ class InfHeader(ModuleHeaderClass):
         TAB_INF_DEFINES_FFS_EXT                     : "FfsExt",\r
         TAB_INF_DEFINES_FV_EXT                      : "FvExt",\r
         TAB_INF_DEFINES_SOURCE_FV                   : "SourceFv",\r
-        TAB_INF_DEFINES_VERSION_NUMBER              : "Version",\r
-        TAB_INF_DEFINES_VERSION_STRING              : "Version",\r
+        TAB_INF_DEFINES_VERSION_NUMBER              : "VersionNumber",\r
+        TAB_INF_DEFINES_VERSION_STRING              : "VersionString",\r
         TAB_INF_DEFINES_VERSION                     : "Version",\r
         TAB_INF_DEFINES_PCD_IS_DRIVER               : "PcdIsDriver",\r
         TAB_INF_DEFINES_TIANO_R8_FLASHMAP_H         : "TianoR8FlashMap_h",\r
@@ -120,6 +120,8 @@ class InfHeader(ModuleHeaderClass):
 \r
     def __init__(self):\r
         ModuleHeaderClass.__init__(self)\r
+        self.VersionNumber = ''\r
+        self.VersionString = ''\r
         #print self.__dict__\r
     def __setitem__(self, key, value):\r
         self.__dict__[self._Mapping_[key]] = value\r
@@ -162,12 +164,13 @@ class InfObject(object):
 # @var KeyList:             To store value for KeyList, a list for all Keys used in Inf\r
 #\r
 class Inf(InfObject):\r
-    def __init__(self, Filename = None, IsMergeAllArches = False, IsToModule = False, WorkspaceDir = None, Database = None, SupArchList = DataType.ARCH_LIST):\r
+    def __init__(self, Filename = None, IsToDatabase = False, IsToModule = False, WorkspaceDir = None, Database = None, SupArchList = DataType.ARCH_LIST):\r
         self.Identification = Identification()\r
         self.Module = ModuleClass()\r
         self.UserExtensions = ''\r
         self.WorkspaceDir = WorkspaceDir\r
         self.SupArchList = SupArchList\r
+        self.IsToDatabase = IsToDatabase\r
         \r
         self.Cur = Database.Cur\r
         self.TblFile = Database.TblFile\r
@@ -602,6 +605,29 @@ class Inf(InfObject):
                     else:\r
                         ModuleHeader.Specification[CleanString(List[0])] = CleanString(List[1])\r
             \r
+            #\r
+            # Get version of INF\r
+            #\r
+            if ModuleHeader.InfVersion != "":\r
+                # R9 inf\r
+                VersionNumber = ModuleHeader.VersionNumber\r
+                VersionString = ModuleHeader.VersionString\r
+                if len(VersionNumber) > 0 and len(VersionString) == 0:\r
+                    EdkLogger.warn(2000, 'VERSION_NUMBER depricated; INF file %s should be modified to use VERSION_STRING instead.' % self.Identification.FileFullPath)\r
+                    ModuleHeader.Version = VersionNumber\r
+                if len(VersionString) > 0:\r
+                    if len(VersionNumber) > 0:\r
+                        EdkLogger.warn(2001, 'INF file %s defines both VERSION_NUMBER and VERSION_STRING, using VERSION_STRING' % self.Identification.FileFullPath)\r
+                    ModuleHeader.Version = VersionString\r
+            else:\r
+                # R8 inf\r
+                ModuleHeader.InfVersion = "0x00010000"\r
+                if ModuleHeader.ComponentType in gComponentType2ModuleType:\r
+                    ModuleHeader.ModuleType = gComponentType2ModuleType[ModuleHeader.ComponentType]\r
+                elif ModuleHeader.ComponentType != '':\r
+                    EdkLogger.error("Parser", PARSER_ERROR, "Unsupported R8 component type [%s]" % ModuleHeader.ComponentType,\r
+                                    ExtraData=File)\r
+                \r
             self.Module.Header[Arch] = ModuleHeader\r
     \r
     \r
index 6464bd1..e57ccb5 100755 (executable)
@@ -49,6 +49,7 @@ from CommonClass import *
 # @var CustomMakefile:           To store value for CustomMakefile, it is a set structure as\r
 #                                { Family : Filename, ... }\r
 # @var Shadow:                   To store value for Shadow\r
+# @var MacroDefines              To store the defined macros\r
 #\r
 class ModuleHeaderClass(IdentificationClass, CommonHeaderClass, DefineClass):\r
     def __init__(self):\r