Skip to content

Commit

Permalink
Auto merge of #4976 - mbrubeck:doc-check, r=alexcrichton
Browse files Browse the repository at this point in the history
cargo doc: Generate rmeta files for dependencies instead of compiling rlibs

This makes `cargo doc` require only metadata (`.rmeta` files) instead of compiled libraries (`.rlib` files) for dependencies.  This makes `cargo doc` faster in cases where rlibs are not already built and/or metadata is already available.

Unfortunately, this is not a win for every workflow.  In the case where the user has already compiled but has not generated metadata, it makes `cargo doc` do extra work.  This is probably a common case, though tools like RLS and `cargo check` mean that many developers *will* have up-to-date metadata available.

It would become an unequivocal win if `cargo build` and `cargo check` re-used shared metadata (#3501). For now, starting from a clean working directory, the following sequences of commands will become:

* `cargo doc`: faster
* `cargo build; cargo doc`: slower
* `cargo check; cargo doc`: faster
* `cargo build --release; cargo doc`: faster
* `cargo check; cargo build; cargo doc`: no change
  • Loading branch information
bors committed Feb 5, 2018
2 parents df089f4 + 9bb9dbd commit 16ffc05
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/cargo/ops/cargo_rustc/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
ret.push(Unit {
pkg: dep,
target: lib,
profile: self.lib_profile(),
profile: self.lib_or_check_profile(unit, lib),
kind: unit.kind.for_target(lib),
});
if self.build_config.doc_all {
Expand Down Expand Up @@ -1055,11 +1055,12 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
}

pub fn lib_or_check_profile(&self, unit: &Unit, target: &Target) -> &'a Profile {
if unit.profile.check && !target.is_custom_build() && !target.for_host() {
&self.profiles.check
} else {
self.lib_profile()
if !target.is_custom_build() && !target.for_host() {
if unit.profile.check || (unit.profile.doc && !unit.profile.test) {
return &self.profiles.check
}
}
self.lib_profile()
}

pub fn build_script_profile(&self, _pkg: &PackageId) -> &'a Profile {
Expand Down

0 comments on commit 16ffc05

Please sign in to comment.