@@ -125,28 +125,28 @@ def desc_common(command_name):
125125 west { command_name } --context -d BUILD_DIR
126126 ''' )
127127
128- def do_run_common (command , args , user_runner_args ):
128+ def do_run_common (command , user_args , user_runner_args ):
129129 # This is the main routine for all the "west flash", "west debug",
130130 # etc. commands.
131131
132- if args .context :
133- dump_context (command , args , user_runner_args )
132+ if user_args .context :
133+ dump_context (command , user_args , user_runner_args )
134134 return
135135
136136 command_name = command .name
137- build_dir = get_build_dir (args )
138- cache = load_cmake_cache (build_dir , args )
137+ build_dir = get_build_dir (user_args )
138+ cache = load_cmake_cache (build_dir , user_args )
139139 board = cache ['CACHED_BOARD' ]
140- if not args .skip_rebuild :
141- rebuild (command , build_dir , args )
140+ if not user_args .skip_rebuild :
141+ rebuild (command , build_dir , user_args )
142142
143143 # Load runners.yaml.
144144 runners_yaml = runners_yaml_path (cache )
145- runner_config = load_runners_yaml (runners_yaml , args )
145+ runner_config = load_runners_yaml (runners_yaml , user_args )
146146
147147 # Get a concrete ZephyrBinaryRunner subclass to use based on
148148 # runners.yaml and command line arguments.
149- runner_cls = use_runner_cls (command , board , args , runner_config )
149+ runner_cls = use_runner_cls (command , board , user_args , runner_config )
150150 runner_name = runner_cls .name ()
151151
152152 # Set up runner logging to delegate to west.log commands.
@@ -168,16 +168,23 @@ def do_run_common(command, args, user_runner_args):
168168 runner_config ['args' ][runner_name ] +
169169 runner_args )
170170
171- # At this point, 'args' contains parsed arguments which are both:
171+ # 'user_args' contains parsed arguments which are:
172+ #
173+ # 1. provided on the command line, and
174+ # 2. handled by add_parser_common(), and
175+ # 3. *not* runner-specific
176+ #
177+ # 'final_argv' contains unparsed arguments from either:
172178 #
173- # 1. provided on the command line
174- # 2. handled by add_parser_common()
179+ # 1. runners.yaml, or
180+ # 2. the command line
175181 #
176- # This doesn't include runner specific arguments on the command line or
177- # anything from runners.yaml.
182+ # We next have to:
178183 #
179- # We therefore have to re-parse now that we know everything,
180- # including the final runner.
184+ # - parse 'final_argv' now that we have all the command line
185+ # arguments
186+ # - create a RunnerConfig using 'user_args' and the result
187+ # of parsing 'final_argv'
181188 parser = argparse .ArgumentParser (prog = runner_name )
182189 add_parser_common (command , parser = parser )
183190 runner_cls .add_parser (parser )
@@ -206,7 +213,7 @@ def do_run_common(command, args, user_runner_args):
206213 log .die ('required program' , e .filename ,
207214 'not found; install it or add its location to PATH' )
208215 except RuntimeError as re :
209- if not args .verbose :
216+ if not user_args .verbose :
210217 log .die (re )
211218 else :
212219 log .err ('verbose mode enabled, dumping stack:' , fatal = True )
0 commit comments