Skip to content

Commit

Permalink
Auto merge of #7411 - Eh2406:mtime, r=alexcrichton
Browse files Browse the repository at this point in the history
set -Zmtime_on_use from config or ENV

This lets you set the `-Zmtime_on_use` in config, it worked for me with
```toml
[unstable]
mtime_on_use=true
```
I did not find the ENV that would allow work. Suggestions?
Does this need tests?

Closes: #6978
  • Loading branch information
bors committed Sep 24, 2019
2 parents aa6b7e0 + 473f999 commit 400221e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ impl CliUnstable {
"advanced-env" => self.advanced_env = true,
"config-profile" => self.config_profile = true,
"dual-proc-macros" => self.dual_proc_macros = true,
// can also be set in .cargo/config or with and ENV
"mtime-on-use" => self.mtime_on_use = true,
"install-upgrade" => self.install_upgrade = true,
"cache-messages" => self.cache_messages = true,
Expand Down
8 changes: 7 additions & 1 deletion src/cargo/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use url::Url;
use self::ConfigValue as CV;
use crate::core::profiles::ConfigProfiles;
use crate::core::shell::Verbosity;
use crate::core::{CliUnstable, Shell, SourceId, Workspace};
use crate::core::{nightly_features_allowed, CliUnstable, Shell, SourceId, Workspace};
use crate::ops;
use crate::util::errors::{self, internal, CargoResult, CargoResultExt};
use crate::util::toml as cargo_toml;
Expand Down Expand Up @@ -626,6 +626,12 @@ impl Config {
self.target_dir = cli_target_dir;
self.cli_flags.parse(unstable_flags)?;

if nightly_features_allowed() {
if let Some(val) = self.get::<Option<bool>>("unstable.mtime_on_use")? {
self.cli_flags.mtime_on_use |= val;
}
}

Ok(())
}

Expand Down
11 changes: 11 additions & 0 deletions src/doc/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ the registry index. This is intended for tools such as Crater that issue many
Cargo commands, and you want to avoid the network latency for updating the
index each time.

### mtime-on-use
* Original Issue: [#6477](https://github.com/rust-lang/cargo/pull/6477)
* Cache usage meta tracking issue: [#7150](https://github.com/rust-lang/cargo/issues/7150)

The `-Z mtime-on-use` flag is an experiment to have Cargo update the mtime of
used files to make it easier for tools like cargo-sweep to detect which files
are stale. For many workflows this needs to be set on *all* invocations of cargo.
To make this more practical setting the `unstable.mtime_on_use` flag in `.cargo/config`
or the corresponding ENV variable will apply the `-Z mtime-on-use` to all
invocations of nightly cargo. (the config flag is ignored by stable)

### avoid-dev-deps
* Original Issue: [#4988](https://github.com/rust-lang/cargo/issues/4988)
* Stabilization Issue: [#5133](https://github.com/rust-lang/cargo/issues/5133)
Expand Down

0 comments on commit 400221e

Please sign in to comment.