scripts: add --build-opt option to west build

This allows passing arguments to the underlying build tool (ninja,
make, etc.).

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
diff --git a/scripts/west_commands/build.py b/scripts/west_commands/build.py
index f33b845..ed0c783 100644
--- a/scripts/west_commands/build.py
+++ b/scripts/west_commands/build.py
@@ -18,7 +18,8 @@
 BUILD_USAGE = '''\
 west build [-h] [-b BOARD] [-d BUILD_DIR]
            [-t TARGET] [-p {auto, always, never}] [-c] [--cmake-only]
-           [-n] [-f] [source_dir] -- [cmake_opt [cmake_opt ...]]
+           [-n] [-o BUILD_OPT] [-f]
+           [source_dir] -- [cmake_opt [cmake_opt ...]]
 '''
 
 BUILD_DESCRIPTION = '''\
@@ -143,6 +144,10 @@
                             dest='dry_run', action='store_true',
                             help='''Just print the build commands which would
                             have run, without actually running them.''')
+        parser.add_argument('-o', '--build-opt', default=[], action='append',
+                            help='''Options to pass to the build tool.
+                            May be given more than once to append multiple
+                            values.''')
         self.add_force_arg(parser)
         return parser
 
@@ -432,5 +437,8 @@
 
     def _run_build(self, target):
         extra_args = ['--target', target] if target else []
+        if self.args.build_opt:
+            extra_args.append('--')
+            extra_args.extend(self.args.build_opt)
         run_build(self.build_dir, extra_args=extra_args,
                   dry_run=self.args.dry_run)