blob: 0da6797e7f016a4c66ade07d60913f42446b17f3 [file] [log] [blame]
Jagannadha Sutradharudu Tekia707b3d2013-09-28 23:08:14 +05301#!/usr/bin/env python
Simon Glassfc3fe1c2013-04-03 11:07:16 +00002#
3# Copyright (c) 2012 The Chromium OS Authors.
4#
Wolfgang Denk1a459662013-07-08 09:37:19 +02005# SPDX-License-Identifier: GPL-2.0+
Simon Glassfc3fe1c2013-04-03 11:07:16 +00006#
7
8"""See README for more information"""
9
10import multiprocessing
11from optparse import OptionParser
12import os
13import re
14import sys
15import unittest
16
17# Bring in the patman libraries
18our_path = os.path.dirname(os.path.realpath(__file__))
19sys.path.append(os.path.join(our_path, '../patman'))
20
21# Our modules
22import board
23import builder
24import checkpatch
25import command
26import control
27import doctest
28import gitutil
29import patchstream
30import terminal
31import toolchain
32
33def RunTests():
34 import test
Simon Glass4281ad82013-09-23 17:35:17 -060035 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 Glassfc3fe1c2013-04-03 11:07:16 +000048
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
62parser = OptionParser()
63parser.add_option('-b', '--branch', type='string',
64 help='Branch name to build')
65parser.add_option('-B', '--bloat', dest='show_bloat',
66 action='store_true', default=False,
67 help='Show changes in function code size for each board')
68parser.add_option('-c', '--count', dest='count', type='int',
69 default=-1, help='Run build on the top n commits')
70parser.add_option('-e', '--show_errors', action='store_true',
71 default=False, help='Show errors and warnings')
72parser.add_option('-f', '--force-build', dest='force_build',
73 action='store_true', default=False,
74 help='Force build of boards even if already built')
Simon Glass4266dc22014-07-13 12:22:31 -060075parser.add_option('-F', '--force-build-failures', dest='force_build_failures',
76 action='store_true', default=False,
77 help='Force build of previously-failed build')
Simon Glassfc3fe1c2013-04-03 11:07:16 +000078parser.add_option('-d', '--detail', dest='show_detail',
79 action='store_true', default=False,
80 help='Show detailed information for each board in summary')
81parser.add_option('-g', '--git', type='string',
82 help='Git repo containing branch to build', default='.')
83parser.add_option('-H', '--full-help', action='store_true', dest='full_help',
84 default=False, help='Display the README file')
85parser.add_option('-j', '--jobs', dest='jobs', type='int',
86 default=None, help='Number of jobs to run at once (passed to make)')
87parser.add_option('-k', '--keep-outputs', action='store_true',
88 default=False, help='Keep all build output files (e.g. binaries)')
89parser.add_option('--list-tool-chains', action='store_true', default=False,
90 help='List available tool chains')
91parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
92 default=False, help="Do a try run (describe actions, but no nothing)")
93parser.add_option('-Q', '--quick', action='store_true',
94 default=False, help='Do a rough build, with limited warning resolution')
95parser.add_option('-s', '--summary', action='store_true',
96 default=False, help='Show a build summary')
97parser.add_option('-S', '--show-sizes', action='store_true',
98 default=False, help='Show image size variation in summary')
99parser.add_option('--step', type='int',
100 default=1, help='Only build every n commits (0=just first and last)')
101parser.add_option('-t', '--test', action='store_true', dest='test',
102 default=False, help='run tests')
103parser.add_option('-T', '--threads', type='int',
104 default=None, help='Number of builder threads to use')
105parser.add_option('-u', '--show_unknown', action='store_true',
106 default=False, help='Show boards with unknown build result')
Daniel Schwierzecke0ba9292014-04-17 21:13:11 +0200107parser.add_option('-o', '--output-dir', type='string',
108 dest='output_dir', default='..',
109 help='Directory where all builds happen and buildman has its workspace (default is ../)')
Simon Glassfc3fe1c2013-04-03 11:07:16 +0000110
111parser.usage = """buildman -b <branch> [options]
112
113Build U-Boot for all commits in a branch. Use -n to do a dry run"""
114
115(options, args) = parser.parse_args()
116
117# Run our meagre tests
118if options.test:
119 RunTests()
120elif 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
127# Build selected commits for selected boards
128else:
129 control.DoBuildman(options, args)