buildman.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #!/usr/bin/python
  2. #
  3. # Copyright (c) 2012 The Chromium OS Authors.
  4. #
  5. # See file CREDITS for list of people who contributed to this
  6. # project.
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License as
  10. # published by the Free Software Foundation; either version 2 of
  11. # the License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. # MA 02111-1307 USA
  22. #
  23. """See README for more information"""
  24. import multiprocessing
  25. from optparse import OptionParser
  26. import os
  27. import re
  28. import sys
  29. import unittest
  30. # Bring in the patman libraries
  31. our_path = os.path.dirname(os.path.realpath(__file__))
  32. sys.path.append(os.path.join(our_path, '../patman'))
  33. # Our modules
  34. import board
  35. import builder
  36. import checkpatch
  37. import command
  38. import control
  39. import doctest
  40. import gitutil
  41. import patchstream
  42. import terminal
  43. import toolchain
  44. def RunTests():
  45. import test
  46. sys.argv = [sys.argv[0]]
  47. suite = unittest.TestLoader().loadTestsFromTestCase(test.TestBuild)
  48. result = unittest.TestResult()
  49. suite.run(result)
  50. # TODO: Surely we can just 'print' result?
  51. print result
  52. for test, err in result.errors:
  53. print err
  54. for test, err in result.failures:
  55. print err
  56. parser = OptionParser()
  57. parser.add_option('-b', '--branch', type='string',
  58. help='Branch name to build')
  59. parser.add_option('-B', '--bloat', dest='show_bloat',
  60. action='store_true', default=False,
  61. help='Show changes in function code size for each board')
  62. parser.add_option('-c', '--count', dest='count', type='int',
  63. default=-1, help='Run build on the top n commits')
  64. parser.add_option('-e', '--show_errors', action='store_true',
  65. default=False, help='Show errors and warnings')
  66. parser.add_option('-f', '--force-build', dest='force_build',
  67. action='store_true', default=False,
  68. help='Force build of boards even if already built')
  69. parser.add_option('-d', '--detail', dest='show_detail',
  70. action='store_true', default=False,
  71. help='Show detailed information for each board in summary')
  72. parser.add_option('-g', '--git', type='string',
  73. help='Git repo containing branch to build', default='.')
  74. parser.add_option('-H', '--full-help', action='store_true', dest='full_help',
  75. default=False, help='Display the README file')
  76. parser.add_option('-j', '--jobs', dest='jobs', type='int',
  77. default=None, help='Number of jobs to run at once (passed to make)')
  78. parser.add_option('-k', '--keep-outputs', action='store_true',
  79. default=False, help='Keep all build output files (e.g. binaries)')
  80. parser.add_option('--list-tool-chains', action='store_true', default=False,
  81. help='List available tool chains')
  82. parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
  83. default=False, help="Do a try run (describe actions, but no nothing)")
  84. parser.add_option('-Q', '--quick', action='store_true',
  85. default=False, help='Do a rough build, with limited warning resolution')
  86. parser.add_option('-s', '--summary', action='store_true',
  87. default=False, help='Show a build summary')
  88. parser.add_option('-S', '--show-sizes', action='store_true',
  89. default=False, help='Show image size variation in summary')
  90. parser.add_option('--step', type='int',
  91. default=1, help='Only build every n commits (0=just first and last)')
  92. parser.add_option('-t', '--test', action='store_true', dest='test',
  93. default=False, help='run tests')
  94. parser.add_option('-T', '--threads', type='int',
  95. default=None, help='Number of builder threads to use')
  96. parser.add_option('-u', '--show_unknown', action='store_true',
  97. default=False, help='Show boards with unknown build result')
  98. parser.usage = """buildman -b <branch> [options]
  99. Build U-Boot for all commits in a branch. Use -n to do a dry run"""
  100. (options, args) = parser.parse_args()
  101. # Run our meagre tests
  102. if options.test:
  103. RunTests()
  104. elif options.full_help:
  105. pager = os.getenv('PAGER')
  106. if not pager:
  107. pager = 'more'
  108. fname = os.path.join(os.path.dirname(sys.argv[0]), 'README')
  109. command.Run(pager, fname)
  110. # Build selected commits for selected boards
  111. else:
  112. control.DoBuildman(options, args)