[meson] Pull the functionality of make_build_bin.sh into Meson.

This change is part of the effort to implement the directory structure
described in #650.

Signed-off-by: Miguel Young de la Sota <mcyoung@google.com>
diff --git a/sw/device/examples/hello_usbdev/meson.build b/sw/device/examples/hello_usbdev/meson.build
index 506cfca..970f780 100644
--- a/sw/device/examples/hello_usbdev/meson.build
+++ b/sw/device/examples/hello_usbdev/meson.build
@@ -2,21 +2,32 @@
 # Licensed under the Apache License, Version 2.0, see LICENSE for details.
 # SPDX-License-Identifier: Apache-2.0
 
-custom_target(
+hello_usbdev_elf = executable(
+  'hello_usbdev',
+  sources: ['hello_usbdev.c'],
+  name_suffix: 'elf',
+  dependencies: [
+    sw_lib_gpio,
+    sw_lib_irq,
+    sw_lib_uart,
+    sw_lib_usb,
+    riscv_crt,
+  ],
+)
+
+hello_usbdev_embedded = custom_target(
   'hello_usbdev',
   command: make_embedded_target,
+  input: hello_usbdev_elf,
   output: make_embedded_target_outputs,
   build_by_default: true,
-  input: executable(
-    'hello_usbdev',
-    sources: ['hello_usbdev.c'],
-    name_suffix: 'elf',
-    dependencies: [
-      sw_lib_gpio,
-      sw_lib_irq,
-      sw_lib_uart,
-      sw_lib_usb,
-      riscv_crt,
-    ],
-  ),
+)
+
+custom_target(
+  'hello_usbdev_export',
+  command: export_embedded_target,
+  input: [hello_usbdev_elf, hello_usbdev_embedded],
+  output: 'hello_usbdev_export',
+  build_always_stale: true,
+  build_by_default: true,
 )