import multiprocessing
import os
import shutil
+import subprocess
import sys
-import board
-import bsettings
-from builder import Builder
-import gitutil
-import patchstream
-import terminal
-from terminal import Print
-import toolchain
-import command
-import subprocess
+from buildman import board
+from buildman import bsettings
+from buildman import cfgutil
+from buildman import toolchain
+from buildman.builder import Builder
+from patman import command
+from patman import gitutil
+from patman import patchstream
+from patman import terminal
+from patman import tools
+from patman.terminal import Print
def GetPlural(count):
"""Returns a plural 's' if count is not 1"""
return None
def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
- clean_dir=False):
+ clean_dir=False, test_thread_exceptions=False):
"""The main control code for buildman
Args:
arguments. This setting is useful for tests.
board: Boards() object to use, containing a list of available
boards. If this is None it will be created and scanned.
+ clean_dir: Used for tests only, indicates that the existing output_dir
+ should be removed before starting the build
+ test_thread_exceptions: Uses for tests only, True to make the threads
+ raise an exception instead of reporting their result. This simulates
+ a failure in the code somewhere
"""
global builder
if options.full_help:
- pager = os.getenv('PAGER')
- if not pager:
- pager = 'more'
- fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
- 'README')
- command.Run(pager, fname)
+ tools.print_full_help(
+ os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'README')
+ )
return 0
gitutil.Setup()
print()
return 0
+ if options.incremental:
+ print(col.Color(col.RED,
+ 'Warning: -I has been removed. See documentation'))
+ if not options.output_dir:
+ if options.work_in_output:
+ sys.exit(col.Color(col.RED, '-w requires that you specify -o'))
+ options.output_dir = '..'
+
# Work out what subset of the boards we are building
if not boards:
if not os.path.exists(options.output_dir):
os.makedirs(options.output_dir)
board_file = os.path.join(options.output_dir, 'boards.cfg')
- genboardscfg = os.path.join(options.git, 'tools/genboardscfg.py')
+ our_path = os.path.dirname(os.path.realpath(__file__))
+ genboardscfg = os.path.join(our_path, '../genboardscfg.py')
+ if not os.path.exists(genboardscfg):
+ genboardscfg = os.path.join(options.git, 'tools/genboardscfg.py')
status = subprocess.call([genboardscfg, '-q', '-o', board_file])
if status != 0:
- sys.exit("Failed to generate boards.cfg")
+ # Older versions don't support -q
+ status = subprocess.call([genboardscfg, '-o', board_file])
+ if status != 0:
+ sys.exit("Failed to generate boards.cfg")
boards = board.Boards()
boards.ReadBoards(board_file)
sys.exit(col.Color(col.RED, 'No matching boards found'))
if options.print_prefix:
- err = ShowToolchainInfo(boards, toolchains)
+ err = ShowToolchainPrefix(boards, toolchains)
if err:
sys.exit(col.Color(col.RED, err))
return 0
options.branch)
upstream_commit = gitutil.GetUpstream(options.git_dir,
options.branch)
- series = patchstream.GetMetaDataForList(upstream_commit,
+ series = patchstream.get_metadata_for_list(upstream_commit,
options.git_dir, 1, series=None, allow_overwrite=True)
- series = patchstream.GetMetaDataForList(range_expr,
+ series = patchstream.get_metadata_for_list(range_expr,
options.git_dir, None, series, allow_overwrite=True)
else:
# Honour the count
- series = patchstream.GetMetaDataForList(options.branch,
+ series = patchstream.get_metadata_for_list(options.branch,
options.git_dir, count, series=None, allow_overwrite=True)
else:
series = None
# By default we have one thread per CPU. But if there are not enough jobs
# we can have fewer threads and use a high '-j' value for make.
- if not options.threads:
+ if options.threads is None:
options.threads = min(multiprocessing.cpu_count(), len(selected))
if not options.jobs:
options.jobs = max(1, (multiprocessing.cpu_count() +
if not options.step:
options.step = len(series.commits) - 1
- gnu_make = command.Output(os.path.join(options.git,
+ gnu_make = command.output(os.path.join(options.git,
'scripts/show-gnu-make'), raise_on_error=False).rstrip()
if not gnu_make:
sys.exit('GNU Make not found')
output_dir = os.path.join(options.output_dir, dirname)
if clean_dir and os.path.exists(output_dir):
shutil.rmtree(output_dir)
+ adjust_cfg = cfgutil.convert_list_to_dict(options.adjust_cfg)
+
builder = Builder(toolchains, output_dir, options.git_dir,
options.threads, options.jobs, gnu_make=gnu_make, checkout=True,
show_unknown=options.show_unknown, step=options.step,
no_subdirs=options.no_subdirs, full_path=options.full_path,
verbose_build=options.verbose_build,
- incremental=options.incremental,
+ mrproper=options.mrproper,
per_board_out_dir=options.per_board_out_dir,
config_only=options.config_only,
squash_config_y=not options.preserve_config_y,
warnings_as_errors=options.warnings_as_errors,
- work_in_output=options.work_in_output)
+ work_in_output=options.work_in_output,
+ test_thread_exceptions=test_thread_exceptions,
+ adjust_cfg=adjust_cfg)
builder.force_config_on_failure = not options.quick
if make_func:
builder.do_make = make_func
commits = None
Print(GetActionSummary(options.summary, commits, board_selected,
- options))
+ options))
# We can't show function sizes without board details at present
if options.show_bloat:
options.show_detail = True
- builder.SetDisplayOptions(options.show_errors, options.show_sizes,
- options.show_detail, options.show_bloat,
- options.list_error_boards,
- options.show_config,
- options.show_environment)
+ builder.SetDisplayOptions(
+ options.show_errors, options.show_sizes, options.show_detail,
+ options.show_bloat, options.list_error_boards, options.show_config,
+ options.show_environment, options.filter_dtb_warnings,
+ options.filter_migration_warnings)
if options.summary:
builder.ShowSummary(commits, board_selected)
else:
- fail, warned = builder.BuildBoards(commits, board_selected,
- options.keep_outputs, options.verbose)
- if fail:
- return 128
+ fail, warned, excs = builder.BuildBoards(
+ commits, board_selected, options.keep_outputs, options.verbose)
+ if excs:
+ return 102
+ elif fail:
+ return 100
elif warned and not options.ignore_warnings:
- return 129
+ return 101
return 0