cmdline.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # SPDX-License-Identifier: GPL-2.0+
  2. # Copyright (c) 2016 Google, Inc
  3. # Written by Simon Glass <sjg@chromium.org>
  4. #
  5. # Command-line parser for binman
  6. #
  7. from optparse import OptionParser
  8. def ParseArgs(argv):
  9. """Parse the binman command-line arguments
  10. Args:
  11. argv: List of string arguments
  12. Returns:
  13. Tuple (options, args) with the command-line options and arugments.
  14. options provides access to the options (e.g. option.debug)
  15. args is a list of string arguments
  16. """
  17. parser = OptionParser()
  18. parser.add_option('-a', '--entry-arg', type='string', action='append',
  19. help='Set argument value arg=value')
  20. parser.add_option('-b', '--board', type='string',
  21. help='Board name to build')
  22. parser.add_option('-B', '--build-dir', type='string', default='b',
  23. help='Directory containing the build output')
  24. parser.add_option('-d', '--dt', type='string',
  25. help='Configuration file (.dtb) to use')
  26. parser.add_option('-D', '--debug', action='store_true',
  27. help='Enabling debugging (provides a full traceback on error)')
  28. parser.add_option('-E', '--entry-docs', action='store_true',
  29. help='Write out entry documentation (see README.entries)')
  30. parser.add_option('--fake-dtb', action='store_true',
  31. help='Use fake device tree contents (for testing only)')
  32. parser.add_option('-i', '--image', type='string', action='append',
  33. help='Image filename to build (if not specified, build all)')
  34. parser.add_option('-I', '--indir', action='append',
  35. help='Add a path to a directory to use for input files')
  36. parser.add_option('-H', '--full-help', action='store_true',
  37. default=False, help='Display the README file')
  38. parser.add_option('-m', '--map', action='store_true',
  39. default=False, help='Output a map file for each image')
  40. parser.add_option('-O', '--outdir', type='string',
  41. action='store', help='Path to directory to use for intermediate and '
  42. 'output files')
  43. parser.add_option('-p', '--preserve', action='store_true',\
  44. help='Preserve temporary output directory even if option -O is not '
  45. 'given')
  46. parser.add_option('-P', '--processes', type=int,
  47. help='set number of processes to use for running tests')
  48. parser.add_option('-t', '--test', action='store_true',
  49. default=False, help='run tests')
  50. parser.add_option('-T', '--test-coverage', action='store_true',
  51. default=False, help='run tests and check for 100% coverage')
  52. parser.add_option('-u', '--update-fdt', action='store_true',
  53. default=False, help='Update the binman node with offset/size info')
  54. parser.add_option('-v', '--verbosity', default=1,
  55. type='int', help='Control verbosity: 0=silent, 1=progress, 3=full, '
  56. '4=debug')
  57. parser.usage += """
  58. Create images for a board from a set of binaries. It is controlled by a
  59. description in the board device tree."""
  60. return parser.parse_args(argv)