]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
buildman: Write out the build command used
authorSimon Glass <sjg@chromium.org>
Tue, 21 Feb 2023 19:40:27 +0000 (12:40 -0700)
committerSimon Glass <sjg@chromium.org>
Wed, 8 Mar 2023 19:38:48 +0000 (11:38 -0800)
It is sometimes useful to see the exact 'make' command used by buildman
for a commit. Add an output file for this.

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

index 680efae02d7f52d7af8ebd7286d5b5fb0842ea6a..7ba9a856dd58a9e3d1d0fc084c8efd6433277e75 100644 (file)
@@ -273,14 +273,19 @@ class BuilderThread(threading.Thread):
 
                 # If we need to reconfigure, do that now
                 cfg_file = os.path.join(out_dir, '.config')
+                cmd_list = []
                 if do_config or adjust_cfg:
                     config_out = ''
                     if self.mrproper:
                         result = self.Make(commit, brd, 'mrproper', cwd,
                                 'mrproper', *args, env=env)
                         config_out += result.combined
+                        cmd_list.append([self.builder.gnu_make, 'mrproper',
+                                         *args])
                     result = self.Make(commit, brd, 'config', cwd,
                             *(args + config_args), env=env)
+                    cmd_list.append([self.builder.gnu_make] + args +
+                                    config_args)
                     config_out += result.combined
                     do_config = False   # No need to configure next time
                     if adjust_cfg:
@@ -290,6 +295,7 @@ class BuilderThread(threading.Thread):
                         args.append('cfg')
                     result = self.Make(commit, brd, 'build', cwd, *args,
                             env=env)
+                    cmd_list.append([self.builder.gnu_make] + args)
                     if (result.return_code == 2 and
                         ('Some images are invalid' in result.stderr)):
                         # This is handled later by the check for output in
@@ -303,6 +309,7 @@ class BuilderThread(threading.Thread):
                 result.stderr = result.stderr.replace(src_dir + '/', '')
                 if self.builder.verbose_build:
                     result.stdout = config_out + result.stdout
+                result.cmd_list = cmd_list
             else:
                 result.return_code = 1
                 result.stderr = 'No tool chain for %s\n' % brd.arch
@@ -378,6 +385,12 @@ class BuilderThread(threading.Thread):
             with open(os.path.join(build_dir, 'out-env'), 'wb') as fd:
                 for var in sorted(env.keys()):
                     fd.write(b'%s="%s"' % (var, env[var]))
+
+            with open(os.path.join(build_dir, 'out-cmd'), 'w',
+                      encoding='utf-8') as fd:
+                for cmd in result.cmd_list:
+                    print(' '.join(cmd), file=fd)
+
             lines = []
             for fname in BASE_ELF_FILENAMES:
                 cmd = ['%snm' % self.toolchain.cross, '--size-sort', fname]
index 9a2d913c785ebfc748b57cc8068f1df1e9de7ddc..11c721417912e8c3b6957abfeef6c36bea89fe54 100644 (file)
@@ -1300,6 +1300,14 @@ You should use 'buildman -nv <criteria>' instead of greoing the boards.cfg file,
 since it may be dropped altogether in future.
 
 
+Checking the command
+--------------------
+
+Buildman writes out the toolchain information to a `toolchain` file within the
+output directory. It also writes the commands used to build U-Boot in an
+`out-cmd` file. You can check these if you suspect something strange is
+happening.
+
 TODO
 ----
 
index 559e4edf74bc7988298174f9d728eb2cb9c8cda3..799c609446e5850737b2e529986997b19e5303c2 100644 (file)
@@ -723,3 +723,16 @@ Some images are invalid'''
                          control.get_allow_missing(False, False, 2, True))
         self.assertEqual(False,
                          control.get_allow_missing(False, True, 2, True))
+
+    def testCmdFile(self):
+        """Test that the -cmd-out file is produced"""
+        self._RunControl('-o', self._output_dir)
+        board0_dir = os.path.join(self._output_dir, 'current', 'board0')
+        self.assertTrue(os.path.exists(os.path.join(board0_dir, 'done')))
+        cmd_fname = os.path.join(board0_dir, 'out-cmd')
+        self.assertTrue(os.path.exists(cmd_fname))
+        data = tools.read_file(cmd_fname)
+        lines = data.splitlines()
+        self.assertEqual(2, len(lines))
+        self.assertRegex(lines[0], b'make O=/.*board0_defconfig')
+        self.assertRegex(lines[0], b'make O=/.*-s.*')