buildman.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #!/usr/bin/env python
  2. #
  3. # Copyright (c) 2012 The Chromium OS Authors.
  4. #
  5. # SPDX-License-Identifier: GPL-2.0+
  6. #
  7. """See README for more information"""
  8. import multiprocessing
  9. from optparse import OptionParser
  10. import os
  11. import re
  12. import sys
  13. import unittest
  14. # Bring in the patman libraries
  15. our_path = os.path.dirname(os.path.realpath(__file__))
  16. sys.path.append(os.path.join(our_path, '../patman'))
  17. # Our modules
  18. import board
  19. import builder
  20. import checkpatch
  21. import command
  22. import control
  23. import doctest
  24. import gitutil
  25. import patchstream
  26. import terminal
  27. import toolchain
  28. def RunTests():
  29. import test
  30. import doctest
  31. result = unittest.TestResult()
  32. for module in ['toolchain']:
  33. suite = doctest.DocTestSuite(module)
  34. suite.run(result)
  35. # TODO: Surely we can just 'print' result?
  36. print result
  37. for test, err in result.errors:
  38. print err
  39. for test, err in result.failures:
  40. print err
  41. sys.argv = [sys.argv[0]]
  42. suite = unittest.TestLoader().loadTestsFromTestCase(test.TestBuild)
  43. result = unittest.TestResult()
  44. suite.run(result)
  45. # TODO: Surely we can just 'print' result?
  46. print result
  47. for test, err in result.errors:
  48. print err
  49. for test, err in result.failures:
  50. print err
  51. parser = OptionParser()
  52. parser.add_option('-b', '--branch', type='string',
  53. help='Branch name to build')
  54. parser.add_option('-B', '--bloat', dest='show_bloat',
  55. action='store_true', default=False,
  56. help='Show changes in function code size for each board')
  57. parser.add_option('-c', '--count', dest='count', type='int',
  58. default=-1, help='Run build on the top n commits')
  59. parser.add_option('-C', '--force-reconfig', dest='force_reconfig',
  60. action='store_true', default=False,
  61. help='Reconfigure for every commit (disable incremental build)')
  62. parser.add_option('-d', '--detail', dest='show_detail',
  63. action='store_true', default=False,
  64. help='Show detailed information for each board in summary')
  65. parser.add_option('-e', '--show_errors', action='store_true',
  66. default=False, help='Show errors and warnings')
  67. parser.add_option('-f', '--force-build', dest='force_build',
  68. action='store_true', default=False,
  69. help='Force build of boards even if already built')
  70. parser.add_option('-F', '--force-build-failures', dest='force_build_failures',
  71. action='store_true', default=False,
  72. help='Force build of previously-failed build')
  73. parser.add_option('-g', '--git', type='string',
  74. help='Git repo containing branch to build', default='.')
  75. parser.add_option('-G', '--config-file', type='string',
  76. help='Path to buildman config file', default='')
  77. parser.add_option('-H', '--full-help', action='store_true', dest='full_help',
  78. default=False, help='Display the README file')
  79. parser.add_option('-i', '--in-tree', dest='in_tree',
  80. action='store_true', default=False,
  81. help='Build in the source tree instead of a separate directory')
  82. parser.add_option('-j', '--jobs', dest='jobs', type='int',
  83. default=None, help='Number of jobs to run at once (passed to make)')
  84. parser.add_option('-k', '--keep-outputs', action='store_true',
  85. default=False, help='Keep all build output files (e.g. binaries)')
  86. parser.add_option('-l', '--list-error-boards', action='store_true',
  87. default=False, help='Show a list of boards next to each error/warning')
  88. parser.add_option('--list-tool-chains', action='store_true', default=False,
  89. help='List available tool chains')
  90. parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
  91. default=False, help="Do a try run (describe actions, but no nothing)")
  92. parser.add_option('-o', '--output-dir', type='string',
  93. dest='output_dir', default='..',
  94. help='Directory where all builds happen and buildman has its workspace (default is ../)')
  95. parser.add_option('-Q', '--quick', action='store_true',
  96. default=False, help='Do a rough build, with limited warning resolution')
  97. parser.add_option('-s', '--summary', action='store_true',
  98. default=False, help='Show a build summary')
  99. parser.add_option('-S', '--show-sizes', action='store_true',
  100. default=False, help='Show image size variation in summary')
  101. parser.add_option('--step', type='int',
  102. default=1, help='Only build every n commits (0=just first and last)')
  103. parser.add_option('-t', '--test', action='store_true', dest='test',
  104. default=False, help='run tests')
  105. parser.add_option('-T', '--threads', type='int',
  106. default=None, help='Number of builder threads to use')
  107. parser.add_option('-u', '--show_unknown', action='store_true',
  108. default=False, help='Show boards with unknown build result')
  109. parser.add_option('-v', '--verbose', action='store_true',
  110. default=False, help='Show build results while the build progresses')
  111. parser.add_option('-x', '--exclude', dest='exclude',
  112. type='string', action='append',
  113. help='Specify a list of boards to exclude, separated by comma')
  114. parser.usage += """
  115. Build U-Boot for all commits in a branch. Use -n to do a dry run"""
  116. (options, args) = parser.parse_args()
  117. # Run our meagre tests
  118. if options.test:
  119. RunTests()
  120. elif options.full_help:
  121. pager = os.getenv('PAGER')
  122. if not pager:
  123. pager = 'more'
  124. fname = os.path.join(os.path.dirname(sys.argv[0]), 'README')
  125. command.Run(pager, fname)
  126. # Build selected commits for selected boards
  127. else:
  128. ret_code = control.DoBuildman(options, args)
  129. sys.exit(ret_code)