X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FTargetTool%2FTargetTool.py;h=0d4a59198e7bd84a628093fd733894a37d453e4a;hb=92beb1e4c73a40a708c7c0cade5c7cee314b3887;hp=7a366db5fb5693fadbbd989d0ebf0d6721165ec7;hpb=1be2ed90a20618d71ddf34b8a07d038da0b36854;p=mirror_edk2.git
diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py b/BaseTools/Source/Python/TargetTool/TargetTool.py
index 7a366db5fb..0d4a59198e 100644
--- a/BaseTools/Source/Python/TargetTool/TargetTool.py
+++ b/BaseTools/Source/Python/TargetTool/TargetTool.py
@@ -1,5 +1,7 @@
+## @file
+# Target Tool Parser
#
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, 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
@@ -10,6 +12,7 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
+from __future__ import print_function
import Common.LongFilePathOs as os
import sys
import traceback
@@ -30,7 +33,7 @@ class TargetTool():
self.Arg = args[0]
self.FileName = os.path.normpath(os.path.join(self.WorkSpace, 'Conf', 'target.txt'))
if os.path.isfile(self.FileName) == False:
- print "%s does not exist." % self.FileName
+ print("%s does not exist." % self.FileName)
sys.exit(1)
self.TargetTxtDictionary = {
TAB_TAT_DEFINES_ACTIVE_PLATFORM : None,
@@ -63,7 +66,7 @@ class TargetTool():
LineList = Line.split(KeySplitCharacter,1)
if len(LineList) >= 2:
Key = LineList[0].strip()
- if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys():
+ if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary:
if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM or Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF \
or Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER \
or Key == TAB_TAT_DEFINES_ACTIVE_MODULE:
@@ -78,18 +81,17 @@ class TargetTool():
traceback.print_exception(last_type, last_value, last_tb)
def Print(self):
- KeyList = self.TargetTxtDictionary.keys()
errMsg = ''
- for Key in KeyList:
+ for Key in self.TargetTxtDictionary:
if type(self.TargetTxtDictionary[Key]) == type([]):
- print "%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key]))
- elif self.TargetTxtDictionary[Key] == None:
+ print("%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key])))
+ elif self.TargetTxtDictionary[Key] is None:
errMsg += " Missing %s configuration information, please use TargetTool to set value!" % Key + os.linesep
else:
- print "%-30s = %s" % (Key, self.TargetTxtDictionary[Key])
+ print("%-30s = %s" % (Key, self.TargetTxtDictionary[Key]))
if errMsg != '':
- print os.linesep + 'Warning:' + os.linesep + errMsg
+ print(os.linesep + 'Warning:' + os.linesep + errMsg)
def RWFile(self, CommentCharacter, KeySplitCharacter, Num):
try:
@@ -104,24 +106,24 @@ class TargetTool():
LineList = Line.split(KeySplitCharacter,1)
if len(LineList) >= 2:
Key = LineList[0].strip()
- if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary.keys():
+ if Key.startswith(CommentCharacter) == False and Key in self.TargetTxtDictionary:
if Key not in existKeys:
existKeys.append(Key)
else:
- print "Warning: Found duplicate key item in original configuration files!"
+ print("Warning: Found duplicate key item in original configuration files!")
if Num == 0:
Line = "%-30s = \n" % Key
else:
ret = GetConfigureKeyValue(self, Key)
- if ret != None:
+ if ret is not None:
Line = ret
fw.write(Line)
- for key in self.TargetTxtDictionary.keys():
+ for key in self.TargetTxtDictionary:
if key not in existKeys:
- print "Warning: %s does not exist in original configuration file" % key
+ print("Warning: %s does not exist in original configuration file" % key)
Line = GetConfigureKeyValue(self, key)
- if Line == None:
+ if Line is None:
Line = "%-30s = " % key
fw.write(Line)
@@ -136,14 +138,14 @@ class TargetTool():
def GetConfigureKeyValue(self, Key):
Line = None
- if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM and self.Opt.DSCFILE != None:
+ if Key == TAB_TAT_DEFINES_ACTIVE_PLATFORM and self.Opt.DSCFILE is not None:
dscFullPath = os.path.join(self.WorkSpace, self.Opt.DSCFILE)
if os.path.exists(dscFullPath):
Line = "%-30s = %s\n" % (Key, self.Opt.DSCFILE)
else:
EdkLogger.error("TagetTool", BuildToolError.FILE_NOT_FOUND,
"DSC file %s does not exist!" % self.Opt.DSCFILE, RaiseError=False)
- elif Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF and self.Opt.TOOL_DEFINITION_FILE != None:
+ elif Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF and self.Opt.TOOL_DEFINITION_FILE is not None:
tooldefFullPath = os.path.join(self.WorkSpace, self.Opt.TOOL_DEFINITION_FILE)
if os.path.exists(tooldefFullPath):
Line = "%-30s = %s\n" % (Key, self.Opt.TOOL_DEFINITION_FILE)
@@ -155,15 +157,15 @@ def GetConfigureKeyValue(self, Key):
Line = "%-30s = %s\n" % (Key, 'Enable')
elif self.Opt.NUM <= 1:
Line = "%-30s = %s\n" % (Key, 'Disable')
- elif Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER and self.Opt.NUM != None:
+ elif Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER and self.Opt.NUM is not None:
Line = "%-30s = %s\n" % (Key, str(self.Opt.NUM))
- elif Key == TAB_TAT_DEFINES_TARGET and self.Opt.TARGET != None:
+ elif Key == TAB_TAT_DEFINES_TARGET and self.Opt.TARGET is not None:
Line = "%-30s = %s\n" % (Key, ''.join(elem + ' ' for elem in self.Opt.TARGET))
- elif Key == TAB_TAT_DEFINES_TARGET_ARCH and self.Opt.TARGET_ARCH != None:
+ elif Key == TAB_TAT_DEFINES_TARGET_ARCH and self.Opt.TARGET_ARCH is not None:
Line = "%-30s = %s\n" % (Key, ''.join(elem + ' ' for elem in self.Opt.TARGET_ARCH))
- elif Key == TAB_TAT_DEFINES_TOOL_CHAIN_TAG and self.Opt.TOOL_CHAIN_TAG != None:
+ elif Key == TAB_TAT_DEFINES_TOOL_CHAIN_TAG and self.Opt.TOOL_CHAIN_TAG is not None:
Line = "%-30s = %s\n" % (Key, self.Opt.TOOL_CHAIN_TAG)
- elif Key == TAB_TAT_DEFINES_BUILD_RULE_CONF and self.Opt.BUILD_RULE_FILE != None:
+ elif Key == TAB_TAT_DEFINES_BUILD_RULE_CONF and self.Opt.BUILD_RULE_FILE is not None:
buildruleFullPath = os.path.join(self.WorkSpace, self.Opt.BUILD_RULE_FILE)
if os.path.exists(buildruleFullPath):
Line = "%-30s = %s\n" % (Key, self.Opt.BUILD_RULE_FILE)
@@ -221,26 +223,26 @@ def MyOptionParser():
if __name__ == '__main__':
EdkLogger.Initialize()
EdkLogger.SetLevel(EdkLogger.QUIET)
- if os.getenv('WORKSPACE') == None:
- print "ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool"
+ if os.getenv('WORKSPACE') is None:
+ print("ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool")
sys.exit(1)
(opt, args) = MyOptionParser()
if len(args) != 1 or (args[0].lower() != 'print' and args[0].lower() != 'clean' and args[0].lower() != 'set'):
- print "The number of args isn't 1 or the value of args is invalid."
+ print("The number of args isn't 1 or the value of args is invalid.")
sys.exit(1)
- if opt.NUM != None and opt.NUM < 1:
- print "The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0."
+ if opt.NUM is not None and opt.NUM < 1:
+ print("The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0.")
sys.exit(1)
- if opt.TARGET != None and len(opt.TARGET) > 1:
+ if opt.TARGET is not None and len(opt.TARGET) > 1:
for elem in opt.TARGET:
if elem == '0':
- print "0 will clear the TARGET setting in target.txt and can't combine with other value."
+ print("0 will clear the TARGET setting in target.txt and can't combine with other value.")
sys.exit(1)
- if opt.TARGET_ARCH != None and len(opt.TARGET_ARCH) > 1:
+ if opt.TARGET_ARCH is not None and len(opt.TARGET_ARCH) > 1:
for elem in opt.TARGET_ARCH:
if elem == '0':
- print "0 will clear the TARGET_ARCH setting in target.txt and can't combine with other value."
+ print("0 will clear the TARGET_ARCH setting in target.txt and can't combine with other value.")
sys.exit(1)
try:
@@ -252,7 +254,7 @@ if __name__ == '__main__':
FileHandle.RWFile('#', '=', 0)
else:
FileHandle.RWFile('#', '=', 1)
- except Exception, e:
+ except Exception as e:
last_type, last_value, last_tb = sys.exc_info()
traceback.print_exception(last_type, last_value, last_tb)