cmdline.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright (c) 2016 Google, Inc
  2. # Written by Simon Glass <sjg@chromium.org>
  3. #
  4. # SPDX-License-Identifier: GPL-2.0+
  5. #
  6. # Command-line parser for binman
  7. #
  8. from optparse import OptionParser
  9. def ParseArgs(argv):
  10. """Parse the binman command-line arguments
  11. Args:
  12. argv: List of string arguments
  13. Returns:
  14. Tuple (options, args) with the command-line options and arugments.
  15. options provides access to the options (e.g. option.debug)
  16. args is a list of string arguments
  17. """
  18. parser = OptionParser()
  19. parser.add_option('-b', '--board', type='string',
  20. help='Board name to build')
  21. parser.add_option('-B', '--build-dir', type='string', default='b',
  22. help='Directory containing the build output')
  23. parser.add_option('-d', '--dt', type='string',
  24. help='Configuration file (.dtb) to use')
  25. parser.add_option('-D', '--debug', action='store_true',
  26. help='Enabling debugging (provides a full traceback on error)')
  27. parser.add_option('-I', '--indir', action='append',
  28. help='Add a path to a directory to use for input files')
  29. parser.add_option('-H', '--full-help', action='store_true',
  30. default=False, help='Display the README file')
  31. parser.add_option('-O', '--outdir', type='string',
  32. action='store', help='Path to directory to use for intermediate and '
  33. 'output files')
  34. parser.add_option('-p', '--preserve', action='store_true',\
  35. help='Preserve temporary output directory even if option -O is not '
  36. 'given')
  37. parser.add_option('-t', '--test', action='store_true',
  38. default=False, help='run tests')
  39. parser.add_option('-T', '--test-coverage', action='store_true',
  40. default=False, help='run tests and check for 100% coverage')
  41. parser.add_option('-v', '--verbosity', default=1,
  42. type='int', help='Control verbosity: 0=silent, 1=progress, 3=full, '
  43. '4=debug')
  44. parser.usage += """
  45. Create images for a board from a set of binaries. It is controlled by a
  46. description in the board device tree."""
  47. return parser.parse_args(argv)