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