binman: Make the tooldir configurable

Add a command-line argument for setting the tooldir, so that the default
can be overridden. Add this directory to the toolpath automatically.
Create the directory if it does not already exist.

Put the default in the argument parser instead of the class, so that it
is more obvious.

Update a few tests that expect the utility name to be provided without
any path (e.g. 'futility'), so they can accept a path, e.g.
/path/to/futility

Update the documentation and add a few tests.

Improve the help for --toolpath while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2023-02-22 12:14:49 -07:00
parent 932e40d0b5
commit fe7e9245c5
6 changed files with 64 additions and 14 deletions

View File

@@ -1750,7 +1750,7 @@ class TestFunctional(unittest.TestCase):
def _HandleGbbCommand(self, pipe_list):
"""Fake calls to the futility utility"""
if pipe_list[0][0] == 'futility':
if 'futility' in pipe_list[0][0]:
fname = pipe_list[0][-1]
# Append our GBB data to the file, which will happen every time the
# futility command is called.
@@ -1812,7 +1812,7 @@ class TestFunctional(unittest.TestCase):
self._hash_data is False, it writes VBLOCK_DATA, else it writes a hash
of the input data (here, 'input.vblock').
"""
if pipe_list[0][0] == 'futility':
if 'futility' in pipe_list[0][0]:
fname = pipe_list[0][3]
with open(fname, 'wb') as fd:
if self._hash_data:
@@ -6386,6 +6386,23 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
self.assertEqual(['u-boot', 'atf-2'],
fdt_util.GetStringList(node, 'loadables'))
def testTooldir(self):
"""Test that we can specify the tooldir"""
with test_util.capture_sys_output() as (stdout, stderr):
self.assertEqual(0, self._DoBinman('--tooldir', 'fred',
'tool', '-l'))
self.assertEqual('fred', bintool.Bintool.tooldir)
# Check that the toolpath is updated correctly
self.assertEqual(['fred'], tools.tool_search_paths)
# Try with a few toolpaths; the tooldir should be at the end
with test_util.capture_sys_output() as (stdout, stderr):
self.assertEqual(0, self._DoBinman(
'--toolpath', 'mary', '--toolpath', 'anna', '--tooldir', 'fred',
'tool', '-l'))
self.assertEqual(['mary', 'anna', 'fred'], tools.tool_search_paths)
if __name__ == "__main__":
unittest.main()