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>
diff --git a/tools/binman/bintool.py b/tools/binman/bintool.py
index 6ca3d88..7674dfd 100644
--- a/tools/binman/bintool.py
+++ b/tools/binman/bintool.py
@@ -51,8 +51,9 @@
     # List of bintools to regard as missing
     missing_list = []
 
-    # Directory to store tools
-    tooldir = os.path.join(os.getenv('HOME'), '.binman-tools')
+    # Directory to store tools. Note that this set up by set_tool_dir() which
+    # must be called before this class is used.
+    tooldir = ''
 
     def __init__(self, name, desc, version_regex=None, version_args='-V'):
         self.name = name
@@ -113,6 +114,11 @@
         obj = cls(name)
         return obj
 
+    @classmethod
+    def set_tool_dir(cls, pathname):
+        """Set the path to use to store and find tools"""
+        cls.tooldir = pathname
+
     def show(self):
         """Show a line of information about a bintool"""
         if self.is_present():
@@ -210,6 +216,7 @@
         if result is not True:
             fname, tmpdir = result
             dest = os.path.join(self.tooldir, self.name)
+            os.makedirs(self.tooldir, exist_ok=True)
             print(f"- writing to '{dest}'")
             shutil.move(fname, dest)
             if tmpdir: