git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@251 7335b...
authorhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 3 Jul 2007 02:58:10 +0000 (02:58 +0000)
committerhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 3 Jul 2007 02:58:10 +0000 (02:58 +0000)
Source/Python/StrGather.py
Source/Python/UniClassObject.py

index 2533f70..68a3e99 100644 (file)
@@ -257,10 +257,20 @@ def WriteLine(Target, Item):
 if __name__ == '__main__':\r
     print 'start'\r
     \r
-    #UniFileList = ['C:\\Tiano\\Edk\\Sample\\Universal\\UserInterface\\SetupBrowser\\Dxe\\DriverSample\\inventorystrings.uni', 'C:\\Tiano\\Edk\\Sample\\Universal\\UserInterface\\SetupBrowser\\Dxe\\DriverSample\\VfrStrings.uni']\r
-    #IncludeList = ['C:\\Tiano\\Edk\\Sample\\Universal\\UserInterface\\SetupBrowser\\Dxe\\DriverSample']\r
-    UniFileList = ['C:\\Tiano\\Edk\\Sample\\Universal\\UserInterface\\SetupBrowser\\Dxe\\SetupBrowserStr.uni']\r
-    IncludeList = ['C:\\Tiano\\Edk\\Sample\\Universal\\UserInterface\\SetupBrowser\\Dxe']\r
+    UniFileList = ['C:\\Tiano\\Edk\\Sample\\Universal\\UserInterface\\SetupBrowser\\Dxe\\DriverSample\\inventorystrings.uni', 'C:\\Tiano\\Edk\\Sample\\Universal\\UserInterface\\SetupBrowser\\Dxe\\DriverSample\\VfrStrings.uni']\r
+    IncludeList = ['C:\\Tiano\\Edk\\Sample\\Universal\\UserInterface\\SetupBrowser\\Dxe\\DriverSample']\r
+#    UniFileList = (['C:\\Tiano\\Edk\\Sample\\Platform\\Generic\\Dxe\\PlatformBds\\DeviceMngr\\DeviceManagerStrings.uni'])\r
+#    UniFileList.append('C:\\Tiano\\Edk\\Sample\\Platform\\Generic\\Dxe\\PlatformBds\\BootMngr\\BootManagerStrings.uni')\r
+#    UniFileList.append('C:\\Tiano\\Edk\\Sample\\Platform\\Generic\\Dxe\\PlatformBds\\Strings.uni')\r
+#    UniFileList.append('C:\\Tiano\\Edk\\Sample\\Platform\\Generic\\Dxe\\PlatformBds\\FrontPageStrings.uni')\r
+#\r
+#    IncludeList = ['C:\\Tiano\\Edk\\Sample\\Platform\\Generic\\']\r
+#    IncludeList.append('C:\\Tiano\\Edk\\Sample\\Platform\\Generic\\Dxe\\PlatformBds\\BootMngr\\')\r
+#    IncludeList.append('C:\\Tiano\\Edk\\Sample\\Platform\\Generic\\Dxe\\')\r
+#    IncludeList.append('C:\\Tiano\\Edk\\Sample\\Platform\\Generic\\Dxe\\PlatformBds\\')\r
+#    IncludeList.append('C:\\Tiano\\Edk\\Sample\\Platform\\Generic\\Dxe\\PlatformBds\\DeviceMngr\\')\r
+   \r
+    \r
     SkipList = ['.inf', '.uni']\r
     BaseName = 'SetupBrowser'\r
     (h, c) = GetStringFiles(UniFileList, IncludeList, SkipList, BaseName)\r
index 6ad01c3..71363b4 100644 (file)
@@ -78,8 +78,12 @@ class UniFileClassObject(object):
             self.LoadUniFiles(FileList)\r
 \r
     def GetLangDef(self, Line):\r
-        LangName = Line[Line.find(u'#langdef ') + len(u'#langdef ') : Line.find(u' ', len(u'#langdef '))]\r
-        LangPrintName = Line[Line.find(u'\"') + len(u'\"') : Line.rfind(u'\"')]\r
+        Lang = Line.split()\r
+        if len(Lang) != 3:\r
+            EdkLogger.error("""Wrong language definition '""" + Line + """' which should be '#langdef eng "English"'""")\r
+        else:\r
+            LangName = Lang[1]\r
+            LangPrintName = Lang[2][1:-1]\r
 \r
         if [LangName, LangPrintName] not in self.LanguageDef:\r
             self.LanguageDef.append([LangName, LangPrintName])\r
@@ -97,16 +101,20 @@ class UniFileClassObject(object):
         Language = ''\r
         Value = ''\r
         \r
-        Name = Item[Item.find(u'#string ') + len(u'#string ') :Item.find(u' ', len(u'#string '))]\r
+        Name = Item.split()[1]\r
         LanguageList = Item.split(u'#language ')\r
         for IndexI in range(len(LanguageList)):\r
             if IndexI == 0:\r
                 continue\r
             else:\r
-                Language = LanguageList[IndexI][ : LanguageList[IndexI].find(u' ')]\r
+                Language = LanguageList[IndexI].split()[0]\r
                 Value = LanguageList[IndexI][LanguageList[IndexI].find(u'\"') + len(u'\"') : LanguageList[IndexI].rfind(u'\"')].replace(u'\r\n', u'')\r
                 self.AddStringToList(Name, Language, Value)\r
     \r
+    def GetIncludeFile(self, Item, Dir):\r
+        FileName = Item[Item.find(u'#include ') + len(u'#include ') :Item.find(u' ', len(u'#include '))][1:-1]\r
+        self.LoadUniFile(FileName)\r
+    \r
     def PreProcess(self, FileIn):\r
         Lines = []\r
         #\r
@@ -118,7 +126,8 @@ class UniFileClassObject(object):
             FileIn[Index] = FileIn[Index].replace(u'/langdef', u'#langdef')\r
             FileIn[Index] = FileIn[Index].replace(u'/string', u'#string')\r
             FileIn[Index] = FileIn[Index].replace(u'/language', u'#language')\r
-            \r
+            FileIn[Index] = FileIn[Index].replace(u'/include', u'#include')\r
+                        \r
             FileIn[Index] = FileIn[Index].replace(UNICODE_WIDE_CHAR, WIDE_CHAR)\r
             FileIn[Index] = FileIn[Index].replace(UNICODE_NARROW_CHAR, NARROW_CHAR)\r
             FileIn[Index] = FileIn[Index].replace(UNICODE_NON_BREAKING_CHAR, NON_BREAKING_CHAR)\r
@@ -140,6 +149,7 @@ class UniFileClassObject(object):
     def LoadUniFile(self, File = None):\r
         if File != None:\r
             if os.path.exists(File) and os.path.isfile(File):\r
+                Dir = File.rsplit('\\', 1)[0]\r
                 FileIn = codecs.open(File, mode='rb', encoding='utf-16').readlines()             \r
                 \r
                 #\r
@@ -170,10 +180,13 @@ class UniFileClassObject(object):
                         self.GetLangDef(Line)\r
                         continue\r
                     \r
+#                    if Line.find(u'#include ') >= 0:\r
+#                        self.GetIncludeFile(Line, Dir)\r
+#                        continue\r
+                    \r
                     Name = ''\r
                     Language = ''\r
                     Value = ''\r
-                    \r
                     #\r
                     # Get string def information format 1 as below\r
                     #\r