]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/TargetTool/TargetTool.py
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / BaseTools / Source / Python / TargetTool / TargetTool.py
index 26d2bb9ebfce1ab4bc8dc5b253d71201810ce949..7f2479f0f0acbf92563d096f55beb9fd9bdc7c22 100644 (file)
@@ -1,15 +1,9 @@
 ## @file\r
 # Target Tool Parser\r
 #\r
-#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.<BR>\r
 #\r
-#  This program and the accompanying materials\r
-#  are licensed and made available under the terms and conditions of the BSD License\r
-#  which accompanies this distribution.  The full text of the license may be found at\r
-#  http://opensource.org/licenses/bsd-license.php\r
-#\r
-#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 \r
 from __future__ import print_function\r
@@ -23,6 +17,7 @@ import Common.BuildToolError as BuildToolError
 from Common.DataType import *\r
 from Common.BuildVersion import gBUILD_VERSION\r
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
+from Common.TargetTxtClassObject import gDefaultTargetTxtFile\r
 \r
 # To Do 1.set clean, 2. add item, if the line is disabled.\r
 \r
@@ -31,7 +26,7 @@ class TargetTool():
         self.WorkSpace = os.path.normpath(os.getenv('WORKSPACE'))\r
         self.Opt       = opt\r
         self.Arg       = args[0]\r
-        self.FileName  = os.path.normpath(os.path.join(self.WorkSpace, 'Conf', 'target.txt'))\r
+        self.FileName  = os.path.normpath(os.path.join(self.WorkSpace, 'Conf', gDefaultTargetTxtFile))\r
         if os.path.isfile(self.FileName) == False:\r
             print("%s does not exist." % self.FileName)\r
             sys.exit(1)\r
