Skip to content
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

x.py: allow configuring the build directory #71994

Merged
merged 1 commit into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@
# for each target triple.
#target = ["x86_64-unknown-linux-gnu"] # defaults to just the build triple

# Use this directory to store build artifacts.
# You can use "$ROOT" to indicate the root of the git repository.
#build-dir = "build"

# Instead of downloading the src/stage0.txt version of Cargo specified, use
# this Cargo binary instead to build all Rust code
#cargo = "/path/to/bin/cargo"
Expand Down
11 changes: 9 additions & 2 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def __init__(self):
self.rustc_channel = ''
self.rustfmt_channel = ''
self.build = ''
self.build_dir = os.path.join(os.getcwd(), "build")
self.build_dir = ''
self.clean = False
self.config_toml = ''
self.rust_root = ''
Expand Down Expand Up @@ -891,7 +891,11 @@ def bootstrap(help_triggered):
build.clean = args.clean

try:
with open(args.config or 'config.toml') as config:
toml_path = args.config or 'config.toml'
if not os.path.exists(toml_path):
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved
toml_path = os.path.join(build.rust_root, toml_path)

with open(toml_path) as config:
build.config_toml = config.read()
except (OSError, IOError):
pass
Expand All @@ -906,6 +910,9 @@ def bootstrap(help_triggered):

build.check_vendored_status()

build_dir = build.get_toml('build-dir', 'build') or 'build'
build.build_dir = os.path.abspath(build_dir.replace("$ROOT", build.rust_root))

data = stage0_data(build.rust_root)
build.date = data['date']
build.rustc_channel = data['rustc']
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ struct Build {
host: Vec<String>,
#[serde(default)]
target: Vec<String>,
// This is ignored, the rust code always gets the build directory from the `BUILD_DIR` env variable
build_dir: Option<String>,
cargo: Option<String>,
rustc: Option<String>,
rustfmt: Option<String>, /* allow bootstrap.py to use rustfmt key */
Expand Down