binman: Allow external binaries to be missing

Sometimes it is useful to build an image even though external binaries are
not present. This allows the build system to continue to function without
these files, albeit not producing valid images.

U-Boot does with with ATF (ARM Trusted Firmware) today.

Add a new flag to binman to request this behaviour.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index f8d5191..7c8b3eb 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -285,7 +285,7 @@
 
     def _DoTestFile(self, fname, debug=False, map=False, update_dtb=False,
                     entry_args=None, images=None, use_real_dtb=False,
-                    verbosity=None):
+                    verbosity=None, allow_missing=False):
         """Run binman with a given test file
 
         Args:
@@ -319,6 +319,8 @@
         if entry_args:
             for arg, value in entry_args.items():
                 args.append('-a%s=%s' % (arg, value))
+        if allow_missing:
+            args.append('-M')
         if images:
             for image in images:
                 args += ['-i', image]
@@ -3376,6 +3378,10 @@
         self.assertIn("Filename 'missing-file' not found in input path",
                       str(e.exception))
 
+    def testExtblobMissingOk(self):
+        """Test an image with an missing external blob that is allowed"""
+        self._DoTestFile('158_blob_ext_missing.dts', allow_missing=True)
+
 
 if __name__ == "__main__":
     unittest.main()