mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Merge branch 'master' into 7656-format-placeholder-code-when-generating-a-crate
This commit is contained in:
commit
68a1c781d5
87
CHANGELOG.md
87
CHANGELOG.md
@ -1,25 +1,106 @@
|
||||
# Changelog
|
||||
|
||||
## Cargo 1.43 (2020-04-23)
|
||||
[9d32b7b0...HEAD](https://github.com/rust-lang/cargo/compare/9d32b7b0...HEAD)
|
||||
|
||||
### Added
|
||||
- 🔥 Profiles may now be specified in config files (and environment variables).
|
||||
[#7823](https://github.com/rust-lang/cargo/pull/7823)
|
||||
|
||||
### Changed
|
||||
- `cargo install --git` now honors workspaces in a git repository. This allows
|
||||
workspace settings, like `[patch]`, `[replace]`, or `[profile]` to be used.
|
||||
[#7768](https://github.com/rust-lang/cargo/pull/7768)
|
||||
|
||||
### Fixed
|
||||
|
||||
### Nightly only
|
||||
- Added `build.out-dir` config variable to set the output directory.
|
||||
[#7810](https://github.com/rust-lang/cargo/pull/7810)
|
||||
- Added `-Zjobserver-per-rustc` feature to support improved performance for
|
||||
parallel rustc.
|
||||
[#7731](https://github.com/rust-lang/cargo/pull/7731)
|
||||
|
||||
|
||||
|
||||
## Cargo 1.42 (2020-03-12)
|
||||
[0bf7aafe...HEAD](https://github.com/rust-lang/cargo/compare/0bf7aafe...HEAD)
|
||||
[0bf7aafe...rust-1.42.0](https://github.com/rust-lang/cargo/compare/0bf7aafe...rust-1.42.0)
|
||||
|
||||
### Added
|
||||
- Added documentation on git authentication.
|
||||
[#7658](https://github.com/rust-lang/cargo/pull/7658)
|
||||
- Bitbucket Pipeline badges are now supported on crates.io.
|
||||
[#7663](https://github.com/rust-lang/cargo/pull/7663)
|
||||
- `cargo vendor` now accepts the `--versioned-dirs` option to force it to
|
||||
always include the version number in each package's directory name.
|
||||
[#7631](https://github.com/rust-lang/cargo/pull/7631)
|
||||
- The `proc_macro` crate is now automatically added to the extern prelude for
|
||||
proc-macro packages. This means that `extern crate proc_macro;` is no longer
|
||||
necessary for proc-macros.
|
||||
[#7700](https://github.com/rust-lang/cargo/pull/7700)
|
||||
|
||||
### Changed
|
||||
- Emit a warning if `debug_assertions`, `test`, `proc_macro`, or `feature=` is
|
||||
used in a `cfg()` expression.
|
||||
[#7660](https://github.com/rust-lang/cargo/pull/7660)
|
||||
- Large update to the Cargo documentation, adding new chapters on Cargo
|
||||
targets, workspaces, and features.
|
||||
[#7733](https://github.com/rust-lang/cargo/pull/7733)
|
||||
- Windows: `.lib` DLL import libraries are now copied next to the dll for all
|
||||
Windows MSVC targets. Previously it was only supported for
|
||||
`pc-windows-msvc`. This adds DLL support for `uwp-windows-msvc` targets.
|
||||
[#7758](https://github.com/rust-lang/cargo/pull/7758)
|
||||
- The `ar` field in the `[target]` configuration is no longer read. It has
|
||||
been ignored for over 4 years.
|
||||
[#7763](https://github.com/rust-lang/cargo/pull/7763)
|
||||
- Bash completion file simplified and updated for latest changes.
|
||||
[#7789](https://github.com/rust-lang/cargo/pull/7789)
|
||||
- Credentials are only loaded when needed, instead of every Cargo command.
|
||||
[#7774](https://github.com/rust-lang/cargo/pull/7774)
|
||||
|
||||
### Fixed
|
||||
- Removed `--offline` empty index check, which was a false positive in some cases.
|
||||
- Removed `--offline` empty index check, which was a false positive in some
|
||||
cases.
|
||||
[#7655](https://github.com/rust-lang/cargo/pull/7655)
|
||||
- Files and directories starting with a `.` can now be included in a package
|
||||
by adding it to the `include` list.
|
||||
[#7680](https://github.com/rust-lang/cargo/pull/7680)
|
||||
- Fixed `cargo login` removing alternative registry tokens when previous
|
||||
entries existed in the credentials file.
|
||||
[#7708](https://github.com/rust-lang/cargo/pull/7708)
|
||||
- Fixed `cargo vendor` from panicking when used with alternative registries.
|
||||
[#7718](https://github.com/rust-lang/cargo/pull/7718)
|
||||
- Fixed incorrect explanation in the fingerprint debug log message.
|
||||
[#7749](https://github.com/rust-lang/cargo/pull/7749)
|
||||
- A `[source]` that is defined multiple times will now result in an error.
|
||||
Previously it was randomly picking a source, which could cause
|
||||
non-deterministic behavior.
|
||||
[#7751](https://github.com/rust-lang/cargo/pull/7751)
|
||||
- `dep_kinds` in `cargo metadata` are now de-duplicated.
|
||||
[#7756](https://github.com/rust-lang/cargo/pull/7756)
|
||||
- Fixed packaging where `Cargo.lock` was listed in `.gitignore` in a
|
||||
subdirectory inside a git repository. Previously it was assuming
|
||||
`Cargo.lock` was at the root of the repo.
|
||||
[#7779](https://github.com/rust-lang/cargo/pull/7779)
|
||||
- Partial file transfer errors will now cause an automatic retry.
|
||||
[#7788](https://github.com/rust-lang/cargo/pull/7788)
|
||||
- Linux: Fixed panic if CPU iowait stat decreases.
|
||||
[#7803](https://github.com/rust-lang/cargo/pull/7803)
|
||||
- Fixed using the wrong sysroot for detecting host compiler settings when
|
||||
`--sysroot` is passed in via `RUSTFLAGS`.
|
||||
[#7798](https://github.com/rust-lang/cargo/pull/7798)
|
||||
|
||||
### Nightly only
|
||||
|
||||
- `build-std` now uses `--extern` instead of `--sysroot` to find sysroot
|
||||
pacakges.
|
||||
[#7699](https://github.com/rust-lang/cargo/pull/7699)
|
||||
- Added `--config` command-line option to set config settings.
|
||||
[#7649](https://github.com/rust-lang/cargo/pull/7649)
|
||||
- Added `include` config setting which allows including another config file.
|
||||
[#7649](https://github.com/rust-lang/cargo/pull/7649)
|
||||
- Profiles in config files now support any named profile. Previously it was
|
||||
limited to dev/release.
|
||||
[#7750](https://github.com/rust-lang/cargo/pull/7750)
|
||||
|
||||
## Cargo 1.41 (2020-01-30)
|
||||
[5da4b4d4...rust-1.41.0](https://github.com/rust-lang/cargo/compare/5da4b4d4...rust-1.41.0)
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "cargo"
|
||||
version = "0.43.0"
|
||||
version = "0.44.0"
|
||||
edition = "2018"
|
||||
authors = ["Yehuda Katz <wycats@gmail.com>",
|
||||
"Carl Lerche <me@carllerche.com>",
|
||||
|
@ -61,7 +61,7 @@ proptest! {
|
||||
config
|
||||
.configure(
|
||||
1,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
@ -569,7 +569,7 @@ fn test_resolving_minimum_version_with_transitive_deps() {
|
||||
config
|
||||
.configure(
|
||||
1,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
|
@ -36,7 +36,6 @@ Available unstable (nightly-only) flags:
|
||||
-Z minimal-versions -- Install minimal dependency versions instead of maximum
|
||||
-Z no-index-update -- Do not update the registry, avoids a network request for benchmarking
|
||||
-Z unstable-options -- Allow the usage of unstable options
|
||||
-Z config-profile -- Read profiles from .cargo/config files
|
||||
-Z timings -- Display concurrency information
|
||||
-Z doctest-xcompile -- Compile and run doctests for non-host target using runner config
|
||||
|
||||
@ -92,8 +91,11 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let args = expand_aliases(config, args)?;
|
||||
let (cmd, subcommand_args) = match args.subcommand() {
|
||||
// Global args need to be extracted before expanding aliases because the
|
||||
// clap code for extracting a subcommand discards global options
|
||||
// (appearing before the subcommand).
|
||||
let (expanded_args, global_args) = expand_aliases(config, args)?;
|
||||
let (cmd, subcommand_args) = match expanded_args.subcommand() {
|
||||
(cmd, Some(args)) => (cmd, args),
|
||||
_ => {
|
||||
// No subcommand provided.
|
||||
@ -101,7 +103,7 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
config_configure(config, &args, subcommand_args)?;
|
||||
config_configure(config, &expanded_args, subcommand_args, global_args)?;
|
||||
super::init_git_transports(config);
|
||||
|
||||
execute_subcommand(config, cmd, subcommand_args)
|
||||
@ -129,7 +131,7 @@ pub fn get_version_string(is_verbose: bool) -> String {
|
||||
fn expand_aliases(
|
||||
config: &mut Config,
|
||||
args: ArgMatches<'static>,
|
||||
) -> Result<ArgMatches<'static>, CliError> {
|
||||
) -> Result<(ArgMatches<'static>, GlobalArgs), CliError> {
|
||||
if let (cmd, Some(args)) = args.subcommand() {
|
||||
match (
|
||||
commands::builtin_exec(cmd),
|
||||
@ -148,41 +150,60 @@ fn expand_aliases(
|
||||
.unwrap_or_default()
|
||||
.map(|s| s.to_string()),
|
||||
);
|
||||
let args = cli()
|
||||
// new_args strips out everything before the subcommand, so
|
||||
// capture those global options now.
|
||||
// Note that an alias to an external command will not receive
|
||||
// these arguments. That may be confusing, but such is life.
|
||||
let global_args = GlobalArgs::new(&args);
|
||||
let new_args = cli()
|
||||
.setting(AppSettings::NoBinaryName)
|
||||
.get_matches_from_safe(alias)?;
|
||||
return expand_aliases(config, args);
|
||||
let (expanded_args, _) = expand_aliases(config, new_args)?;
|
||||
return Ok((expanded_args, global_args));
|
||||
}
|
||||
(_, None) => {}
|
||||
}
|
||||
};
|
||||
|
||||
Ok(args)
|
||||
Ok((args, GlobalArgs::default()))
|
||||
}
|
||||
|
||||
fn config_configure(
|
||||
config: &mut Config,
|
||||
args: &ArgMatches<'_>,
|
||||
subcommand_args: &ArgMatches<'_>,
|
||||
global_args: GlobalArgs,
|
||||
) -> CliResult {
|
||||
let arg_target_dir = &subcommand_args.value_of_path("target-dir", config);
|
||||
let config_args: Vec<&str> = args.values_of("config").unwrap_or_default().collect();
|
||||
let quiet = if args.is_present("quiet") || subcommand_args.is_present("quiet") {
|
||||
Some(true)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let verbose = global_args.verbose + args.occurrences_of("verbose") as u32;
|
||||
// quiet is unusual because it is redefined in some subcommands in order
|
||||
// to provide custom help text.
|
||||
let quiet =
|
||||
args.is_present("quiet") || subcommand_args.is_present("quiet") || global_args.quiet;
|
||||
let global_color = global_args.color; // Extract so it can take reference.
|
||||
let color = args
|
||||
.value_of("color")
|
||||
.or_else(|| global_color.as_ref().map(|s| s.as_ref()));
|
||||
let frozen = args.is_present("frozen") || global_args.frozen;
|
||||
let locked = args.is_present("locked") || global_args.locked;
|
||||
let offline = args.is_present("offline") || global_args.offline;
|
||||
let mut unstable_flags = global_args.unstable_flags;
|
||||
if let Some(values) = args.values_of("unstable-features") {
|
||||
unstable_flags.extend(values.map(|s| s.to_string()));
|
||||
}
|
||||
let mut config_args = global_args.config_args;
|
||||
if let Some(values) = args.values_of("config") {
|
||||
config_args.extend(values.map(|s| s.to_string()));
|
||||
}
|
||||
config.configure(
|
||||
args.occurrences_of("verbose") as u32,
|
||||
verbose,
|
||||
quiet,
|
||||
args.value_of("color"),
|
||||
args.is_present("frozen"),
|
||||
args.is_present("locked"),
|
||||
args.is_present("offline"),
|
||||
color,
|
||||
frozen,
|
||||
locked,
|
||||
offline,
|
||||
arg_target_dir,
|
||||
&args
|
||||
.values_of_lossy("unstable-features")
|
||||
.unwrap_or_default(),
|
||||
&unstable_flags,
|
||||
&config_args,
|
||||
)?;
|
||||
Ok(())
|
||||
@ -202,6 +223,39 @@ fn execute_subcommand(
|
||||
super::execute_external_subcommand(config, cmd, &ext_args)
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct GlobalArgs {
|
||||
verbose: u32,
|
||||
quiet: bool,
|
||||
color: Option<String>,
|
||||
frozen: bool,
|
||||
locked: bool,
|
||||
offline: bool,
|
||||
unstable_flags: Vec<String>,
|
||||
config_args: Vec<String>,
|
||||
}
|
||||
|
||||
impl GlobalArgs {
|
||||
fn new(args: &ArgMatches<'_>) -> GlobalArgs {
|
||||
GlobalArgs {
|
||||
verbose: args.occurrences_of("verbose") as u32,
|
||||
quiet: args.is_present("quiet"),
|
||||
color: args.value_of("color").map(|s| s.to_string()),
|
||||
frozen: args.is_present("frozen"),
|
||||
locked: args.is_present("locked"),
|
||||
offline: args.is_present("offline"),
|
||||
unstable_flags: args
|
||||
.values_of_lossy("unstable-features")
|
||||
.unwrap_or_default(),
|
||||
config_args: args
|
||||
.values_of("config")
|
||||
.unwrap_or_default()
|
||||
.map(|s| s.to_string())
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn cli() -> App {
|
||||
App::new("cargo")
|
||||
.settings(&[
|
||||
|
@ -39,8 +39,6 @@ pub struct TargetInfo {
|
||||
pub rustflags: Vec<String>,
|
||||
/// Extra flags to pass to `rustdoc`, see `env_args`.
|
||||
pub rustdocflags: Vec<String>,
|
||||
// Remove this when it hits stable (1.41).
|
||||
pub supports_pathless_extern: Option<bool>,
|
||||
}
|
||||
|
||||
/// Kind of each file generated by a Unit, part of `FileType`.
|
||||
@ -103,13 +101,6 @@ impl TargetInfo {
|
||||
.args(&rustflags)
|
||||
.env_remove("RUSTC_LOG");
|
||||
|
||||
let mut pathless_test = process.clone();
|
||||
pathless_test.args(&["--extern", "proc_macro"]);
|
||||
let supports_pathless_extern = match kind {
|
||||
CompileKind::Host => Some(rustc.cached_output(&pathless_test).is_ok()),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if let CompileKind::Target(target) = kind {
|
||||
process.arg("--target").arg(target.rustc_target());
|
||||
}
|
||||
@ -192,7 +183,6 @@ impl TargetInfo {
|
||||
"RUSTDOCFLAGS",
|
||||
)?,
|
||||
cfg,
|
||||
supports_pathless_extern,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1018,13 +1018,7 @@ pub fn extern_args<'a>(
|
||||
link_to(dep, dep.extern_crate_name, dep.noprelude)?;
|
||||
}
|
||||
}
|
||||
if unit.target.proc_macro()
|
||||
&& cx
|
||||
.bcx
|
||||
.info(CompileKind::Host)
|
||||
.supports_pathless_extern
|
||||
.unwrap()
|
||||
{
|
||||
if unit.target.proc_macro() {
|
||||
// Automatically import `proc_macro`.
|
||||
result.push(OsString::from("--extern"));
|
||||
result.push(OsString::from("proc_macro"));
|
||||
|
@ -331,7 +331,6 @@ pub struct CliUnstable {
|
||||
pub minimal_versions: bool,
|
||||
pub package_features: bool,
|
||||
pub advanced_env: bool,
|
||||
pub config_profile: bool,
|
||||
pub config_include: bool,
|
||||
pub dual_proc_macros: bool,
|
||||
pub mtime_on_use: bool,
|
||||
@ -397,7 +396,6 @@ impl CliUnstable {
|
||||
"minimal-versions" => self.minimal_versions = parse_empty(k, v)?,
|
||||
"package-features" => self.package_features = parse_empty(k, v)?,
|
||||
"advanced-env" => self.advanced_env = parse_empty(k, v)?,
|
||||
"config-profile" => self.config_profile = parse_empty(k, v)?,
|
||||
"config-include" => self.config_include = parse_empty(k, v)?,
|
||||
"dual-proc-macros" => self.dual_proc_macros = parse_empty(k, v)?,
|
||||
// can also be set in .cargo/config or with and ENV
|
||||
|
@ -908,13 +908,9 @@ fn merge_config_profiles(
|
||||
};
|
||||
// List of profile names to check if defined in config only.
|
||||
let mut check_to_add = vec![requested_profile];
|
||||
// Flag so -Zconfig-profile warning is only printed once.
|
||||
let mut unstable_warned = false;
|
||||
// Merge config onto manifest profiles.
|
||||
for (name, profile) in &mut profiles {
|
||||
if let Some(config_profile) =
|
||||
get_config_profile(name, config, features, &mut unstable_warned)?
|
||||
{
|
||||
if let Some(config_profile) = get_config_profile(name, config, features)? {
|
||||
profile.merge(&config_profile);
|
||||
}
|
||||
if let Some(inherits) = &profile.inherits {
|
||||
@ -928,9 +924,7 @@ fn merge_config_profiles(
|
||||
std::mem::swap(&mut current, &mut check_to_add);
|
||||
for name in current.drain(..) {
|
||||
if !profiles.contains_key(&name) {
|
||||
if let Some(config_profile) =
|
||||
get_config_profile(&name, config, features, &mut unstable_warned)?
|
||||
{
|
||||
if let Some(config_profile) = get_config_profile(&name, config, features)? {
|
||||
if let Some(inherits) = &config_profile.inherits {
|
||||
check_to_add.push(*inherits);
|
||||
}
|
||||
@ -947,20 +941,12 @@ fn get_config_profile(
|
||||
name: &str,
|
||||
config: &Config,
|
||||
features: &Features,
|
||||
unstable_warned: &mut bool,
|
||||
) -> CargoResult<Option<TomlProfile>> {
|
||||
let profile: Option<config::Value<TomlProfile>> = config.get(&format!("profile.{}", name))?;
|
||||
let profile = match profile {
|
||||
Some(profile) => profile,
|
||||
None => return Ok(None),
|
||||
};
|
||||
if !*unstable_warned && !config.cli_unstable().config_profile {
|
||||
config.shell().warn(format!(
|
||||
"config profiles require the `-Z config-profile` command-line option (found profile `{}` in {})",
|
||||
name, profile.definition))?;
|
||||
*unstable_warned = true;
|
||||
return Ok(None);
|
||||
}
|
||||
let mut warnings = Vec::new();
|
||||
profile
|
||||
.val
|
||||
|
@ -602,14 +602,14 @@ impl Config {
|
||||
pub fn configure(
|
||||
&mut self,
|
||||
verbose: u32,
|
||||
quiet: Option<bool>,
|
||||
quiet: bool,
|
||||
color: Option<&str>,
|
||||
frozen: bool,
|
||||
locked: bool,
|
||||
offline: bool,
|
||||
target_dir: &Option<PathBuf>,
|
||||
unstable_flags: &[String],
|
||||
cli_config: &[&str],
|
||||
cli_config: &[String],
|
||||
) -> CargoResult<()> {
|
||||
self.unstable_flags.parse(unstable_flags)?;
|
||||
if !cli_config.is_empty() {
|
||||
@ -618,7 +618,7 @@ impl Config {
|
||||
self.merge_cli_args()?;
|
||||
}
|
||||
let extra_verbose = verbose >= 2;
|
||||
let verbose = if verbose == 0 { None } else { Some(true) };
|
||||
let verbose = verbose != 0;
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
struct TermConfig {
|
||||
@ -632,25 +632,19 @@ impl Config {
|
||||
let color = color.or_else(|| term.color.as_ref().map(|s| s.as_ref()));
|
||||
|
||||
let verbosity = match (verbose, term.verbose, quiet) {
|
||||
(Some(true), _, None) | (None, Some(true), None) => Verbosity::Verbose,
|
||||
(true, _, false) | (_, Some(true), false) => Verbosity::Verbose,
|
||||
|
||||
// Command line takes precedence over configuration, so ignore the
|
||||
// configuration..
|
||||
(None, _, Some(true)) => Verbosity::Quiet,
|
||||
(false, _, true) => Verbosity::Quiet,
|
||||
|
||||
// Can't pass both at the same time on the command line regardless
|
||||
// of configuration.
|
||||
(Some(true), _, Some(true)) => {
|
||||
(true, _, true) => {
|
||||
bail!("cannot set both --verbose and --quiet");
|
||||
}
|
||||
|
||||
// Can't actually get `Some(false)` as a value from the command
|
||||
// line, so just ignore them here to appease exhaustiveness checking
|
||||
// in match statements.
|
||||
(Some(false), _, _)
|
||||
| (_, _, Some(false))
|
||||
| (None, Some(false), None)
|
||||
| (None, None, None) => Verbosity::Normal,
|
||||
(false, _, false) => Verbosity::Normal,
|
||||
};
|
||||
|
||||
let cli_target_dir = match target_dir.as_ref() {
|
||||
@ -659,7 +653,7 @@ impl Config {
|
||||
};
|
||||
|
||||
self.shell().set_verbosity(verbosity);
|
||||
self.shell().set_color_choice(color.map(|s| &s[..]))?;
|
||||
self.shell().set_color_choice(color)?;
|
||||
self.extra_verbose = extra_verbose;
|
||||
self.frozen = frozen;
|
||||
self.locked = locked;
|
||||
|
@ -87,6 +87,21 @@ retry = 2 # network retries
|
||||
git-fetch-with-cli = true # use the `git` executable for git operations
|
||||
offline = false # do not access the network
|
||||
|
||||
[profile.<name>] # Modify profile settings via config.
|
||||
opt-level = 0 # Optimization level.
|
||||
debug = true # Include debug info.
|
||||
debug-assertions = true # Enables debug assertions.
|
||||
overflow-checks = true # Enables runtime integer overflow checks.
|
||||
lto = false # Sets link-time optimization.
|
||||
panic = 'unwind' # The panic strategy.
|
||||
incremental = true # Incremental compilation.
|
||||
codegen-units = 16 # Number of code generation units.
|
||||
rpath = false # Sets the rpath linking option.
|
||||
[profile.<name>.build-override] # Overrides build-script settings.
|
||||
# Same keys for a normal profile.
|
||||
[profile.<name>.package.<name>] # Override profile for a package.
|
||||
# Same keys for a normal profile (minus `panic`, `lto`, and `rpath`).
|
||||
|
||||
[registries.<name>] # registries other than crates.io
|
||||
index = "…" # URL of the registry index
|
||||
token = "…" # authentication token for the registry
|
||||
@ -549,6 +564,93 @@ needed, and generate an error if it encounters a network error.
|
||||
|
||||
Can be overridden with the `--offline` command-line option.
|
||||
|
||||
#### `[profile]`
|
||||
|
||||
The `[profile]` table can be used to globally change profile settings, and
|
||||
override settings specified in `Cargo.toml`. It has the same syntax and
|
||||
options as profiles specified in `Cargo.toml`. See the [Profiles chapter] for
|
||||
details about the options.
|
||||
|
||||
[Profiles chapter]: profiles.md
|
||||
|
||||
##### `[profile.<name>.build-override]`
|
||||
* Environment: `CARGO_PROFILE_<name>_BUILD_OVERRIDE_<key>`
|
||||
|
||||
The build-override table overrides settings for build scripts, proc macros,
|
||||
and their dependencies. It has the same keys as a normal profile. See the
|
||||
[overrides section](profiles.md#overrides) for more details.
|
||||
|
||||
##### `[profile.<name>.package.<name>]`
|
||||
* Environment: not supported
|
||||
|
||||
The package table overrides settings for specific packages. It has the same
|
||||
keys as a normal profile, minus the `panic`, `lto`, and `rpath` settings. See
|
||||
the [overrides section](profiles.md#overrides) for more details.
|
||||
|
||||
##### `profile.<name>.codegen-units`
|
||||
* Type: integer
|
||||
* Default: See profile docs.
|
||||
* Environment: `CARGO_PROFILE_<name>_CODEGEN_UNITS`
|
||||
|
||||
See [codegen-units](profiles.md#codegen-units).
|
||||
|
||||
##### `profile.<name>.debug`
|
||||
* Type: integer or boolean
|
||||
* Default: See profile docs.
|
||||
* Environment: `CARGO_PROFILE_<name>_DEBUG`
|
||||
|
||||
See [debug](profiles.md#debug).
|
||||
|
||||
##### `profile.<name>.debug-assertions`
|
||||
* Type: boolean
|
||||
* Default: See profile docs.
|
||||
* Environment: `CARGO_PROFILE_<name>_DEBUG_ASSERTIONS`
|
||||
|
||||
See [debug-assertions](profiles.md#debug-assertions).
|
||||
|
||||
##### `profile.<name>.incremental`
|
||||
* Type: boolean
|
||||
* Default: See profile docs.
|
||||
* Environment: `CARGO_PROFILE_<name>_INCREMENTAL`
|
||||
|
||||
See [incremental](profiles.md#incremental).
|
||||
|
||||
##### `profile.<name>.lto`
|
||||
* Type: string or boolean
|
||||
* Default: See profile docs.
|
||||
* Environment: `CARGO_PROFILE_<name>_LTO`
|
||||
|
||||
See [lto](profiles.md#lto).
|
||||
|
||||
##### `profile.<name>.overflow-checks`
|
||||
* Type: boolean
|
||||
* Default: See profile docs.
|
||||
* Environment: `CARGO_PROFILE_<name>_OVERFLOW_CHECKS`
|
||||
|
||||
See [overflow-checks](profiles.md#overflow-checks).
|
||||
|
||||
##### `profile.<name>.opt-level`
|
||||
* Type: integer or string
|
||||
* Default: See profile docs.
|
||||
* Environment: `CARGO_PROFILE_<name>_OPT_LEVEL`
|
||||
|
||||
See [opt-level](profiles.md#opt-level).
|
||||
|
||||
##### `profile.<name>.panic`
|
||||
* Type: string
|
||||
* default: See profile docs.
|
||||
* Environment: `CARGO_PROFILE_<name>_PANIC`
|
||||
|
||||
See [panic](profiles.md#panic).
|
||||
|
||||
##### `profile.<name>.rpath`
|
||||
* Type: boolean
|
||||
* default: See profile docs.
|
||||
* Environment: `CARGO_PROFILE_<name>_RPATH`
|
||||
|
||||
See [rpath](profiles.md#rpath).
|
||||
|
||||
|
||||
#### `[registries]`
|
||||
|
||||
The `[registries]` table is used for specifying additional [registries]. It
|
||||
|
@ -84,6 +84,16 @@ supported environment variables are:
|
||||
* `CARGO_NET_RETRY` — Number of times to retry network errors, see [`net.retry`].
|
||||
* `CARGO_NET_GIT_FETCH_WITH_CLI` — Enables the use of the `git` executable to fetch, see [`net.git-fetch-with-cli`].
|
||||
* `CARGO_NET_OFFLINE` — Offline mode, see [`net.offline`].
|
||||
* `CARGO_PROFILE_<name>_BUILD_OVERRIDE_<key>` — Override build script profile, see [`profile.<name>.build-override`].
|
||||
* `CARGO_PROFILE_<name>_CODEGEN_UNITS` — Set code generation units, see [`profile.<name>.codegen-units`].
|
||||
* `CARGO_PROFILE_<name>_DEBUG` — What kind of debug info to include, see [`profile.<name>.debug`].
|
||||
* `CARGO_PROFILE_<name>_DEBUG_ASSERTIONS` — Enable/disable debug assertions, see [`profile.<name>.debug-assertions`].
|
||||
* `CARGO_PROFILE_<name>_INCREMENTAL` — Enable/disable incremental compilation, see [`profile.<name>.incremental`].
|
||||
* `CARGO_PROFILE_<name>_LTO` — Link-time optimization, see [`profile.<name>.lto`].
|
||||
* `CARGO_PROFILE_<name>_OVERFLOW_CHECKS` — Enable/disable overflow checks, see [`profile.<name>.overflow-checks`].
|
||||
* `CARGO_PROFILE_<name>_OPT_LEVEL` — Set the optimization level, see [`profile.<name>.opt-level`].
|
||||
* `CARGO_PROFILE_<name>_PANIC` — The panic strategy to use, see [`profile.<name>.panic`].
|
||||
* `CARGO_PROFILE_<name>_RPATH` — The rpath linking option, see [`profile.<name>.rpath`].
|
||||
* `CARGO_REGISTRIES_<name>_INDEX` — URL of a registry index, see [`registries.<name>.index`].
|
||||
* `CARGO_REGISTRIES_<name>_TOKEN` — Authentication token of a registry, see [`registries.<name>.token`].
|
||||
* `CARGO_REGISTRY_DEFAULT` — Default registry for the `--registry` flag, see [`registry.default`].
|
||||
@ -129,6 +139,16 @@ supported environment variables are:
|
||||
[`net.retry`]: config.md#netretry
|
||||
[`net.git-fetch-with-cli`]: config.md#netgit-fetch-with-cli
|
||||
[`net.offline`]: config.md#netoffline
|
||||
[`profile.<name>.build-override`]: config.md#profilenamebuild-override
|
||||
[`profile.<name>.codegen-units`]: config.md#profilenamecodegen-units
|
||||
[`profile.<name>.debug`]: config.md#profilenamedebug
|
||||
[`profile.<name>.debug-assertions`]: config.md#profilenamedebug-assertions
|
||||
[`profile.<name>.incremental`]: config.md#profilenameincremental
|
||||
[`profile.<name>.lto`]: config.md#profilenamelto
|
||||
[`profile.<name>.overflow-checks`]: config.md#profilenameoverflow-checks
|
||||
[`profile.<name>.opt-level`]: config.md#profilenameopt-level
|
||||
[`profile.<name>.panic`]: config.md#profilenamepanic
|
||||
[`profile.<name>.rpath`]: config.md#profilenamerpath
|
||||
[`registries.<name>.index`]: config.md#registriesnameindex
|
||||
[`registries.<name>.token`]: config.md#registriesnametoken
|
||||
[`registry.default`]: config.md#registrydefault
|
||||
|
@ -22,6 +22,12 @@ Cargo only looks at the profile settings in the `Cargo.toml` manifest at the
|
||||
root of the workspace. Profile settings defined in dependencies will be
|
||||
ignored.
|
||||
|
||||
Additionally, profiles can be overridden from a [config] definition.
|
||||
Specifying a profile in a config file or environment variable will override
|
||||
the settings from `Cargo.toml`.
|
||||
|
||||
[config]: config.md
|
||||
|
||||
### Profile settings
|
||||
|
||||
The following is a list of settings that can be controlled in a profile.
|
||||
@ -393,5 +399,4 @@ crates. When experimenting with optimizing dependencies for development,
|
||||
consider trying opt-level 1, which will apply some optimizations while still
|
||||
allowing monomorphized items to be shared.
|
||||
|
||||
|
||||
[nalgebra]: https://crates.io/crates/nalgebra
|
||||
|
@ -158,26 +158,6 @@ lto = true
|
||||
```
|
||||
|
||||
|
||||
### Config Profiles
|
||||
* Tracking Issue: [rust-lang/rust#48683](https://github.com/rust-lang/rust/issues/48683)
|
||||
* RFC: [#2282](https://github.com/rust-lang/rfcs/blob/master/text/2282-profile-dependencies.md)
|
||||
|
||||
Profiles can be specified in `.cargo/config` files. The `-Z config-profile`
|
||||
command-line flag is required to use this feature. The format is the same as
|
||||
in a `Cargo.toml` manifest. If found in multiple config files, settings will
|
||||
be merged using the regular [config hierarchy](config.md#hierarchical-structure).
|
||||
Config settings take precedence over manifest settings.
|
||||
|
||||
```toml
|
||||
[profile.dev]
|
||||
opt-level = 3
|
||||
```
|
||||
|
||||
```
|
||||
cargo +nightly build -Z config-profile
|
||||
```
|
||||
|
||||
|
||||
### Namespaced features
|
||||
* Original issue: [#1286](https://github.com/rust-lang/cargo/issues/1286)
|
||||
* Tracking Issue: [#5565](https://github.com/rust-lang/cargo/issues/5565)
|
||||
|
@ -176,3 +176,19 @@ fn builtin_alias_takes_options() {
|
||||
|
||||
p.cargo("r --example ex1 -- asdf").with_stdout("asdf").run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn global_options_with_alias() {
|
||||
// Check that global options are passed through.
|
||||
let p = project().file("src/lib.rs", "").build();
|
||||
|
||||
p.cargo("-v c")
|
||||
.with_stderr(
|
||||
"\
|
||||
[CHECKING] foo [..]
|
||||
[RUNNING] `rustc [..]
|
||||
[FINISHED] dev [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
@ -76,17 +76,16 @@ impl ConfigBuilder {
|
||||
let homedir = paths::home();
|
||||
let mut config = Config::new(shell, cwd, homedir);
|
||||
config.set_env(self.env.clone());
|
||||
let config_args: Vec<&str> = self.config_args.iter().map(AsRef::as_ref).collect();
|
||||
config.configure(
|
||||
0,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
&None,
|
||||
&self.unstable,
|
||||
&config_args,
|
||||
&self.config_args,
|
||||
)?;
|
||||
Ok(config)
|
||||
}
|
||||
|
@ -443,10 +443,6 @@ Caused by:
|
||||
|
||||
#[cargo_test]
|
||||
fn proc_macro_extern_prelude() {
|
||||
if !is_nightly() {
|
||||
// remove once pathless `--extern` hits stable (1.41)
|
||||
return;
|
||||
}
|
||||
// Check that proc_macro is in the extern prelude.
|
||||
let p = project()
|
||||
.file(
|
||||
|
@ -3,31 +3,6 @@
|
||||
use cargo_test_support::paths::CargoPathExt;
|
||||
use cargo_test_support::{basic_lib_manifest, paths, project};
|
||||
|
||||
#[cargo_test]
|
||||
fn profile_config_gated() {
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_lib_manifest("foo"))
|
||||
.file("src/lib.rs", "")
|
||||
.file(
|
||||
".cargo/config",
|
||||
r#"
|
||||
[profile.dev]
|
||||
debug = 1
|
||||
"#,
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -v")
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
[WARNING] config profiles require the `-Z config-profile` command-line option \
|
||||
(found profile `dev` in [..]/foo/.cargo/config)
|
||||
",
|
||||
)
|
||||
.with_stderr_contains("[..]-C debuginfo=2[..]")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn named_profile_gated() {
|
||||
// Named profile in config requires enabling in Cargo.toml.
|
||||
@ -42,7 +17,7 @@ fn named_profile_gated() {
|
||||
"#,
|
||||
)
|
||||
.build();
|
||||
p.cargo("build --profile foo -Zunstable-options -Zconfig-profile")
|
||||
p.cargo("build --profile foo -Zunstable-options")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr(
|
||||
"\
|
||||
@ -84,8 +59,7 @@ fn profile_config_validate_warnings() {
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z config-profile")
|
||||
.masquerade_as_nightly_cargo()
|
||||
p.cargo("build")
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[WARNING] unused config key `profile.dev.bad-key` in `[..].cargo/config`
|
||||
@ -120,8 +94,7 @@ fn profile_config_error_paths() {
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z config-profile")
|
||||
.masquerade_as_nightly_cargo()
|
||||
p.cargo("build")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
@ -148,8 +121,7 @@ fn profile_config_validate_errors() {
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z config-profile")
|
||||
.masquerade_as_nightly_cargo()
|
||||
p.cargo("build")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
@ -176,8 +148,7 @@ fn profile_config_syntax_errors() {
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z config-profile")
|
||||
.masquerade_as_nightly_cargo()
|
||||
p.cargo("build")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
@ -221,8 +192,7 @@ fn profile_config_override_spec_multiple() {
|
||||
|
||||
// Unfortunately this doesn't tell you which file, hopefully it's not too
|
||||
// much of a problem.
|
||||
p.cargo("build -v -Z config-profile")
|
||||
.masquerade_as_nightly_cargo()
|
||||
p.cargo("build -v")
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
@ -254,8 +224,7 @@ fn profile_config_all_options() {
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build --release -v -Z config-profile")
|
||||
.masquerade_as_nightly_cargo()
|
||||
p.cargo("build --release -v")
|
||||
.env_remove("CARGO_INCREMENTAL")
|
||||
.with_stderr(
|
||||
"\
|
||||
@ -309,8 +278,7 @@ fn profile_config_override_precedence() {
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -v -Z config-profile")
|
||||
.masquerade_as_nightly_cargo()
|
||||
p.cargo("build -v")
|
||||
.with_stderr(
|
||||
"\
|
||||
[COMPILING] bar [..]
|
||||
@ -336,8 +304,7 @@ fn profile_config_no_warn_unknown_override() {
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z config-profile")
|
||||
.masquerade_as_nightly_cargo()
|
||||
p.cargo("build")
|
||||
.with_stderr_does_not_contain("[..]warning[..]")
|
||||
.run();
|
||||
}
|
||||
@ -363,8 +330,7 @@ fn profile_config_mixed_types() {
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -v -Z config-profile")
|
||||
.masquerade_as_nightly_cargo()
|
||||
p.cargo("build -v")
|
||||
.with_stderr_contains("[..]-C opt-level=3 [..]")
|
||||
.run();
|
||||
}
|
||||
@ -406,7 +372,7 @@ fn named_config_profile() {
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
let config = ConfigBuilder::new().unstable_flag("config-profile").build();
|
||||
let config = ConfigBuilder::new().build();
|
||||
let mut warnings = Vec::new();
|
||||
let features = Features::new(&["named-profiles".to_string()], &mut warnings).unwrap();
|
||||
assert_eq!(warnings.len(), 0);
|
||||
@ -481,7 +447,7 @@ fn named_env_profile() {
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build -v -Zconfig-profile -Zunstable-options --profile=other")
|
||||
p.cargo("build -v -Zunstable-options --profile=other")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.env("CARGO_PROFILE_OTHER_CODEGEN_UNITS", "1")
|
||||
.env("CARGO_PROFILE_OTHER_INHERITS", "dev")
|
||||
|
@ -6,11 +6,6 @@ use std::env;
|
||||
|
||||
#[cargo_test]
|
||||
fn rustc_info_cache() {
|
||||
if !cargo_test_support::is_nightly() {
|
||||
// remove once pathless `--extern` hits stable (1.41)
|
||||
return;
|
||||
}
|
||||
|
||||
let p = project()
|
||||
.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
|
||||
.build();
|
||||
|
Loading…
x
Reference in New Issue
Block a user