diff options
Diffstat (limited to 'tools/buildman/control.py')
-rw-r--r-- | tools/buildman/control.py | 96 |
1 files changed, 65 insertions, 31 deletions
diff --git a/tools/buildman/control.py b/tools/buildman/control.py index c55a65d0c3..969d866547 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -107,6 +107,34 @@ def CheckOutputDir(output_dir): break path = parent +def ShowToolchainInfo(boards, toolchains, print_arch, print_prefix): + """Show information about a the tool chain used by one or more boards + + The function checks that all boards use the same toolchain. + + Args: + boards: Boards object containing selected boards + toolchains: Toolchains object containing available toolchains + print_arch: True to print ARCH value + print_prefix: True to print CROSS_COMPILE value + + Return: + None on success, string error message otherwise + """ + boards = boards.GetSelectedDict() + tc_set = set() + for brd in boards.values(): + tc_set.add(toolchains.Select(brd.arch)) + if len(tc_set) != 1: + return 'Supplied boards must share one toolchain' + return False + tc = tc_set.pop() + if print_arch: + print(tc.GetEnvArgs(toolchain.VAR_ARCH)) + if print_prefix: + print(tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE)) + return None + def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, clean_dir=False): """The main control code for buildman @@ -170,42 +198,13 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, print() return 0 - # Work out how many commits to build. We want to build everything on the - # branch. We also build the upstream commit as a control so we can see - # problems introduced by the first commit on the branch. - count = options.count - has_range = options.branch and '..' in options.branch - if count == -1: - if not options.branch: - count = 1 - else: - if has_range: - count, msg = gitutil.CountCommitsInRange(options.git_dir, - options.branch) - else: - count, msg = gitutil.CountCommitsInBranch(options.git_dir, - options.branch) - if count is None: - sys.exit(col.Color(col.RED, msg)) - elif count == 0: - sys.exit(col.Color(col.RED, "Range '%s' has no commits" % - options.branch)) - if msg: - print(col.Color(col.YELLOW, msg)) - count += 1 # Build upstream commit also - - if not count: - str = ("No commits found to process in branch '%s': " - "set branch's upstream or use -c flag" % options.branch) - sys.exit(col.Color(col.RED, str)) - # 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') - status = subprocess.call([genboardscfg, '-o', board_file]) + status = subprocess.call([genboardscfg, '-q', '-o', board_file]) if status != 0: sys.exit("Failed to generate boards.cfg") @@ -217,7 +216,6 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, for arg in options.exclude: exclude += arg.split(',') - if options.boards: requested_boards = [] for b in options.boards: @@ -230,6 +228,42 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, if not len(selected): sys.exit(col.Color(col.RED, 'No matching boards found')) + if options.print_arch or options.print_prefix: + err = ShowToolchainInfo(boards, toolchains, options.print_arch, + options.print_prefix) + if err: + sys.exit(col.Color(col.RED, err)) + return 0 + + # Work out how many commits to build. We want to build everything on the + # branch. We also build the upstream commit as a control so we can see + # problems introduced by the first commit on the branch. + count = options.count + has_range = options.branch and '..' in options.branch + if count == -1: + if not options.branch: + count = 1 + else: + if has_range: + count, msg = gitutil.CountCommitsInRange(options.git_dir, + options.branch) + else: + count, msg = gitutil.CountCommitsInBranch(options.git_dir, + options.branch) + if count is None: + sys.exit(col.Color(col.RED, msg)) + elif count == 0: + sys.exit(col.Color(col.RED, "Range '%s' has no commits" % + options.branch)) + if msg: + print(col.Color(col.YELLOW, msg)) + count += 1 # Build upstream commit also + + if not count: + str = ("No commits found to process in branch '%s': " + "set branch's upstream or use -c flag" % options.branch) + sys.exit(col.Color(col.RED, str)) + # Read the metadata from the commits. First look at the upstream commit, # then the ones in the branch. We would like to do something like # upstream/master~..branch but that isn't possible if upstream/master is |