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