diff options
author | Simon Glass <sjg@chromium.org> | 2018-09-14 04:57:12 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-09-28 11:09:01 -0600 |
commit | 0bfa7b09ba16f4ffaf0cfc9315336aaa708dcd26 (patch) | |
tree | 476912878f3da01fe02636b91b510e7d51b40e31 /tools | |
parent | a326b495cdcfd56507841e38158683e6e4d5894c (diff) | |
download | u-boot-0bfa7b09ba16f4ffaf0cfc9315336aaa708dcd26.tar.gz u-boot-0bfa7b09ba16f4ffaf0cfc9315336aaa708dcd26.tar.bz2 u-boot-0bfa7b09ba16f4ffaf0cfc9315336aaa708dcd26.zip |
binman: Support building a selection of images
Sometimes it is useful to build only a subset of the images provided by
the binman configuration. Add a -i option for this. It can be given
multiple times to build several images. If the option is not given, all
images are built.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/binman/cmdline.py | 2 | ||||
-rw-r--r-- | tools/binman/control.py | 9 | ||||
-rw-r--r-- | tools/binman/ftest.py | 19 |
3 files changed, 29 insertions, 1 deletions
diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py index f0de4ded44..4ce8bc6ab4 100644 --- a/tools/binman/cmdline.py +++ b/tools/binman/cmdline.py @@ -30,6 +30,8 @@ def ParseArgs(argv): help='Enabling debugging (provides a full traceback on error)') parser.add_option('-E', '--entry-docs', action='store_true', help='Write out entry documentation (see README.entries)') + parser.add_option('-i', '--image', type='string', action='append', + help='Image filename to build (if not specified, build all)') parser.add_option('-I', '--indir', action='append', help='Add a path to a directory to use for input files') parser.add_option('-H', '--full-help', action='store_true', diff --git a/tools/binman/control.py b/tools/binman/control.py index 2de1c86ecf..8c48008fc7 100644 --- a/tools/binman/control.py +++ b/tools/binman/control.py @@ -162,6 +162,15 @@ def Binman(options, args): images = _ReadImageDesc(node) + if options.image: + skip = [] + for name, image in images.iteritems(): + if name not in options.image: + del images[name] + skip.append(name) + if skip: + print 'Skipping images: %s\n' % ', '.join(skip) + # Prepare the device tree by making sure that any missing # properties are added (e.g. 'pos' and 'size'). The values of these # may not be correct yet, but we add placeholders so that the diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index c4065551e7..290e9aebf1 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -171,7 +171,7 @@ class TestFunctional(unittest.TestCase): return control.Binman(options, args) def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False, - entry_args=None): + entry_args=None, images=None): """Run binman with a given test file Args: @@ -180,6 +180,10 @@ class TestFunctional(unittest.TestCase): map: True to output map files for the images update_dtb: Update the offset and size of each entry in the device tree before packing it into the image + entry_args: Dict of entry args to supply to binman + key: arg name + value: value of that arg + images: List of image names to build """ args = ['-p', '-I', self._indir, '-d', self.TestFile(fname)] if debug: @@ -191,6 +195,9 @@ class TestFunctional(unittest.TestCase): if entry_args: for arg, value in entry_args.iteritems(): args.append('-a%s=%s' % (arg, value)) + if images: + for image in images: + args += ['-i', image] return self._DoBinman(*args) def _SetupDtb(self, fname, outfile='u-boot.dtb'): @@ -1384,6 +1391,16 @@ class TestFunctional(unittest.TestCase): data = self._DoReadFile('81_x86-start16-tpl.dts') self.assertEqual(X86_START16_TPL_DATA, data[:len(X86_START16_TPL_DATA)]) + def testSelectImage(self): + """Test that we can select which images to build""" + with test_util.capture_sys_output() as (stdout, stderr): + retcode = self._DoTestFile('06_dual_image.dts', images=['image2']) + self.assertEqual(0, retcode) + self.assertIn('Skipping images: image1', stdout.getvalue()) + + self.assertFalse(os.path.exists(tools.GetOutputFilename('image1.bin'))) + self.assertTrue(os.path.exists(tools.GetOutputFilename('image2.bin'))) + if __name__ == "__main__": unittest.main() |