summaryrefslogtreecommitdiff
path: root/tools/buildman
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-01-30 00:14:17 +0300
committerSimon Glass <sjg@chromium.org>2022-02-09 22:30:13 +0300
commit252ac589969acbc4c17379a4e862a18e1518d12d (patch)
treec17e36e0f9590e6de59f812066e6649c22be0000 /tools/buildman
parent82e0e732ee2cf6d0e125aeb7ed7de69711f35ec8 (diff)
downloadu-boot-252ac589969acbc4c17379a4e862a18e1518d12d.tar.xz
patman: Rename Color() method to build()
This method has the same name as its class which is confusing. It is also annoying when searching the code. It builds a string with a colour, so rename it to build(). Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/buildman')
-rw-r--r--tools/buildman/builder.py24
-rw-r--r--tools/buildman/control.py28
-rw-r--r--tools/buildman/test.py20
-rw-r--r--tools/buildman/toolchain.py10
4 files changed, 41 insertions, 41 deletions
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 8c7fc725de..364adb1cb5 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -518,14 +518,14 @@ class Builder:
# Display separate counts for ok, warned and fail
ok = self.upto - self.warned - self.fail
- line = '\r' + self.col.Color(self.col.GREEN, '%5d' % ok)
- line += self.col.Color(self.col.YELLOW, '%5d' % self.warned)
- line += self.col.Color(self.col.RED, '%5d' % self.fail)
+ line = '\r' + self.col.build(self.col.GREEN, '%5d' % ok)
+ line += self.col.build(self.col.YELLOW, '%5d' % self.warned)
+ line += self.col.build(self.col.RED, '%5d' % self.fail)
line += ' /%-5d ' % self.count
remaining = self.count - self.upto
if remaining:
- line += self.col.Color(self.col.MAGENTA, ' -%-5d ' % remaining)
+ line += self.col.build(self.col.MAGENTA, ' -%-5d ' % remaining)
else:
line += ' ' * 8
@@ -933,9 +933,9 @@ class Builder:
arch = board_dict[target].arch
else:
arch = 'unknown'
- str = self.col.Color(color, ' ' + target)
+ str = self.col.build(color, ' ' + target)
if not arch in done_arch:
- str = ' %s %s' % (self.col.Color(color, char), str)
+ str = ' %s %s' % (self.col.build(color, char), str)
done_arch[arch] = True
if not arch in arch_list:
arch_list[arch] = str
@@ -947,7 +947,7 @@ class Builder:
color = self.col.RED if num > 0 else self.col.GREEN
if num == 0:
return '0'
- return self.col.Color(color, str(num))
+ return self.col.build(color, str(num))
def ResetResultSummary(self, board_selected):
"""Reset the results summary ready for use.
@@ -1010,7 +1010,7 @@ class Builder:
args = [self.ColourNum(x) for x in args]
indent = ' ' * 15
Tprint('%s%s: add: %s/%s, grow: %s/%s bytes: %s/%s (%s)' %
- tuple([indent, self.col.Color(self.col.YELLOW, fname)] + args))
+ tuple([indent, self.col.build(self.col.YELLOW, fname)] + args))
Tprint('%s %-38s %7s %7s %+7s' % (indent, 'function', 'old', 'new',
'delta'))
for diff, name in delta:
@@ -1324,12 +1324,12 @@ class Builder:
names = [board.target for board in line.boards]
board_str = ' '.join(names) if names else ''
if board_str:
- out = self.col.Color(colour, line.char + '(')
- out += self.col.Color(self.col.MAGENTA, board_str,
+ out = self.col.build(colour, line.char + '(')
+ out += self.col.build(self.col.MAGENTA, board_str,
bright=False)
- out += self.col.Color(colour, ') %s' % line.errline)
+ out += self.col.build(colour, ') %s' % line.errline)
else:
- out = self.col.Color(colour, line.char + line.errline)
+ out = self.col.build(colour, line.char + line.errline)
out_list.append(out)
Tprint('\n'.join(out_list))
self._error_lines += 1
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 0e4b2e0a9d..195d27a044 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -73,7 +73,7 @@ def ShowActions(series, why_selected, boards_selected, builder, options,
if commits:
for upto in range(0, len(series.commits), options.step):
commit = series.commits[upto]
- print(' ', col.Color(col.YELLOW, commit.hash[:8], bright=False), end=' ')
+ print(' ', col.build(col.YELLOW, commit.hash[:8], bright=False), end=' ')
print(commit.subject)
print()
for arg in why_selected:
@@ -85,7 +85,7 @@ def ShowActions(series, why_selected, boards_selected, builder, options,
len(why_selected['all'])))
if board_warnings:
for warning in board_warnings:
- print(col.Color(col.YELLOW, warning))
+ print(col.build(col.YELLOW, warning))
def ShowToolchainPrefix(boards, toolchains):
"""Show information about a the tool chain used by one or more boards
@@ -152,14 +152,14 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
if options.fetch_arch:
if options.fetch_arch == 'list':
sorted_list = toolchains.ListArchs()
- print(col.Color(col.BLUE, 'Available architectures: %s\n' %
+ print(col.build(col.BLUE, 'Available architectures: %s\n' %
' '.join(sorted_list)))
return 0
else:
fetch_arch = options.fetch_arch
if fetch_arch == 'all':
fetch_arch = ','.join(toolchains.ListArchs())
- print(col.Color(col.CYAN, '\nDownloading toolchains: %s' %
+ print(col.build(col.CYAN, '\nDownloading toolchains: %s' %
fetch_arch))
for arch in fetch_arch.split(','):
print()
@@ -177,11 +177,11 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
return 0
if options.incremental:
- print(col.Color(col.RED,
+ print(col.build(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'))
+ sys.exit(col.build(col.RED, '-w requires that you specify -o'))
options.output_dir = '..'
# Work out what subset of the boards we are building
@@ -218,12 +218,12 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
requested_boards)
selected = boards.GetSelected()
if not len(selected):
- sys.exit(col.Color(col.RED, 'No matching boards found'))
+ sys.exit(col.build(col.RED, 'No matching boards found'))
if options.print_prefix:
err = ShowToolchainPrefix(boards, toolchains)
if err:
- sys.exit(col.Color(col.RED, err))
+ sys.exit(col.build(col.RED, err))
return 0
# Work out how many commits to build. We want to build everything on the
@@ -242,24 +242,24 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
count, msg = gitutil.count_commits_in_branch(options.git_dir,
options.branch)
if count is None:
- sys.exit(col.Color(col.RED, msg))
+ sys.exit(col.build(col.RED, msg))
elif count == 0:
- sys.exit(col.Color(col.RED, "Range '%s' has no commits" %
+ sys.exit(col.build(col.RED, "Range '%s' has no commits" %
options.branch))
if msg:
- print(col.Color(col.YELLOW, msg))
+ print(col.build(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))
+ sys.exit(col.build(col.RED, str))
if options.work_in_output:
if len(selected) != 1:
- sys.exit(col.Color(col.RED,
+ sys.exit(col.build(col.RED,
'-w can only be used with a single board'))
if count != 1:
- sys.exit(col.Color(col.RED,
+ sys.exit(col.build(col.RED,
'-w can only be used with a single commit'))
# Read the metadata from the commits. First look at the upstream commit,
diff --git a/tools/buildman/test.py b/tools/buildman/test.py
index 43b012171d..4b4a0349e8 100644
--- a/tools/buildman/test.py
+++ b/tools/buildman/test.py
@@ -182,10 +182,10 @@ class TestBuild(unittest.TestCase):
col.YELLOW if outcome == OUTCOME_WARN else col.RED)
expect = '%10s: ' % arch
# TODO(sjg@chromium.org): If plus is '', we shouldn't need this
- expect += ' ' + col.Color(expected_colour, plus)
+ expect += ' ' + col.build(expected_colour, plus)
expect += ' '
for board in boards:
- expect += col.Color(expected_colour, ' %s' % board)
+ expect += col.build(expected_colour, ' %s' % board)
self.assertEqual(text, expect)
def _SetupTest(self, echo_lines=False, threads=1, **kwdisplay_args):
@@ -254,12 +254,12 @@ class TestBuild(unittest.TestCase):
new_lines = []
for line in lines:
if boards:
- expect = self._col.Color(colour, prefix + '(')
- expect += self._col.Color(self._col.MAGENTA, boards,
+ expect = self._col.build(colour, prefix + '(')
+ expect += self._col.build(self._col.MAGENTA, boards,
bright=False)
- expect += self._col.Color(colour, ') %s' % line)
+ expect += self._col.build(colour, ') %s' % line)
else:
- expect = self._col.Color(colour, prefix + line)
+ expect = self._col.build(colour, prefix + line)
new_lines.append(expect)
return '\n'.join(new_lines)
@@ -317,12 +317,12 @@ class TestBuild(unittest.TestCase):
self.assertEqual(next(lines).text, '04: %s' % commits[3][1])
if filter_migration_warnings:
expect = '%10s: ' % 'powerpc'
- expect += ' ' + col.Color(col.GREEN, '')
+ expect += ' ' + col.build(col.GREEN, '')
expect += ' '
- expect += col.Color(col.GREEN, ' %s' % 'board2')
- expect += ' ' + col.Color(col.YELLOW, 'w+')
+ expect += col.build(col.GREEN, ' %s' % 'board2')
+ expect += ' ' + col.build(col.YELLOW, 'w+')
expect += ' '
- expect += col.Color(col.YELLOW, ' %s' % 'board3')
+ expect += col.build(col.YELLOW, ' %s' % 'board3')
self.assertEqual(next(lines).text, expect)
else:
self.assertSummary(next(lines).text, 'powerpc', 'w+',
diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
index 3442d998ab..46a4e5ed40 100644
--- a/tools/buildman/toolchain.py
+++ b/tools/buildman/toolchain.py
@@ -381,7 +381,7 @@ class Toolchains:
def List(self):
"""List out the selected toolchains for each architecture"""
col = terminal.Color()
- print(col.Color(col.BLUE, 'List of available toolchains (%d):' %
+ print(col.build(col.BLUE, 'List of available toolchains (%d):' %
len(self.toolchains)))
if len(self.toolchains):
for key, value in sorted(self.toolchains.items()):
@@ -559,7 +559,7 @@ class Toolchains:
"""
# Fist get the URL for this architecture
col = terminal.Color()
- print(col.Color(col.BLUE, "Downloading toolchain for arch '%s'" % arch))
+ print(col.build(col.BLUE, "Downloading toolchain for arch '%s'" % arch))
url = self.LocateArchUrl(arch)
if not url:
print(("Cannot find toolchain for arch '%s' - use 'list' to list" %
@@ -574,7 +574,7 @@ class Toolchains:
tarfile, tmpdir = tools.download(url, '.buildman')
if not tarfile:
return 1
- print(col.Color(col.GREEN, 'Unpacking to: %s' % dest), end=' ')
+ print(col.build(col.GREEN, 'Unpacking to: %s' % dest), end=' ')
sys.stdout.flush()
path = self.Unpack(tarfile, dest)
os.remove(tarfile)
@@ -582,14 +582,14 @@ class Toolchains:
print()
# Check that the toolchain works
- print(col.Color(col.GREEN, 'Testing'))
+ print(col.build(col.GREEN, 'Testing'))
dirpath = os.path.join(dest, path)
compiler_fname_list = self.ScanPath(dirpath, True)
if not compiler_fname_list:
print('Could not locate C compiler - fetch failed.')
return 1
if len(compiler_fname_list) != 1:
- print(col.Color(col.RED, 'Warning, ambiguous toolchains: %s' %
+ print(col.build(col.RED, 'Warning, ambiguous toolchains: %s' %
', '.join(compiler_fname_list)))
toolchain = Toolchain(compiler_fname_list[0], True, True)