dtoc: Convert to use ArgumentParser
Use this parser instead of OptionParser, which is deprecated. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
This commit is contained in:
@@ -21,7 +21,7 @@ options. For more information about the use of this options and tool please
|
|||||||
see doc/driver-model/of-plat.rst
|
see doc/driver-model/of-plat.rst
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
@@ -51,7 +51,7 @@ def run_tests(processes, args):
|
|||||||
|
|
||||||
result = unittest.TestResult()
|
result = unittest.TestResult()
|
||||||
sys.argv = [sys.argv[0]]
|
sys.argv = [sys.argv[0]]
|
||||||
test_name = args and args[0] or None
|
test_name = args.files and args.files[0] or None
|
||||||
|
|
||||||
test_dtoc.setup()
|
test_dtoc.setup()
|
||||||
|
|
||||||
@@ -66,47 +66,50 @@ def RunTestCoverage():
|
|||||||
"""Run the tests and check that we get 100% coverage"""
|
"""Run the tests and check that we get 100% coverage"""
|
||||||
sys.argv = [sys.argv[0]]
|
sys.argv = [sys.argv[0]]
|
||||||
test_util.RunTestCoverage('tools/dtoc/dtoc', '/main.py',
|
test_util.RunTestCoverage('tools/dtoc/dtoc', '/main.py',
|
||||||
['tools/patman/*.py', '*/fdt*', '*test*'], options.build_dir)
|
['tools/patman/*.py', '*/fdt*', '*test*'], args.build_dir)
|
||||||
|
|
||||||
|
|
||||||
if __name__ != '__main__':
|
if __name__ != '__main__':
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
parser = OptionParser()
|
epilog = '''Generate C code from devicetree files. See of-plat.rst for details'''
|
||||||
parser.add_option('-B', '--build-dir', type='string', default='b',
|
|
||||||
|
parser = ArgumentParser(epilog=epilog)
|
||||||
|
parser.add_argument('-B', '--build-dir', type=str, default='b',
|
||||||
help='Directory containing the build output')
|
help='Directory containing the build output')
|
||||||
parser.add_option('-c', '--c-output-dir', action='store',
|
parser.add_argument('-c', '--c-output-dir', action='store',
|
||||||
help='Select output directory for C files')
|
help='Select output directory for C files')
|
||||||
parser.add_option('-C', '--h-output-dir', action='store',
|
parser.add_argument('-C', '--h-output-dir', action='store',
|
||||||
help='Select output directory for H files (defaults to --c-output-di)')
|
help='Select output directory for H files (defaults to --c-output-di)')
|
||||||
parser.add_option('-d', '--dtb-file', action='store',
|
parser.add_argument('-d', '--dtb-file', action='store',
|
||||||
help='Specify the .dtb input file')
|
help='Specify the .dtb input file')
|
||||||
parser.add_option('-i', '--instantiate', action='store_true', default=False,
|
parser.add_argument('-i', '--instantiate', action='store_true', default=False,
|
||||||
help='Instantiate devices to avoid needing device_bind()')
|
help='Instantiate devices to avoid needing device_bind()')
|
||||||
parser.add_option('--include-disabled', action='store_true',
|
parser.add_argument('--include-disabled', action='store_true',
|
||||||
help='Include disabled nodes')
|
help='Include disabled nodes')
|
||||||
parser.add_option('-o', '--output', action='store',
|
parser.add_argument('-o', '--output', action='store',
|
||||||
help='Select output filename')
|
help='Select output filename')
|
||||||
parser.add_option('-p', '--phase', type=str,
|
parser.add_argument('-p', '--phase', type=str,
|
||||||
help='set phase of U-Boot this invocation is for (spl/tpl)')
|
help='set phase of U-Boot this invocation is for (spl/tpl)')
|
||||||
parser.add_option('-P', '--processes', type=int,
|
parser.add_argument('-P', '--processes', type=int,
|
||||||
help='set number of processes to use for running tests')
|
help='set number of processes to use for running tests')
|
||||||
parser.add_option('-t', '--test', action='store_true', dest='test',
|
parser.add_argument('-t', '--test', action='store_true', dest='test',
|
||||||
default=False, help='run tests')
|
default=False, help='run tests')
|
||||||
parser.add_option('-T', '--test-coverage', action='store_true',
|
parser.add_argument('-T', '--test-coverage', action='store_true',
|
||||||
default=False, help='run tests and check for 100% coverage')
|
default=False, help='run tests and check for 100%% coverage')
|
||||||
(options, args) = parser.parse_args()
|
parser.add_argument('files', nargs='*')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Run our meagre tests
|
# Run our meagre tests
|
||||||
if options.test:
|
if args.test:
|
||||||
ret_code = run_tests(options.processes, args)
|
ret_code = run_tests(args.processes, args)
|
||||||
sys.exit(ret_code)
|
sys.exit(ret_code)
|
||||||
|
|
||||||
elif options.test_coverage:
|
elif args.test_coverage:
|
||||||
RunTestCoverage()
|
RunTestCoverage()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
dtb_platdata.run_steps(args, options.dtb_file, options.include_disabled,
|
dtb_platdata.run_steps(args.files, args.dtb_file, args.include_disabled,
|
||||||
options.output,
|
args.output,
|
||||||
[options.c_output_dir, options.h_output_dir],
|
[args.c_output_dir, args.h_output_dir],
|
||||||
options.phase, instantiate=options.instantiate)
|
args.phase, instantiate=args.instantiate)
|
||||||
|
Reference in New Issue
Block a user