Skip to content

Commit

Permalink
Auto merge of #2909 - jonathandturner:debug_release_at_bottom, r=alex…
Browse files Browse the repository at this point in the history
…crichton

Switch to output release/debug after compile

This is similar to #2896 but instead of inline, it puts an indicator at the bottom showing if it was a release or debug build.

```
jturner-23759:cargo jturner$ ./target/release/cargo build
Finished debug (unoptimized + debuginfo) build.
jturner-23759:cargo jturner$ ./target/release/cargo build --release
Finished release (optimized) build.
```
  • Loading branch information
bors authored Jul 25, 2016
2 parents f578ee5 + cd955f1 commit dc46aba
Show file tree
Hide file tree
Showing 29 changed files with 323 additions and 31 deletions.
24 changes: 24 additions & 0 deletions src/cargo/ops/cargo_rustc/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub struct JobQueue<'a> {
compiled: HashSet<&'a PackageId>,
documented: HashSet<&'a PackageId>,
counts: HashMap<&'a PackageId, usize>,
is_release: bool,
is_doc_all: bool,
}

/// A helper structure for metadata about the state of a building package.
Expand Down Expand Up @@ -88,6 +90,8 @@ impl<'a> JobQueue<'a> {
compiled: HashSet::new(),
documented: HashSet::new(),
counts: HashMap::new(),
is_release: cx.build_config.release,
is_doc_all: cx.build_config.doc_all,
}
}

