Jagannadha Sutradharudu Teki | a707b3d | 2013-09-28 23:08:14 +0530 | [diff] [blame] | 1 | #!/usr/bin/env python |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 2 | # |
| 3 | # Copyright (c) 2012 The Chromium OS Authors. |
| 4 | # |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | fc3fe1c | 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 |
Simon Glass | 4281ad8 | 2013-09-23 17:35:17 -0600 | [diff] [blame] | 35 | import doctest |
| 36 | |
| 37 | result = unittest.TestResult() |
| 38 | for module in ['toolchain']: |
| 39 | suite = doctest.DocTestSuite(module) |
| 40 | suite.run(result) |
| 41 | |
| 42 | # TODO: Surely we can just 'print' result? |
| 43 | print result |
| 44 | for test, err in result.errors: |
| 45 | print err |
| 46 | for test, err in result.failures: |
| 47 | print err |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 48 | |
| 49 | sys.argv = [sys.argv[0]] |
| 50 | suite = unittest.TestLoader().loadTestsFromTestCase(test.TestBuild) |
| 51 | result = unittest.TestResult() |
| 52 | suite.run(result) |
| 53 | |
| 54 | # TODO: Surely we can just 'print' result? |
| 55 | print result |
| 56 | for test, err in result.errors: |
| 57 | print err |
| 58 | for test, err in result.failures: |
| 59 | print err |
| 60 | |
| 61 | |
| 62 | parser = OptionParser() |
| 63 | parser.add_option('-b', '--branch', type='string', |
| 64 | help='Branch name to build') |
| 65 | parser.add_option('-B', '--bloat', dest='show_bloat', |
| 66 | action='store_true', default=False, |
| 67 | help='Show changes in function code size for each board') |
| 68 | parser.add_option('-c', '--count', dest='count', type='int', |
| 69 | default=-1, help='Run build on the top n commits') |
Simon Glass | 97e9152 | 2014-07-14 17:51:02 -0600 | [diff] [blame] | 70 | parser.add_option('-C', '--force-reconfig', dest='force_reconfig', |
| 71 | action='store_true', default=False, |
| 72 | help='Reconfigure for every commit (disable incremental build)') |
Simon Glass | c1de501 | 2014-08-09 15:33:01 -0600 | [diff] [blame^] | 73 | parser.add_option('-d', '--detail', dest='show_detail', |
| 74 | action='store_true', default=False, |
| 75 | help='Show detailed information for each board in summary') |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 76 | parser.add_option('-e', '--show_errors', action='store_true', |
| 77 | default=False, help='Show errors and warnings') |
| 78 | parser.add_option('-f', '--force-build', dest='force_build', |
| 79 | action='store_true', default=False, |
| 80 | help='Force build of boards even if already built') |
Simon Glass | 4266dc2 | 2014-07-13 12:22:31 -0600 | [diff] [blame] | 81 | parser.add_option('-F', '--force-build-failures', dest='force_build_failures', |
| 82 | action='store_true', default=False, |
| 83 | help='Force build of previously-failed build') |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 84 | parser.add_option('-g', '--git', type='string', |
| 85 | help='Git repo containing branch to build', default='.') |
| 86 | parser.add_option('-H', '--full-help', action='store_true', dest='full_help', |
| 87 | default=False, help='Display the README file') |
Simon Glass | 189a496 | 2014-07-14 17:51:03 -0600 | [diff] [blame] | 88 | parser.add_option('-i', '--in-tree', dest='in_tree', |
| 89 | action='store_true', default=False, |
| 90 | help='Build in the source tree instead of a separate directory') |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 91 | parser.add_option('-j', '--jobs', dest='jobs', type='int', |
| 92 | default=None, help='Number of jobs to run at once (passed to make)') |
| 93 | parser.add_option('-k', '--keep-outputs', action='store_true', |
| 94 | default=False, help='Keep all build output files (e.g. binaries)') |
| 95 | parser.add_option('--list-tool-chains', action='store_true', default=False, |
| 96 | help='List available tool chains') |
| 97 | parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run', |
| 98 | default=False, help="Do a try run (describe actions, but no nothing)") |
Simon Glass | c1de501 | 2014-08-09 15:33:01 -0600 | [diff] [blame^] | 99 | parser.add_option('-o', '--output-dir', type='string', |
| 100 | dest='output_dir', default='..', |
| 101 | help='Directory where all builds happen and buildman has its workspace (default is ../)') |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 102 | parser.add_option('-Q', '--quick', action='store_true', |
| 103 | default=False, help='Do a rough build, with limited warning resolution') |
| 104 | parser.add_option('-s', '--summary', action='store_true', |
| 105 | default=False, help='Show a build summary') |
| 106 | parser.add_option('-S', '--show-sizes', action='store_true', |
| 107 | default=False, help='Show image size variation in summary') |
| 108 | parser.add_option('--step', type='int', |
| 109 | default=1, help='Only build every n commits (0=just first and last)') |
| 110 | parser.add_option('-t', '--test', action='store_true', dest='test', |
| 111 | default=False, help='run tests') |
| 112 | parser.add_option('-T', '--threads', type='int', |
| 113 | default=None, help='Number of builder threads to use') |
| 114 | parser.add_option('-u', '--show_unknown', action='store_true', |
| 115 | default=False, help='Show boards with unknown build result') |
Simon Glass | fc3fe1c | 2013-04-03 11:07:16 +0000 | [diff] [blame] | 116 | |
| 117 | parser.usage = """buildman -b <branch> [options] |
| 118 | |
| 119 | Build U-Boot for all commits in a branch. Use -n to do a dry run""" |
| 120 | |
| 121 | (options, args) = parser.parse_args() |
| 122 | |
| 123 | # Run our meagre tests |
| 124 | if options.test: |
| 125 | RunTests() |
| 126 | elif options.full_help: |
| 127 | pager = os.getenv('PAGER') |
| 128 | if not pager: |
| 129 | pager = 'more' |
| 130 | fname = os.path.join(os.path.dirname(sys.argv[0]), 'README') |
| 131 | command.Run(pager, fname) |
| 132 | |
| 133 | # Build selected commits for selected boards |
| 134 | else: |
| 135 | control.DoBuildman(options, args) |