Skip to content

Commit 924331c

Browse files
committed
configure.py: fix --disable-option-checking
Getting the value of this argument needs another level of indexing, as `known_args` are stored in `{dict}[list](opt, value)` form. Also, when option-checking is disabled, let this bypass the check that options are only passed once, and just apply the last value.
1 parent b218a02 commit 924331c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/bootstrap/configure.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,12 @@ def err(msg):
225225
unknown_args.append(arg)
226226
p("")
227227

228-
if 'option-checking' not in known_args or known_args['option-checking'][1]:
228+
# Note: here and a few other places, we use [-1] to apply the *last* value
229+
# passed. But if option-checking is enabled, then the known_args loop will
230+
# also assert that options are only passed once.
231+
option_checking = ('option-checking' not in known_args
232+
or known_args['option-checking'][-1][1])
233+
if option_checking:
229234
if len(unknown_args) > 0:
230235
err("Option '" + unknown_args[0] + "' is not recognized")
231236
if len(need_value_args) > 0:
@@ -238,7 +243,7 @@ def err(msg):
238243

239244
def build():
240245
if 'build' in known_args:
241-
return known_args['build'][0][1]
246+
return known_args['build'][-1][1]
242247
return bootstrap.default_build_triple()
243248

244249

@@ -276,9 +281,9 @@ def set(key, value):
276281

277282
# Ensure each option is only passed once
278283
arr = known_args[key]
279-
if len(arr) > 1:
284+
if option_checking and len(arr) > 1:
280285
err("Option '{}' provided more than once".format(key))
281-
option, value = arr[0]
286+
option, value = arr[-1]
282287

283288
# If we have a clear avenue to set our value in rustbuild, do so
284289
if option.rustbuild is not None:

0 commit comments

Comments
 (0)