1. Add a feature to support handling R8's comment style.
authorhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 29 Feb 2008 06:59:19 +0000 (06:59 +0000)
committerhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Fri, 29 Feb 2008 06:59:19 +0000 (06:59 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1038 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Common/DataType.py
Source/Python/Common/DecClassObject.py
Source/Python/Common/DscClassObject.py
Source/Python/Common/InfClassObject.py
Source/Python/Common/String.py

index 778dde5..0f11c0f 100644 (file)
@@ -14,6 +14,9 @@
 # Common Definitions\r
 #\r
 TAB_SPLIT = '.'\r
+TAB_COMMENT_R8_START = '/*'\r
+TAB_COMMENT_R8_END = '*/'\r
+TAB_COMMENT_R8_SPLIT = '//'\r
 TAB_COMMENT_SPLIT = '#'\r
 TAB_EQUAL_SPLIT = '='\r
 TAB_VALUE_SPLIT = '|'\r
index b0e71ad..587ff8e 100644 (file)
@@ -153,20 +153,23 @@ class Dec(DecObject):
         #\r
         # Parse file content\r
         #\r
-        FileContent = open(Filename, 'r').read()\r
-        for Line in FileContent.splitlines():\r
+        IsFindBlockComment = False\r
+        ReservedLine = ''\r
+        for Line in open(Filename, 'r'):\r
             LineNo = LineNo + 1\r
             #\r
-            # Reomve spaces in head and tail\r
+            # Remove comment block\r
             #\r
-            Line = Line.strip()\r
-            \r
-            #\r
-            # Ignore comments\r
-            #\r
-            if Line.startswith(TAB_COMMENT_SPLIT):\r
+            if Line.find(TAB_COMMENT_R8_START) > -1:\r
+                ReservedLine = GetSplitValueList(Line, TAB_COMMENT_R8_START, 1)[0]\r
+                IsFindBlockComment = True\r
+            if Line.find(TAB_COMMENT_R8_END) > -1:\r
+                Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_R8_END, 1)[1]\r
+                ReservedLine = ''\r
+                IsFindBlockComment = False\r
+            if IsFindBlockComment:\r
                 continue\r
-            \r
+\r
             #\r
             # Remove comments at tail and remove spaces again\r
             #\r
index 71c2c34..ac2abb1 100755 (executable)
@@ -997,20 +997,23 @@ class Dsc(DscObject):
         #\r
         # Parse file content\r
         #\r
-        FileContent = open(Filename, 'r').read()\r
-        for Line in FileContent.splitlines():\r
+        IsFindBlockComment = False\r
+        ReservedLine = ''\r
+        for Line in open(Filename, 'r'):\r
             LineNo = LineNo + 1\r
             #\r
-            # Reomve spaces in head and tail\r
+            # Remove comment block\r
             #\r
-            Line = Line.strip()\r
-            \r
-            #\r
-            # Ignore comments\r
-            #\r
-            if Line.startswith(TAB_COMMENT_SPLIT):\r
+            if Line.find(TAB_COMMENT_R8_START) > -1:\r
+                ReservedLine = GetSplitValueList(Line, TAB_COMMENT_R8_START, 1)[0]\r
+                IsFindBlockComment = True\r
+            if Line.find(TAB_COMMENT_R8_END) > -1:\r
+                Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_R8_END, 1)[1]\r
+                ReservedLine = ''\r
+                IsFindBlockComment = False\r
+            if IsFindBlockComment:\r
                 continue\r
-            \r
+\r
             #\r
             # Remove comments at tail and remove spaces again\r
             #\r
index c32f277..799f9a8 100755 (executable)
@@ -341,8 +341,23 @@ class Inf(InfObject):
         #\r
         # Parse file content\r
         #\r
+        IsFindBlockComment = False\r
+        ReservedLine = ''\r
         for Line in open(Filename, 'r'):\r
             LineNo = LineNo + 1\r
+            #\r
+            # Remove comment block\r
+            #\r
+            if Line.find(TAB_COMMENT_R8_START) > -1:\r
+                ReservedLine = GetSplitValueList(Line, TAB_COMMENT_R8_START, 1)[0]\r
+                IsFindBlockComment = True\r
+            if Line.find(TAB_COMMENT_R8_END) > -1:\r
+                Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_R8_END, 1)[1]\r
+                ReservedLine = ''\r
+                IsFindBlockComment = False\r
+            if IsFindBlockComment:\r
+                continue\r
+            \r
             #\r
             # Remove comments at tail and remove spaces again\r
             #\r
index a04ae01..8425d3e 100644 (file)
@@ -256,6 +256,10 @@ def CleanString(Line, CommentCharacter = DataType.TAB_COMMENT_SPLIT):
     #\r
     Line = Line.strip();\r
     #\r
+    # Replace R8's comment character\r
+    #\r
+    Line = Line.replace(DataType.TAB_COMMENT_R8_SPLIT, CommentCharacter)\r
+    #\r
     # remove comments\r
     #\r
     Line = Line.split(CommentCharacter, 1)[0];\r