]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
buildman: Correct behaviour of --in-tree
authorSimon Glass <sjg@chromium.org>
Tue, 27 May 2025 11:19:20 +0000 (05:19 -0600)
committerTom Rini <trini@konsulko.com>
Tue, 1 Jul 2025 16:49:32 +0000 (10:49 -0600)
This option doesn't work as expected since it sets the cwd to the work
directory, which does not necessarily hold the source code.

It should be left unset, so that the current directory is the source
directory.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/buildman/builderthread.py
tools/buildman/buildman.rst

index b4cb66397bb777562b4b5218a8534a7839c7e3cc..4617f516f4090ebc00d029e7e42c9e15bd9c019e 100644 (file)
@@ -37,6 +37,8 @@ def mkdir(dirname, parents=False):
     Raises:
         OSError: File already exists
     """
+    if os.path.exists(dirname):
+        return
     try:
         if parents:
             os.makedirs(dirname)
@@ -45,8 +47,8 @@ def mkdir(dirname, parents=False):
     except OSError as err:
         if err.errno == errno.EEXIST:
             if os.path.realpath('.') == os.path.realpath(dirname):
-                print(f"Cannot create the current working directory '{dirname}'!")
-                sys.exit(1)
+                raise ValueError(
+                    f"Cannot create the current working directory '{dirname}'!")
         else:
             raise
 
@@ -205,21 +207,20 @@ class BuilderThread(threading.Thread):
         args = []
         cwd = work_dir
         src_dir = os.path.realpath(work_dir)
-        if not self.builder.in_tree:
-            if commit_upto is None:
-                # In this case we are building in the original source directory
-                # (i.e. the current directory where buildman is invoked. The
-                # output directory is set to this thread's selected work
-                # directory.
-                #
-                # Symlinks can confuse U-Boot's Makefile since we may use '..'
-                # in our path, so remove them.
-                real_dir = os.path.realpath(out_dir)
-                args.append(f'O={real_dir}')
-                cwd = None
-                src_dir = os.getcwd()
-            else:
-                args.append(f'O={out_rel_dir}')
+        if commit_upto is None:
+            # In this case we are building in the original source directory
+            # (i.e. the current directory where buildman is invoked. The
+            # output directory is set to this thread's selected work
+            # directory.
+            #
+            # Symlinks can confuse U-Boot's Makefile since we may use '..'
+            # in our path, so remove them.
+            real_dir = os.path.realpath(out_dir)
+            args.append(f'O={real_dir}')
+            cwd = None
+            src_dir = os.getcwd()
+        elif out_rel_dir:
+            args.append(f'O={out_rel_dir}')
         if self.builder.verbose_build:
             args.append('V=1')
         else:
@@ -409,7 +410,8 @@ class BuilderThread(threading.Thread):
         """
         # Set up the environment and command line
         env = self.builder.make_environment(self.toolchain)
-        mkdir(out_dir)
+        if not os.path.exists(out_dir):
+            mkdir(out_dir)
 
         args, cwd, src_dir = self._build_args(brd, out_dir, out_rel_dir,
                                               work_dir, commit_upto)
index 5fa7b277cb8cf24ba43ca3375d8f7703e2ee7002..2555139334f295c644602f141d92765a87957353 100644 (file)
@@ -1333,6 +1333,12 @@ To build a particular target, rather than the default U-Boot target, use the
 `--target` option. This is unlikely to be useful unless you are building a
 single board.
 
+Buildman normally builds out-of-tree, meaning that the source directory is not
+disturbed by the build. Use `-i` to do an in-tree build instead. Note that this
+does not affect the source directory, since buildman creates a separate git
+'worktree' for each board. This means that it is possible to do an in-tree
+build of an entire branch, or even a 'current source' build for multiple boards.
+
 Build summary
 -------------