cmdline.py 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. # SPDX-License-Identifier: GPL-2.0+
  2. # Copyright (c) 2014 Google, Inc
  3. #
  4. """Handles parsing of buildman arguments
  5. This creates the argument parser and uses it to parse the arguments passed in
  6. """
  7. import argparse
  8. import os
  9. import pathlib
  10. BUILDMAN_DIR = pathlib.Path(__file__).parent
  11. HAS_TESTS = os.path.exists(BUILDMAN_DIR / "test.py")
  12. def add_upto_m(parser):
  13. """Add arguments up to 'M'
  14. Args:
  15. parser (ArgumentParser): Parse to add to
  16. This is split out to avoid having too many statements in one function
  17. """
  18. parser.add_argument('-a', '--adjust-cfg', type=str, action='append',
  19. help='Adjust the Kconfig settings in .config before building')
  20. parser.add_argument('-A', '--print-prefix', action='store_true',
  21. help='Print the tool-chain prefix for a board (CROSS_COMPILE=)')
  22. parser.add_argument('-b', '--branch', type=str,
  23. help='Branch name to build, or range of commits to build')
  24. parser.add_argument('-B', '--bloat', dest='show_bloat',
  25. action='store_true', default=False,
  26. help='Show changes in function code size for each board')
  27. parser.add_argument('--boards', type=str, action='append',
  28. help='List of board names to build separated by comma')
  29. parser.add_argument('-c', '--count', dest='count', type=int,
  30. default=-1, help='Run build on the top n commits')
  31. parser.add_argument('-C', '--force-reconfig', dest='force_reconfig',
  32. action='store_true', default=False,
  33. help='Reconfigure for every commit (disable incremental build)')
  34. parser.add_argument('--config-only', action='store_true',
  35. default=False,
  36. help="Don't build, just configure each commit")
  37. parser.add_argument('-d', '--detail', dest='show_detail',
  38. action='store_true', default=False,
  39. help='Show detailed size delta for each board in the -S summary')
  40. parser.add_argument('-D', '--debug', action='store_true',
  41. help='Enabling debugging (provides a full traceback on error)')
  42. parser.add_argument('-e', '--show_errors', action='store_true',
  43. default=False, help='Show errors and warnings')
  44. parser.add_argument('-E', '--warnings-as-errors', action='store_true',
  45. default=False, help='Treat all compiler warnings as errors')
  46. parser.add_argument('-f', '--force-build', dest='force_build',
  47. action='store_true', default=False,
  48. help='Force build of boards even if already built')
  49. parser.add_argument('-F', '--force-build-failures', dest='force_build_failures',
  50. action='store_true', default=False,
  51. help='Force build of previously-failed build')
  52. parser.add_argument('--fetch-arch', type=str,
  53. help="Fetch a toolchain for architecture FETCH_ARCH ('list' to list)."
  54. ' You can also fetch several toolchains separate by comma, or'
  55. " 'all' to download all")
  56. parser.add_argument(
  57. '--full-check', action='store_true',
  58. help='Check maintainer entries and TARGET configs')
  59. parser.add_argument('-g', '--git', type=str,
  60. help='Git repo containing branch to build', default='.')
  61. parser.add_argument('-G', '--config-file', type=str,
  62. help='Path to buildman config file', default='')
  63. parser.add_argument('-H', '--full-help', action='store_true', dest='full_help',
  64. default=False, help='Display the README file')
  65. parser.add_argument('-i', '--in-tree', dest='in_tree',
  66. action='store_true', default=False,
  67. help='Build in the source tree instead of a separate directory')
  68. parser.add_argument('-I', '--ide', action='store_true', default=False,
  69. help='Create build output that can be parsed by an IDE')
  70. parser.add_argument('-j', '--jobs', dest='jobs', type=int,
  71. default=None, help='Number of jobs to run at once (passed to make)')
  72. parser.add_argument('-k', '--keep-outputs', action='store_true',
  73. default=False, help='Keep all build output files (e.g. binaries)')
  74. parser.add_argument('-K', '--show-config', action='store_true',
  75. default=False,
  76. help='Show configuration changes in summary (both board config files and Kconfig)')
  77. parser.add_argument('--preserve-config-y', action='store_true',
  78. default=False, help="Don't convert y to 1 in configs")
  79. parser.add_argument('-l', '--list-error-boards', action='store_true',
  80. default=False, help='Show a list of boards next to each error/warning')
  81. parser.add_argument('-L', '--no-lto', action='store_true',
  82. default=False, help='Disable Link-time Optimisation (LTO) for builds')
  83. parser.add_argument('--list-tool-chains', action='store_true', default=False,
  84. help='List available tool chains (use -v to see probing detail)')
  85. parser.add_argument('-m', '--mrproper', action='store_true',
  86. default=False, help="Run 'make mrproper before reconfiguring")
  87. parser.add_argument(
  88. '-M', '--allow-missing', action='store_true', default=False,
  89. help='Tell binman to allow missing blobs and generate fake ones as needed')
  90. parser.add_argument(
  91. '--maintainer-check', action='store_true',
  92. help='Check that maintainer entries exist for each board')
  93. parser.add_argument(
  94. '--no-allow-missing', action='store_true', default=False,
  95. help='Disable telling binman to allow missing blobs')
  96. parser.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
  97. default=False, help="Do a dry run (describe actions, but do nothing)")
  98. parser.add_argument('-N', '--no-subdirs', action='store_true', dest='no_subdirs',
  99. default=False,
  100. help="Don't create subdirectories when building current source for a single board")
  101. def add_after_m(parser):
  102. """Add arguments after 'M'
  103. Args:
  104. parser (ArgumentParser): Parse to add to
  105. This is split out to avoid having too many statements in one function
  106. """
  107. parser.add_argument('-o', '--output-dir', type=str, dest='output_dir',
  108. help='Directory where all builds happen and buildman has its workspace (default is ../)')
  109. parser.add_argument('-O', '--override-toolchain', type=str,
  110. help="Override host toochain to use for sandbox (e.g. 'clang-7')")
  111. parser.add_argument('-Q', '--quick', action='store_true',
  112. default=False, help='Do a rough build, with limited warning resolution')
  113. parser.add_argument('-p', '--full-path', action='store_true',
  114. default=False, help="Use full toolchain path in CROSS_COMPILE")
  115. parser.add_argument('-P', '--per-board-out-dir', action='store_true',
  116. default=False, help="Use an O= (output) directory per board rather than per thread")
  117. parser.add_argument('--print-arch', action='store_true',
  118. default=False, help="Print the architecture for a board (ARCH=)")
  119. parser.add_argument('-r', '--reproducible-builds', action='store_true',
  120. help='Set SOURCE_DATE_EPOCH=0 to suuport a reproducible build')
  121. parser.add_argument('-R', '--regen-board-list', type=str,
  122. help='Force regeneration of the list of boards, like the old boards.cfg file')
  123. parser.add_argument('-s', '--summary', action='store_true',
  124. default=False, help='Show a build summary')
  125. parser.add_argument('-S', '--show-sizes', action='store_true',
  126. default=False, help='Show image size variation in summary')
  127. parser.add_argument('--step', type=int,
  128. default=1, help='Only build every n commits (0=just first and last)')
  129. if HAS_TESTS:
  130. parser.add_argument('--skip-net-tests', action='store_true', default=False,
  131. help='Skip tests which need the network')
  132. parser.add_argument('-t', '--test', action='store_true', dest='test',
  133. default=False, help='run tests')
  134. parser.add_argument('--coverage', action='store_true',
  135. help='Calculated test coverage')
  136. parser.add_argument('-T', '--threads', type=int,
  137. default=None,
  138. help='Number of builder threads to use (0=single-thread)')
  139. parser.add_argument('-u', '--show_unknown', action='store_true',
  140. default=False, help='Show boards with unknown build result')
  141. parser.add_argument('-U', '--show-environment', action='store_true',
  142. default=False, help='Show environment changes in summary')
  143. parser.add_argument('-v', '--verbose', action='store_true',
  144. default=False, help='Show build results while the build progresses')
  145. parser.add_argument('-V', '--verbose-build', action='store_true',
  146. default=False, help='Run make with V=1, logging all output')
  147. parser.add_argument('-w', '--work-in-output', action='store_true',
  148. default=False, help='Use the output directory as the work directory')
  149. parser.add_argument('-W', '--ignore-warnings', action='store_true',
  150. default=False, help='Return success even if there are warnings')
  151. parser.add_argument('-x', '--exclude', dest='exclude',
  152. type=str, action='append',
  153. help='Specify a list of boards to exclude, separated by comma')
  154. parser.add_argument('-y', '--filter-dtb-warnings', action='store_true',
  155. default=False,
  156. help='Filter out device-tree-compiler warnings from output')
  157. parser.add_argument('-Y', '--filter-migration-warnings', action='store_true',
  158. default=False,
  159. help='Filter out migration warnings from output')
  160. def parse_args():
  161. """Parse command line arguments from sys.argv[]
  162. Returns:
  163. tuple containing:
  164. options: command line options
  165. args: command lin arguments
  166. """
  167. epilog = """ [list of target/arch/cpu/board/vendor/soc to build]
  168. Build U-Boot for all commits in a branch. Use -n to do a dry run"""
  169. parser = argparse.ArgumentParser(epilog=epilog)
  170. add_upto_m(parser)
  171. add_after_m(parser)
  172. parser.add_argument('terms', type=str, nargs='*',
  173. help='Board / SoC names to build')
  174. return parser.parse_args()