diff mbox series

[5/5] buildman: Write output files when using -w

Message ID 20200417235134.226223-6-sjg@chromium.org
State Accepted
Commit 60b285f8c3bcd1f169fa72ad58387509673eec8b
Headers show
Series buildman: A few more tweaks | expand

Commit Message

Simon Glass April 17, 2020, 11:51 p.m. UTC
At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 tools/buildman/builder.py       |  5 +++++
 tools/buildman/builderthread.py | 31 +++++++++++++++++--------------
 tools/buildman/func_test.py     |  4 ++++
 3 files changed, 26 insertions(+), 14 deletions(-)

Comments

Simon Glass April 27, 2020, 3:06 a.m. UTC | #1
At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 tools/buildman/builder.py       |  5 +++++
 tools/buildman/builderthread.py | 31 +++++++++++++++++--------------
 tools/buildman/func_test.py     |  4 ++++
 3 files changed, 26 insertions(+), 14 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 30ebe1d820..1b61e3a837 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -479,6 +479,9 @@  class Builder:
         Args:
             commit_upto: Commit number to use (0..self.count-1)
         """
+        if self.work_in_output:
+            return self._working_dir
+
         commit_dir = None
         if self.commits:
             commit = self.commits[commit_upto]
@@ -502,6 +505,8 @@  class Builder:
             target: Target name
         """
         output_dir = self._GetOutputDir(commit_upto)
+        if self.work_in_output:
+            return output_dir
         return os.path.join(output_dir, target)
 
     def GetDoneFile(self, commit_upto, target):
diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py
index 063bbc0145..f673f386e4 100644
--- a/tools/buildman/builderthread.py
+++ b/tools/buildman/builderthread.py
@@ -280,8 +280,6 @@  class BuilderThread(threading.Thread):
             work_in_output: Use the output directory as the work directory and
                 don't write to a separate output directory.
         """
-        if work_in_output:
-            return
         # Fatal error
         if result.return_code < 0:
             return
@@ -379,7 +377,8 @@  class BuilderThread(threading.Thread):
                             capture_stderr=True, cwd=result.out_dir,
                             raise_on_error=False, env=env)
             ubootenv = os.path.join(result.out_dir, 'uboot.env')
-            self.CopyFiles(result.out_dir, build_dir, '', ['uboot.env'])
+            if not work_in_output:
+                self.CopyFiles(result.out_dir, build_dir, '', ['uboot.env'])
 
             # Write out the image sizes file. This is similar to the output
             # of binutil's 'size' utility, but it omits the header line and
@@ -391,17 +390,21 @@  class BuilderThread(threading.Thread):
                 with open(sizes, 'w') as fd:
                     print('\n'.join(lines), file=fd)
 
-        # Write out the configuration files, with a special case for SPL
-        for dirname in ['', 'spl', 'tpl']:
-            self.CopyFiles(result.out_dir, build_dir, dirname, ['u-boot.cfg',
-                'spl/u-boot-spl.cfg', 'tpl/u-boot-tpl.cfg', '.config',
-                'include/autoconf.mk', 'include/generated/autoconf.h'])
-
-        # Now write the actual build output
-        if keep_outputs:
-            self.CopyFiles(result.out_dir, build_dir, '', ['u-boot*', '*.bin',
-                '*.map', '*.img', 'MLO', 'SPL', 'include/autoconf.mk',
-                'spl/u-boot-spl*'])
+        if not work_in_output:
+            # Write out the configuration files, with a special case for SPL
+            for dirname in ['', 'spl', 'tpl']:
+                self.CopyFiles(
+                    result.out_dir, build_dir, dirname,
+                    ['u-boot.cfg', 'spl/u-boot-spl.cfg', 'tpl/u-boot-tpl.cfg',
+                     '.config', 'include/autoconf.mk',
+                     'include/generated/autoconf.h'])
+
+            # Now write the actual build output
+            if keep_outputs:
+                self.CopyFiles(
+                    result.out_dir, build_dir, '',
+                    ['u-boot*', '*.bin', '*.map', '*.img', 'MLO', 'SPL',
+                     'include/autoconf.mk', 'spl/u-boot-spl*'])
 
     def CopyFiles(self, out_dir, build_dir, dirname, patterns):
         """Copy files from the build directory to the output.
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index e11dc8f899..29b28f5a9f 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -561,6 +561,10 @@  class TestFunctional(unittest.TestCase):
                          boards=board_list)
         self.assertTrue(
             os.path.exists(os.path.join(self._output_dir, 'u-boot')))
+        self.assertTrue(
+            os.path.exists(os.path.join(self._output_dir, 'done')))
+        self.assertTrue(
+            os.path.exists(os.path.join(self._output_dir, 'out-env')))
 
     def testWorkInOutputFail(self):
         """Test the -w option failures"""