Skip to content

Commit 3fa3001

Browse files
committed
Address minor issues
1 parent 197e25c commit 3fa3001

File tree

5 files changed

+30
-40
lines changed

5 files changed

+30
-40
lines changed

src/cargo/ops/cargo_rustc/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use core::{SourceMap, Package, PackageId, PackageSet, Resolve, Target};
66
use util::{mod, CargoResult, ChainError, internal, Config, profile};
77
use util::human;
88

9-
use super::{Kind, KindForHost, KindTarget, Compilation};
9+
use super::{Kind, KindHost, KindTarget, Compilation};
1010
use super::layout::{Layout, LayoutProxy};
1111

1212
#[deriving(Show)]
@@ -164,7 +164,7 @@ impl<'a, 'b> Context<'a, 'b> {
164164
pub fn layout(&self, pkg: &Package, kind: Kind) -> LayoutProxy {
165165
let primary = pkg.get_package_id() == self.resolve.root();
166166
match kind {
167-
KindForHost => LayoutProxy::new(&self.host, primary),
167+
KindHost => LayoutProxy::new(&self.host, primary),
168168
KindTarget => LayoutProxy::new(self.target.as_ref()
169169
.unwrap_or(&self.host),
170170
primary),
@@ -176,7 +176,7 @@ impl<'a, 'b> Context<'a, 'b> {
176176
/// If `plugin` is true, the pair corresponds to the host platform,
177177
/// otherwise it corresponds to the target platform.
178178
fn dylib(&self, kind: Kind) -> CargoResult<(&str, &str)> {
179-
let (triple, pair) = if kind == KindForHost {
179+
let (triple, pair) = if kind == KindHost {
180180
(self.config.rustc_host(), &self.host_dylib)
181181
} else {
182182
(self.target_triple.as_slice(), &self.target_dylib)
@@ -205,7 +205,7 @@ impl<'a, 'b> Context<'a, 'b> {
205205
} else {
206206
if target.is_dylib() {
207207
let plugin = target.get_profile().is_for_host();
208-
let kind = if plugin {KindForHost} else {KindTarget};
208+
let kind = if plugin {KindHost} else {KindTarget};
209209
let (prefix, suffix) = try!(self.dylib(kind));
210210
ret.push(format!("{}{}{}", prefix, stem, suffix));
211211
}

src/cargo/ops/cargo_rustc/job.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ impl Job {
2525

2626
/// Consumes this job by running it, returning the result of the
2727
/// computation.
28-
pub fn run(self, fresh: Freshness, sender: Sender<String>) -> CargoResult<()> {
28+
pub fn run(self, fresh: Freshness, tx: Sender<String>) -> CargoResult<()> {
2929
match fresh {
30-
Fresh => (self.fresh)(sender),
31-
Dirty => (self.dirty)(sender),
30+
Fresh => (self.fresh)(tx),
31+
Dirty => (self.dirty)(tx),
3232
}
3333
}
3434
}

src/cargo/ops/cargo_rustc/job_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl<'a, 'b> JobQueue<'a, 'b> {
186186
my_tx.send((id, stage, fresh, job.run(fresh, desc_tx)));
187187
});
188188
if fresh == Dirty {
189-
// TODO: only the first message of each job is processed
189+
// only the first message of each job is processed
190190
match desc_rx.recv_opt() {
191191
Ok(ref msg) if msg.len() >= 1 => {
192192
try!(config.shell().verbose(|shell| {

src/cargo/ops/cargo_rustc/mod.rs

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod job_queue;
2626
mod layout;
2727

2828
#[deriving(PartialEq, Eq)]
29-
pub enum Kind { KindForHost, KindTarget }
29+
pub enum Kind { KindHost, KindTarget }
3030

3131
/// Run `rustc` to figure out what its current version string is.
3232
///
@@ -116,10 +116,10 @@ pub fn compile_targets<'a>(env: &str, targets: &[&'a Target], pkg: &'a Package,
116116
}
117117

118118
let compiled = compiled.contains(dep.get_package_id());
119-
try!(compile(targets.as_slice(), dep, pkg, compiled, &mut cx, &mut queue));
119+
try!(compile(targets.as_slice(), dep, compiled, &mut cx, &mut queue));
120120
}
121121

122-
try!(compile(targets, pkg, pkg, true, &mut cx, &mut queue));
122+
try!(compile(targets, pkg, true, &mut cx, &mut queue));
123123

124124
// Now that we've figured out everything that we're going to do, do it!
125125
try!(queue.execute(cx.config));
@@ -128,7 +128,7 @@ pub fn compile_targets<'a>(env: &str, targets: &[&'a Target], pkg: &'a Package,
128128
}
129129

130130
fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
131-
root_pkg: &'a Package, compiled: bool,
131+
compiled: bool,
132132
cx: &mut Context<'a, 'b>,
133133
jobs: &mut JobQueue<'a, 'b>) -> CargoResult<()> {
134134
debug!("compile_pkg; pkg={}; targets={}", pkg, targets);
@@ -149,7 +149,7 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
149149
let (target1, target2) = fingerprint::prepare_init(cx, pkg, KindTarget);
150150
let mut init = vec![(Job::new(target1, target2), Fresh)];
151151
if cx.config.target().is_some() {
152-
let (plugin1, plugin2) = fingerprint::prepare_init(cx, pkg, KindForHost);
152+
let (plugin1, plugin2) = fingerprint::prepare_init(cx, pkg, KindHost);
153153
init.push((Job::new(plugin1, plugin2), Fresh));
154154
}
155155
jobs.enqueue(pkg, jq::StageStart, init);
@@ -174,14 +174,13 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
174174
use std::mem;
175175

176176
let (old_build, script_output) = {
177-
let layout = cx.layout(pkg, KindForHost);
177+
let layout = cx.layout(pkg, KindHost);
178178
let old_build = layout.proxy().old_build(pkg);
179179
let script_output = layout.build(pkg);
180180
(old_build, script_output)
181181
};
182182

183183
let execute_cmd = try!(prepare_execute_custom_build(pkg,
184-
root_pkg,
185184
target, cx));
186185

187186
// building a `Work` that creates the directory where the compiled script
@@ -388,7 +387,8 @@ impl CustomBuildCommandOutput {
388387
};
389388

390389
if key == "rustc-flags" {
391-
let mut flags_iter = value.split(|c: char| c == ' ' || c == '\t');
390+
// TODO: some arguments (like paths) may contain spaces
391+
let mut flags_iter = value.words();
392392
loop {
393393
let flag = match flags_iter.next() {
394394
Some(f) => f,
@@ -427,32 +427,22 @@ impl CustomBuildCommandOutput {
427427
}
428428

429429
// Prepares a `Work` that executes the target as a custom build script.
430-
// `pkg` is the package the build script belongs to, and `root_pkg` is the package
431-
// Cargo is being run on.
432-
fn prepare_execute_custom_build(pkg: &Package, root_pkg: &Package, target: &Target,
430+
fn prepare_execute_custom_build(pkg: &Package, target: &Target,
433431
cx: &mut Context)
434432
-> CargoResult<Work> {
435-
let layout = cx.layout(pkg, KindForHost);
433+
let layout = cx.layout(pkg, KindHost);
436434
let script_output = layout.build(pkg);
437435
let build_output = layout.build_out(pkg);
438436

439437
// Building the command to execute
440-
let to_exec = try!(cx.target_filenames(target));
441-
if to_exec.len() >= 2 {
442-
return Err(human(format!("custom build script shouldn't have multiple outputs")));
443-
}
444-
let to_exec = to_exec.into_iter().next();
445-
let to_exec = match to_exec {
446-
Some(cmd) => cmd,
447-
None => return Err(human(format!("failed to determine output of custom build script"))),
448-
};
438+
let to_exec = try!(cx.target_filenames(target))[0].clone();
449439
let to_exec = script_output.join(to_exec);
450440

451441
// Filling environment variables
452442
let profile = target.get_profile();
453443
let mut p = process(to_exec, pkg, cx)
454444
.env("OUT_DIR", Some(&build_output))
455-
.env("CARGO_MANIFEST_DIR", Some(root_pkg.get_manifest_path()
445+
.env("CARGO_MANIFEST_DIR", Some(pkg.get_manifest_path()
456446
.display().to_string()))
457447
.env("NUM_JOBS", profile.get_codegen_units().map(|n| n.to_string()))
458448
.env("TARGET", Some(cx.target_triple()))
@@ -476,7 +466,7 @@ fn prepare_execute_custom_build(pkg: &Package, root_pkg: &Package, target: &Targ
476466
// building the list of all possible `build/$pkg/output` files
477467
// whether they exist or not will be checked during the work
478468
let command_output_files = {
479-
let layout = cx.layout(pkg, KindForHost);
469+
let layout = cx.layout(pkg, KindHost);
480470
cx.dep_targets(pkg).iter().map(|&(pkg, _)| {
481471
layout.build(pkg).join("output")
482472
}).collect::<Vec<_>>()
@@ -553,7 +543,7 @@ fn rustc(package: &Package, target: &Target,
553543
let show_warnings = package.get_package_id() == cx.resolve.root() ||
554544
is_path_source;
555545
let rustc = if show_warnings {rustc} else {rustc.arg("-Awarnings")};
556-
let build_cmd_layout = cx.layout(package, KindForHost);
546+
let build_cmd_layout = cx.layout(package, KindHost);
557547

558548
// building the possible `build/$pkg/output` file for this local package
559549
let command_output_file = build_cmd_layout.build(package).join("output");
@@ -619,19 +609,19 @@ fn prepare_rustc(package: &Package, target: &Target, crate_types: Vec<&str>,
619609
let base = build_base_args(cx, base, package, target, crate_types.as_slice());
620610

621611
let target_cmd = build_plugin_args(base.clone(), cx, package, target, KindTarget);
622-
let plugin_cmd = build_plugin_args(base, cx, package, target, KindForHost);
612+
let plugin_cmd = build_plugin_args(base, cx, package, target, KindHost);
623613
let target_cmd = try!(build_deps_args(target_cmd, target, package, cx,
624614
KindTarget));
625615
let plugin_cmd = try!(build_deps_args(plugin_cmd, target, package, cx,
626-
KindForHost));
616+
KindHost));
627617

628618
Ok(match req {
629619
PlatformTarget => vec![(target_cmd, KindTarget)],
630-
PlatformPlugin => vec![(plugin_cmd, KindForHost)],
620+
PlatformPlugin => vec![(plugin_cmd, KindHost)],
631621
PlatformPluginAndTarget if cx.config.target().is_none() =>
632622
vec![(target_cmd, KindTarget)],
633623
PlatformPluginAndTarget => vec![(target_cmd, KindTarget),
634-
(plugin_cmd, KindForHost)],
624+
(plugin_cmd, KindHost)],
635625
})
636626
}
637627

@@ -840,8 +830,8 @@ fn build_deps_args(mut cmd: ProcessBuilder, target: &Target, package: &Package,
840830
// plugin, then we want the plugin directory. Otherwise we want the
841831
// target directory (hence the || here).
842832
let layout = cx.layout(pkg, match kind {
843-
KindForHost => KindForHost,
844-
KindTarget if target.get_profile().is_for_host() => KindForHost,
833+
KindHost => KindHost,
834+
KindTarget if target.get_profile().is_for_host() => KindHost,
845835
KindTarget => KindTarget,
846836
});
847837

@@ -861,7 +851,7 @@ fn build_deps_args(mut cmd: ProcessBuilder, target: &Target, package: &Package,
861851
pub fn process<T: ToCStr>(cmd: T, pkg: &Package, cx: &Context) -> ProcessBuilder {
862852
// When invoking a tool, we need the *host* deps directory in the dynamic
863853
// library search path for plugins and such which have dynamic dependencies.
864-
let layout = cx.layout(pkg, KindForHost);
854+
let layout = cx.layout(pkg, KindHost);
865855
let mut search_path = DynamicLibrary::search_path();
866856
search_path.push(layout.deps().clone());
867857

src/cargo/ops/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pub use self::cargo_clean::{clean, CleanOptions};
22
pub use self::cargo_compile::{compile, compile_pkg, CompileOptions};
33
pub use self::cargo_read_manifest::{read_manifest,read_package,read_packages};
44
pub use self::cargo_rustc::{compile_targets, Compilation, Layout, Kind, rustc_version};
5-
pub use self::cargo_rustc::{KindTarget, KindForHost, Context, LayoutProxy};
5+
pub use self::cargo_rustc::{KindTarget, KindHost, Context, LayoutProxy};
66
pub use self::cargo_rustc::{PlatformRequirement, PlatformTarget};
77
pub use self::cargo_rustc::{PlatformPlugin, PlatformPluginAndTarget};
88
pub use self::cargo_run::run;

0 commit comments

Comments
 (0)