X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FUPT%2FLibrary%2FParserValidate.py;h=028cf9a54f84cc569397ab5bd590a96653618129;hb=06eb35402e456066c86f621e566160967b7740ad;hp=d6b9a096c7894955c48930e7633f1ef7585de75d;hpb=4234283c3acb8c35014acc1546621fbc2621b095;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/UPT/Library/ParserValidate.py b/BaseTools/Source/Python/UPT/Library/ParserValidate.py
index d6b9a096c7..028cf9a54f 100644
--- a/BaseTools/Source/Python/UPT/Library/ParserValidate.py
+++ b/BaseTools/Source/Python/UPT/Library/ParserValidate.py
@@ -1,6 +1,7 @@
## @file ParserValidate.py
+# Functions for parser validation
#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@@ -17,6 +18,7 @@ PaserValidate
import os.path
import re
+import platform
from Library.DataType import MODULE_LIST
from Library.DataType import COMPONENT_TYPE_LIST
@@ -25,6 +27,7 @@ from Library.DataType import TAB_SPACE_SPLIT
from Library.String import GetSplitValueList
from Library.ExpressionValidate import IsValidBareCString
from Library.ExpressionValidate import IsValidFeatureFlagExp
+from Common.MultipleWorkspace import MultipleWorkspace as mws
## __HexDigit() method
#
@@ -234,7 +237,7 @@ def IsValidPath(Path, Root):
Path = os.path.normpath(Path).replace('\\', '/')
Root = os.path.normpath(Root).replace('\\', '/')
- FullPath = os.path.normpath(os.path.join(Root, Path)).replace('\\', '/')
+ FullPath = mws.join(Root, Path)
if not os.path.exists(FullPath):
return False
@@ -281,9 +284,14 @@ def IsValidPath(Path, Root):
# @param Path: path to be checked
#
def IsValidInstallPath(Path):
- if os.path.isabs(Path):
- return False
-
+ if platform.platform().find("Windows") >= 0:
+ if os.path.isabs(Path):
+ return False
+ else:
+ if Path[1:2] == ':':
+ return False
+ if os.path.isabs(Path):
+ return False
if Path.startswith('.'):
return False
@@ -560,7 +568,7 @@ def IsValidPcdValue(PcdValue):
for Char in PcdValue:
if Char == '\n' or Char == '\t' or Char == '\f':
return False
-
+
#
#
#
@@ -576,7 +584,7 @@ def IsValidPcdValue(PcdValue):
if IsValidHex(PcdValue):
return True
- ReIsValidIntegerSingle = re.compile(r"^\s*[0-9]\s*$", re.DOTALL)
+ ReIsValidIntegerSingle = re.compile(r"^\s*[0-9]\s*$", re.DOTALL)
if ReIsValidIntegerSingle.match(PcdValue) != None:
return True
@@ -584,7 +592,6 @@ def IsValidPcdValue(PcdValue):
if ReIsValidIntegerMulti.match(PcdValue) != None:
return True
-
#
# ::= {} {} {"$(" ")"}
# ::= {} {}
@@ -715,3 +722,12 @@ def IsValidUserId(UserId):
return False
return True
+#
+# Check if a UTF16-LE file has a BOM header
+#
+def CheckUTF16FileHeader(File):
+ FileIn = open(File, 'rb').read(2)
+ if FileIn != '\xff\xfe':
+ return False
+
+ return True