@@ -86,13 +81,13 @@ class TargetTool():
             if isinstance(self.TargetTxtDictionary[Key], type([])):\r
                 print("%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key])))\r
             elif self.TargetTxtDictionary[Key] is None:\r
-                errMsg += "  Missing %s configuration information, please use TargetTool to set value!" % Key + os.linesep \r
+                errMsg += "  Missing %s configuration information, please use TargetTool to set value!" % Key + os.linesep\r
             else:\r
                 print("%-30s = %s" % (Key, self.TargetTxtDictionary[Key]))\r
-        \r
+\r
         if errMsg != '':\r
             print(os.linesep + 'Warning:' + os.linesep + errMsg)\r
-            \r
+\r
     def RWFile(self, CommentCharacter, KeySplitCharacter, Num):\r
         try:\r
             fr = open(self.FileName, 'r')\r
@@ -111,7 +106,7 @@ class TargetTool():
                                 existKeys.append(Key)\r
                             else:\r
                                 print("Warning: Found duplicate key item in original configuration files!")\r
-                                \r
+\r
                             if Num == 0:\r
                                 Line = "%-30s = \n" % Key\r
                             else:\r
@@ -126,12 +121,12 @@ class TargetTool():
                     if Line is None:\r
                         Line = "%-30s = " % key\r
                     fw.write(Line)\r
-                \r
+\r
             fr.close()\r
             fw.close()\r
             os.remove(self.FileName)\r
             os.rename(os.path.normpath(os.path.join(self.WorkSpace, 'Conf\\targetnew.txt')), self.FileName)\r
-            \r
+\r
         except:\r
             last_type, last_value, last_tb = sys.exc_info()\r
             traceback.print_exception(last_type, last_value, last_tb)\r
@@ -143,20 +138,20 @@ def GetConfigureKeyValue(self, Key):
         if os.path.exists(dscFullPath):\r
             Line = "%-30s = %s\n" % (Key, self.Opt.DSCFILE)\r
         else:\r
-            EdkLogger.error("TagetTool", BuildToolError.FILE_NOT_FOUND, \r
+            EdkLogger.error("TargetTool", BuildToolError.FILE_NOT_FOUND,\r
                             "DSC file %s does not exist!" % self.Opt.DSCFILE, RaiseError=False)\r
     elif Key == TAB_TAT_DEFINES_TOOL_CHAIN_CONF and self.Opt.TOOL_DEFINITION_FILE is not None:\r
         tooldefFullPath = os.path.join(self.WorkSpace, self.Opt.TOOL_DEFINITION_FILE)\r
         if os.path.exists(tooldefFullPath):\r
             Line = "%-30s = %s\n" % (Key, self.Opt.TOOL_DEFINITION_FILE)\r
         else:\r
-            EdkLogger.error("TagetTool", BuildToolError.FILE_NOT_FOUND, \r
+            EdkLogger.error("TargetTool", BuildToolError.FILE_NOT_FOUND,\r
                             "Tooldef file %s does not exist!" % self.Opt.TOOL_DEFINITION_FILE, RaiseError=False)\r
 \r
     elif self.Opt.NUM >= 2:\r
         Line = "%-30s = %s\n" % (Key, 'Enable')\r
     elif self.Opt.NUM <= 1:\r
-        Line = "%-30s = %s\n" % (Key, 'Disable')        \r
+        Line = "%-30s = %s\n" % (Key, 'Disable')\r
     elif Key == TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER and self.Opt.NUM is not None:\r
         Line = "%-30s = %s\n" % (Key, str(self.Opt.NUM))\r
     elif Key == TAB_TAT_DEFINES_TARGET and self.Opt.TARGET is not None:\r
@@ -170,13 +165,13 @@ def GetConfigureKeyValue(self, Key):
         if os.path.exists(buildruleFullPath):\r
             Line = "%-30s = %s\n" % (Key, self.Opt.BUILD_RULE_FILE)\r
         else:\r
-            EdkLogger.error("TagetTool", BuildToolError.FILE_NOT_FOUND, \r
+            EdkLogger.error("TagetTool", BuildToolError.FILE_NOT_FOUND,\r
                             "Build rule file %s does not exist!" % self.Opt.BUILD_RULE_FILE, RaiseError=False)\r
     return Line\r
 \r
 VersionNumber = ("0.01" + " " + gBUILD_VERSION)\r
 __version__ = "%prog Version " + VersionNumber\r
-__copyright__ = "Copyright (c) 2007 - 2010, Intel Corporation  All rights reserved."\r
+__copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation  All rights reserved."\r
 __usage__ = "%prog [options] {args} \\r
 \nArgs:                                                  \\r
 \n Clean  clean the all default configuration of target.txt. \\r
@@ -200,11 +195,11 @@ def RangeCheckCallback(option, opt_str, value, parser):
             setattr(parser.values, option.dest, value)\r
     else:\r
         parser.error("Option %s only allows one instance in command line!" % option)\r
-        \r
+\r
 def MyOptionParser():\r
     parser = OptionParser(version=__version__, prog="TargetTool.exe", usage=__usage__, description=__copyright__)\r
-    parser.add_option("-a", "--arch", action="append", type="choice", choices=['IA32', 'X64', 'IPF', 'EBC', 'ARM', 'AARCH64', '0'], dest="TARGET_ARCH",\r
-        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.")\r
+    parser.add_option("-a", "--arch", action="append", dest="TARGET_ARCH",\r
+        help="ARCHS is one of list: IA32, X64, 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.")\r
     parser.add_option("-p", "--platform", action="callback", type="string", dest="DSCFILE", callback=SingleCheckCallback,\r
         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.")\r
     parser.add_option("-c", "--tooldef", action="callback", type="string", dest="TOOL_DEFINITION_FILE", callback=SingleCheckCallback,\r
@@ -226,7 +221,7 @@ if __name__ == '__main__':
     if os.getenv('WORKSPACE') is None:\r
         print("ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool")\r
         sys.exit(1)\r
-        \r
+\r
     (opt, args) = MyOptionParser()\r
     if len(args) != 1 or (args[0].lower() != 'print' and args[0].lower() != 'clean' and args[0].lower() != 'set'):\r
         print("The number of args isn't 1 or the value of args is invalid.")\r