X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FTargetTool%2FTargetTool.py;h=143b53ec35efb516647287608910a34de622c5c3;hp=476e927a881e513ed05cf97bf9196ab441d97e31;hb=1563349a967d7e02c43492ba853babb9c660a083;hpb=b36d134faf4305247830522b8e2bb255e98c5699
diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py b/BaseTools/Source/Python/TargetTool/TargetTool.py
index 476e927a88..143b53ec35 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 - 2010, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 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
@@ -10,7 +12,7 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
-import os
+import Common.LongFilePathOs as os
import sys
import traceback
from optparse import OptionParser
@@ -19,6 +21,7 @@ import Common.EdkLogger as EdkLogger
import Common.BuildToolError as BuildToolError
from Common.DataType import *
from Common.BuildVersion import gBUILD_VERSION
+from Common.LongFilePathSupport import OpenLongFilePath as open
# To Do 1.set clean, 2. add item, if the line is disabled.
@@ -77,12 +80,11 @@ 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:
+ 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])
@@ -113,14 +115,14 @@ class TargetTool():
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():
if key not in existKeys:
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)
@@ -135,14 +137,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)
@@ -154,15 +156,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)
@@ -200,8 +202,8 @@ def RangeCheckCallback(option, opt_str, value, parser):
def MyOptionParser():
parser = OptionParser(version=__version__,prog="TargetTool.exe",usage=__usage__,description=__copyright__)
- parser.add_option("-a", "--arch", action="append", type="choice", choices=['IA32','X64','IPF','EBC', 'ARM','0'], dest="TARGET_ARCH",
- help="ARCHS is one of list: IA32, X64, IPF, ARM or EBC, which replaces target.txt's TARGET_ARCH definition. To specify more archs, please repeat this option. 0 will clear this setting in target.txt and can't combine with other value.")
+ parser.add_option("-a", "--arch", action="append", type="choice", choices=['IA32','X64','IPF','EBC', 'ARM', 'AARCH64','0'], dest="TARGET_ARCH",
+ help="ARCHS is one of list: IA32, X64, IPF, ARM, AARCH64 or EBC, which replaces target.txt's TARGET_ARCH definition. To specify more archs, please repeat this option. 0 will clear this setting in target.txt and can't combine with other value.")
parser.add_option("-p", "--platform", action="callback", type="string", dest="DSCFILE", callback=SingleCheckCallback,
help="Specify a DSC file, which replace target.txt's ACTIVE_PLATFORM definition. 0 will clear this setting in target.txt and can't combine with other value.")
parser.add_option("-c", "--tooldef", action="callback", type="string", dest="TOOL_DEFINITION_FILE", callback=SingleCheckCallback,
@@ -220,7 +222,7 @@ def MyOptionParser():
if __name__ == '__main__':
EdkLogger.Initialize()
EdkLogger.SetLevel(EdkLogger.QUIET)
- if os.getenv('WORKSPACE') == None:
+ if os.getenv('WORKSPACE') is None:
print "ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool"
sys.exit(1)
@@ -228,15 +230,15 @@ if __name__ == '__main__':
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."
sys.exit(1)
- if opt.NUM != None and opt.NUM < 1:
+ 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."
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."