Skip to content

Commit

Permalink
rename config.toml to bootstrap.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
LuuuXXX authored and LuuuXXX committed Jul 25, 2024
1 parent f4831e6 commit 7643a69
Show file tree
Hide file tree
Showing 78 changed files with 336 additions and 315 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file should only ignore things that are generated during a `x.py` build,
# generated by common IDEs, and optional files controlled by the user that
# affect the build (such as config.toml).
# affect the build (such as bootstrap.toml).
# In particular, things like `mir_dump` should not be listed here; they are only
# created during manual debugging and many people like to clean up instead of
# having git ignore such leftovers. You can use `.git/info/exclude` to
Expand Down Expand Up @@ -30,6 +30,7 @@ Session.vim
!/tests/run-make/thumb-none-qemu/example/.cargo

## Configuration
/bootstrap.toml
/config.toml
/Makefile
config.mk
Expand Down
3 changes: 2 additions & 1 deletion .ignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Make vscode *not* count `config.toml` as ignored, so it is included in search
# Make vscode *not* count `bootstrap.toml` and `config.toml` as ignored, so it is included in search
!/bootstrap.toml
!/config.toml
10 changes: 5 additions & 5 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ If you just want to install Rust, check out the [README.md](README.md) instead.*

The Rust build system uses a Python script called `x.py` to build the compiler,
which manages the bootstrapping process. It lives at the root of the project.
It also uses a file named `config.toml` to determine various configuration
It also uses a file named `bootstrap.toml` to determine various configuration
settings for the build. You can see a full list of options in
`config.example.toml`.
`bootstrap.example.toml`.

