buildman: Correct various issues with missing blobs
v3 cover buildman: Correct various issues with missing blobs
This series attempts to tidy up the problem of missing blobs, making U-Boot default to failing the build, but providing ways to configure this so that buildman can still be used for build testing by people who don't have the blobs or don't care about them.
This is based on discussion in [1] as well as some experimentation.
It also moves the buildman docs to rST.
[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Changes in v3:
- Add new patch to convert documentation to rST
- Add new patch to drop mention of MAKEALL
- Add new patch to drop mention of old architectures
- Add tests docs and a settings-file option
Changes in v2:
- Use a separate rule for running binman
Simon Glass (7):
Makefile: Correct the binman rule
doc: Correct the path to the Makefile documentation
binman: Use an exit code when blobs are missing
buildman: Convert documentation to rST
buildman: Drop mention of MAKEALL
buildman: Drop mention of old architectures
buildman: Detect binman reporting missing blobs
Tom Rini (2):
global: Do not default to faking missing binaries for buildman
buildman: Add --allow-missing flag to allow missing blobs
.azure-pipelines.yml | 2 +- .gitlab-ci.yml | 6 +- Makefile | 15 +- doc/build/buildman.rst | 1 + doc/build/index.rst | 1 + scripts/Kbuild.include | 2 +- tools/binman/binman.rst | 21 + tools/binman/cmdline.py | 3 + tools/binman/control.py | 7 +- tools/binman/ftest.py | 20 +- tools/buildman/README | 1349 ------------------------------- tools/buildman/README.rst | 1 + tools/buildman/bsettings.py | 18 +- tools/buildman/builder.py | 5 +- tools/buildman/builderthread.py | 8 +- tools/buildman/buildman.rst | 1324 ++++++++++++++++++++++++++++++ tools/buildman/cmdline.py | 6 + tools/buildman/control.py | 33 +- tools/buildman/func_test.py | 100 ++- 19 files changed, 1544 insertions(+), 1378 deletions(-) create mode 120000 doc/build/buildman.rst delete mode 100644 tools/buildman/README create mode 120000 tools/buildman/README.rst create mode 100644 tools/buildman/buildman.rst
Signature · 1 line
2.38.1.431.g37b22c650d-goog
PATCH v3 1/9 Makefile: Correct the binman rule
This currently uses if_changed on a phony target. Use a real file as the target and add FORCE at the end, as required. Drop the 'inputs' phony since it is not needed.
---
(no changes since v2)
Changes in v2:
- Use a separate rule for running binman
Makefile | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
Makefile +4 -7
@@ -1108,18 +1108,15 @@ define deprecated endef -PHONY += inputs -inputs: $(INPUTS-y) - -all: .binman_stamp inputs +# Timestamp file to make sure that binman always runs +.binman_stamp: $(INPUTS-y) FORCE ifeq ($(CONFIG_BINMAN),y) $(call if_changed,binman) endif - -# Timestamp file to make sure that binman always runs -.binman_stamp: FORCE @touch $@ +all: .binman_stamp + ifeq ($(CONFIG_DEPRECATED),y) $(warning "You have deprecated configuration options enabled in your .config! Please check your configuration.") endif
Signature · 1 line
2.38.1.431.g37b22c650d-goog
PATCH v3 2/9 doc: Correct the path to the Makefile documentation
In reply to Simon GlassThis is out-of-date now. Fix it.
---
(no changes since v1)
scripts/Kbuild.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Kbuild.include +1 -1
@@ -229,7 +229,7 @@ objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) # if_changed_dep - as if_changed, but uses fixdep to reveal dependencies # including used config symbols # if_changed_rule - as if_changed but execute rule instead -# See Documentation/kbuild/makefiles.txt for more info +# See doc/develop/makefiles.rst for more info ifneq ($(KBUILD_NOCMDDEP),1) # Check if both arguments are the same including their order. Result is empty
Signature · 1 line
2.38.1.431.g37b22c650d-goog
PATCH v3 3/9 binman: Use an exit code when blobs are missing
In reply to Simon GlassAt present binman returns success when told to handle missing blobs. This is confusing this in fact the resulting image cannot work.
Use exit code 103 to signal this problem, with a -W option to convert it to a warning.
Add documentation about exit codes while we are here.
---
(no changes since v1)
tools/binman/binman.rst | 21 +++++++++++++++++++++ tools/binman/cmdline.py | 3 +++ tools/binman/control.py | 7 ++++++- tools/binman/ftest.py | 20 ++++++++++++++++++-- 4 files changed, 48 insertions(+), 3 deletions(-)
tools/binman/binman.rst +21 -0
@@ -1461,6 +1461,10 @@ space-separated list of directories to search for binary blobs:: odroid-c4/build/board/hardkernel/odroidc4/firmware \ odroid-c4/build/scp_task" binman ... +Note that binman fails with exit code 103 when there are missing blobs. If you +wish binman to continue anyway, you can pass `-W` to binman. + + Code coverage -------------
@@ -1472,6 +1476,23 @@ To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):: $ sudo apt-get install python-coverage python3-coverage python-pytest +Exit status +----------- + +Binman produces the following exit codes: + +0 + Success + +1 + Any sort of failure - see output for more details + +103 + There are missing external blobs or bintools. This is only returned if + -M is passed to binman, otherwise missing blobs return in an exit status of + 1. + + Error messages --------------
tools/binman/cmdline.py +3 -0
@@ -128,6 +128,9 @@ controlled by a description in the board device tree.''' default=False, help='Update the binman node with offset/size info') build_parser.add_argument('--update-fdt-in-elf', type=str, help='Update an ELF file with the output dtb: infile,outfile,begin_sym,end_sym') + build_parser.add_argument( + '-W', '--ignore-missing-blobs', action='store_true', default=False, + help='Return success even if there are missing blobs') subparsers.add_parser( 'bintool-docs', help='Write out bintool documentation (see bintool.rst)')
tools/binman/control.py +6 -1
@@ -742,7 +742,12 @@ def Binman(args): elf.UpdateFile(*elf_params, data) if invalid: - tout.warning("\nSome images are invalid") + msg = '\nSome images are invalid' + if args.ignore_missing_blobs: + tout.warning(msg) + else: + tout.error(msg) + return 103 # Use this to debug the time take to pack the image #state.TimingShow()
tools/binman/ftest.py +18 -2
@@ -340,7 +340,7 @@ class TestFunctional(unittest.TestCase): use_expanded=False, verbosity=None, allow_missing=False, allow_fake_blobs=False, extra_indirs=None, threads=None, test_section_timeout=False, update_fdt_in_elf=None, - force_missing_bintools=''): + force_missing_bintools='', ignore_missing_blobs=False): """Run binman with a given test file Args:
@@ -403,6 +403,8 @@ class TestFunctional(unittest.TestCase): args.append('-a%s=%s' % (arg, value)) if allow_missing: args.append('-M') + if ignore_missing_blobs: + args.append('-W') if allow_fake_blobs: args.append('--fake-ext-blobs') if force_missing_bintools:
@@ -3725,9 +3727,23 @@ class TestFunctional(unittest.TestCase): def testExtblobMissingOk(self): """Test an image with an missing external blob that is allowed""" with test_util.capture_sys_output() as (stdout, stderr): - self._DoTestFile('158_blob_ext_missing.dts', allow_missing=True) + ret = self._DoTestFile('158_blob_ext_missing.dts', + allow_missing=True) + self.assertEqual(103, ret) err = stderr.getvalue() self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext") + self.assertIn('Some images are invalid', err) + + def testExtblobMissingOkFlag(self): + """Test an image with an missing external blob allowed with -W""" + with test_util.capture_sys_output() as (stdout, stderr): + ret = self._DoTestFile('158_blob_ext_missing.dts', + allow_missing=True, + ignore_missing_blobs=True) + self.assertEqual(0, ret) + err = stderr.getvalue() + self.assertRegex(err, "Image 'main-section'.*missing.*: blob-ext") + self.assertIn('Some images are invalid', err) def testExtblobMissingOkSect(self): """Test an image with an missing external blob that is allowed"""
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Re: [PATCH v3 3/9] binman: Use an exit code when blobs are missing
Hi Simon,
Quoted 42 lines · Simon Glass
At present binman returns success when told to handle missing blobs. This is confusing this in fact the resulting image cannot work.
Use exit code 103 to signal this problem, with a -W option to convert it to a warning.
Add documentation about exit codes while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
tools/binman/binman.rst | 21 +++++++++++++++++++++ tools/binman/cmdline.py | 3 +++ tools/binman/control.py | 7 ++++++- tools/binman/ftest.py | 20 ++++++++++++++++++-- 4 files changed, 48 insertions(+), 3 deletions(-)tools/binman/binman.rst +8
-0@@ -1461,6 +1461,10 @@ space-separated list of directories to search for binary blobs:: odroid-c4/build/board/hardkernel/odroidc4/firmware \ odroid-c4/build/scp_task" binman ... +Note that binman fails with exit code 103 when there are missing blobs. If you +wish binman to continue anyway, you can pass `-W` to binman. + + Code coverage -------------@@ -1472,6 +1476,23 @@ To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):: $ sudo apt-get install python-coverage python3-coverage python-pytest +Exit status +----------- + +Binman produces the following exit codes:
tools/binman/binman.rst To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):: · line 1492
Quoted 10 lines
tools/binman/binman.rst +10
-0+ +0 + Success + +1 + Any sort of failure - see output for more details + +103 + There are missing external blobs or bintools. This is only returned if + -M is passed to binman, otherwise missing blobs return in an exit status of
and if -W is *not* passed to binman, no?
Quoted 11 lines
tools/binman/binman.rst +3
-0+ 1. + + Error messages --------------tools/binman/cmdline.py +0
-0
tools/binman/cmdline.py controlled by a description in the board device tree.''' · line 134
Quoted 7 lines
tools/binman/cmdline.py +3
-0@@ -128,6 +128,9 @@ controlled by a description in the board device tree.''' default=False, help='Update the binman node with offset/size info') build_parser.add_argument('--update-fdt-in-elf', type=str, help='Update an ELF file with the output dtb: infile,outfile,begin_sym,end_sym') + build_parser.add_argument( + '-W', '--ignore-missing-blobs', action='store_true', default=False, + help='Return success even if there are missing blobs')
Is -W supposed to be able to be used without --allow-missing? If not, I think it could make sense to use a subparser here to have the -W option available only when -M is selected?
Quoted 7 lines
tools/binman/cmdline.py +0
-0subparsers.add_parser( 'bintool-docs', help='Write out bintool documentation (see bintool.rst)')tools/binman/control.py +0
-0
tools/binman/control.py def Binman(args): · line 750
Quoted 10 lines
tools/binman/control.py +6
-1@@ -742,7 +742,12 @@ def Binman(args): elf.UpdateFile(*elf_params, data) if invalid: - tout.warning("\nSome images are invalid") + msg = '\nSome images are invalid' + if args.ignore_missing_blobs: + tout.warning(msg) + else: + tout.error(msg) + return 103
I think this could be an issue.
invalid can mean either missing blob, faked blob or missing btool. Here, we only want to warn/fail in case of missing blob and not the other two?
Also, shouldn't we have this only if we have allow_missing set?
Quoted 17 lines
tools/binman/control.py +0
-0# Use this to debug the time take to pack the image #state.TimingShow()tools/binman/ftest.py +1
-1@@ -340,7 +340,7 @@ class TestFunctional(unittest.TestCase): use_expanded=False, verbosity=None, allow_missing=False, allow_fake_blobs=False, extra_indirs=None, threads=None, test_section_timeout=False, update_fdt_in_elf=None, - force_missing_bintools=''): + force_missing_bintools='', ignore_missing_blobs=False): """Run binman with a given test file Args:
tools/binman/ftest.py class TestFunctional(unittest.TestCase): · line 407
Quoted 5 lines
tools/binman/ftest.py +2
-0@@ -403,6 +403,8 @@ class TestFunctional(unittest.TestCase): args.append('-a%s=%s' % (arg, value)) if allow_missing: args.append('-M') + if ignore_missing_blobs: + args.append('-W')
Can -W really be used when -M is not passed?
Cheers,
Quentin
Re: [PATCH v3 3/9] binman: Use an exit code when blobs are missing
Hi Quentin,
Quoted 42 lines · Quentin Schulz
Hi Simon,
Quoted 38 lines · Simon Glass
At present binman returns success when told to handle missing blobs. This is confusing this in fact the resulting image cannot work.
Use exit code 103 to signal this problem, with a -W option to convert it to a warning.
Add documentation about exit codes while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
tools/binman/binman.rst | 21 +++++++++++++++++++++ tools/binman/cmdline.py | 3 +++ tools/binman/control.py | 7 ++++++- tools/binman/ftest.py | 20 ++++++++++++++++++-- 4 files changed, 48 insertions(+), 3 deletions(-)tools/binman/binman.rst +4
-0@@ -1461,6 +1461,10 @@ space-separated list of directories to search for binary blobs:: odroid-c4/build/board/hardkernel/odroidc4/firmware \ odroid-c4/build/scp_task" binman ... +Note that binman fails with exit code 103 when there are missing blobs. If you +wish binman to continue anyway, you can pass `-W` to binman. + + Code coverage -------------@@ -1472,6 +1476,23 @@ To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):: $ sudo apt-get install python-coverage python3-coverage python-pytest
Quoted 16 lines
Quoted 4 lines
tools/binman/binman.rst +4
-0+Exit status +----------- + +Binman produces the following exit codes:tools/binman/binman.rst To enable Python test coverage on Debian-type distributions (e.g. Ubuntu):: · line 1492
Quoted 10 lines
tools/binman/binman.rst +10
-0+ +0 + Success + +1 + Any sort of failure - see output for more details + +103 + There are missing external blobs or bintools. This is only returned if + -M is passed to binman, otherwise missing blobs return in an exit status ofand if -W is *not* passed to binman, no?]
will update
Quoted 7 lines
Quoted 7 lines
tools/binman/binman.rst +3
-0+ 1. + + Error messages --------------
Quoted 16 lines
tools/binman/cmdline.py controlled by a description in the board device tree.''' · line 134
Quoted 12 lines
tools/binman/cmdline.py +3
-0@@ -128,6 +128,9 @@ controlled by a description in the board device tree.''' default=False, help='Update the binman node with offset/size info') build_parser.add_argument('--update-fdt-in-elf', type=str, help='Update an ELF file with the output dtb: infile,outfile,begin_sym,end_sym') + build_parser.add_argument( + '-W', '--ignore-missing-blobs', action='store_true', default=False, + help='Return success even if there are missing blobs')Is -W supposed to be able to be used without --allow-missing? If not, I think it could make sense to use a subparser here to have the -W option available only when -M is selected?
I am not sure how to do that, but have updated help.
Quoted 21 lines
Quoted 8 lines
tools/binman/cmdline.py +0
-0subparsers.add_parser( 'bintool-docs', help='Write out bintool documentation (see bintool.rst)')tools/binman/control.py +0
-0tools/binman/control.py def Binman(args): · line 750
Quoted 10 lines
tools/binman/control.py +6
-1@@ -742,7 +742,12 @@ def Binman(args): elf.UpdateFile(*elf_params, data) if invalid: - tout.warning("\nSome images are invalid") + msg = '\nSome images are invalid' + if args.ignore_missing_blobs: + tout.warning(msg) + else: + tout.error(msg) + return 103I think this could be an issue.
Quoted 2 lines
invalid can mean either missing blob, faked blob or missing btool. Here, we only want to warn/fail in case of missing blob and not the other two?
I'll rename the option as the intent is to use it for missing blobs and bintools, since they both result in the same thing. A faked blob is just a subset of a missing blob, so there really just needs to be an --allow-missing option.
Quoted 18 lines
Also, shouldn't we have this only if we have
allow_missingset?Quoted 15 lines
tools/binman/control.py +0
-0# Use this to debug the time take to pack the image #state.TimingShow()tools/binman/ftest.py +1
-1@@ -340,7 +340,7 @@ class TestFunctional(unittest.TestCase): use_expanded=False, verbosity=None, allow_missing=False, allow_fake_blobs=False, extra_indirs=None, threads=None, test_section_timeout=False, update_fdt_in_elf=None, - force_missing_bintools=''): + force_missing_bintools='', ignore_missing_blobs=False): """Run binman with a given test file
Quoted 9 lines
tools/binman/ftest.py class TestFunctional(unittest.TestCase): · line 407
Quoted 7 lines
tools/binman/ftest.py +2
-0Args:@@ -403,6 +403,8 @@ class TestFunctional(unittest.TestCase): args.append('-a%s=%s' % (arg, value)) if allow_missing: args.append('-M') + if ignore_missing_blobs: + args.append('-W')Can -W really be used when -M is not passed?
No, will update this code.
Regards,
Simon
PATCH v3 4/9 buildman: Convert documentation to rST
In reply to Simon GlassConvert the buildman documentation to rST format and include it in the 'build' section.
---
Changes in v3:
- Add new patch to convert documentation to rST
doc/build/buildman.rst | 1 + doc/build/index.rst | 1 + tools/buildman/README | 1349 --------------------------------- tools/buildman/README.rst | 1 + tools/buildman/buildman.rst | 1413 +++++++++++++++++++++++++++++++++++ tools/buildman/control.py | 4 +- tools/buildman/func_test.py | 4 +- 7 files changed, 1420 insertions(+), 1353 deletions(-) create mode 120000 doc/build/buildman.rst delete mode 100644 tools/buildman/README create mode 120000 tools/buildman/README.rst create mode 100644 tools/buildman/buildman.rst
doc/build/buildman.rst new file +1 -0
@@ -0,0 +1 @@ +../../tools/buildman/buildman.rst
doc/build/index.rst +1 -0
@@ -11,3 +11,4 @@ Build U-Boot clang docker tools + buildman
tools/buildman/README deleted +0 -1349
1,349 lines not on this page · raw message
tools/buildman/README.rst new file +1 -0
@@ -0,0 +1 @@ +buildman.rst
tools/buildman/buildman.rst new file +1413 -0
1,413 lines not on this page · raw message
tools/buildman/control.py +2 -2
@@ -136,8 +136,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None, if options.full_help: tools.print_full_help( - os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'README') - ) + os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), + 'README.rst')) return 0 gitutil.setup()
tools/buildman/func_test.py +2 -2
@@ -249,7 +249,7 @@ class TestFunctional(unittest.TestCase): def testFullHelp(self): command.test_result = None result = self._RunBuildman('-H') - help_file = os.path.join(self._buildman_dir, 'README') + help_file = os.path.join(self._buildman_dir, 'README.rst') # Remove possible extraneous strings extra = '::::::::::::::\n' + help_file + '\n::::::::::::::\n' gothelp = result.stdout.replace(extra, '')
@@ -260,7 +260,7 @@ class TestFunctional(unittest.TestCase): def testHelp(self): command.test_result = None result = self._RunBuildman('-h') - help_file = os.path.join(self._buildman_dir, 'README') + help_file = os.path.join(self._buildman_dir, 'README.rst') self.assertTrue(len(result.stdout) > 1000) self.assertEqual(0, len(result.stderr)) self.assertEqual(0, result.return_code)
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Re: [PATCH v3 4/9] buildman: Convert documentation to rST
Hi Simon,
Quoted 5 lines · Simon Glass
Convert the buildman documentation to rST format and include it in the 'build' section.
Signed-off-by Simon Glass <[email protected]>---
[...]
tools/buildman/buildman.rst line 140
Quoted 10 lines
tools/buildman/buildman.rst new file +10
-0+Selecting which boards to build +------------------------------- + +Buildman lets you build all boards, or a subset. Specify the subset by passing +command-line arguments that list the desired build target, architecture, +CPU, board name, vendor, SoC or options. Multiple arguments are allowed. Each +argument will be interpreted as a regular expression, so behaviour is a superset +of exact or substring matching. Examples are: + +'tegra20'
I would have made those list items, but it's a matter of taste I guess :)
[...]
tools/buildman/buildman.rst line 685
Quoted 7 lines
tools/buildman/buildman.rst new file +7
-0+The full build output in this case is available in:: + + ../lcd9b/12_of_18_gd92aff7_lcd--Add-support-for/lubbock/ + +Files: + +done
Ditto.
[...]
tools/buildman/buildman.rst line 894
Quoted 8 lines
tools/buildman/buildman.rst new file +8
-0+This shows that commit 19 has reduced codesize for arm slightly and increased +it for powerpc. This increase was offset in by reductions in rodata and +data/bss. + +Shown below the summary lines are the sizes for each board. Below each board +are the sizes for each function. This information starts with: + +add
Ditto.
Quoted 20 lines
tools/buildman/buildman.rst new file +20
-0+ number of functions added / removed + +grow + number of functions which grew / shrunk + +bytes + number of bytes of code added to / removed from all functions, plus the total + byte change in brackets + +The change seems to be that hash_command() has increased by more than the +do_mem_crc() function has decreased. The function sizes typically add up to +roughly the text area size, but note that every read-only section except +rodata is included in 'text', so the function total does not exactly +correspond. + +It is common when refactoring code for the rodata to decrease as the text size +increases, and vice versa. + + +.. _buildman_settings:
tools/buildman/buildman.rst line 924
Quoted 10 lines
tools/buildman/buildman.rst new file +10
-0+ +The .buildman settings file +--------------------------- + +The .buildman file provides information about the available toolchains and +also allows build flags to be passed to 'make'. It consists of several +sections, with the section name in square brackets. Within each section are +a set of (tag, value) pairs. + +'[toolchain]' section
Ditto.
[...]
Quoted 7 lines
tools/buildman/buildman.rst new file +7
-0+Other options +------------- + +Buildman has various other command-line options. Try --help to see them. + +To find out what toolchain prefix buildman will use for a build, use the -A +option.
tools/buildman/buildman.rst line 1224
Quoted 10 lines
tools/buildman/buildman.rst new file +10
-0+ +To request that compiler warnings be promoted to errors, use -E. This passes the +-Werror flag to the compiler. Note that the build can still produce warnings +with -E, e.g. the migration warnings:: + + --------------------- WARNING ---------------------- + This board does not use CONFIG_DM_MMC. Please update + ... + ---------------------------------------------------- +
Those are still = and not -, I assume the result of a regexp a bit too aggressive :)
Otherwise looks fine,
Cheers,
Quentin
PATCH v3 5/9 buildman: Drop mention of MAKEALL
In reply to Simon GlassThis script was removed about 6 years ago so most people should be aware that it is not needed anymore. Drop mention of it.
---
Changes in v3:
- Add new patch to drop mention of MAKEALL
tools/buildman/buildman.rst | 110 ------------------------------------ 1 file changed, 110 deletions(-)
tools/buildman/buildman.rst +0 -110
@@ -3,8 +3,6 @@ Buildman build tool =================== -(Please read 'How to change from MAKEALL' if you are used to that tool) - Quick-start -----------
@@ -1257,114 +1255,6 @@ latter number depends on the speed of your machine and the efficiency of the U-Boot build. -How to change from MAKEALL --------------------------- - -Buildman includes most of the features of MAKEALL and is generally faster -and easier to use. In particular it builds entire branches: if a particular -commit introduces an error in a particular board, buildman can easily show -you this, even if a later commit fixes that error. - -The reasons to deprecate MAKEALL are: -- We don't want to maintain two build systems -- Buildman is typically faster -- Buildman has a lot more features - -But still, many people will be sad to lose MAKEALL. If you are used to -MAKEALL, here are a few pointers. - -First you need to set up your tool chains - see the 'Setting up' section -for details. Once you have your required toolchain(s) detected then you are -ready to go. - -To build the current source tree, run buildman without a -b flag: - -.. code-block:: bash - - ./tools/buildman/buildman <list of things to build> - -This will build the current source tree for the given boards and display -the results and errors. - -However buildman usually works on entire branches, and for that you must -specify a board flag: - -.. code-block:: bash - - ./tools/buildman/buildman -b <branch_name> <list of things to build> - -followed by (afterwards, or perhaps concurrently in another terminal): - -.. code-block:: bash - - ./tools/buildman/buildman -b <branch_name> -s <list of things to build> - -to see the results of the build. Rather than showing you all the output, -buildman just shows a summary, with red indicating that a commit introduced -an error and green indicating that a commit fixed an error. Use the -e -flag to see the full errors and -l to see which boards caused which errors. - -If you really want to see build results as they happen, use -v when doing a -build (and -e to see the errors/warnings too). - -You don't need to stick around on that branch while buildman is running. It -checks out its own copy of the source code, so you can change branches, -add commits, etc. without affecting the build in progress. - -The <list of things to build> can include board names, architectures or the -like. There are no flags to disambiguate since ambiguities are rare. Using -the examples from MAKEALL: - -Examples:: - - - build all Power Architecture boards: - MAKEALL -a powerpc - MAKEALL --arch powerpc - MAKEALL powerpc - ** buildman -b <branch> powerpc - - build all PowerPC boards manufactured by vendor "esd": - MAKEALL -a powerpc -v esd - ** buildman -b <branch> esd - - build all PowerPC boards manufactured either by "keymile" or "siemens": - MAKEALL -a powerpc -v keymile -v siemens - ** buildman -b <branch> keymile siemens - - build all Freescale boards with MPC83xx CPUs, plus all 4xx boards: - MAKEALL -c mpc83xx -v freescale 4xx - ** buildman -b <branch> mpc83xx freescale 4xx - -Buildman automatically tries to use all the CPUs in your machine. If you -are building a lot of boards it will use one thread for every CPU core -it detects in your machine. This is like MAKEALL's BUILD_NBUILDS option. -You can use the -T flag to change the number of threads. If you are only -building a few boards, buildman will automatically run make with the -j -flag to increase the number of concurrent make tasks. It isn't normally -that helpful to fiddle with this option, but if you use the BUILD_NCPUS -option in MAKEALL then -j is the equivalent in buildman. - -Buildman puts its output in ../<branch_name> by default but you can change -this with the -o option. Buildman normally does out-of-tree builds: use -i -to disable that if you really want to. But be careful that once you have -used -i you pollute buildman's copies of the source tree, and you will need -to remove the build directory (normally ../<branch_name>) to run buildman -in normal mode (without -i). - -Buildman doesn't keep the output result normally, but use the -k option to -do this. - -Please read 'Theory of Operation' a few times as it will make a lot of -things clearer. - -Some options you might like are:: - - -B shows which functions are growing/shrinking in which commit - great - for finding code bloat. - -S shows image sizes for each commit (just an overall summary) - -u shows boards that you haven't built yet - --step 0 will build just the upstream commit and the last commit of your - branch. This is often a quick sanity check that your branch doesn't - break anything. But note this does not check bisectability! - - Using boards.cfg ----------------
Signature · 1 line
2.38.1.431.g37b22c650d-goog
PATCH v3 6/9 buildman: Drop mention of old architectures
In reply to Simon GlassSupport for some architectures has been removed since buildman was first written. Also all toolchains are now available at kernel.org so we don't need the links.
---
Changes in v3:
- Add new patch to drop mention of old architectures
tools/buildman/bsettings.py | 2 -- tools/buildman/buildman.rst | 24 +----------------------- 2 files changed, 1 insertion(+), 25 deletions(-)
tools/buildman/bsettings.py +0 -2
@@ -84,8 +84,6 @@ other = / # arch = alias # Indicates which toolchain should be used to build for that arch x86 = i386 -blackfin = bfin -openrisc = or1k [make-flags] # Special flags to pass to 'make' for certain boards, e.g. to pass a test
tools/buildman/buildman.rst +1 -23
@@ -204,8 +204,6 @@ Setting up [toolchain-alias] x86: i386 - blackfin: bfin - openrisc: or1k This selects the available toolchain paths. Add the base directory for
@@ -479,24 +477,11 @@ Setting up sudo mkdir -p /toolchains sudo mv ~/.buildman-toolchains/*/* /toolchains/ - For those not available from kernel.org, download from the following links: - - - `Arc Toolchain`_ - - `Blackfin Toolchain`_ - - `Nios2 Toolchain`_ - - `SH Toolchain`_ - - Note openrisc kernel.org toolchain is out of date. Download the latest one - from `OpenRISC Toolchains`_, e.g. `OpenRISC 4.8.1`_. - Buildman should now be set up to use your new toolchain. At the time of writing, U-Boot has these architectures: - arc, arm, blackfin, m68k, microblaze, mips, nios2, openrisc - powerpc, sandbox, sh, sparc, x86 - - Of these, only arc is not available at kernel.org. + arc, arm, m68k, microblaze, mips, nios2, powerpc, sandbox, sh, x86, xtensa How to run it
@@ -1287,13 +1272,6 @@ Thanks to Grant Grundler <[email protected]> for his ideas for improving the build speed by building all commits for a board instead of the other way around. -.. _`Arc Toolchain`: https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2016.09-release/arc_gnu_2016.09_prebuilt_uclibc_le_archs_linux_install.tar.gz -.. _`Blackfin Toolchain`: http://sourceforge.net/projects/adi-toolchain/files/blackfin-toolchain-elf-gcc-4.5-2014R1_45-RC2.x86_64.tar.bz2 -.. _`Nios2 Toolchain`: http://sourcery.mentor.com/public/gnu_toolchain/nios2-linux-gnu/sourceryg++-2015.11-27-nios2-linux-gnu-i686-pc-linux-gnu.tar.bz2 -.. _`SH Toolchain`: http://sourcery.mentor.com/public/gnu_toolchain/sh-linux-gnu/renesas-4.4-200-sh-linux-gnu-i686-pc-linux-gnu.tar.bz2 -.. _`OpenRISC Toolchains`: http://opencores.org/or1k/OpenRISC_GNU_tool_chain#Prebuilt_versions -.. _`OpenRISC 4.8.1`: ftp://ocuser:[email protected]/toolchain/gcc-or1k-elf-4.8.1-x86.tar.bz2 - .. sectionauthor:: Simon Glass .. sectionauthor:: Copyright (c) 2013 The Chromium OS Authors. .. sectionauthor:: [email protected]
Signature · 1 line
2.38.1.431.g37b22c650d-goog
PATCH v3 7/9 buildman: Detect binman reporting missing blobs
In reply to Simon GlassBuildman should consider a build as a success (with warnings) if missing blobs have been dealt with by binman, even though buildman itself returns and error code overall. This is how other warnings are dealt with.
We cannot easily access the 103 exit code, so detect the problem in the output.
With this change, missing blobs result in an exit code of 101, although they still indicate failure.
---
(no changes since v1)
tools/buildman/builderthread.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/buildman/builderthread.py +5 -1
@@ -288,10 +288,14 @@ class BuilderThread(threading.Thread): args.append('cfg') result = self.Make(commit, brd, 'build', cwd, *args, env=env) + if (result.return_code == 2 and + ('Some images are invalid' in result.stderr)): + # This is handled later by the check for output in + # stderr + result.return_code = 0 if adjust_cfg: errs = cfgutil.check_cfg_file(cfg_file, adjust_cfg) if errs: - print('errs', errs) result.stderr += errs result.return_code = 1 result.stderr = result.stderr.replace(src_dir + '/', '')
Signature · 1 line
2.38.1.431.g37b22c650d-goog
PATCH v3 8/9 global: Do not default to faking missing binaries for buildman
In reply to Simon GlassFrom: Tom Rini <[email protected]>
While it is possible and documented on how to re-run buildman to replace faked required binary files after the fact, this behavior ends up being more confusing than helpful in practice. Switch to requiring BINMAN_ALLOW_MISSING=1 to be passed on the 'make' line to enable this behavior.
---
(no changes since v1)
Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -1333,8 +1333,8 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \ $(foreach f,$(BINMAN_TOOLPATHS),--toolpath $(f)) \ --toolpath $(objtree)/tools \ $(if $(BINMAN_VERBOSE),-v$(BINMAN_VERBOSE)) \ - build -u -d u-boot.dtb -O . -m --allow-missing \ - --fake-ext-blobs \ + build -u -d u-boot.dtb -O . -m \ + $(if $(BINMAN_ALLOW_MISSING),--allow-missing --fake-ext-blobs) \ -I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \ -I arch/$(ARCH)/dts -a of-list=$(CONFIG_OF_LIST) \ $(foreach f,$(BINMAN_INDIRS),-I $(f)) \
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Re: [PATCH v3 8/9] global: Do not default to faking missing binaries for buildman
Quoted 7 lines · Simon Glass
From: Tom Rini <[email protected]>
While it is possible and documented on how to re-run buildman to replace faked required binary files after the fact, this behavior ends up being more confusing than helpful in practice. Switch to requiring BINMAN_ALLOW_MISSING=1 to be passed on the 'make' line to enable this behavior.
Please, document all relevant environment variables for binman in doc/develop/package/binman.rst. (This could be a follow up patch to the series.)
Best regards
Heinrich
Quoted 27 lines
Cc Rasmus Villemoes <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Tom Rini <[email protected]>Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Makefile +2
-2@@ -1333,8 +1333,8 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \ $(foreach f,$(BINMAN_TOOLPATHS),--toolpath $(f)) \ --toolpath $(objtree)/tools \ $(if $(BINMAN_VERBOSE),-v$(BINMAN_VERBOSE)) \ - build -u -d u-boot.dtb -O . -m --allow-missing \ - --fake-ext-blobs \ + build -u -d u-boot.dtb -O . -m \ + $(if $(BINMAN_ALLOW_MISSING),--allow-missing --fake-ext-blobs) \ -I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \ -I arch/$(ARCH)/dts -a of-list=$(CONFIG_OF_LIST) \ $(foreach f,$(BINMAN_INDIRS),-I $(f)) \
PATCH v3 9/9 buildman: Add --allow-missing flag to allow missing blobs
In reply to Simon GlassFrom: Tom Rini <[email protected]>
Add a new flag to buildman so that we will in turn pass BINMAN_ALLOW_MISSING=1 to 'make'. Make use of this flag in CI.
Allow the settings file to control this.
---
Changes in v3:
- Add tests docs and a settings-file option
.azure-pipelines.yml | 2 +- .gitlab-ci.yml | 6 +-- tools/buildman/bsettings.py | 16 ++++++ tools/buildman/builder.py | 5 +- tools/buildman/builderthread.py | 2 + tools/buildman/buildman.rst | 43 +++++++++++++++ tools/buildman/cmdline.py | 6 +++ tools/buildman/control.py | 29 +++++++++- tools/buildman/func_test.py | 96 +++++++++++++++++++++++++++++++-- 9 files changed, 196 insertions(+), 9 deletions(-)
.azure-pipelines.yml +1 -1
@@ -553,7 +553,7 @@ stages: cat << "EOF" >> build.sh if [[ "${BUILDMAN}" != "" ]]; then ret=0; - tools/buildman/buildman -o /tmp -P -E -W ${BUILDMAN} ${OVERRIDE} || ret=$?; + tools/buildman/buildman -o /tmp -PEWM ${BUILDMAN} ${OVERRIDE} || ret=$?; if [[ $ret -ne 0 ]]; then tools/buildman/buildman -o /tmp -seP ${BUILDMAN}; exit $ret;
.gitlab-ci.yml +3 -3
@@ -81,7 +81,7 @@ build all 32bit ARM platforms: stage: world build script: - ret=0; - ./tools/buildman/buildman -o /tmp -P -E -W arm -x aarch64 || ret=$?; + ./tools/buildman/buildman -o /tmp -PEWM arm -x aarch64 || ret=$?; if [[ $ret -ne 0 ]]; then ./tools/buildman/buildman -o /tmp -seP; exit $ret;
@@ -93,7 +93,7 @@ build all 64bit ARM platforms: - virtualenv -p /usr/bin/python3 /tmp/venv - . /tmp/venv/bin/activate - ret=0; - ./tools/buildman/buildman -o /tmp -P -E -W aarch64 || ret=$?; + ./tools/buildman/buildman -o /tmp -PEWM aarch64 || ret=$?; if [[ $ret -ne 0 ]]; then ./tools/buildman/buildman -o /tmp -seP; exit $ret;
@@ -113,7 +113,7 @@ build all other platforms: stage: world build script: - ret=0; - ./tools/buildman/buildman -o /tmp -P -E -W -x arm,powerpc || ret=$?; + ./tools/buildman/buildman -o /tmp -PEWM -x arm,powerpc || ret=$?; if [[ $ret -ne 0 ]]; then ./tools/buildman/buildman -o /tmp -seP; exit $ret;
tools/buildman/bsettings.py +16 -0
@@ -5,6 +5,7 @@ import configparser import os import io +config_fname = None def Setup(fname=''): """Set up the buildman settings module by reading config files
@@ -46,6 +47,21 @@ def GetItems(section): except: raise +def GetGlobalItem(name): + """Get an items from the 'global' section of the config. + + Args: + name: name of item to retrieve + + Returns: + str: Value of item, or None if not present + """ + items = GetItems('global') + for item in items: + if item[0] == name: + return item[1] + return None + def SetItem(section, tag, value): """Set an item and write it back to the settings file""" global settings
tools/buildman/builder.py +4 -1
@@ -252,7 +252,8 @@ class Builder: mrproper=False, per_board_out_dir=False, config_only=False, squash_config_y=False, warnings_as_errors=False, work_in_output=False, - test_thread_exceptions=False, adjust_cfg=None): + test_thread_exceptions=False, adjust_cfg=None, + allow_missing=False): """Create a new Builder object Args:
@@ -290,6 +291,7 @@ class Builder: ~C to disable C C=val to set the value of C (val must have quotes if C is a string Kconfig + allow_missing: Run build with BINMAN_ALLOW_MISSING=1 """ self.toolchains = toolchains
@@ -327,6 +329,7 @@ class Builder: self.config_filenames = BASE_CONFIG_FILENAMES self.work_in_output = work_in_output self.adjust_cfg = adjust_cfg + self.allow_missing = allow_missing self._ide = False if not self.squash_config_y:
tools/buildman/builderthread.py +2 -0
@@ -253,6 +253,8 @@ class BuilderThread(threading.Thread): args.extend(['-j', str(self.builder.num_jobs)]) if self.builder.warnings_as_errors: args.append('KCFLAGS=-Werror') + if self.builder.allow_missing: + args.append('BINMAN_ALLOW_MISSING=1') config_args = ['%s_defconfig' % brd.target] config_out = '' args.extend(self.builder.toolchains.GetMakeArguments(brd))
tools/buildman/buildman.rst +43 -0
55 lines not on this page · raw message
tools/buildman/cmdline.py +6 -0
@@ -75,6 +75,12 @@ def ParseArgs(): help='List available tool chains (use -v to see probing detail)') parser.add_option('-m', '--mrproper', action='store_true', default=False, help="Run 'make mrproper before reconfiguring") + parser.add_option( + '-M', '--allow-missing', action='store_true', default=False, + help='Tell binman to allow missing blobs and generate fake ones as needed'), + parser.add_option( + '--no-allow-missing', action='store_true', default=False, + help='Disable telling binman to allow missing blobs'), parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run', default=False, help="Do a dry run (describe actions, but do nothing)") parser.add_option('-N', '--no-subdirs', action='store_true', dest='no_subdirs',
tools/buildman/control.py +28 -1
@@ -111,6 +111,23 @@ def ShowToolchainPrefix(brds, toolchains): print(tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE)) return None +def get_allow_missing(opt_allow, opt_no_allow, num_selected, has_branch): + allow_missing = False + am_setting = bsettings.GetGlobalItem('allow-missing') + if am_setting: + if am_setting == 'always': + allow_missing = True + if 'multiple' in am_setting and num_selected > 1: + allow_missing = True + if 'branch' in am_setting and has_branch: + allow_missing = True + + if opt_allow: + allow_missing = True + if opt_no_allow: + allow_missing = False + return allow_missing + def DoBuildman(options, args, toolchains=None, make_func=None, brds=None, clean_dir=False, test_thread_exceptions=False): """The main control code for buildman
@@ -305,6 +322,15 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None, if not gnu_make: sys.exit('GNU Make not found') + allow_missing = get_allow_missing(options.allow_missing, + options.no_allow_missing, len(selected), + options.branch) + + if options.allow_missing: + allow_missing = True + if options.no_allow_missing: + allow_missing = False + # Create a new builder with the selected options. output_dir = options.output_dir if options.branch:
@@ -329,7 +355,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None, warnings_as_errors=options.warnings_as_errors, work_in_output=options.work_in_output, test_thread_exceptions=test_thread_exceptions, - adjust_cfg=adjust_cfg) + adjust_cfg=adjust_cfg, + allow_missing=allow_missing) builder.force_config_on_failure = not options.quick if make_func: builder.do_make = make_func
tools/buildman/func_test.py +93 -3
125 lines not on this page · raw message
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Re: [PATCH v3 9/9] buildman: Add --allow-missing flag to allow missing blobs
Quoted 4 lines · Simon Glass
From: Tom Rini <[email protected]>
Add a new flag to buildman so that we will in turn pass BINMAN_ALLOW_MISSING=1 to 'make'. Make use of this flag in CI.
Please, document all arguments of binman in doc/develop/package/binman.rst.
Best regards
Heinrich
Quoted 409 lines
Allow the settings file to control this.
Cc Rasmus Villemoes <[email protected]>Cc Simon Glass <[email protected]>Signed-off-by Tom Rini <[email protected]>Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Add tests docs and a settings-file option.azure-pipelines.yml | 2 +- .gitlab-ci.yml | 6 +-- tools/buildman/bsettings.py | 16 ++++++ tools/buildman/builder.py | 5 +- tools/buildman/builderthread.py | 2 + tools/buildman/buildman.rst | 43 +++++++++++++++ tools/buildman/cmdline.py | 6 +++ tools/buildman/control.py | 29 +++++++++- tools/buildman/func_test.py | 96 +++++++++++++++++++++++++++++++-- 9 files changed, 196 insertions(+), 9 deletions(-).azure-pipelines.yml +1
-1@@ -553,7 +553,7 @@ stages: cat << "EOF" >> build.sh if [[ "${BUILDMAN}" != "" ]]; then ret=0; - tools/buildman/buildman -o /tmp -P -E -W ${BUILDMAN} ${OVERRIDE} || ret=$?; + tools/buildman/buildman -o /tmp -PEWM ${BUILDMAN} ${OVERRIDE} || ret=$?; if [[ $ret -ne 0 ]]; then tools/buildman/buildman -o /tmp -seP ${BUILDMAN}; exit $ret;.gitlab-ci.yml +3
-3@@ -81,7 +81,7 @@ build all 32bit ARM platforms: stage: world build script: - ret=0; - ./tools/buildman/buildman -o /tmp -P -E -W arm -x aarch64 || ret=$?; + ./tools/buildman/buildman -o /tmp -PEWM arm -x aarch64 || ret=$?; if [[ $ret -ne 0 ]]; then ./tools/buildman/buildman -o /tmp -seP; exit $ret;@@ -93,7 +93,7 @@ build all 64bit ARM platforms: - virtualenv -p /usr/bin/python3 /tmp/venv - . /tmp/venv/bin/activate - ret=0; - ./tools/buildman/buildman -o /tmp -P -E -W aarch64 || ret=$?; + ./tools/buildman/buildman -o /tmp -PEWM aarch64 || ret=$?; if [[ $ret -ne 0 ]]; then ./tools/buildman/buildman -o /tmp -seP; exit $ret;@@ -113,7 +113,7 @@ build all other platforms: stage: world build script: - ret=0; - ./tools/buildman/buildman -o /tmp -P -E -W -x arm,powerpc || ret=$?; + ./tools/buildman/buildman -o /tmp -PEWM -x arm,powerpc || ret=$?; if [[ $ret -ne 0 ]]; then ./tools/buildman/buildman -o /tmp -seP; exit $ret;tools/buildman/bsettings.py +16
-0@@ -5,6 +5,7 @@ import configparser import os import io +config_fname = None def Setup(fname=''): """Set up the buildman settings module by reading config files@@ -46,6 +47,21 @@ def GetItems(section): except: raise +def GetGlobalItem(name): + """Get an items from the 'global' section of the config. + + Args: + name: name of item to retrieve + + Returns: + str: Value of item, or None if not present + """ + items = GetItems('global') + for item in items: + if item[0] == name: + return item[1] + return None + def SetItem(section, tag, value): """Set an item and write it back to the settings file""" global settingstools/buildman/builder.py +4
-1@@ -252,7 +252,8 @@ class Builder: mrproper=False, per_board_out_dir=False, config_only=False, squash_config_y=False, warnings_as_errors=False, work_in_output=False, - test_thread_exceptions=False, adjust_cfg=None): + test_thread_exceptions=False, adjust_cfg=None, + allow_missing=False): """Create a new Builder object Args:@@ -290,6 +291,7 @@ class Builder: ~C to disable C C=val to set the value of C (val must have quotes if C is a string Kconfig + allow_missing: Run build with BINMAN_ALLOW_MISSING=1 """ self.toolchains = toolchains@@ -327,6 +329,7 @@ class Builder: self.config_filenames = BASE_CONFIG_FILENAMES self.work_in_output = work_in_output self.adjust_cfg = adjust_cfg + self.allow_missing = allow_missing self._ide = False if not self.squash_config_y:tools/buildman/builderthread.py +2
-0@@ -253,6 +253,8 @@ class BuilderThread(threading.Thread): args.extend(['-j', str(self.builder.num_jobs)]) if self.builder.warnings_as_errors: args.append('KCFLAGS=-Werror') + if self.builder.allow_missing: + args.append('BINMAN_ALLOW_MISSING=1') config_args = ['%s_defconfig' % brd.target] config_out = '' args.extend(self.builder.toolchains.GetMakeArguments(brd))tools/buildman/buildman.rst +43
-0@@ -904,6 +904,25 @@ also allows build flags to be passed to 'make'. It consists of several sections, with the section name in square brackets. Within each section are a set of (tag, value) pairs. +global section + allow-missing + Indicates the policy to use for missing blobs. Note that the flags + --allow-missing (-M) and --no-allow-missing (--no-a) override these + setting. + + always + Run with -M by default. + + multiple + Run with -M if more than one board is being built. + + branch + Run with -M if a branch is being built. + + Note that the last two can be given together:: + + allow-missing = multiple branch + '[toolchain]' section This lists the available toolchains. The tag here doesn't matter, but make sure it is unique. The value is the path to the toolchain. Buildman@@ -1131,6 +1150,30 @@ not cause the build to fail: buildman -o /tmp/build --board sandbox -wWI +Support for binary blobs +------------------------ + +U-Boot is moving to using Binman (see :doc:`../develop/package/binman`) for +dealing with the complexities of packaging U-Boot along with binary files from +other projects. These are called 'external blobs' by Binman. + +Typically a missing external blob causes a build failure. For build testing of +a lot of boards, or boards for which you do not have the blobs, you can use the +-M flag to allow missing blobs. This marks the build as if it succeeded, +although with warnings shown, including 'Some images are invalid'. If any boards +fail in this way, buildman exits with status 101. + +To convert warnings to errors, use -E. To make buildman return success with +these warnings, use -W. + +It is generally safe to default to enabling -M for all runs of buildman, so long +as you check the exit code. To do this, add:: + + allow-missing = "always" + +to the top of the buildman_settings_ file. + + Changing the configuration --------------------------tools/buildman/cmdline.py +6
-0@@ -75,6 +75,12 @@ def ParseArgs(): help='List available tool chains (use -v to see probing detail)') parser.add_option('-m', '--mrproper', action='store_true', default=False, help="Run 'make mrproper before reconfiguring") + parser.add_option( + '-M', '--allow-missing', action='store_true', default=False, + help='Tell binman to allow missing blobs and generate fake ones as needed'), + parser.add_option( + '--no-allow-missing', action='store_true', default=False, + help='Disable telling binman to allow missing blobs'), parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run', default=False, help="Do a dry run (describe actions, but do nothing)") parser.add_option('-N', '--no-subdirs', action='store_true', dest='no_subdirs',tools/buildman/control.py +28
-1@@ -111,6 +111,23 @@ def ShowToolchainPrefix(brds, toolchains): print(tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE)) return None +def get_allow_missing(opt_allow, opt_no_allow, num_selected, has_branch): + allow_missing = False + am_setting = bsettings.GetGlobalItem('allow-missing') + if am_setting: + if am_setting == 'always': + allow_missing = True + if 'multiple' in am_setting and num_selected > 1: + allow_missing = True + if 'branch' in am_setting and has_branch: + allow_missing = True + + if opt_allow: + allow_missing = True + if opt_no_allow: + allow_missing = False + return allow_missing + def DoBuildman(options, args, toolchains=None, make_func=None, brds=None, clean_dir=False, test_thread_exceptions=False): """The main control code for buildman@@ -305,6 +322,15 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None, if not gnu_make: sys.exit('GNU Make not found') + allow_missing = get_allow_missing(options.allow_missing, + options.no_allow_missing, len(selected), + options.branch) + + if options.allow_missing: + allow_missing = True + if options.no_allow_missing: + allow_missing = False + # Create a new builder with the selected options. output_dir = options.output_dir if options.branch:@@ -329,7 +355,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None, warnings_as_errors=options.warnings_as_errors, work_in_output=options.work_in_output, test_thread_exceptions=test_thread_exceptions, - adjust_cfg=adjust_cfg) + adjust_cfg=adjust_cfg, + allow_missing=allow_missing) builder.force_config_on_failure = not options.quick if make_func: builder.do_make = make_functools/buildman/func_test.py +93
-3@@ -22,6 +22,7 @@ from patman import tools settings_data = ''' # Buildman settings file +[global] [toolchain]@@ -205,13 +206,16 @@ class TestFunctional(unittest.TestCase): self._test_branch = TEST_BRANCH + # Set to True to report missing blobs + self._missing = False + # Avoid sending any output and clear all terminal output terminal.set_print_test_mode() terminal.get_print_test_lines() def tearDown(self): shutil.rmtree(self._base_dir) - #shutil.rmtree(self._output_dir) + shutil.rmtree(self._output_dir) def setupToolchains(self): self._toolchains = toolchain.Toolchains()@@ -424,10 +428,21 @@ class TestFunctional(unittest.TestCase): out_dir = arg[2:] fname = os.path.join(cwd or '', out_dir, 'u-boot') tools.write_file(fname, b'U-Boot') - if type(commit) is not str: + + # Handle missing blobs + if self._missing: + if 'BINMAN_ALLOW_MISSING=1' in args: + stderr = '''+Image 'main-section' is missing external blobs and is non-functional: intel-descriptor intel-ifwi intel-fsp-m intel-fsp-s intel-vbt +Image 'main-section' has faked external blobs and is non-functional: descriptor.bin fsp_m.bin fsp_s.bin vbt.bin + +Some images are invalid''' + else: + stderr = "binman: Filename 'fsp.bin' not found in input path" + elif type(commit) is not str: stderr = self._error.get((brd.target, commit.sequence)) + if stderr: - return command.CommandResult(return_code=1, stderr=stderr) + return command.CommandResult(return_code=2, stderr=stderr) return command.CommandResult(return_code=0) # Not handled, so abort@@ -621,3 +636,78 @@ class TestFunctional(unittest.TestCase): self.assertIn( 'Thread exception (use -T0 to run without threads): test exception', stdout.getvalue()) + + def testBlobs(self): + """Test handling of missing blobs""" + self._missing = True + + board0_dir = os.path.join(self._output_dir, 'current', 'board0') + errfile = os.path.join(board0_dir, 'err') + logfile = os.path.join(board0_dir, 'log') + + # We expect failure when there are missing blobs + result = self._RunControl('board0', '-o', self._output_dir) + self.assertEqual(100, result) + self.assertTrue(os.path.exists(os.path.join(board0_dir, 'done'))) + self.assertTrue(os.path.exists(errfile)) + self.assertIn(b"Filename 'fsp.bin' not found in input path", + tools.read_file(errfile)) + + # Allow missing blobs - still failure but a different exit code + result = self._RunControl('board0', '-o', self._output_dir, '-M', + clean_dir=True) + self.assertEqual(101, result) + self.assertTrue(os.path.exists(errfile)) + self.assertIn(b'Some images are invalid', tools.read_file(errfile)) + + # Allow missing blobs and ignore warnings + result = self._RunControl('board0', '-o', self._output_dir, '-MW') + self.assertEqual(0, result) + self.assertIn(b'Some images are invalid', tools.read_file(errfile)) + + def testBlobSettings(self): + # Test with no settings + self.assertEqual(False, + control.get_allow_missing(False, False, 1, False)) + self.assertEqual(True, + control.get_allow_missing(True, False, 1, False)) + self.assertEqual(False, + control.get_allow_missing(True, True, 1, False)) + + # Check 'always' + bsettings.SetItem('global', 'allow-missing', 'always') + self.assertEqual(True, + control.get_allow_missing(False, False, 1, False)) + self.assertEqual(False, + control.get_allow_missing(False, True, 1, False)) + + # Check 'branch' + bsettings.SetItem('global', 'allow-missing', 'branch') + self.assertEqual(False, + control.get_allow_missing(False, False, 1, False)) + self.assertEqual(True, + control.get_allow_missing(False, False, 1, True)) + self.assertEqual(False, + control.get_allow_missing(False, True, 1, True)) + + # Check 'multiple' + bsettings.SetItem('global', 'allow-missing', 'multiple') + self.assertEqual(False, + control.get_allow_missing(False, False, 1, False)) + self.assertEqual(True, + control.get_allow_missing(False, False, 2, False)) + self.assertEqual(False, + control.get_allow_missing(False, True, 2, False)) + + # Check 'branch multiple' + bsettings.SetItem('global', 'allow-missing', 'branch multiple') + self.assertEqual(False, + control.get_allow_missing(False, False, 1, False)) + self.assertEqual(True, + control.get_allow_missing(False, False, 1, True)) + self.assertEqual(True, + control.get_allow_missing(False, False, 2, False)) + self.assertEqual(True, + control.get_allow_missing(False, False, 2, True)) + self.assertEqual(False, + control.get_allow_missing(False, True, 2, True))