pub used_in_plugin: HashSet<Unit<'a>>,
pub jobserver: Client,
pub profiles: &'a Profiles,
- /// This is a workaround to carry the extra compiler args given on the
- /// command-line for `cargo rustc` and `cargo rustdoc`. These commands
- /// only support one target, but we don't want the args passed to any
- /// dependencies.
- pub extra_compiler_args: HashMap<Unit<'a>, Vec<String>>,
+ /// This is a workaround to carry the extra compiler args for either
+ /// `rustc` or `rustdoc` given on the command-line for the commands `cargo
+ /// rustc` and `cargo rustdoc`. These commands only support one target,
+ /// but we don't want the args passed to any dependencies, so we include
+ /// the `Unit` corresponding to the top-level target.
+ pub extra_compiler_args: Option<(Unit<'a>, Vec<String>)>,
target_info: TargetInfo,
host_info: TargetInfo,
config: &'cfg Config,
build_config: BuildConfig,
profiles: &'a Profiles,
- extra_compiler_args: HashMap<Unit<'a>, Vec<String>>,
+ extra_compiler_args: Option<(Unit<'a>, Vec<String>)>,
) -> CargoResult<Context<'a, 'cfg>> {
let incremental_env = match env::var("CARGO_INCREMENTAL") {
Ok(v) => Some(v == "1"),
}
}
- let allow_failure = cx.extra_compiler_args.get(unit).is_some();
+ let allow_failure = cx.extra_compiler_args.is_some();
let target_root = cx.files().target_root().to_path_buf();
let write_fingerprint = Work::new(move |_| {
match fingerprint.update_local(&target_root) {
rustdoc.arg(format!("--edition={}", &manifest.edition()));
}
- if let Some(args) = cx.extra_compiler_args.get(unit) {
- rustdoc.args(args);
+ if let Some((ref args_unit, ref args)) = cx.extra_compiler_args {
+ if args_unit == unit {
+ rustdoc.args(args);
+ }
}
build_deps_args(&mut rustdoc, cx, unit)?;
cmd.arg("-C").arg(format!("debuginfo={}", debuginfo));
}
- if let Some(args) = cx.extra_compiler_args.get(unit) {
- cmd.args(args);
+ if let Some((ref args_unit, ref args)) = cx.extra_compiler_args {
+ if args_unit == unit {
+ cmd.args(args);
+ }
}
// -C overflow-checks is implied by the setting of -C debug-assertions,
// `build_unit_profiles` normally ensures that it selects the
// ancestor's profile. However `cargo clean -p` can hit this
// path.
- // TODO: I think `cargo clean -p xxx` is not cleaning out
- // the "OUT_DIR" directory. This is not a new bug.
if release {
&self.release
} else {
/// The precedence of profiles are (first one wins):
/// - [profile.dev.overrides.name] - A named package.
/// - [profile.dev.overrides."*"] - This cannot apply to workspace members.
-/// - [profile.dev.build_override] - This can only apply to `build.rs` scripts
+/// - [profile.dev.build-override] - This can only apply to `build.rs` scripts
/// and their dependencies.
/// - [profile.dev]
/// - Default (hard-coded) values.
/// A general-purpose target.
Any,
/// A target for `build.rs` or any of its dependencies. This enables
- /// `build_override` profiles for these targets.
+ /// `build-override` profiles for these targets.
CustomBuild,
/// A target that is a dependency of a test or benchmark. Currently this
/// enforces that the `panic` setting is not set.
}
impl ProfileFor {
- pub fn all_values() -> Vec<ProfileFor> {
- vec![
+ pub fn all_values() -> &'static [ProfileFor] {
+ static ALL: [ProfileFor; 3] = [
ProfileFor::Any,
ProfileFor::CustomBuild,
ProfileFor::TestDependency,
- ]
+ ];
+ &ALL
}
}
use std::fs;
use std::path::Path;
-use std::collections::HashMap;
use core::Workspace;
use core::compiler::{BuildConfig, Context, Kind, Unit};
let profile = profiles.get_profile(
&pkg.name(),
ws.is_member(pkg),
- profile_for,
- mode,
+ *profile_for,
+ *mode,
opts.release,
);
units.push(Unit {
target,
profile,
kind: *kind,
- mode,
+ mode: *mode,
});
}
}
opts.config,
build_config,
profiles,
- HashMap::new(),
+ None,
)?;
cx.prepare_units(None, &units)?;
//! previously compiled dependency
//!
-use std::collections::{HashMap, HashSet};
+use std::collections::HashSet;
use std::path::{Path, PathBuf};
use std::sync::Arc;
/// List of all modes (currently used by `cargo clean -p` for computing
/// all possible outputs).
- pub fn all_modes() -> Vec<CompileMode> {
- vec![
+ pub fn all_modes() -> &'static [CompileMode] {
+ static ALL: [CompileMode; 9] = [
CompileMode::Test,
CompileMode::Build,
CompileMode::Check { test: true },
CompileMode::Doc { deps: false },
CompileMode::Doctest,
CompileMode::RunCustomBuild,
- ]
+ ];
+ &ALL
}
}
}
let profiles = ws.profiles();
- let mut extra_compiler_args = HashMap::new();
+ let mut extra_compiler_args = None;
let units = generate_targets(
ws,
extra_args_name
);
}
- extra_compiler_args.insert(units[0], args);
+ extra_compiler_args = Some((units[0], args));
}
let mut ret = {
pub overflow_checks: Option<bool>,
pub incremental: Option<bool>,
pub overrides: Option<BTreeMap<String, TomlProfile>>,
- #[serde(rename = "build_override")]
pub build_override: Option<Box<TomlProfile>>,
}
[profile.dev.overrides.image]
opt-level = 3
-# All dependencies (but not this crate itself) will be compiled
-# with -Copt-level=2 . This includes build dependencies.
+# All dependencies (but not this crate itself or any workspace member)
+# will be compiled with -Copt-level=2 . This includes build dependencies.
[profile.dev.overrides."*"]
opt-level = 2
# Build scripts and their dependencies will be compiled with -Copt-level=3
# By default, build scripts use the same rules as the rest of the profile
-[profile.dev.build_override]
+[profile.dev.build-override]
opt-level = 3
```
version = "0.0.1"
authors = []
- [profile.dev.build_override]
+ [profile.dev.build-override]
opt-level = 3
"#,
)