Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame^] | 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 | |
| 24 | """See README for more information""" |
| 25 | |
| 26 | import multiprocessing |
| 27 | from optparse import OptionParser |
| 28 | import os |
| 29 | import re |
| 30 | import sys |
| 31 | import unittest |
| 32 | |
| 33 | # Bring in the patman libraries |
| 34 | our_path = os.path.dirname(os.path.realpath(__file__)) |
| 35 | sys.path.append(os.path.join(our_path, '../patman')) |
| 36 | |
| 37 | # Our modules |
| 38 | import board |
| 39 | import builder |
| 40 | import checkpatch |
| 41 | import command |
| 42 | import control |
| 43 | import doctest |
| 44 | import gitutil |
| 45 | import patchstream |
| 46 | import terminal |
| 47 | import toolchain |
| 48 | |
| 49 | def RunTests(): |
| 50 | import test |
| 51 | |
| 52 | sys.argv = [sys.argv[0]] |
| 53 | suite = unittest.TestLoader().loadTestsFromTestCase(test.TestBuild) |
| 54 | result = unittest.TestResult() |
| 55 | suite.run(result) |
| 56 | |
| 57 | # TODO: Surely we can just 'print' result? |
| 58 | print result |
| 59 | for test, err in result.errors: |
| 60 | print err |
| 61 | for test, err in result.failures: |
| 62 | print err |
| 63 | |
| 64 | |
| 65 | parser = OptionParser() |
| 66 | parser.add_option('-b', '--branch', type='string', |
| 67 | help='Branch name to build') |
| 68 | parser.add_option('-B', '--bloat', dest='show_bloat', |
| 69 | action='store_true', default=False, |
| 70 | help='Show changes in function code size for each board') |
| 71 | parser.add_option('-c', '--count', dest='count', type='int', |
| 72 | default=-1, help='Run build on the top n commits') |
| 73 | parser.add_option('-e', '--show_errors', action='store_true', |
| 74 | default=False, help='Show errors and warnings') |
| 75 | parser.add_option('-f', '--force-build', dest='force_build', |
| 76 | action='store_true', default=False, |
| 77 | help='Force build of boards even if already built') |
| 78 | parser.add_option('-d', '--detail', dest='show_detail', |
| 79 | action='store_true', default=False, |
| 80 | help='Show detailed information for each board in summary') |
| 81 | parser.add_option('-g', '--git', type='string', |
| 82 | help='Git repo containing branch to build', default='.') |
| 83 | parser.add_option('-H', '--full-help', action='store_true', dest='full_help', |
| 84 | default=False, help='Display the README file') |
| 85 | parser.add_option('-j', '--jobs', dest='jobs', type='int', |
| 86 | default=None, help='Number of jobs to run at once (passed to make)') |
| 87 | parser.add_option('-k', '--keep-outputs', action='store_true', |
| 88 | default=False, help='Keep all build output files (e.g. binaries)') |
| 89 | parser.add_option('--list-tool-chains', action='store_true', default=False, |
| 90 | help='List available tool chains') |
| 91 | parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run', |
| 92 | default=False, help="Do a try run (describe actions, but no nothing)") |
| 93 | parser.add_option('-Q', '--quick', action='store_true', |
| 94 | default=False, help='Do a rough build, with limited warning resolution') |
| 95 | parser.add_option('-s', '--summary', action='store_true', |
| 96 | default=False, help='Show a build summary') |
| 97 | parser.add_option('-S', '--show-sizes', action='store_true', |
| 98 | default=False, help='Show image size variation in summary') |
| 99 | parser.add_option('--step', type='int', |
| 100 | default=1, help='Only build every n commits (0=just first and last)') |
| 101 | parser.add_option('-t', '--test', action='store_true', dest='test', |
| 102 | default=False, help='run tests') |
| 103 | parser.add_option('-T', '--threads', type='int', |
| 104 | default=None, help='Number of builder threads to use') |
| 105 | parser.add_option('-u', '--show_unknown', action='store_true', |
| 106 | default=False, help='Show boards with unknown build result') |
| 107 | |
| 108 | parser.usage = """buildman -b <branch> [options] |
| 109 | |
| 110 | Build U-Boot for all commits in a branch. Use -n to do a dry run""" |
| 111 | |
| 112 | (options, args) = parser.parse_args() |
| 113 | |
| 114 | # Run our meagre tests |
| 115 | if options.test: |
| 116 | RunTests() |
| 117 | elif options.full_help: |
| 118 | pager = os.getenv('PAGER') |
| 119 | if not pager: |
| 120 | pager = 'more' |
| 121 | fname = os.path.join(os.path.dirname(sys.argv[0]), 'README') |
| 122 | command.Run(pager, fname) |
| 123 | |
| 124 | # Build selected commits for selected boards |
| 125 | else: |
| 126 | control.DoBuildman(options, args) |