mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-03 10:17:21 +00:00
buildman: Support a tilde to represent the home directory
It is convenient to use ~ to represent the home directory in the settings file. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
eae1eb0e86
commit
e2ca257287
3 changed files with 73 additions and 11 deletions
|
@ -933,12 +933,18 @@ a set of (tag, value) pairs.
|
||||||
For example powerpc-linux-gcc will be noted as a toolchain for 'powerpc'
|
For example powerpc-linux-gcc will be noted as a toolchain for 'powerpc'
|
||||||
and CROSS_COMPILE will be set to powerpc-linux- when using it.
|
and CROSS_COMPILE will be set to powerpc-linux- when using it.
|
||||||
|
|
||||||
|
The tilde character ``~`` is supported in paths, to represent the home
|
||||||
|
directory.
|
||||||
|
|
||||||
'[toolchain-prefix]' section
|
'[toolchain-prefix]' section
|
||||||
This can be used to provide the full toolchain-prefix for one or more
|
This can be used to provide the full toolchain-prefix for one or more
|
||||||
architectures. The full CROSS_COMPILE prefix must be provided. These
|
architectures. The full CROSS_COMPILE prefix must be provided. These
|
||||||
typically have a higher priority than matches in the '[toolchain]', due to
|
typically have a higher priority than matches in the '[toolchain]', due to
|
||||||
this prefix.
|
this prefix.
|
||||||
|
|
||||||
|
The tilde character ``~`` is supported in paths, to represent the home
|
||||||
|
directory.
|
||||||
|
|
||||||
'[toolchain-alias]' section
|
'[toolchain-alias]' section
|
||||||
This converts toolchain architecture names to U-Boot names. For example,
|
This converts toolchain architecture names to U-Boot names. For example,
|
||||||
if an x86 toolchains is called i386-linux-gcc it will not normally be
|
if an x86 toolchains is called i386-linux-gcc it will not normally be
|
||||||
|
|
|
@ -46,6 +46,16 @@ main: /usr/sbin
|
||||||
wrapper = ccache
|
wrapper = ccache
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
settings_data_homedir = '''
|
||||||
|
# Buildman settings file
|
||||||
|
|
||||||
|
[toolchain]
|
||||||
|
main = ~/mypath
|
||||||
|
|
||||||
|
[toolchain-prefix]
|
||||||
|
x86 = ~/mypath-x86-
|
||||||
|
'''
|
||||||
|
|
||||||
migration = '''===================== WARNING ======================
|
migration = '''===================== WARNING ======================
|
||||||
This board does not use CONFIG_DM. CONFIG_DM will be
|
This board does not use CONFIG_DM. CONFIG_DM will be
|
||||||
compulsory starting with the v2020.01 release.
|
compulsory starting with the v2020.01 release.
|
||||||
|
@ -1030,6 +1040,46 @@ class TestBuild(unittest.TestCase):
|
||||||
finally:
|
finally:
|
||||||
os.environ['PATH'] = old_path
|
os.environ['PATH'] = old_path
|
||||||
|
|
||||||
|
def testHomedir(self):
|
||||||
|
"""Test using ~ in a toolchain or toolchain-prefix section"""
|
||||||
|
# Add some test settings
|
||||||
|
bsettings.setup(None)
|
||||||
|
bsettings.add_file(settings_data_homedir)
|
||||||
|
|
||||||
|
# Set up the toolchains
|
||||||
|
home = os.path.expanduser('~')
|
||||||
|
toolchains = toolchain.Toolchains()
|
||||||
|
toolchains.GetSettings()
|
||||||
|
self.assertEqual([f'{home}/mypath'], toolchains.paths)
|
||||||
|
|
||||||
|
# Check scanning
|
||||||
|
with test_util.capture_sys_output() as (stdout, _):
|
||||||
|
toolchains.Scan(verbose=True, raise_on_error=False)
|
||||||
|
lines = iter(stdout.getvalue().splitlines() + ['##done'])
|
||||||
|
self.assertEqual('Scanning for tool chains', next(lines))
|
||||||
|
self.assertEqual(f" - scanning prefix '{home}/mypath-x86-'",
|
||||||
|
next(lines))
|
||||||
|
self.assertEqual(
|
||||||
|
f"Error: No tool chain found for prefix '{home}/mypath-x86-gcc'",
|
||||||
|
next(lines))
|
||||||
|
self.assertEqual(f" - scanning path '{home}/mypath'", next(lines))
|
||||||
|
self.assertEqual(f" - looking in '{home}/mypath/.'", next(lines))
|
||||||
|
self.assertEqual(f" - looking in '{home}/mypath/bin'", next(lines))
|
||||||
|
self.assertEqual(f" - looking in '{home}/mypath/usr/bin'",
|
||||||
|
next(lines))
|
||||||
|
self.assertEqual('##done', next(lines))
|
||||||
|
|
||||||
|
# Check adding a toolchain
|
||||||
|
with test_util.capture_sys_output() as (stdout, _):
|
||||||
|
toolchains.Add('~/aarch64-linux-gcc', test=True, verbose=True)
|
||||||
|
lines = iter(stdout.getvalue().splitlines() + ['##done'])
|
||||||
|
self.assertEqual('Tool chain test: BAD', next(lines))
|
||||||
|
self.assertEqual(f'Command: {home}/aarch64-linux-gcc --version',
|
||||||
|
next(lines))
|
||||||
|
self.assertEqual('', next(lines))
|
||||||
|
self.assertEqual('', next(lines))
|
||||||
|
self.assertEqual('##done', next(lines))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -65,12 +65,13 @@ class Toolchain:
|
||||||
"""Create a new toolchain object.
|
"""Create a new toolchain object.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
fname: Filename of the gcc component
|
fname: Filename of the gcc component, possibly with ~ or $HOME in it
|
||||||
test: True to run the toolchain to test it
|
test: True to run the toolchain to test it
|
||||||
verbose: True to print out the information
|
verbose: True to print out the information
|
||||||
priority: Priority to use for this toolchain, or PRIORITY_CALC to
|
priority: Priority to use for this toolchain, or PRIORITY_CALC to
|
||||||
calculate it
|
calculate it
|
||||||
"""
|
"""
|
||||||
|
fname = os.path.expanduser(fname)
|
||||||
self.gcc = fname
|
self.gcc = fname
|
||||||
self.path = os.path.dirname(fname)
|
self.path = os.path.dirname(fname)
|
||||||
self.override_toolchain = override_toolchain
|
self.override_toolchain = override_toolchain
|
||||||
|
@ -109,7 +110,7 @@ class Toolchain:
|
||||||
self.priority))
|
self.priority))
|
||||||
else:
|
else:
|
||||||
print('BAD')
|
print('BAD')
|
||||||
print('Command: ', cmd)
|
print(f"Command: {' '.join(cmd)}")
|
||||||
print(result.stdout)
|
print(result.stdout)
|
||||||
print(result.stderr)
|
print(result.stderr)
|
||||||
else:
|
else:
|
||||||
|
@ -296,10 +297,11 @@ class Toolchains:
|
||||||
|
|
||||||
paths = []
|
paths = []
|
||||||
for name, value in toolchains:
|
for name, value in toolchains:
|
||||||
|
fname = os.path.expanduser(value)
|
||||||
if '*' in value:
|
if '*' in value:
|
||||||
paths += glob.glob(value)
|
paths += glob.glob(fname)
|
||||||
else:
|
else:
|
||||||
paths.append(value)
|
paths.append(fname)
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
def GetSettings(self, show_warning=True):
|
def GetSettings(self, show_warning=True):
|
||||||
|
@ -373,7 +375,7 @@ class Toolchains:
|
||||||
pathname_list.append(pathname)
|
pathname_list.append(pathname)
|
||||||
return pathname_list
|
return pathname_list
|
||||||
|
|
||||||
def Scan(self, verbose):
|
def Scan(self, verbose, raise_on_error=True):
|
||||||
"""Scan for available toolchains and select the best for each arch.
|
"""Scan for available toolchains and select the best for each arch.
|
||||||
|
|
||||||
We look for all the toolchains we can file, figure out the
|
We look for all the toolchains we can file, figure out the
|
||||||
|
@ -385,11 +387,12 @@ class Toolchains:
|
||||||
"""
|
"""
|
||||||
if verbose: print('Scanning for tool chains')
|
if verbose: print('Scanning for tool chains')
|
||||||
for name, value in self.prefixes:
|
for name, value in self.prefixes:
|
||||||
if verbose: print(" - scanning prefix '%s'" % value)
|
fname = os.path.expanduser(value)
|
||||||
if os.path.exists(value):
|
if verbose: print(" - scanning prefix '%s'" % fname)
|
||||||
self.Add(value, True, verbose, PRIORITY_FULL_PREFIX, name)
|
if os.path.exists(fname):
|
||||||
|
self.Add(fname, True, verbose, PRIORITY_FULL_PREFIX, name)
|
||||||
continue
|
continue
|
||||||
fname = value + 'gcc'
|
fname += 'gcc'
|
||||||
if os.path.exists(fname):
|
if os.path.exists(fname):
|
||||||
self.Add(fname, True, verbose, PRIORITY_PREFIX_GCC, name)
|
self.Add(fname, True, verbose, PRIORITY_PREFIX_GCC, name)
|
||||||
continue
|
continue
|
||||||
|
@ -397,8 +400,11 @@ class Toolchains:
|
||||||
for f in fname_list:
|
for f in fname_list:
|
||||||
self.Add(f, True, verbose, PRIORITY_PREFIX_GCC_PATH, name)
|
self.Add(f, True, verbose, PRIORITY_PREFIX_GCC_PATH, name)
|
||||||
if not fname_list:
|
if not fname_list:
|
||||||
raise ValueError("No tool chain found for prefix '%s'" %
|
msg = f"No tool chain found for prefix '{fname}'"
|
||||||
value)
|
if raise_on_error:
|
||||||
|
raise ValueError(msg)
|
||||||
|
else:
|
||||||
|
print(f'Error: {msg}')
|
||||||
for path in self.paths:
|
for path in self.paths:
|
||||||
if verbose: print(" - scanning path '%s'" % path)
|
if verbose: print(" - scanning path '%s'" % path)
|
||||||
fnames = self.ScanPath(path, verbose)
|
fnames = self.ScanPath(path, verbose)
|
||||||
|
|
Loading…
Add table
Reference in a new issue