@@ -125,28 +125,28 @@ def desc_common(command_name):
125
125
west { command_name } --context -d BUILD_DIR
126
126
''' )
127
127
128
- def do_run_common (command , args , user_runner_args ):
128
+ def do_run_common (command , user_args , user_runner_args ):
129
129
# This is the main routine for all the "west flash", "west debug",
130
130
# etc. commands.
131
131
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 )
134
134
return
135
135
136
136
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 )
139
139
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 )
142
142
143
143
# Load runners.yaml.
144
144
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 )
146
146
147
147
# Get a concrete ZephyrBinaryRunner subclass to use based on
148
148
# 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 )
150
150
runner_name = runner_cls .name ()
151
151
152
152
# Set up runner logging to delegate to west.log commands.
@@ -168,16 +168,23 @@ def do_run_common(command, args, user_runner_args):
168
168
runner_config ['args' ][runner_name ] +
169
169
runner_args )
170
170
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:
172
178
#
173
- # 1. provided on the command line
174
- # 2. handled by add_parser_common()
179
+ # 1. runners.yaml, or
180
+ # 2. the command line
175
181
#
176
- # This doesn't include runner specific arguments on the command line or
177
- # anything from runners.yaml.
182
+ # We next have to:
178
183
#
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'
181
188
parser = argparse .ArgumentParser (prog = runner_name )
182
189
add_parser_common (command , parser = parser )
183
190
runner_cls .add_parser (parser )
@@ -206,7 +213,7 @@ def do_run_common(command, args, user_runner_args):
206
213
log .die ('required program' , e .filename ,
207
214
'not found; install it or add its location to PATH' )
208
215
except RuntimeError as re :
209
- if not args .verbose :
216
+ if not user_args .verbose :
210
217
log .die (re )
211
218
else :
212
219
log .err ('verbose mode enabled, dumping stack:' , fatal = True )
0 commit comments