## @file\r
# Intel Binary Product Data Generation Tool (Intel BPDG).\r
-# This tool provide a simple process for the creation of a binary file containing read-only \r
-# configuration data for EDK II platforms that contain Dynamic and DynamicEx PCDs described \r
-# in VPD sections. It also provide an option for specifying an alternate name for a mapping \r
-# file of PCD layout for use during the build when the platform integrator selects to use \r
+# This tool provide a simple process for the creation of a binary file containing read-only\r
+# configuration data for EDK II platforms that contain Dynamic and DynamicEx PCDs described\r
+# in VPD sections. It also provide an option for specifying an alternate name for a mapping\r
+# file of PCD layout for use during the build when the platform integrator selects to use\r
# automatic offset calculation.\r
#\r
-# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2010 - 2018, 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
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
+from __future__ import absolute_import\r
import Common.LongFilePathOs as os\r
import sys\r
import encodings.ascii\r
from Common.BuildToolError import *\r
from Common.BuildVersion import gBUILD_VERSION\r
\r
-import StringTable as st\r
-import GenVpd\r
+from . import StringTable as st\r
+from . import GenVpd\r
\r
PROJECT_NAME = st.LBL_BPDG_LONG_UNI\r
VERSION = (st.LBL_BPDG_VERSION + " Build " + gBUILD_VERSION)\r
#\r
def main():\r
global Options, Args\r
- \r
+\r
# Initialize log system\r
- EdkLogger.Initialize() \r
+ EdkLogger.Initialize()\r
Options, Args = MyOptionParser()\r
- \r
+\r
ReturnCode = 0\r
- \r
+\r
if Options.opt_verbose:\r
EdkLogger.SetLevel(EdkLogger.VERBOSE)\r
elif Options.opt_quiet:\r
EdkLogger.SetLevel(EdkLogger.QUIET)\r
- elif Options.debug_level != None:\r
- EdkLogger.SetLevel(Options.debug_level + 1) \r
+ elif Options.debug_level is not None:\r
+ EdkLogger.SetLevel(Options.debug_level + 1)\r
else:\r
EdkLogger.SetLevel(EdkLogger.INFO)\r
- \r
- if Options.bin_filename == None:\r
- EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please use the -o option to specify the file name for the VPD binary file") \r
- if Options.filename == None:\r
- EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please use the -m option to specify the file name for the mapping file") \r
+\r
+ if Options.bin_filename is None:\r
+ EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please use the -o option to specify the file name for the VPD binary file")\r
+ if Options.filename is None:\r
+ EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please use the -m option to specify the file name for the mapping file")\r
\r
Force = False\r
- if Options.opt_force != None:\r
+ if Options.opt_force is not None:\r
Force = True\r
\r
- if (Args[0] != None) :\r
+ if (Args[0] is not None) :\r
StartBpdg(Args[0], Options.filename, Options.bin_filename, Force)\r
else :\r
EdkLogger.error("BPDG", ATTRIBUTE_NOT_AVAILABLE, "Please specify the file which contain the VPD pcd info.",\r
- None) \r
- \r
+ None)\r
+\r
return ReturnCode\r
\r
\r
#\r
# @retval options A optparse.Values object containing the parsed options\r
# @retval args Target of BPDG command\r
-# \r
-def MyOptionParser(): \r
+#\r
+def MyOptionParser():\r
#\r
# Process command line firstly.\r
#\r
parser.add_option('-o', '--vpd-filename', action='store', dest='bin_filename',\r
help=st.MSG_OPTION_VPD_FILENAME)\r
parser.add_option('-m', '--map-filename', action='store', dest='filename',\r
- help=st.MSG_OPTION_MAP_FILENAME) \r
+ help=st.MSG_OPTION_MAP_FILENAME)\r
parser.add_option('-f', '--force', action='store_true', dest='opt_force',\r
- help=st.MSG_OPTION_FORCE) \r
- \r
+ help=st.MSG_OPTION_FORCE)\r
+\r
(options, args) = parser.parse_args()\r
if len(args) == 0:\r
EdkLogger.info("Please specify the filename.txt file which contain the VPD pcd info!")\r
return options, args\r
\r
\r
-## Start BPDG and call the main functions \r
+## Start BPDG and call the main functions\r
#\r
# This method mainly focus on call GenVPD class member functions to complete\r
# BPDG's target. It will process VpdFile override, and provide the interface file\r
#\r
def StartBpdg(InputFileName, MapFileName, VpdFileName, Force):\r
if os.path.exists(VpdFileName) and not Force:\r
- print "\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName\r
+ print("\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName)\r
choice = sys.stdin.readline()\r
if choice.strip().lower() not in ['y', 'yes', '']:\r
return\r
- \r
+\r
GenVPD = GenVpd.GenVPD (InputFileName, MapFileName, VpdFileName)\r
- \r
- EdkLogger.info('%-24s = %s' % ("VPD input data file: ", InputFileName)) \r
+\r
+ EdkLogger.info('%-24s = %s' % ("VPD input data file: ", InputFileName))\r
EdkLogger.info('%-24s = %s' % ("VPD output map file: ", MapFileName))\r
- EdkLogger.info('%-24s = %s' % ("VPD output binary file: ", VpdFileName)) \r
- \r
+ EdkLogger.info('%-24s = %s' % ("VPD output binary file: ", VpdFileName))\r
+\r
GenVPD.ParserInputFile()\r
GenVPD.FormatFileLine()\r
GenVPD.FixVpdOffset()\r
GenVPD.GenerateVpdFile(MapFileName, VpdFileName)\r
- \r
- EdkLogger.info("- Vpd pcd fixed done! -") \r
+\r
+ EdkLogger.info("- Vpd pcd fixed done! -")\r
\r
if __name__ == '__main__':\r
- r = main()\r
+ try:\r
+ r = main()\r
+ except FatalError as e:\r
+ r = e\r
## 0-127 is a safe return range, and 1 is a standard default error\r
if r < 0 or r > 127: r = 1\r
sys.exit(r)\r
\r
- \r
+\r