Expand Down Expand Up @@ -118,6 +122,8 @@ impl<'a> JobQueue<'a> {

fn drain_the_queue(&mut self, cx: &mut Context, scope: &Scope<'a>)
-> CargoResult<()> {
use std::time::Instant;

let mut queue = Vec::new();
trace!("queue: {:#?}", self.queue);

Expand All @@ -131,6 +137,7 @@ impl<'a> JobQueue<'a> {
// successful and otherwise wait for pending work to finish if it failed
// and then immediately return.
let mut error = None;
let start_time = Instant::now();
loop {
while error.is_none() && self.active < self.jobs {
if !queue.is_empty() {
Expand Down Expand Up @@ -191,7 +198,24 @@ impl<'a> JobQueue<'a> {
}
}

let build_type = if self.is_release { "release" } else { "debug" };
let profile = cx.lib_profile(cx.resolve.root());
let mut opt_type = String::from(if profile.opt_level > 0 { "optimized" }
else { "unoptimized" });
if profile.debuginfo {
opt_type = opt_type + " + debuginfo";
}
let duration = start_time.elapsed();
let time_elapsed = format!("{}.{1:.2} secs",
duration.as_secs(),
duration.subsec_nanos() / 10000000);
if self.queue.is_empty() {
if !self.is_doc_all {
try!(cx.config.shell().status("Finished", format!("{} [{}] target(s) in {}",
build_type,
opt_type,
time_elapsed)));
}
Ok(())
} else if let Some(e) = error {
Err(e)
Expand Down
2 changes: 2 additions & 0 deletions tests/bad-config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ fn unused_keys() {
execs().with_status(0).with_stderr("\
warning: unused manifest key: target.foo.bar
[COMPILING] foo v0.1.0 (file:///[..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
"));
}

Expand Down Expand Up @@ -509,5 +510,6 @@ invalid), but this file has a table header which does not have a newline after
it. A newline needs to be added and this warning will soon become a hard error
in the future.
[COMPILING] empty_deps v0.0.0 ([..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
"));
}
22 changes: 20 additions & 2 deletions tests/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fn cargo_bench_simple() {
assert_that(p.cargo("bench"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.5.0 ({})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]foo-[..]", p.url()))
.with_stdout("
running 1 test
Expand Down Expand Up @@ -76,6 +77,7 @@ fn bench_tarname() {
execs().with_status(0)
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]bin2[..]
", dir = prj.url()))
.with_stdout("
Expand Down Expand Up @@ -104,6 +106,7 @@ fn cargo_bench_verbose() {
execs().with_stderr(&format!("\
[COMPILING] foo v0.5.0 ({url})
[RUNNING] `rustc src[..]foo.rs [..]`
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] `[..]target[..]release[..]foo-[..] hello --bench`", url = p.url()))
.with_stdout("
running 1 test
Expand Down Expand Up @@ -186,6 +189,7 @@ running 1 test
test bench_hello ... ")
.with_stderr_contains(format!("\
[COMPILING] foo v0.5.0 ({})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]foo-[..]
thread '[..]' panicked at 'assertion failed: \
`(left == right)` (left: \
Expand Down Expand Up @@ -238,6 +242,7 @@ fn bench_with_lib_dep() {
assert_that(p.cargo_process("bench"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]baz-[..]
[RUNNING] target[..]release[..]foo-[..]", p.url()))
.with_stdout("
Expand Down Expand Up @@ -301,6 +306,7 @@ fn bench_with_deep_lib_dep() {
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ([..])
[COMPILING] bar v0.0.1 ({dir})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]", dir = p.url()))
.with_stdout("
running 1 test
Expand Down Expand Up @@ -346,6 +352,7 @@ fn external_bench_explicit() {
assert_that(p.cargo_process("bench"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]bench-[..]
[RUNNING] target[..]release[..]foo-[..]", p.url()))
.with_stdout("
Expand Down Expand Up @@ -395,6 +402,7 @@ fn external_bench_implicit() {
assert_that(p.cargo_process("bench"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]external-[..]
[RUNNING] target[..]release[..]foo-[..]", p.url()))
.with_stdout("
Expand Down Expand Up @@ -455,6 +463,7 @@ fn pass_through_command_line() {
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]foo-[..]", dir = p.url()))
.with_stdout("
running 1 test
Expand All @@ -466,7 +475,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured

assert_that(p.cargo("bench").arg("foo"),
execs().with_status(0)
.with_stderr("\
.with_stderr("[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]foo-[..]")
.with_stdout("
running 1 test
Expand Down Expand Up @@ -536,6 +545,7 @@ fn lib_bin_same_name() {
assert_that(p.cargo_process("bench"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]foo-[..]
[RUNNING] target[..]release[..]foo-[..]", p.url()))
.with_stdout("
Expand Down Expand Up @@ -589,6 +599,7 @@ fn lib_with_standard_name() {
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] syntax v0.0.1 ({dir})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]bench-[..]
[RUNNING] target[..]release[..]syntax-[..]", dir = p.url()))
.with_stdout("
Expand Down Expand Up @@ -640,6 +651,7 @@ fn lib_with_standard_name2() {
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] syntax v0.0.1 ({dir})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]syntax-[..]", dir = p.url()))
.with_stdout("
running 1 test
Expand Down Expand Up @@ -709,6 +721,7 @@ fn bench_dylib() {
[RUNNING] [..] -C opt-level=3 [..]
[RUNNING] [..] -C opt-level=3 [..]
[RUNNING] [..] -C opt-level=3 [..]
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] [..]target[..]release[..]bench-[..]
[RUNNING] [..]target[..]release[..]foo-[..]", dir = p.url()))
.with_stdout("
Expand All @@ -730,6 +743,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
.with_stderr(&format!("\
[FRESH] bar v0.0.1 ({dir}/bar)
[FRESH] foo v0.0.1 ({dir})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] [..]target[..]release[..]bench-[..]
[RUNNING] [..]target[..]release[..]foo-[..]", dir = p.url()))
.with_stdout("
Expand Down Expand Up @@ -771,6 +785,7 @@ fn bench_twice_with_build_cmd() {
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]foo-[..]", dir = p.url()))
.with_stdout("
running 1 test
Expand All @@ -782,7 +797,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured

assert_that(p.cargo("bench"),
execs().with_status(0)
.with_stderr("\
.with_stderr("[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[..]release[..]foo-[..]")
.with_stdout("
running 1 test
Expand Down Expand Up @@ -855,6 +870,7 @@ fn bench_with_examples() {
[RUNNING] `rustc [..]`
[RUNNING] `rustc [..]`
[RUNNING] `rustc [..]`
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] `{dir}[..]target[..]release[..]testb1-[..] --bench`
[RUNNING] `{dir}[..]target[..]release[..]testbench-[..] --bench`",
dir = p.root().display(), url = p.url()))
Expand Down Expand Up @@ -903,6 +919,7 @@ fn test_a_bench() {
execs().with_status(0)
.with_stderr("\
[COMPILING] foo v0.1.0 ([..])
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
[RUNNING] target[..]debug[..]b-[..]")
.with_stdout("
running 1 test
Expand Down Expand Up @@ -940,6 +957,7 @@ fn test_bench_no_run() {
execs().with_status(0)
.with_stderr("\
[COMPILING] foo v0.1.0 ([..])
[FINISHED] release [optimized] target(s) in [..]
"));
}

Expand Down
1 change: 1 addition & 0 deletions tests/build-lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fn verbose_output_for_lib(p: &ProjectBuilder) -> String {
--emit=dep-info,link \
-L dependency={dir}{sep}target{sep}debug \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]
", sep = SEP,
dir = p.root().display(), url = p.url(),
name = "foo", version = "0.0.1")
Expand Down
Loading

0 comments on commit dc46aba

Please sign in to comment.