Skip to content

Commit

Permalink
Add an rpath option to the profile section
Browse files Browse the repository at this point in the history
This will enable passing `-C rpath` on all compiles to rustc itself.

Closes #705
  • Loading branch information
alexcrichton committed Oct 15, 2014
1 parent 6ad622f commit bd9a9b0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ pub struct Profile {
opt_level: uint,
codegen_units: Option<uint>, // None = use rustc default
debug: bool,
rpath: bool,
test: bool,
doctest: bool,
doc: bool,
Expand All @@ -126,6 +127,7 @@ impl Profile {
opt_level: 0,
codegen_units: None,
debug: false,
rpath: false,
test: false,
doc: false,
dest: None,
Expand Down Expand Up @@ -218,6 +220,10 @@ impl Profile {
self.debug
}

pub fn get_rpath(&self) -> bool {
self.rpath
}

pub fn get_env(&self) -> &str {
self.env.as_slice()
}
Expand All @@ -241,6 +247,11 @@ impl Profile {
self
}

pub fn rpath(mut self, rpath: bool) -> Profile {
self.rpath = rpath;
self
}

pub fn test(mut self, test: bool) -> Profile {
self.test = test;
self
Expand Down Expand Up @@ -275,6 +286,7 @@ impl<H: hash::Writer> hash::Hash<H> for Profile {
opt_level,
codegen_units,
debug,
rpath,
plugin,
dest: ref dest,
harness: harness,
Expand All @@ -287,7 +299,7 @@ impl<H: hash::Writer> hash::Hash<H> for Profile {
test: _,
doctest: _,
} = *self;
(opt_level, codegen_units, debug, plugin, dest, harness).hash(into)
(opt_level, codegen_units, debug, rpath, plugin, dest, harness).hash(into)
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/cargo/ops/cargo_rustc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ fn build_base_args(cx: &Context,
let root_profile = target.get_profile();
if root_profile.get_env() != profile.get_env() { continue }
profile = profile.opt_level(root_profile.get_opt_level())
.debug(root_profile.get_debug());
.debug(root_profile.get_debug())
.rpath(root_profile.get_rpath())
}

if profile.get_opt_level() != 0 {
Expand Down Expand Up @@ -405,6 +406,10 @@ fn build_base_args(cx: &Context,
None => {}
}

if profile.get_rpath() {
cmd = cmd.arg("-C").arg("rpath");
}

return cmd;
}

Expand Down
3 changes: 3 additions & 0 deletions src/cargo/util/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ pub struct TomlProfile {
opt_level: Option<uint>,
codegen_units: Option<uint>,
debug: Option<bool>,
rpath: Option<bool>,
}

#[deriving(Decodable)]
Expand Down Expand Up @@ -613,7 +614,9 @@ fn normalize(libs: &[TomlLibTarget],
let opt_level = toml.opt_level.unwrap_or(profile.get_opt_level());
let codegen_units = toml.codegen_units;
let debug = toml.debug.unwrap_or(profile.get_debug());
let rpath = toml.rpath.unwrap_or(profile.get_rpath());
profile.opt_level(opt_level).codegen_units(codegen_units).debug(debug)
.rpath(rpath)
}

fn target_profiles(target: &TomlTarget, profiles: &TomlProfiles,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cargo_profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ test!(profile_overrides {
[profile.dev]
opt-level = 1
debug = false
rpath = true
"#)
.file("src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v"),
Expand All @@ -31,6 +32,7 @@ test!(profile_overrides {
--cfg ndebug \
-C metadata=[..] \
-C extra-filename=-[..] \
-C rpath \
--out-dir {dir}{sep}target \
--dep-info [..] \
-L {dir}{sep}target \
Expand Down

5 comments on commit bd9a9b0

@bors
Copy link
Contributor

@bors bors commented on bd9a9b0 Oct 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at alexcrichton@bd9a9b0

@bors
Copy link
Contributor

@bors bors commented on bd9a9b0 Oct 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging alexcrichton/cargo/issue-705 = bd9a9b0 into auto-cargo

@bors
Copy link
Contributor

@bors bors commented on bd9a9b0 Oct 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alexcrichton/cargo/issue-705 = bd9a9b0 merged ok, testing candidate = 9788700

@bors
Copy link
Contributor

@bors bors commented on bd9a9b0 Oct 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on bd9a9b0 Oct 15, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto-cargo = 9788700

Please sign in to comment.