Skip to content

Commit

Permalink
Rollup merge of rust-lang#38388 - redox-os:config_toml_prefix, r=alex…
Browse files Browse the repository at this point in the history
…crichton

Add prefix to config.toml

This allows `rustbuild` to be used to install to a prefix.
```toml
[build]
prefix = "/path/to/install"
```
For example, the following `config.toml` will cause `x.py dist --install` to install to `/path/to/install`
  • Loading branch information
alexcrichton committed Dec 20, 2016
2 parents adfafff + 228e495 commit 0874149
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pub struct Target {
#[derive(RustcDecodable, Default)]
struct TomlConfig {
build: Option<Build>,
install: Option<Install>,
llvm: Option<Llvm>,
rust: Option<Rust>,
target: Option<HashMap<String, TomlTarget>>,
Expand All @@ -135,6 +136,12 @@ struct Build {
python: Option<String>,
}

/// TOML representation of various global install decisions.
#[derive(RustcDecodable, Default, Clone)]
struct Install {
prefix: Option<String>,
}

/// TOML representation of how the LLVM build is configured.
#[derive(RustcDecodable, Default)]
struct Llvm {
Expand Down Expand Up @@ -258,6 +265,10 @@ impl Config {
set(&mut config.submodules, build.submodules);
set(&mut config.vendor, build.vendor);

if let Some(ref install) = toml.install {
config.prefix = install.prefix.clone();
}

if let Some(ref llvm) = toml.llvm {
match llvm.ccache {
Some(StringOrBool::String(ref s)) => {
Expand All @@ -275,6 +286,7 @@ impl Config {
set(&mut config.llvm_version_check, llvm.version_check);
set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp);
}

if let Some(ref rust) = toml.rust {
set(&mut config.rust_debug_assertions, rust.debug_assertions);
set(&mut config.rust_debuginfo, rust.debuginfo);
Expand Down
8 changes: 8 additions & 0 deletions src/bootstrap/config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@
# Indicate whether the vendored sources are used for Rust dependencies or not
#vendor = false

# =============================================================================
# General install configuration options
# =============================================================================
[install]

# Instead of installing to /usr/local, install to this path instead.
#prefix = "/path/to/install"

# =============================================================================
# Options for compiling Rust code itself
# =============================================================================
Expand Down

0 comments on commit 0874149

Please sign in to comment.