cmdline.py 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #
  2. # Copyright (c) 2014 Google, Inc
  3. #
  4. # SPDX-License-Identifier: GPL-2.0+
  5. #
  6. from optparse import OptionParser
  7. def ParseArgs():
  8. """Parse command line arguments from sys.argv[]
  9. Returns:
  10. tuple containing:
  11. options: command line options
  12. args: command lin arguments
  13. """
  14. parser = OptionParser()
  15. parser.add_option('-b', '--branch', type='string',
  16. help='Branch name to build, or range of commits to build')
  17. parser.add_option('-B', '--bloat', dest='show_bloat',
  18. action='store_true', default=False,
  19. help='Show changes in function code size for each board')
  20. parser.add_option('-c', '--count', dest='count', type='int',
  21. default=-1, help='Run build on the top n commits')
  22. parser.add_option('-C', '--force-reconfig', dest='force_reconfig',
  23. action='store_true', default=False,
  24. help='Reconfigure for every commit (disable incremental build)')
  25. parser.add_option('-d', '--detail', dest='show_detail',
  26. action='store_true', default=False,
  27. help='Show detailed information for each board in summary')
  28. parser.add_option('-D', '--config-only', action='store_true', default=False,
  29. help="Don't build, just configure each commit")
  30. parser.add_option('-e', '--show_errors', action='store_true',
  31. default=False, help='Show errors and warnings')
  32. parser.add_option('-f', '--force-build', dest='force_build',
  33. action='store_true', default=False,
  34. help='Force build of boards even if already built')
  35. parser.add_option('-F', '--force-build-failures', dest='force_build_failures',
  36. action='store_true', default=False,
  37. help='Force build of previously-failed build')
  38. parser.add_option('--fetch-arch', type='string',
  39. help="Fetch a toolchain for architecture FETCH_ARCH ('list' to list)."
  40. ' You can also fetch several toolchains separate by comma, or'
  41. " 'all' to download all")
  42. parser.add_option('-g', '--git', type='string',
  43. help='Git repo containing branch to build', default='.')
  44. parser.add_option('-G', '--config-file', type='string',
  45. help='Path to buildman config file', default='')
  46. parser.add_option('-H', '--full-help', action='store_true', dest='full_help',
  47. default=False, help='Display the README file')
  48. parser.add_option('-i', '--in-tree', dest='in_tree',
  49. action='store_true', default=False,
  50. help='Build in the source tree instead of a separate directory')
  51. parser.add_option('-I', '--incremental', action='store_true',
  52. default=False, help='Do not run make mrproper (when reconfiguring)')
  53. parser.add_option('-j', '--jobs', dest='jobs', type='int',
  54. default=None, help='Number of jobs to run at once (passed to make)')
  55. parser.add_option('-k', '--keep-outputs', action='store_true',
  56. default=False, help='Keep all build output files (e.g. binaries)')
  57. parser.add_option('-K', '--show-config', action='store_true',
  58. default=False, help='Show configuration changes in summary (both board config files and Kconfig)')
  59. parser.add_option('--preserve-config-y', action='store_true',
  60. default=False, help="Don't convert y to 1 in configs")
  61. parser.add_option('-l', '--list-error-boards', action='store_true',
  62. default=False, help='Show a list of boards next to each error/warning')
  63. parser.add_option('--list-tool-chains', action='store_true', default=False,
  64. help='List available tool chains')
  65. parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
  66. default=False, help="Do a dry run (describe actions, but do nothing)")
  67. parser.add_option('-N', '--no-subdirs', action='store_true', dest='no_subdirs',
  68. default=False, help="Don't create subdirectories when building current source for a single board")
  69. parser.add_option('-o', '--output-dir', type='string',
  70. dest='output_dir', default='..',
  71. help='Directory where all builds happen and buildman has its workspace (default is ../)')
  72. parser.add_option('-Q', '--quick', action='store_true',
  73. default=False, help='Do a rough build, with limited warning resolution')
  74. parser.add_option('-p', '--full-path', action='store_true',
  75. default=False, help="Use full toolchain path in CROSS_COMPILE")
  76. parser.add_option('-P', '--per-board-out-dir', action='store_true',
  77. default=False, help="Use an O= (output) directory per board rather than per thread")
  78. parser.add_option('-s', '--summary', action='store_true',
  79. default=False, help='Show a build summary')
  80. parser.add_option('-S', '--show-sizes', action='store_true',
  81. default=False, help='Show image size variation in summary')
  82. parser.add_option('--step', type='int',
  83. default=1, help='Only build every n commits (0=just first and last)')
  84. parser.add_option('-t', '--test', action='store_true', dest='test',
  85. default=False, help='run tests')
  86. parser.add_option('-T', '--threads', type='int',
  87. default=None, help='Number of builder threads to use')
  88. parser.add_option('-u', '--show_unknown', action='store_true',
  89. default=False, help='Show boards with unknown build result')
  90. parser.add_option('-v', '--verbose', action='store_true',
  91. default=False, help='Show build results while the build progresses')
  92. parser.add_option('-V', '--verbose-build', action='store_true',
  93. default=False, help='Run make with V=1, logging all output')
  94. parser.add_option('-x', '--exclude', dest='exclude',
  95. type='string', action='append',
  96. help='Specify a list of boards to exclude, separated by comma')
  97. parser.usage += """
  98. Build U-Boot for all commits in a branch. Use -n to do a dry run"""
  99. return parser.parse_args()