-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fixes the --set option in configure.py #107059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1f8935e
appends --set arguments to config.toml
shourya5 65cb513
appends --set arguments to config.toml
shourya5 6e8cf1d
Merge branch 'rust-lang:master' into issue#107049
shourya5 ddb8389
Updated README.md
shourya5 54472e0
Merge branch 'rust-lang:master' into issue#107049
shourya5 3f5ff32
fix formatting issues
shourya5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,13 @@ | |
# ignore-tidy-linelength | ||
|
||
from __future__ import absolute_import, division, print_function | ||
import bootstrap | ||
import sys | ||
import os | ||
rust_dir = os.path.dirname(os.path.abspath(__file__)) | ||
rust_dir = os.path.dirname(rust_dir) | ||
rust_dir = os.path.dirname(rust_dir) | ||
sys.path.append(os.path.join(rust_dir, "src", "bootstrap")) | ||
import bootstrap | ||
|
||
|
||
class Option(object): | ||
|
@@ -31,28 +31,40 @@ def v(*args): | |
options.append(Option(*args, value=True)) | ||
|
||
|
||
o("debug", "rust.debug", "enables debugging environment; does not affect optimization of bootstrapped code") | ||
o("debug", "rust.debug", | ||
"enables debugging environment; does not affect optimization of bootstrapped code") | ||
o("docs", "build.docs", "build standard library documentation") | ||
o("compiler-docs", "build.compiler-docs", "build compiler documentation") | ||
o("optimize-tests", "rust.optimize-tests", "build tests with optimizations") | ||
o("verbose-tests", "rust.verbose-tests", "enable verbose output when running tests") | ||
o("ccache", "llvm.ccache", "invoke gcc/clang via ccache to reuse object files between builds") | ||
o("verbose-tests", "rust.verbose-tests", | ||
"enable verbose output when running tests") | ||
o("ccache", "llvm.ccache", | ||
"invoke gcc/clang via ccache to reuse object files between builds") | ||
o("sccache", None, "invoke gcc/clang via sccache to reuse object files between builds") | ||
o("local-rust", None, "use an installed rustc rather than downloading a snapshot") | ||
v("local-rust-root", None, "set prefix for local rust binary") | ||
o("local-rebuild", "build.local-rebuild", "assume local-rust matches the current version, for rebuilds; implies local-rust, and is implied if local-rust already matches the current version") | ||
o("llvm-static-stdcpp", "llvm.static-libstdcpp", "statically link to libstdc++ for LLVM") | ||
o("llvm-link-shared", "llvm.link-shared", "prefer shared linking to LLVM (llvm-config --link-shared)") | ||
o("local-rebuild", "build.local-rebuild", | ||
"assume local-rust matches the current version, for rebuilds; implies local-rust, and is implied if local-rust already matches the current version") | ||
o("llvm-static-stdcpp", "llvm.static-libstdcpp", | ||
"statically link to libstdc++ for LLVM") | ||
o("llvm-link-shared", "llvm.link-shared", | ||
"prefer shared linking to LLVM (llvm-config --link-shared)") | ||
o("rpath", "rust.rpath", "build rpaths into rustc itself") | ||
o("llvm-version-check", "llvm.version-check", "check if the LLVM version is supported, build anyway") | ||
o("llvm-version-check", "llvm.version-check", | ||
"check if the LLVM version is supported, build anyway") | ||
o("codegen-tests", "rust.codegen-tests", "run the tests/codegen tests") | ||
o("option-checking", None, "complain about unrecognized options in this configure script") | ||
o("ninja", "llvm.ninja", "build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)") | ||
o("ninja", "llvm.ninja", | ||
"build LLVM using the Ninja generator (for MSVC, requires building in the correct environment)") | ||
o("locked-deps", "build.locked-deps", "force Cargo.lock to be up to date") | ||
o("vendor", "build.vendor", "enable usage of vendored Rust crates") | ||
o("sanitizers", "build.sanitizers", "build the sanitizer runtimes (asan, lsan, msan, tsan, hwasan)") | ||
o("dist-src", "rust.dist-src", "when building tarballs enables building a source tarball") | ||
o("cargo-native-static", "build.cargo-native-static", "static native libraries in cargo") | ||
o("sanitizers", "build.sanitizers", | ||
"build the sanitizer runtimes (asan, lsan, msan, tsan, hwasan)") | ||
o("dist-src", "rust.dist-src", | ||
"when building tarballs enables building a source tarball") | ||
o("cargo-native-static", | ||
"build.cargo-native-static", | ||
"static native libraries in cargo") | ||
o("profiler", "build.profiler", "build the profiler runtime") | ||
o("full-tools", None, "enable all tools") | ||
o("lld", "rust.lld", "build lld") | ||
|
@@ -73,16 +85,27 @@ def v(*args): | |
o("llvm-assertions", "llvm.assertions", "build LLVM with assertions") | ||
o("llvm-plugins", "llvm.plugins", "build LLVM with plugin interface") | ||
o("debug-assertions", "rust.debug-assertions", "build with debugging assertions") | ||
o("debug-assertions-std", "rust.debug-assertions-std", "build the standard library with debugging assertions") | ||
o("debug-assertions-std", "rust.debug-assertions-std", | ||
"build the standard library with debugging assertions") | ||
o("overflow-checks", "rust.overflow-checks", "build with overflow checks") | ||
o("overflow-checks-std", "rust.overflow-checks-std", "build the standard library with overflow checks") | ||
o("llvm-release-debuginfo", "llvm.release-debuginfo", "build LLVM with debugger metadata") | ||
o("overflow-checks-std", "rust.overflow-checks-std", | ||
"build the standard library with overflow checks") | ||
o("llvm-release-debuginfo", | ||
"llvm.release-debuginfo", | ||
"build LLVM with debugger metadata") | ||
v("debuginfo-level", "rust.debuginfo-level", "debuginfo level for Rust code") | ||
v("debuginfo-level-rustc", "rust.debuginfo-level-rustc", "debuginfo level for the compiler") | ||
v("debuginfo-level-std", "rust.debuginfo-level-std", "debuginfo level for the standard library") | ||
v("debuginfo-level-tools", "rust.debuginfo-level-tools", "debuginfo level for the tools") | ||
v("debuginfo-level-tests", "rust.debuginfo-level-tests", "debuginfo level for the test suites run with compiletest") | ||
v("save-toolstates", "rust.save-toolstates", "save build and test status of external tools into this file") | ||
v("debuginfo-level-rustc", | ||
"rust.debuginfo-level-rustc", | ||
"debuginfo level for the compiler") | ||
v("debuginfo-level-std", "rust.debuginfo-level-std", | ||
"debuginfo level for the standard library") | ||
v("debuginfo-level-tools", | ||
"rust.debuginfo-level-tools", | ||
"debuginfo level for the tools") | ||
v("debuginfo-level-tests", "rust.debuginfo-level-tests", | ||
"debuginfo level for the test suites run with compiletest") | ||
v("save-toolstates", "rust.save-toolstates", | ||
"save build and test status of external tools into this file") | ||
|
||
v("prefix", "install.prefix", "set installation prefix") | ||
v("localstatedir", "install.localstatedir", "local state directory") | ||
|
@@ -106,7 +129,8 @@ def v(*args): | |
"arm-linux-androideabi NDK standalone path") | ||
v("armv7-linux-androideabi-ndk", "target.armv7-linux-androideabi.android-ndk", | ||
"armv7-linux-androideabi NDK standalone path") | ||
v("thumbv7neon-linux-androideabi-ndk", "target.thumbv7neon-linux-androideabi.android-ndk", | ||
v("thumbv7neon-linux-androideabi-ndk", | ||
"target.thumbv7neon-linux-androideabi.android-ndk", | ||
"thumbv7neon-linux-androideabi NDK standalone path") | ||
v("aarch64-linux-android-ndk", "target.aarch64-linux-android.android-ndk", | ||
"aarch64-linux-android NDK standalone path") | ||
|
@@ -149,7 +173,8 @@ def v(*args): | |
v("experimental-targets", "llvm.experimental-targets", | ||
"experimental LLVM targets to build") | ||
v("release-channel", "rust.channel", "the name of the release channel to build") | ||
v("release-description", "rust.description", "optional descriptive string for version output") | ||
v("release-description", "rust.description", | ||
"optional descriptive string for version output") | ||
v("dist-compression-formats", None, | ||
"comma-separated list of compression formats to use") | ||
|
||
|
@@ -158,8 +183,10 @@ def v(*args): | |
|
||
# Many of these are saved below during the "writing configuration" step | ||
# (others are conditionally saved). | ||
o("manage-submodules", "build.submodules", "let the build manage the git submodules") | ||
o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two (not recommended except for testing reproducible builds)") | ||
o("manage-submodules", "build.submodules", | ||
"let the build manage the git submodules") | ||
o("full-bootstrap", "build.full-bootstrap", | ||
"build three compilers instead of two (not recommended except for testing reproducible builds)") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we undo the re-formatting of this file? |
||
o("extended", "build.extended", "build an extended rust tool set") | ||
|
||
v("tools", None, "List of extended tools will be installed") | ||
|
@@ -189,9 +216,11 @@ def err(msg): | |
# no one needs to know about these obscure options | ||
continue | ||
if option.value: | ||
print('\t{:30} {}'.format('--{}=VAL'.format(option.name), option.desc)) | ||
print('\t{:30} {}'.format( | ||
'--{}=VAL'.format(option.name), option.desc)) | ||
else: | ||
print('\t{:30} {}'.format('--enable-{}'.format(option.name), option.desc)) | ||
print('\t{:30} {}'.format( | ||
'--enable-{}'.format(option.name), option.desc)) | ||
print('') | ||
print('This configure script is a thin configuration shim over the true') | ||
print('configuration system, `config.toml`. You can explore the comments') | ||
|
@@ -386,7 +415,8 @@ def set(key, value): | |
if cur_section.startswith('target'): | ||
cur_section = 'target' | ||
elif '.' in cur_section: | ||
raise RuntimeError("don't know how to deal with section: {}".format(cur_section)) | ||
raise RuntimeError( | ||
"don't know how to deal with section: {}".format(cur_section)) | ||
sections[cur_section] = [line] | ||
section_order.append(cur_section) | ||
else: | ||
|
@@ -407,7 +437,9 @@ def set(key, value): | |
targets[target] = sections['target'][:] | ||
# For `.` to be valid TOML, it needs to be quoted. But `bootstrap.py` doesn't use a proper TOML parser and fails to parse the target. | ||
# Avoid using quotes unless it's necessary. | ||
targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", "'{}'".format(target) if "." in target else target) | ||
targets[target][0] = targets[target][0].replace( | ||
"x86_64-unknown-linux-gnu", | ||
"'{}'".format(target) if "." in target else target) | ||
|
||
|
||
def is_number(value): | ||
|
@@ -456,20 +488,24 @@ def configure_section(lines, config): | |
if key in ["infodir", "localstatedir"]: | ||
print("warning: {} will be ignored".format(key)) | ||
else: | ||
raise RuntimeError("failed to find config line for {}".format(key)) | ||
raise RuntimeError( | ||
"failed to find config line for {}".format(key)) | ||
|
||
|
||
cli_args = {} | ||
for section_key in config: | ||
section_config = config[section_key] | ||
if section_key not in sections: | ||
raise RuntimeError("config key {} not in sections".format(section_key)) | ||
|
||
# key is not in toml file,added via --set from command line | ||
cli_args[section_key] = section_config | ||
continue | ||
if section_key == 'target': | ||
for target in section_config: | ||
configure_section(targets[target], section_config[target]) | ||
else: | ||
configure_section(sections[section_key], section_config) | ||
|
||
|
||
# Now that we've built up our `config.toml`, write it all out in the same | ||
# order that we read it in. | ||
p("") | ||
|
@@ -483,6 +519,8 @@ def configure_section(lines, config): | |
else: | ||
for line in sections[section]: | ||
f.write(line + "\n") | ||
for arg in cli_args: | ||
f.write(arg + ' = ' + cli_args[arg]) | ||
|
||
with bootstrap.output('Makefile') as f: | ||
contents = os.path.join(rust_dir, 'src', 'bootstrap', 'mk', 'Makefile.in') | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't correct, it will overwrite config.toml. You need two
--set
flags in the same command I think. Please test the modified command to make sure it works.