]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - tools/buildman/buildman.py
buildman: Move the command line code into its own file
[karo-tx-uboot.git] / tools / buildman / buildman.py
1 #!/usr/bin/env python
2 #
3 # Copyright (c) 2012 The Chromium OS Authors.
4 #
5 # SPDX-License-Identifier:      GPL-2.0+
6 #
7
8 """See README for more information"""
9
10 import multiprocessing
11 import os
12 import re
13 import sys
14 import unittest
15
16 # Bring in the patman libraries
17 our_path = os.path.dirname(os.path.realpath(__file__))
18 sys.path.append(os.path.join(our_path, '../patman'))
19
20 # Our modules
21 import board
22 import builder
23 import checkpatch
24 import cmdline
25 import control
26 import doctest
27 import gitutil
28 import patchstream
29 import terminal
30 import toolchain
31
32 def RunTests():
33     import test
34     import doctest
35
36     result = unittest.TestResult()
37     for module in ['toolchain']:
38         suite = doctest.DocTestSuite(module)
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     sys.argv = [sys.argv[0]]
49     suite = unittest.TestLoader().loadTestsFromTestCase(test.TestBuild)
50     result = unittest.TestResult()
51     suite.run(result)
52
53     # TODO: Surely we can just 'print' result?
54     print result
55     for test, err in result.errors:
56         print err
57     for test, err in result.failures:
58         print err
59
60
61 options, args = cmdline.ParseArgs()
62
63 # Run our meagre tests
64 if options.test:
65     RunTests()
66 elif options.full_help:
67     pager = os.getenv('PAGER')
68     if not pager:
69         pager = 'more'
70     fname = os.path.join(os.path.dirname(sys.argv[0]), 'README')
71     command.Run(pager, fname)
72
73 # Build selected commits for selected boards
74 else:
75     ret_code = control.DoBuildman(options, args)
76     sys.exit(ret_code)