Skip to content

configure.py doesn't write out the last set key in a section #143605

@lambdageek

Description

@lambdageek

Summary

configure.py parses the bootstrap.example.toml file and writes out a bootstrap.toml based on the example template with values set using command line options like --set dist.vendor=false

The loop that writes the sections of the bootstrap.toml file accumulates the lines to be written for a given key (the comment lines prior to the key=value line, and the key=value line itself) and emits them when it reaches lines that belong to the next key. However when the loop finishes the section, it doesn't not emit any lines that have been accumulated that have not yet been emitted. Practically this means the last key=value pair in each section is never emitted.

Command used

python3 ./src/bootstrap/configure.py --set dist.vendor=false

Expected behaviour

bootstrap.toml contains

[dist]
# ...
vendor = false

Actual behaviour

The [dist] section is empty

Bootstrap configuration (bootstrap.toml)

# Use different pre-set defaults than the global defaults.
#
# See `src/bootstrap/defaults` for more information.
# Note that this has no default value (x.py uses the defaults in `bootstrap.example.toml`).
profile = 'dist'

[llvm]

[gcc]

[build]

# Arguments passed to the `./configure` script, used during distcheck. You
# probably won't fill this in but rather it's filled in by the `./configure`
# script. Useful for debugging.
configure-args = ['--set', 'dist.vendor=false']

[install]

[rust]

[dist]

[target.aarch64-apple-darwin]

Operating system

macOS, Linux

HEAD

1b0bc59

Additional context

def write_uncommented(target, f):
block = []
is_comment = True
for line in target:
block.append(line)
if len(line) == 0:
if not is_comment:
for ln in block:
f.write(ln + "\n")
block = []
is_comment = True
continue
is_comment = is_comment and line.startswith("#")
return f

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions