]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Parser/InfParserMisc.py
BaseTools/UPT: Update the import statement to use StringUtils
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Parser / InfParserMisc.py
index 7058e69da1c1a08e5e5cb1d8e78169f1b70fc4f9..df32225aff039a7cb6bd3dcee7270404499e6ec7 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file contained the miscellaneous functions for INF parser \r
 #\r
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials are licensed and made available \r
 # under the terms and conditions of the BSD License which accompanies this \r
@@ -25,8 +25,8 @@ import re
 from Library import DataType as DT\r
 \r
 \r
-from Library.String import gMACRO_PATTERN\r
-from Library.String import ReplaceMacro\r
+from Library.StringUtils import gMACRO_PATTERN\r
+from Library.StringUtils import ReplaceMacro\r
 from Object.Parser.InfMisc import ErrorInInf\r
 from Logger.StringTable import ERR_MARCO_DEFINITION_MISS_ERROR\r
 \r
@@ -73,15 +73,19 @@ gINF_SECTION_DEF = {
 # @param Flag          If the flag set to True, need to skip macros in a quoted string \r
 #\r
 def InfExpandMacro(Content, LineInfo, GlobalMacros=None, SectionMacros=None, Flag=False):\r
-    if GlobalMacros == None:\r
+    if GlobalMacros is None:\r
         GlobalMacros = {}\r
-    if SectionMacros == None:\r
+    if SectionMacros is None:\r
         SectionMacros = {}\r
     \r
     FileName = LineInfo[0]\r
     LineContent = LineInfo[1]\r
     LineNo = LineInfo[2]\r
     \r
+    # Don't expand macros in comments\r
+    if LineContent.strip().startswith("#"):\r
+        return Content\r
+\r
     NewLineInfo = (FileName, LineNo, LineContent)\r
     \r
     #\r