summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/Common
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-10-11 06:26:52 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-10-11 06:26:52 +0000
commit08dd311f5dc735c595d39faf2e6f7e2810bb79a9 (patch)
treeeb384e3139391ac0dabc69e40b4605d9d7315342 /BaseTools/Source/Python/Common
parentd69bf66dc1ad8143260dcb8e095d7ed91b211dd7 (diff)
downloadedk2-platforms-08dd311f5dc735c595d39faf2e6f7e2810bb79a9.tar.xz
Sync EDKII BaseTools to BaseTools project r2065.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10915 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/Common')
-rw-r--r--BaseTools/Source/Python/Common/BuildToolError.py4
-rw-r--r--BaseTools/Source/Python/Common/DataType.py2
-rw-r--r--BaseTools/Source/Python/Common/Dictionary.py62
-rw-r--r--BaseTools/Source/Python/Common/String.py31
-rw-r--r--BaseTools/Source/Python/Common/TargetTxtClassObject.py9
-rw-r--r--BaseTools/Source/Python/Common/ToolDefClassObject.py2
-rw-r--r--BaseTools/Source/Python/Common/VpdInfoFile.py23
7 files changed, 75 insertions, 58 deletions
diff --git a/BaseTools/Source/Python/Common/BuildToolError.py b/BaseTools/Source/Python/Common/BuildToolError.py
index 9986ba2b0d..b5dc3712e0 100644
--- a/BaseTools/Source/Python/Common/BuildToolError.py
+++ b/BaseTools/Source/Python/Common/BuildToolError.py
@@ -1,7 +1,7 @@
## @file
# Standardized Error Hanlding infrastructures.
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -125,7 +125,7 @@ gErrorMessage = {
RESOURCE_FULL : "Full",
RESOURCE_OVERFLOW : "Overflow",
RESOURCE_UNDERRUN : "Underrun",
- RESOURCE_UNKNOWN_ERROR : "Unkown error",
+ RESOURCE_UNKNOWN_ERROR : "Unknown error",
ATTRIBUTE_NOT_AVAILABLE : "Not available",
ATTRIBUTE_GET_FAILURE : "Failed to retrieve",
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 62a23ea773..d9d1774e27 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -355,7 +355,6 @@ TAB_DSC_DEFINES_BS_BASE_ADDRESS = 'BsBaseAddress'
TAB_DSC_DEFINES_RT_BASE_ADDRESS = 'RtBaseAddress'
TAB_DSC_DEFINES_DEFINE = 'DEFINE'
TAB_DSC_DEFINES_VPD_TOOL_GUID = 'VPD_TOOL_GUID'
-TAB_DSC_DEFINES_VPD_FILENAME = 'VPD_FILENAME'
TAB_FIX_LOAD_TOP_MEMORY_ADDRESS = 'FIX_LOAD_TOP_MEMORY_ADDRESS'
#
@@ -364,7 +363,6 @@ TAB_FIX_LOAD_TOP_MEMORY_ADDRESS = 'FIX_LOAD_TOP_MEMORY_ADDRESS'
TAB_TAT_DEFINES_ACTIVE_PLATFORM = 'ACTIVE_PLATFORM'
TAB_TAT_DEFINES_ACTIVE_MODULE = 'ACTIVE_MODULE'
TAB_TAT_DEFINES_TOOL_CHAIN_CONF = 'TOOL_CHAIN_CONF'
-TAB_TAT_DEFINES_MULTIPLE_THREAD = 'MULTIPLE_THREAD'
TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER = 'MAX_CONCURRENT_THREAD_NUMBER'
TAB_TAT_DEFINES_TARGET = 'TARGET'
TAB_TAT_DEFINES_TOOL_CHAIN_TAG = 'TOOL_CHAIN_TAG'
diff --git a/BaseTools/Source/Python/Common/Dictionary.py b/BaseTools/Source/Python/Common/Dictionary.py
index e3460e9891..de3556b892 100644
--- a/BaseTools/Source/Python/Common/Dictionary.py
+++ b/BaseTools/Source/Python/Common/Dictionary.py
@@ -25,26 +25,26 @@ from DataType import *
# @retval 1 Open file failed
#
def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):
- try:
- F = open(FileName,'r')
- Keys = []
- for Line in F:
- if Line.startswith(CommentCharacter):
- continue
- LineList = Line.split(KeySplitCharacter,1)
- if len(LineList) >= 2:
- Key = LineList[0].split()
- if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys:
- if ValueSplitFlag:
- Dictionary[Key[0]] = LineList[1].replace('\\','/').split(ValueSplitCharacter)
- else:
- Dictionary[Key[0]] = LineList[1].strip().replace('\\','/')
- Keys += [Key[0]]
- F.close()
- return 0
- except:
- EdkLogger.info('Open file failed')
- return 1
+ try:
+ F = open(FileName,'r')
+ Keys = []
+ for Line in F:
+ if Line.startswith(CommentCharacter):
+ continue
+ LineList = Line.split(KeySplitCharacter,1)
+ if len(LineList) >= 2:
+ Key = LineList[0].split()
+ if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys:
+ if ValueSplitFlag:
+ Dictionary[Key[0]] = LineList[1].replace('\\','/').split(ValueSplitCharacter)
+ else:
+ Dictionary[Key[0]] = LineList[1].strip().replace('\\','/')
+ Keys += [Key[0]]
+ F.close()
+ return 0
+ except:
+ EdkLogger.info('Open file failed')
+ return 1
## Print the dictionary
#
@@ -53,11 +53,11 @@ def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplit
# @param Dict: The dictionary to be printed
#
def printDict(Dict):
- if Dict != None:
- KeyList = Dict.keys()
- for Key in KeyList:
- if Dict[Key] != '':
- print Key + ' = ' + str(Dict[Key])
+ if Dict != None:
+ KeyList = Dict.keys()
+ for Key in KeyList:
+ if Dict[Key] != '':
+ print Key + ' = ' + str(Dict[Key])
## Print the dictionary
#
@@ -67,9 +67,9 @@ def printDict(Dict):
# @param key: The key of the item to be printed
#
def printList(Key, List):
- if type(List) == type([]):
- if len(List) > 0:
- if key.find(TAB_SPLIT) != -1:
- print "\n" + Key
- for Item in List:
- print Item
+ if type(List) == type([]):
+ if len(List) > 0:
+ if Key.find(TAB_SPLIT) != -1:
+ print "\n" + Key
+ for Item in List:
+ print Item
diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py
index 283e913b3b..195fa5c6ca 100644
--- a/BaseTools/Source/Python/Common/String.py
+++ b/BaseTools/Source/Python/Common/String.py
@@ -23,6 +23,9 @@ import EdkLogger as EdkLogger
from GlobalData import *
from BuildToolError import *
+gHexVerPatt = re.compile('0x[a-f0-9]{4}[a-f0-9]{4}$',re.IGNORECASE)
+gHumanReadableVerPatt = re.compile(r'([1-9][0-9]*|0)\.[0-9]{1,2}$')
+
## GetSplitValueList
#
# Get a value list from a string with multiple values splited with SplitTag
@@ -377,6 +380,34 @@ def GetDefineValue(String, Key, CommentCharacter):
String = CleanString(String)
return String[String.find(Key + ' ') + len(Key + ' ') : ]
+## GetHexVerValue
+#
+# Get a Hex Version Value
+#
+# @param VerString: The version string to be parsed
+#
+#
+# @retval: If VerString is incorrectly formatted, return "None" which will break the build.
+# If VerString is correctly formatted, return a Hex value of the Version Number (0xmmmmnnnn)
+# where mmmm is the major number and nnnn is the adjusted minor number.
+#
+def GetHexVerValue(VerString):
+ VerString = CleanString(VerString)
+
+ if gHumanReadableVerPatt.match(VerString):
+ ValueList = VerString.split('.')
+ Major = ValueList[0]
+ Minor = ValueList[1]
+ if len(Minor) == 1:
+ Minor += '0'
+ DeciValue = (int(Major) << 16) + int(Minor);
+ return "0x%08x"%DeciValue
+ elif gHexVerPatt.match(VerString):
+ return VerString
+ else:
+ return None
+
+
## GetSingleValueOfKeyFromLines
#
# Parse multiple strings as below to get value of each definition line
diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
index fc5d589a59..a7dec65a25 100644
--- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py
+++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
@@ -1,7 +1,7 @@
## @file
# This file is used to define each component of Target.txt file
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -37,7 +37,6 @@ class TargetTxtClassObject(object):
DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM : '',
DataType.TAB_TAT_DEFINES_ACTIVE_MODULE : '',
DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF : '',
- DataType.TAB_TAT_DEFINES_MULTIPLE_THREAD : '',
DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER : '',
DataType.TAB_TAT_DEFINES_TARGET : [],
DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG : [],
@@ -102,12 +101,6 @@ class TargetTxtClassObject(object):
elif Key in [DataType.TAB_TAT_DEFINES_TARGET, DataType.TAB_TAT_DEFINES_TARGET_ARCH, \
DataType.TAB_TAT_DEFINES_TOOL_CHAIN_TAG]:
self.TargetTxtDictionary[Key] = Value.split()
- elif Key == DataType.TAB_TAT_DEFINES_MULTIPLE_THREAD:
- if Value not in ["Enable", "Disable"]:
- EdkLogger.error("build", FORMAT_INVALID, "Invalid setting of [%s]: %s." % (Key, Value),
- ExtraData="\tSetting must be one of [Enable, Disable]",
- File=FileName)
- self.TargetTxtDictionary[Key] = Value
elif Key == DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER:
try:
V = int(Value, 0)
diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py
index 549f76cee9..b5cd5ee435 100644
--- a/BaseTools/Source/Python/Common/ToolDefClassObject.py
+++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py
@@ -23,7 +23,7 @@ from BuildToolError import *
from TargetTxtClassObject import *
##
-# Static vailabes used for pattern
+# Static variables used for pattern
#
gMacroRefPattern = re.compile('(DEF\([^\(\)]+\))')
gEnvRefPattern = re.compile('(ENV\([^\(\)]+\))')
diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py
index 0111744cc0..5f92fa5cdd 100644
--- a/BaseTools/Source/Python/Common/VpdInfoFile.py
+++ b/BaseTools/Source/Python/Common/VpdInfoFile.py
@@ -219,28 +219,23 @@ class VpdInfoFile:
# @param ToolPath The string path name for BPDG tool
# @param VpdFileName The string path name for VPD information guid.txt
#
-def CallExtenalBPDGTool(ToolPath, VpdFilePath, VpdFileName):
+def CallExtenalBPDGTool(ToolPath, VpdFileName):
assert ToolPath != None, "Invalid parameter ToolPath"
- assert VpdFilePath != None and os.path.exists(VpdFilePath), "Invalid parameter VpdFileName"
+ assert VpdFileName != None and os.path.exists(VpdFileName), "Invalid parameter VpdFileName"
- OutputDir = os.path.dirname(VpdFilePath)
- if (VpdFileName == None or VpdFileName == "") :
- FileName = os.path.basename(VpdFilePath)
- BaseName, ext = os.path.splitext(FileName)
- OutputMapFileName = os.path.join(OutputDir, "%s.map" % BaseName)
- OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName)
- else :
- OutputMapFileName = os.path.join(OutputDir, "%s.map" % VpdFileName)
- OutputBinFileName = os.path.join(OutputDir, "%s.bin" % VpdFileName)
+ OutputDir = os.path.dirname(VpdFileName)
+ FileName = os.path.basename(VpdFileName)
+ BaseName, ext = os.path.splitext(FileName)
+ OutputMapFileName = os.path.join(OutputDir, "%s.map" % BaseName)
+ OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName)
try:
PopenObject = subprocess.Popen([ToolPath,
'-o', OutputBinFileName,
'-m', OutputMapFileName,
- '-s',
+ '-q',
'-f',
- '-v',
- VpdFilePath],
+ VpdFileName],
stdout=subprocess.PIPE,
stderr= subprocess.PIPE)
except Exception, X: