## @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, 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
##\r
# Import Modules\r
#\r
-import os\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
\r
from optparse import OptionParser\r
-from encodings import gbk\r
from Common import EdkLogger\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\r
+VERSION = (st.LBL_BPDG_VERSION + " Build " + gBUILD_VERSION)\r
\r
## Tool entrance method\r
#\r
#\r
def main():\r
global Options, Args\r
- \r
+\r
# Initialize log system\r
- EdkLogger.Initialize() \r
- Options, Args = myOptionParser()\r
- \r
+ EdkLogger.Initialize()\r
+ Options, Args = MyOptionParser()\r
+\r
ReturnCode = 0\r
- \r
- if Options.opt_slient:\r
- EdkLogger.SetLevel(EdkLogger.ERROR)\r
- elif Options.opt_verbose:\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.vpd_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
- startBPDG(Args[0], Options.filename, Options.vpd_filename, Force)\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
-def myOptionParser(): \r
+\r
+\r
+## Parse command line options\r
+#\r
+# Using standard Python module optparse to parse command line option of this tool.\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
# Process command line firstly.\r
#\r
- parser = OptionParser(version="%s - Version %s\n" % (PROJECT_NAME, VERSION),\r
+ parser = OptionParser(version="%s - Version %s" % (PROJECT_NAME, VERSION),\r
description='',\r
prog='BPDG',\r
usage=st.LBL_BPDG_USAGE\r
help=st.MSG_OPTION_DEBUG_LEVEL)\r
parser.add_option('-v', '--verbose', action='store_true', dest='opt_verbose',\r
help=st.MSG_OPTION_VERBOSE)\r
- parser.add_option('-s', '--silent', action='store_true', dest='opt_slient', default=False,\r
- help=st.MSG_OPTION_SILENT)\r
parser.add_option('-q', '--quiet', action='store_true', dest='opt_quiet', default=False,\r
help=st.MSG_OPTION_QUIET)\r
- parser.add_option('-o', '--vpd-filename', action='store', dest='vpd_filename',\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
EdkLogger.info(parser.usage)\r
sys.exit(1)\r
return options, args\r
- \r
-def startBPDG(InputFileName, MapFileName, VpdFileName, Force):\r
+\r
+\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
+# information.\r
+#\r
+# @Param InputFileName The filename include the vpd type pcd information\r
+# @param MapFileName The filename of map file that stores vpd type pcd information.\r
+# This file will be generated by the BPDG tool after fix the offset\r
+# and adjust the offset to make the pcd data aligned.\r
+# @param VpdFileName The filename of Vpd file that hold vpd pcd information.\r
+# @param Force Override the exist Vpdfile or not.\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
if r < 0 or r > 127: r = 1\r
sys.exit(r)\r
\r
- \r
+\r