The `x.py` command can be run directly on most Unix systems in the following
format:
Expand Down Expand Up @@ -101,15 +101,15 @@ See [the rustc-dev-guide for more info][sysllvm].
This project provides a configure script and makefile (the latter of which just
invokes `x.py`). `./configure` is the recommended way to programmatically
generate a `config.toml`. `make` is not recommended (we suggest using `x.py`
generate a `bootstrap.toml`. `make` is not recommended (we suggest using `x.py`
directly), but it is supported and we try not to break it unnecessarily.
```sh
./configure
make && sudo make install
```
`configure` generates a `config.toml` which can also be used with normal `x.py`
`configure` generates a `bootstrap.toml` which can also be used with normal `x.py`
invocations.
## Building on Windows
Expand Down Expand Up @@ -237,7 +237,7 @@ Windows build triples are:
- `x86_64-pc-windows-msvc`

The build triple can be specified by either specifying `--build=<triple>` when
invoking `x.py` commands, or by creating a `config.toml` file (as described in
invoking `x.py` commands, or by creating a `bootstrap.toml` file (as described in
[Building on a Unix-like system](#building-on-a-unix-like-system)), and passing
`--set build.build=<triple>` to `./configure`.

Expand Down
2 changes: 1 addition & 1 deletion REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ path = [
"Cargo.lock",
"Cargo.toml",
"CODE_OF_CONDUCT.md",
"config.example.toml",
"bootstrap.example.toml",
"configure",
"CONTRIBUTING.md",
"COPYRIGHT",
Expand Down
6 changes: 3 additions & 3 deletions config.example.toml → bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# All options are commented out by default in this file, and they're commented
# out with their default values. The build system by default looks for
# `config.toml` in the current directory of a build for build configuration, but
# `bootstrap.toml` in the current directory of a build for build configuration, but
# a custom configuration file can also be specified with `--config` to the build
# system.

Expand All @@ -16,7 +16,7 @@
# 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 `config.example.toml`).
# Note that this has no default value (x.py uses the defaults in `bootstrap.example.toml`).
#profile = <none>

# Keeps track of major changes made to this configuration.
Expand Down Expand Up @@ -311,7 +311,7 @@
# Enable a build of the extended Rust tool set which is not only the compiler
# but also tools such as Cargo. This will also produce "combined installers"
# which are used to install Rust and Cargo together.
# The `tools` (check `config.example.toml` to see its default value) option specifies
# The `tools` (check `bootstrap.example.toml` to see its default value) option specifies
# which tools should be built if `extended = true`.
#
# This is disabled by default.
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ compiler, which will then build the bootstrap binary written in Rust.

Because there are two separate codebases behind `x.py`, they need to
be kept in sync. In particular, both `bootstrap.py` and the bootstrap binary
parse `config.toml` and read the same command line arguments. `bootstrap.py`
parse `bootstrap.toml` and read the same command line arguments. `bootstrap.py`
keeps these in sync by setting various environment variables, and the
programs sometimes have to add arguments that are explicitly ignored, to be
read by the other.
Expand All @@ -185,7 +185,7 @@ Some general areas that you may be interested in modifying are:
If you make a major change on bootstrap configuration, please remember to:

+ Update `CONFIG_CHANGE_HISTORY` in `src/bootstrap/src/utils/change_tracker.rs`.
* Update `change-id = {pull-request-id}` in `config.example.toml`.
* Update `change-id = {pull-request-id}` in `bootstrap.example.toml`.

A 'major change' includes

Expand Down
22 changes: 13 additions & 9 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ def download_toolchain(self):

def should_fix_bins_and_dylibs(self):
"""Whether or not `fix_bin_or_dylib` needs to be run; can only be True
on NixOS or if config.toml has `build.patch-binaries-for-nix` set.
on NixOS or if bootstrap.toml has `build.patch-binaries-for-nix` set.
"""
if self._should_fix_bins_and_dylibs is not None:
return self._should_fix_bins_and_dylibs
Expand Down Expand Up @@ -676,7 +676,7 @@ def get_answer():
in_nix_shell = os.getenv('IN_NIX_SHELL')
if in_nix_shell:
eprint("The IN_NIX_SHELL environment variable is `{}`;".format(in_nix_shell),
"you may need to set `patch-binaries-for-nix=true` in config.toml")
"you may need to set `patch-binaries-for-nix=true` in bootstrap.toml")

return is_nixos

Expand Down Expand Up @@ -778,7 +778,7 @@ def bin_root(self):
return os.path.join(self.build_dir, self.build, subdir)

def get_toml(self, key, section=None):
"""Returns the value of the given key in config.toml, otherwise returns None
"""Returns the value of the given key in bootstrap.toml, otherwise returns None
>>> rb = RustBuild()
>>> rb.config_toml = 'key1 = "value1"\\nkey2 = "value2"'
Expand Down Expand Up @@ -1107,17 +1107,21 @@ def bootstrap(args):
"git clone nor distributed tarball.\nThis build may fail due to missing submodules "
"unless you put them in place manually.")

# Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then `./config.toml`,
# then `config.toml` in the root directory.
# Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then `./bootstrap.toml` or
# `./config.toml`, then `bootstrap.toml` or `config.toml` in the root directory.
toml_path = args.config or os.getenv('RUST_BOOTSTRAP_CONFIG')
using_default_path = toml_path is None
if using_default_path:
toml_path = 'config.toml'
toml_path = 'bootstrap.toml'
if not os.path.exists(toml_path):
toml_path = os.path.join(rust_root, toml_path)
toml_path = 'config.toml'
if not os.path.exists(toml_path):
toml_path = os.path.join(rust_root, 'bootstrap.toml')
if not os.path.exists(toml_path):
toml_path = os.path.join(rust_root, 'config.toml')

# Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path,
# but not if `config.toml` hasn't been created.
# but not if `bootstrap.toml` hasn't been created.
if not using_default_path or os.path.exists(toml_path):
with open(toml_path) as config:
config_toml = config.read()
Expand All @@ -1132,7 +1136,7 @@ def bootstrap(args):
profile_aliases = {
"user": "dist"
}
include_file = 'config.{}.toml'.format(profile_aliases.get(profile) or profile)
include_file = 'bootstrap.{}.toml'.format(profile_aliases.get(profile) or profile)
include_dir = os.path.join(rust_root, 'src', 'bootstrap', 'defaults')
include_path = os.path.join(include_dir, include_file)

Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/bootstrap_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_same_dates(self):


class GenerateAndParseConfig(unittest.TestCase):
"""Test that we can serialize and deserialize a config.toml file"""
"""Test that we can serialize and deserialize a bootstrap.toml file"""
def test_no_args(self):
build = serialize_and_parse([])
self.assertEqual(build.get_toml("profile"), 'dist')
Expand Down Expand Up @@ -143,11 +143,11 @@ def build_args(self, configure_args=None, args=None, env=None):
# problem in most cases, but there is a scenario where it would cause
# the test to fail.
#
# When a custom local Cargo is configured in config.toml (with the
# When a custom local Cargo is configured in bootstrap.toml (with the
# build.cargo setting), no Cargo is downloaded to any location known by
# bootstrap, and bootstrap relies on that setting to find it.
#
# In this test though we are not using the config.toml of the caller:
# In this test though we are not using the bootstrap.toml of the caller:
# we are generating a blank one instead. If we don't set build.cargo in
# it, the test will have no way to find Cargo, failing the test.
cargo_bin = os.environ.get("BOOTSTRAP_TEST_CARGO_BIN")
Expand Down
17 changes: 9 additions & 8 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ def is_value_list(key):
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')
print('in `config.example.toml` next to this configure script to see')
print('configuration system, `bootstrap.toml`. You can explore the comments')
print('in `bootstrap.example.toml` next to this configure script to see')
print('more information about what each option is. Additionally you can')
print('pass `--set` as an argument to set arbitrary key/value pairs')
print('in the TOML configuration if desired')
Expand Down Expand Up @@ -381,8 +381,8 @@ def apply_args(known_args, option_checking, config):
else:
raise RuntimeError("unhandled option {}".format(option.name))

# "Parse" the `config.example.toml` file into the various sections, and we'll
# use this as a template of a `config.toml` to write out which preserves
# "Parse" the `bootstrap.example.toml` file into the various sections, and we'll
# use this as a template of a `bootstrap.toml` to write out which preserves
# all the various comments and whatnot.
#
# Note that the `target` section is handled separately as we'll duplicate it
Expand All @@ -395,7 +395,7 @@ def parse_example_config(known_args, config):
targets = {}
top_level_keys = []

with open(rust_dir + '/config.example.toml') as example_config:
with open(rust_dir + '/bootstrap.example.toml') as example_config:
example_lines = example_config.read().split("\n")
for line in example_lines:
if cur_section is None:
Expand Down Expand Up @@ -549,7 +549,8 @@ def quit_if_file_exists(file):
err(msg)

if __name__ == "__main__":
# If 'config.toml' already exists, exit the script at this point
# If 'bootstrap.toml' or 'config.toml' already exists, exit the script at this point
quit_if_file_exists('bootstrap.toml')
quit_if_file_exists('config.toml')

if "GITHUB_ACTIONS" in os.environ:
Expand All @@ -563,8 +564,8 @@ def quit_if_file_exists(file):
# Now that we've built up our `config.toml`, write it all out in the same
# order that we read it in.
p("")
p("writing `config.toml` in current directory")
with bootstrap.output('config.toml') as f:
p("writing `bootstrap.toml` in current directory")
with bootstrap.output('bootstrap.toml') as f:
write_config_toml(f, section_order, targets, sections)

with bootstrap.output('Makefile') as f:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 13 additions & 11 deletions src/bootstrap/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ fn main() {
let changelog_suggestion =
if matches!(config.cmd, Subcommand::Setup { .. }) { None } else { check_version(&config) };

// NOTE: Since `./configure` generates a `config.toml`, distro maintainers will see the
// NOTE: Since `./configure` generates a `bootstrap.toml`, distro maintainers will see the
// changelog warning, not the `x.py setup` message.
let suggest_setup = config.config.is_none() && !matches!(config.cmd, Subcommand::Setup { .. });
if suggest_setup {
println!("WARNING: you have not made a `config.toml`");
println!("WARNING: you have not made a `bootstrap.toml`");
println!(
"HELP: consider running `./x.py setup` or copying `config.example.toml` by running \
`cp config.example.toml config.toml`"
"HELP: consider running `./x.py setup` or copying `bootstrap.example.toml` by running \
`cp bootstrap.example.toml bootstrap.toml`"
);
} else if let Some(suggestion) = &changelog_suggestion {
println!("{suggestion}");
Expand All @@ -79,10 +79,10 @@ fn main() {
Build::new(config).build();

if suggest_setup {
println!("WARNING: you have not made a `config.toml`");
println!("WARNING: you have not made a `bootstrap.toml`");
println!(
"HELP: consider running `./x.py setup` or copying `config.example.toml` by running \
`cp config.example.toml config.toml`"
"HELP: consider running `./x.py setup` or copying `bootstrap.example.toml` by running \
`cp bootstrap.example.toml bootstrap.toml`"
);
} else if let Some(suggestion) = &changelog_suggestion {
println!("{suggestion}");
Expand Down Expand Up @@ -141,7 +141,7 @@ fn check_version(config: &Config) -> Option<String> {
}

// Always try to use `change-id` from .last-warned-change-id first. If it doesn't exist,
// then use the one from the config.toml. This way we never show the same warnings
// then use the one from the bootstrap.toml. This way we never show the same warnings
// more than once.
if let Ok(t) = fs::read_to_string(&warned_id_path) {
let last_warned_id = usize::from_str(&t)
Expand All @@ -166,16 +166,18 @@ fn check_version(config: &Config) -> Option<String> {

msg.push_str("NOTE: to silence this warning, ");
msg.push_str(&format!(
"update `config.toml` to use `change-id = {latest_change_id}` instead"
"update `bootstrap.toml` to use `change-id = {latest_change_id}` instead"
));

if io::stdout().is_terminal() && !config.dry_run() {
t!(fs::write(warned_id_path, latest_change_id.to_string()));
}
} else {
msg.push_str("WARNING: The `change-id` is missing in the `config.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations.\n");
msg.push_str("WARNING: The `change-id` is missing in the `bootstrap.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations.\n");
msg.push_str("NOTE: to silence this warning, ");
msg.push_str(&format!("add `change-id = {latest_change_id}` at the top of `config.toml`"));
msg.push_str(&format!(
"add `change-id = {latest_change_id}` at the top of `bootstrap.toml`"
));
};

Some(msg)
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ fn copy_self_contained_objects(
} else if target.contains("-wasi") {
let srcdir = builder.wasi_libdir(target).unwrap_or_else(|| {
panic!(
"Target {:?} does not have a \"wasi-root\" key in Config.toml \
"Target {:?} does not have a \"wasi-root\" key in bootstrap.toml \
or `$WASI_SDK_PATH` set",
target.triple
)
Expand Down Expand Up @@ -1081,7 +1081,7 @@ pub fn rustc_cargo_env(
.env("CFG_VERSION", builder.rust_version());

// Some tools like Cargo detect their own git information in build scripts. When omit-git-hash
// is enabled in config.toml, we pass this environment variable to tell build scripts to avoid
// is enabled in bootstrap.toml, we pass this environment variable to tell build scripts to avoid
// detecting git information on their own.
if builder.config.omit_git_hash {
cargo.env("CFG_OMIT_GIT_HASH", "1");
Expand Down Expand Up @@ -1288,7 +1288,7 @@ fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool {
{
run.builder.info(
"WARNING: no codegen-backends config matched the requested path to build a codegen backend. \
HELP: add backend to codegen-backends in config.toml.",
HELP: add backend to codegen-backends in bootstrap.toml.",
);
return true;
}
Expand All @@ -1300,7 +1300,7 @@ fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool {
impl Step for CodegenBackend {
type Output = ();
const ONLY_HOSTS: bool = true;
/// Only the backends specified in the `codegen-backends` entry of `config.toml` are built.
/// Only the backends specified in the `codegen-backends` entry of `bootstrap.toml` are built.
const DEFAULT: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ impl Step for PlainSourceTarball {
"RELEASES.md",
"configure",
"x.py",
"config.example.toml",
"bootstrap.example.toml",
"Cargo.toml",
"Cargo.lock",
".gitmodules",
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ impl Step for RustcBook {
cmd.env("RUSTC_BOOTSTRAP", "1");

// If the lib directories are in an unusual location (changed in
// config.toml), then this needs to explicitly update the dylib search
// bootstrap.toml), then this needs to explicitly update the dylib search
// path.
builder.add_rustc_lib_path(self.compiler, &mut cmd);
let doc_generator_guard = builder.msg(
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/build_steps/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ fn install_sh(
} else {
assert!(
is_dir_writable_for_user(&prefix),
"User doesn't have write access on `install.prefix` path in the `config.toml`.",
"User doesn't have write access on `install.prefix` path in the `bootstrap.toml`.",
);
assert!(
is_dir_writable_for_user(&sysconfdir),
"User doesn't have write access on `install.sysconfdir` path in `config.toml`."
"User doesn't have write access on `install.sysconfdir` path in `bootstrap.toml`."
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl Step for Llvm {
(true, true) => "RelWithDebInfo",
};

// NOTE: remember to also update `config.example.toml` when changing the
// NOTE: remember to also update `bootstrap.example.toml` when changing the
// defaults!
let llvm_targets = match &builder.config.llvm_targets {
Some(s) => s,
Expand Down
Loading

0 comments on commit 7643a69

Please sign in to comment.