Skip to contentSkip to conversation

buildman: Extract environment as part of each build

PATCH New Alex Kiernan 2 participants 4 messages May 31, 2018 – Jun 7, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to uboot.env so we can interrogate it later.

---

Changes in v3:
- update tests for our usage of objcopy

Changes in v2:
- capture stderr/stdout so when the build fails we don't produce spurious output as part of the build

 tools/buildman/builderthread.py | 10 ++++++++++
 tools/buildman/func_test.py     |  5 +++++
 2 files changed, 15 insertions(+)
tools/buildman/builderthread.py +10 -0
index 0efe80d945..c84ba6acf1 100644
@@ -351,6 +351,16 @@ class BuilderThread(threading.Thread):
                     lines.append(size_result.stdout.splitlines()[1] + ' ' +
                                  rodata_size)
 
+            # Extract the environment from U-Boot and dump it out
+            cmd = ['%sobjcopy' % self.toolchain.cross, '-O', 'binary',
+                   '-j', '.rodata.default_environment',
+                   'env/built-in.o', 'uboot.env']
+            command.RunPipe([cmd], capture=True,
+                            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'])
+
             # Write out the image sizes file. This is similar to the output
             # of binutil's 'size' utility, but it omits the header line and
             # adds an additional hex value at the end of each line for the
tools/buildman/func_test.py +5 -0
index 9206fb299d..363db9d8ce 100644
@@ -327,6 +327,9 @@ class TestFunctional(unittest.TestCase):
     def _HandleCommandObjdump(self, args):
         return command.CommandResult(return_code=0)
 
+    def _HandleCommandObjcopy(self, args):
+        return command.CommandResult(return_code=0)
+
     def _HandleCommandSize(self, args):
         return command.CommandResult(return_code=0)
 
@@ -359,6 +362,8 @@ class TestFunctional(unittest.TestCase):
             return self._HandleCommandNm(args)
         elif cmd.endswith('objdump'):
             return self._HandleCommandObjdump(args)
+        elif cmd.endswith('objcopy'):
+            return self._HandleCommandObjcopy(args)
         elif cmd.endswith( 'size'):
             return self._HandleCommandSize(args)
 
Signature · 1 line
2.17.0
#1 lore raw

PATCH v3 2/2 buildman: Add support for environment delta in summary

When summarising the builds, add the -U option to emit delta lines for the default environment built into U-Boot at each commit.

---

Changes in v3: None
Changes in v2:
- update buildman README to cover -U option

 tools/buildman/README     |  28 +++++++++
 tools/buildman/builder.py | 128 +++++++++++++++++++++++++++++++++-----
 tools/buildman/cmdline.py |   2 +
 tools/buildman/control.py |   3 +-
 4 files changed, 145 insertions(+), 16 deletions(-)
tools/buildman/README +28 -0
index 6c43c546f8..76601902cb 100644
@@ -1008,6 +1008,34 @@ variables. This avoids lots of useless output when converting a CONFIG
 option to Kconfig. To disable this behaviour, use --squash-config-y.
 
 
+Checking the environment
+========================
+
+When converting CONFIG options which manipulate the default environment,
+a common requirement is to check that the default environment has not
+changed due to the conversion. Buildman supports this with the -U option,
+used after a build. This shows differences in the default environment
+between one commit and the next.
+
+For example:
+
+$ buildman -b squash brppt1 -sU
+boards.cfg is up to date. Nothing to do.
+Summary of 2 commits for 3 boards (3 threads, 3 jobs per thread)
+01: Migrate bootlimit to Kconfig
+02: Squashed commit of the following:
+   c brppt1_mmc: altbootcmd=mmc dev 1; run mmcboot0; -> mmc dev 1; run mmcboot0
+   c brppt1_spi: altbootcmd=mmc dev 1; run mmcboot0; -> mmc dev 1; run mmcboot0
+   + brppt1_nand: altbootcmd=run usbscript
+   - brppt1_nand:  altbootcmd=run usbscript
+(no errors to report)
+
+This shows that commit 2 modified the value of 'altbootcmd' for 'brppt1_mmc'
+and 'brppt1_spi', removing a trailing semicolon. 'brppt1_nand' gained an a
+value for 'altbootcmd', but lost one for ' altbootcmd'.
+
+The -U option uses the u-boot.env files which are produced by a build.
+
 Other options
 =============
 
tools/buildman/builder.py +113 -15

273 lines not on this page · raw message

tools/buildman/cmdline.py +2 -0
index b8ddd4795c..e493b1ac4a 100644
@@ -92,6 +92,8 @@ def ParseArgs():
           default=None, help='Number of builder threads to use')
     parser.add_option('-u', '--show_unknown', action='store_true',
           default=False, help='Show boards with unknown build result')
+    parser.add_option('-U', '--show-environment', action='store_true',
+          default=False, help='Show environment changes in summary')
     parser.add_option('-v', '--verbose', action='store_true',
           default=False, help='Show build results while the build progresses')
     parser.add_option('-V', '--verbose-build', action='store_true',
tools/buildman/control.py +2 -1
index 4ac4386db6..bc0819784f 100644
@@ -319,7 +319,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
         builder.SetDisplayOptions(options.show_errors, options.show_sizes,
                                   options.show_detail, options.show_bloat,
                                   options.list_error_boards,
-                                  options.show_config)
+                                  options.show_config,
+                                  options.show_environment)
         if options.summary:
             builder.ShowSummary(commits, board_selected)
         else:
Signature · 1 line
2.17.0
#2 lore raw

PATCH v3 2/2 buildman: Add support for environment delta in summary

Quoted 11 lines · Alex Kiernan

When summarising the builds, add the -U option to emit delta lines for the default environment built into U-Boot at each commit.

---

Changes in v3: None
Changes in v2:
- update buildman README to cover -U option

Quoted 5 lines
 tools/buildman/README     |  28 +++++++++
 tools/buildman/builder.py | 128 +++++++++++++++++++++++++++++++++-----
 tools/buildman/cmdline.py |   2 +
 tools/buildman/control.py |   3 +-
 4 files changed, 145 insertions(+), 16 deletions(-)

Applied to u-boot-dm, thanks!

#3 lore raw

PATCH v3 1/2 buildman: Extract environment as part of each build

In reply to Alex Kiernan
Quoted 10 lines · Alex Kiernan

As we're building the boards, extract the default U-Boot environment to uboot.env so we can interrogate it later.

---

Changes in v3:
- update tests for our usage of objcopy

Quoted 7 lines

Changes in v2:
- capture stderr/stdout so when the build fails we don't produce spurious output as part of the build

 tools/buildman/builderthread.py | 10 ++++++++++
 tools/buildman/func_test.py     |  5 +++++
 2 files changed, 15 insertions(+)

Applied to u-boot-dm, thanks!