mirror of https://github.com/rust-lang/cargo
Compare commits
6 Commits
889e087547
...
77c7313368
Author | SHA1 | Date |
---|---|---|
valadaptive | 77c7313368 | |
bors | cf7b3c4cf3 | |
Scott Schafer | 6c2334613c | |
bors | 97181c67e1 | |
Weihang Lo | f8aead9338 | |
valadaptive | bae765e121 |
|
@ -1286,10 +1286,6 @@ pub trait TestEnv: Sized {
|
|||
.env_remove("USER") // not set on some rust-lang docker images
|
||||
.env_remove("XDG_CONFIG_HOME") // see #2345
|
||||
.env_remove("OUT_DIR"); // see #13204
|
||||
if cfg!(target_os = "macos") {
|
||||
// Work-around a bug in macOS 10.15, see `link_or_copy` for details.
|
||||
self = self.env("__CARGO_COPY_DONT_LINK_DO_NOT_USE_THIS", "1");
|
||||
}
|
||||
if cfg!(windows) {
|
||||
self = self.env("USERPROFILE", paths::home());
|
||||
}
|
||||
|
|
|
@ -565,26 +565,18 @@ fn _link_or_copy(src: &Path, dst: &Path) -> Result<()> {
|
|||
src
|
||||
};
|
||||
symlink(src, dst)
|
||||
} else if env::var_os("__CARGO_COPY_DONT_LINK_DO_NOT_USE_THIS").is_some() {
|
||||
// This is a work-around for a bug in macOS 10.15. When running on
|
||||
// APFS, there seems to be a strange race condition with
|
||||
// Gatekeeper where it will forcefully kill a process launched via
|
||||
// `cargo run` with SIGKILL. Copying seems to avoid the problem.
|
||||
// This shouldn't affect anyone except Cargo's test suite because
|
||||
// it is very rare, and only seems to happen under heavy load and
|
||||
// rapidly creating lots of executables and running them.
|
||||
// See https://github.com/rust-lang/cargo/issues/7821 for the
|
||||
// gory details.
|
||||
fs::copy(src, dst).map(|_| ())
|
||||
} else {
|
||||
if cfg!(target_os = "macos") {
|
||||
// This is a work-around for a bug on macos. There seems to be a race condition
|
||||
// with APFS when hard-linking binaries. Gatekeeper does not have signing or
|
||||
// hash information stored in kernel when running the process. Therefore killing it.
|
||||
// This problem does not appear when copying files as kernel has time to process it.
|
||||
// Note that: fs::copy on macos is using CopyOnWrite (syscall fclonefileat) which should be
|
||||
// as fast as hardlinking.
|
||||
// See https://github.com/rust-lang/cargo/issues/10060 for the details
|
||||
// There seems to be a race condition with APFS when hard-linking
|
||||
// binaries. Gatekeeper does not have signing or hash information
|
||||
// stored in kernel when running the process. Therefore killing it.
|
||||
// This problem does not appear when copying files as kernel has
|
||||
// time to process it. Note that: fs::copy on macos is using
|
||||
// CopyOnWrite (syscall fclonefileat) which should be as fast as
|
||||
// hardlinking. See these issues for the details:
|
||||
//
|
||||
// * https://github.com/rust-lang/cargo/issues/7821
|
||||
// * https://github.com/rust-lang/cargo/issues/10060
|
||||
fs::copy(src, dst).map_or_else(
|
||||
|e| {
|
||||
if e.raw_os_error()
|
||||
|
|
|
@ -53,7 +53,7 @@ fn compile(file: &Path) -> Result<Output, Error> {
|
|||
"--error-format=json".into(),
|
||||
"--emit=metadata".into(),
|
||||
"--crate-name=rustfix_test".into(),
|
||||
"--out-dir".into(),
|
||||
"--artifact-dir".into(),
|
||||
tmp.path().into(),
|
||||
];
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ fn compile(
|
|||
crate_type,
|
||||
"--crate-name",
|
||||
crate_name,
|
||||
"--out-dir",
|
||||
"--artifact-dir",
|
||||
]);
|
||||
cmd.arg(&out_dir);
|
||||
if extern_path {
|
||||
|
|
|
@ -34,7 +34,7 @@ pub fn cli() -> Command {
|
|||
.arg_parallel()
|
||||
.arg_target_triple("Build for the target triple")
|
||||
.arg_target_dir()
|
||||
.arg_out_dir()
|
||||
.arg_artifact_dir()
|
||||
.arg_build_plan()
|
||||
.arg_unit_graph()
|
||||
.arg_timings()
|
||||
|
@ -50,14 +50,14 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
|
|||
let mut compile_opts =
|
||||
args.compile_options(gctx, CompileMode::Build, Some(&ws), ProfileChecking::Custom)?;
|
||||
|
||||
if let Some(out_dir) = args.value_of_path("out-dir", gctx) {
|
||||
compile_opts.build_config.export_dir = Some(out_dir);
|
||||
if let Some(artifact_dir) = args.value_of_path("artifact-dir", gctx) {
|
||||
compile_opts.build_config.export_dir = Some(artifact_dir);
|
||||
} else if let Some(out_dir) = gctx.build_config()?.out_dir.as_ref() {
|
||||
let out_dir = out_dir.resolve_path(gctx);
|
||||
compile_opts.build_config.export_dir = Some(out_dir);
|
||||
let artifact_dir = out_dir.resolve_path(gctx);
|
||||
compile_opts.build_config.export_dir = Some(artifact_dir);
|
||||
}
|
||||
if compile_opts.build_config.export_dir.is_some() {
|
||||
gctx.cli_unstable().fail_if_stable_opt("--out-dir", 6790)?;
|
||||
gctx.cli_unstable().fail_if_stable_opt("--artifact-dir", 6790)?;
|
||||
}
|
||||
ops::compile(&ws, &compile_opts)?;
|
||||
Ok(())
|
||||
|
|
|
@ -39,8 +39,9 @@ pub struct BuildConfig {
|
|||
/// The directory to copy final artifacts to. Note that even if `out_dir` is
|
||||
/// set, a copy of artifacts still could be found a `target/(debug\release)`
|
||||
/// as usual.
|
||||
// Note that, although the cmd-line flag name is `out-dir`, in code we use
|
||||
// `export_dir`, to avoid confusion with out dir at `target/debug/deps`.
|
||||
// TODO: originally, the command-line flag was named `out-dir`, so we used
|
||||
// `export_dir` to avoid confusion with out dir at `target/debug/deps`, but
|
||||
// it was renamed to `artifact-dir`. We should change `export_dir` to match.
|
||||
pub export_dir: Option<PathBuf>,
|
||||
/// `true` to output a future incompatibility report at the end of the build
|
||||
pub future_incompat_report: bool,
|
||||
|
|
|
@ -121,7 +121,7 @@ pub struct OutputFile {
|
|||
/// If it should be linked into `target`, and what it should be called
|
||||
/// (e.g., without metadata).
|
||||
pub hardlink: Option<PathBuf>,
|
||||
/// If `--out-dir` is specified, the absolute path to the exported file.
|
||||
/// If `--artifact-dir` is specified, the absolute path to the exported file.
|
||||
pub export_path: Option<PathBuf>,
|
||||
/// Type of the file (library / debug symbol / else).
|
||||
pub flavor: FileFlavor,
|
||||
|
@ -213,7 +213,7 @@ impl<'a, 'gctx: 'a> CompilationFiles<'a, 'gctx> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Additional export directory from `--out-dir`.
|
||||
/// Additional export directory from `--artifact-dir`.
|
||||
pub fn export_dir(&self) -> Option<PathBuf> {
|
||||
self.export_dir.clone()
|
||||
}
|
||||
|
|
|
@ -577,7 +577,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
|
|||
if let Some(ref export_path) = output.export_path {
|
||||
if let Some(other_unit) = output_collisions.insert(export_path.clone(), unit) {
|
||||
self.bcx.gctx.shell().warn(format!(
|
||||
"`--out-dir` filename collision.\n\
|
||||
"`--artifact-dir` filename collision.\n\
|
||||
{}\
|
||||
The exported filenames should be unique.\n\
|
||||
{}",
|
||||
|
|
|
@ -1137,7 +1137,7 @@ fn build_base_args(
|
|||
cmd.arg("-C").arg("rpath");
|
||||
}
|
||||
|
||||
cmd.arg("--out-dir")
|
||||
cmd.arg("--artifact-dir")
|
||||
.arg(&build_runner.files().out_dir(unit));
|
||||
|
||||
fn opt(cmd: &mut ProcessBuilder, key: &str, prefix: &str, val: Option<&OsStr>) {
|
||||
|
|
|
@ -1149,25 +1149,11 @@ impl<'gctx> Workspace<'gctx> {
|
|||
}
|
||||
|
||||
pub fn emit_warnings(&self) -> CargoResult<()> {
|
||||
let ws_lints = self
|
||||
.root_maybe()
|
||||
.workspace_config()
|
||||
.inheritable()
|
||||
.and_then(|i| i.lints().ok())
|
||||
.unwrap_or_default();
|
||||
|
||||
let ws_cargo_lints = ws_lints
|
||||
.get("cargo")
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
||||
for (path, maybe_pkg) in &self.packages.packages {
|
||||
let path = path.join("Cargo.toml");
|
||||
if let MaybePackage::Package(pkg) = maybe_pkg {
|
||||
if self.gctx.cli_unstable().cargo_lints {
|
||||
self.emit_lints(pkg, &path, &ws_cargo_lints)?
|
||||
self.emit_lints(pkg, &path)?
|
||||
}
|
||||
}
|
||||
let warnings = match maybe_pkg {
|
||||
|
@ -1195,12 +1181,7 @@ impl<'gctx> Workspace<'gctx> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn emit_lints(
|
||||
&self,
|
||||
pkg: &Package,
|
||||
path: &Path,
|
||||
ws_cargo_lints: &manifest::TomlToolLints,
|
||||
) -> CargoResult<()> {
|
||||
pub fn emit_lints(&self, pkg: &Package, path: &Path) -> CargoResult<()> {
|
||||
let mut error_count = 0;
|
||||
let toml_lints = pkg
|
||||
.manifest()
|
||||
|
@ -1214,16 +1195,6 @@ impl<'gctx> Workspace<'gctx> {
|
|||
.cloned()
|
||||
.unwrap_or(manifest::TomlToolLints::default());
|
||||
|
||||
// We should only be using workspace lints if the `[lints]` table is
|
||||
// present in the manifest, and `workspace` is set to `true`
|
||||
let ws_cargo_lints = pkg
|
||||
.manifest()
|
||||
.resolved_toml()
|
||||
.lints
|
||||
.as_ref()
|
||||
.is_some_and(|l| l.workspace)
|
||||
.then(|| ws_cargo_lints);
|
||||
|
||||
let ws_contents = match self.root_maybe() {
|
||||
MaybePackage::Package(pkg) => pkg.manifest().contents(),
|
||||
MaybePackage::Virtual(v) => v.contents(),
|
||||
|
@ -1238,36 +1209,14 @@ impl<'gctx> Workspace<'gctx> {
|
|||
pkg,
|
||||
&path,
|
||||
&cargo_lints,
|
||||
ws_cargo_lints,
|
||||
ws_contents,
|
||||
ws_document,
|
||||
self.root_manifest(),
|
||||
self.gctx,
|
||||
)?;
|
||||
check_im_a_teapot(
|
||||
pkg,
|
||||
&path,
|
||||
&cargo_lints,
|
||||
ws_cargo_lints,
|
||||
&mut error_count,
|
||||
self.gctx,
|
||||
)?;
|
||||
check_implicit_features(
|
||||
pkg,
|
||||
&path,
|
||||
&cargo_lints,
|
||||
ws_cargo_lints,
|
||||
&mut error_count,
|
||||
self.gctx,
|
||||
)?;
|
||||
unused_dependencies(
|
||||
pkg,
|
||||
&path,
|
||||
&cargo_lints,
|
||||
ws_cargo_lints,
|
||||
&mut error_count,
|
||||
self.gctx,
|
||||
)?;
|
||||
check_im_a_teapot(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?;
|
||||
check_implicit_features(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?;
|
||||
unused_dependencies(pkg, &path, &cargo_lints, &mut error_count, self.gctx)?;
|
||||
if error_count > 0 {
|
||||
Err(crate::util::errors::AlreadyPrintedError::new(anyhow!(
|
||||
"encountered {error_count} errors(s) while running lints"
|
||||
|
|
|
@ -393,10 +393,10 @@ pub trait CommandExt: Sized {
|
|||
)
|
||||
}
|
||||
|
||||
fn arg_out_dir(self) -> Self {
|
||||
fn arg_artifact_dir(self) -> Self {
|
||||
let unsupported_short_arg = {
|
||||
let value_parser = UnknownArgumentValueParser::suggest_arg("--out-dir");
|
||||
Arg::new("unsupported-short-out-dir-flag")
|
||||
let value_parser = UnknownArgumentValueParser::suggest_arg("--artifact-dir");
|
||||
Arg::new("unsupported-short-artifact-dir-flag")
|
||||
.help("")
|
||||
.short('O')
|
||||
.value_parser(value_parser)
|
||||
|
@ -405,7 +405,7 @@ pub trait CommandExt: Sized {
|
|||
};
|
||||
self._arg(
|
||||
opt(
|
||||
"out-dir",
|
||||
"artifact-dir",
|
||||
"Copy final artifacts to this directory (unstable)",
|
||||
)
|
||||
.value_name("PATH")
|
||||
|
|
|
@ -19,7 +19,6 @@ pub fn analyze_cargo_lints_table(
|
|||
pkg: &Package,
|
||||
path: &Path,
|
||||
pkg_lints: &TomlToolLints,
|
||||
ws_lints: Option<&TomlToolLints>,
|
||||
ws_contents: &str,
|
||||
ws_document: &ImDocument<String>,
|
||||
ws_path: &Path,
|
||||
|
@ -30,20 +29,11 @@ pub fn analyze_cargo_lints_table(
|
|||
let manifest_path = rel_cwd_manifest_path(path, gctx);
|
||||
let ws_path = rel_cwd_manifest_path(ws_path, gctx);
|
||||
let mut unknown_lints = Vec::new();
|
||||
for (lint_name, specified_in) in pkg_lints
|
||||
.keys()
|
||||
.map(|name| (name, SpecifiedIn::Package))
|
||||
.chain(
|
||||
ws_lints
|
||||
.map(|l| l.keys())
|
||||
.unwrap_or_default()
|
||||
.map(|name| (name, SpecifiedIn::Workspace)),
|
||||
)
|
||||
{
|
||||
for lint_name in pkg_lints.keys().map(|name| name) {
|
||||
let Some((name, default_level, edition_lint_opts, feature_gate)) =
|
||||
find_lint_or_group(lint_name)
|
||||
else {
|
||||
unknown_lints.push((lint_name, specified_in));
|
||||
unknown_lints.push(lint_name);
|
||||
continue;
|
||||
};
|
||||
|
||||
|
@ -52,7 +42,6 @@ pub fn analyze_cargo_lints_table(
|
|||
*default_level,
|
||||
*edition_lint_opts,
|
||||
pkg_lints,
|
||||
ws_lints,
|
||||
manifest.edition(),
|
||||
);
|
||||
|
||||
|
@ -66,7 +55,6 @@ pub fn analyze_cargo_lints_table(
|
|||
verify_feature_enabled(
|
||||
name,
|
||||
feature_gate,
|
||||
reason,
|
||||
manifest,
|
||||
&manifest_path,
|
||||
ws_contents,
|
||||
|
@ -83,7 +71,6 @@ pub fn analyze_cargo_lints_table(
|
|||
manifest,
|
||||
&manifest_path,
|
||||
pkg_lints,
|
||||
ws_lints,
|
||||
ws_contents,
|
||||
ws_document,
|
||||
&ws_path,
|
||||
|
@ -130,7 +117,6 @@ fn find_lint_or_group<'a>(
|
|||
fn verify_feature_enabled(
|
||||
lint_name: &str,
|
||||
feature_gate: &Feature,
|
||||
reason: LintLevelReason,
|
||||
manifest: &Manifest,
|
||||
manifest_path: &str,
|
||||
ws_contents: &str,
|
||||
|
@ -151,55 +137,55 @@ fn verify_feature_enabled(
|
|||
"consider adding `cargo-features = [\"{}\"]` to the top of the manifest",
|
||||
dash_feature_name
|
||||
);
|
||||
let message = match reason {
|
||||
LintLevelReason::Package => {
|
||||
let span =
|
||||
get_span(manifest.document(), &["lints", "cargo", lint_name], false).unwrap();
|
||||
|
||||
Level::Error
|
||||
.title(&title)
|
||||
.snippet(
|
||||
Snippet::source(manifest.contents())
|
||||
.origin(&manifest_path)
|
||||
.annotation(Level::Error.span(span).label(&label))
|
||||
.fold(true),
|
||||
)
|
||||
.footer(Level::Help.title(&help))
|
||||
}
|
||||
LintLevelReason::Workspace => {
|
||||
let lint_span = get_span(
|
||||
ws_document,
|
||||
&["workspace", "lints", "cargo", lint_name],
|
||||
false,
|
||||
let message = if let Some(span) =
|
||||
get_span(manifest.document(), &["lints", "cargo", lint_name], false)
|
||||
{
|
||||
Level::Error
|
||||
.title(&title)
|
||||
.snippet(
|
||||
Snippet::source(manifest.contents())
|
||||
.origin(&manifest_path)
|
||||
.annotation(Level::Error.span(span).label(&label))
|
||||
.fold(true),
|
||||
)
|
||||
.unwrap();
|
||||
let inherit_span_key =
|
||||
get_span(manifest.document(), &["lints", "workspace"], false).unwrap();
|
||||
let inherit_span_value =
|
||||
get_span(manifest.document(), &["lints", "workspace"], true).unwrap();
|
||||
.footer(Level::Help.title(&help))
|
||||
} else {
|
||||
let lint_span = get_span(
|
||||
ws_document,
|
||||
&["workspace", "lints", "cargo", lint_name],
|
||||
false,
|
||||
)
|
||||
.expect(&format!(
|
||||
"could not find `cargo::{lint_name}` in `[lints]`, or `[workspace.lints]` "
|
||||
));
|
||||
|
||||
Level::Error
|
||||
.title(&title)
|
||||
.snippet(
|
||||
Snippet::source(ws_contents)
|
||||
.origin(&ws_path)
|
||||
.annotation(Level::Error.span(lint_span).label(&label))
|
||||
.fold(true),
|
||||
)
|
||||
.footer(
|
||||
Level::Note.title(&second_title).snippet(
|
||||
Snippet::source(manifest.contents())
|
||||
.origin(&manifest_path)
|
||||
.annotation(
|
||||
Level::Note
|
||||
.span(inherit_span_key.start..inherit_span_value.end),
|
||||
)
|
||||
.fold(true),
|
||||
),
|
||||
)
|
||||
.footer(Level::Help.title(&help))
|
||||
}
|
||||
_ => unreachable!("LintLevelReason should be one that is user specified"),
|
||||
let inherited_note = if let (Some(inherit_span_key), Some(inherit_span_value)) = (
|
||||
get_span(manifest.document(), &["lints", "workspace"], false),
|
||||
get_span(manifest.document(), &["lints", "workspace"], true),
|
||||
) {
|
||||
Level::Note.title(&second_title).snippet(
|
||||
Snippet::source(manifest.contents())
|
||||
.origin(&manifest_path)
|
||||
.annotation(
|
||||
Level::Note.span(inherit_span_key.start..inherit_span_value.end),
|
||||
)
|
||||
.fold(true),
|
||||
)
|
||||
} else {
|
||||
Level::Note.title(&second_title)
|
||||
};
|
||||
|
||||
Level::Error
|
||||
.title(&title)
|
||||
.snippet(
|
||||
Snippet::source(ws_contents)
|
||||
.origin(&ws_path)
|
||||
.annotation(Level::Error.span(lint_span).label(&label))
|
||||
.fold(true),
|
||||
)
|
||||
.footer(inherited_note)
|
||||
.footer(Level::Help.title(&help))
|
||||
};
|
||||
|
||||
*error_count += 1;
|
||||
|
@ -287,7 +273,6 @@ impl Lint {
|
|||
pub fn level(
|
||||
&self,
|
||||
pkg_lints: &TomlToolLints,
|
||||
ws_lints: Option<&TomlToolLints>,
|
||||
edition: Edition,
|
||||
unstable_features: &Features,
|
||||
) -> (LintLevel, LintLevelReason) {
|
||||
|
@ -310,7 +295,6 @@ impl Lint {
|
|||
g.default_level,
|
||||
g.edition_lint_opts,
|
||||
pkg_lints,
|
||||
ws_lints,
|
||||
edition,
|
||||
),
|
||||
)
|
||||
|
@ -322,7 +306,6 @@ impl Lint {
|
|||
self.default_level,
|
||||
self.edition_lint_opts,
|
||||
pkg_lints,
|
||||
ws_lints,
|
||||
edition,
|
||||
),
|
||||
)))
|
||||
|
@ -378,7 +361,6 @@ pub enum LintLevelReason {
|
|||
Default,
|
||||
Edition(Edition),
|
||||
Package,
|
||||
Workspace,
|
||||
}
|
||||
|
||||
impl Display for LintLevelReason {
|
||||
|
@ -387,7 +369,6 @@ impl Display for LintLevelReason {
|
|||
LintLevelReason::Default => write!(f, "by default"),
|
||||
LintLevelReason::Edition(edition) => write!(f, "in edition {}", edition),
|
||||
LintLevelReason::Package => write!(f, "in `[lints]`"),
|
||||
LintLevelReason::Workspace => write!(f, "in `[workspace.lints]`"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -398,22 +379,15 @@ impl LintLevelReason {
|
|||
LintLevelReason::Default => false,
|
||||
LintLevelReason::Edition(_) => false,
|
||||
LintLevelReason::Package => true,
|
||||
LintLevelReason::Workspace => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum SpecifiedIn {
|
||||
Package,
|
||||
Workspace,
|
||||
}
|
||||
|
||||
fn level_priority(
|
||||
name: &str,
|
||||
default_level: LintLevel,
|
||||
edition_lint_opts: Option<(Edition, LintLevel)>,
|
||||
pkg_lints: &TomlToolLints,
|
||||
ws_lints: Option<&TomlToolLints>,
|
||||
edition: Edition,
|
||||
) -> (LintLevel, LintLevelReason, i8) {
|
||||
let (unspecified_level, reason) = if let Some(level) = edition_lint_opts
|
||||
|
@ -436,12 +410,6 @@ fn level_priority(
|
|||
LintLevelReason::Package,
|
||||
defined_level.priority(),
|
||||
)
|
||||
} else if let Some(defined_level) = ws_lints.and_then(|l| l.get(name)) {
|
||||
(
|
||||
defined_level.level().into(),
|
||||
LintLevelReason::Workspace,
|
||||
defined_level.priority(),
|
||||
)
|
||||
} else {
|
||||
(unspecified_level, reason, 0)
|
||||
}
|
||||
|
@ -460,17 +428,12 @@ pub fn check_im_a_teapot(
|
|||
pkg: &Package,
|
||||
path: &Path,
|
||||
pkg_lints: &TomlToolLints,
|
||||
ws_lints: Option<&TomlToolLints>,
|
||||
error_count: &mut usize,
|
||||
gctx: &GlobalContext,
|
||||
) -> CargoResult<()> {
|
||||
let manifest = pkg.manifest();
|
||||
let (lint_level, reason) = IM_A_TEAPOT.level(
|
||||
pkg_lints,
|
||||
ws_lints,
|
||||
manifest.edition(),
|
||||
manifest.unstable_features(),
|
||||
);
|
||||
let (lint_level, reason) =
|
||||
IM_A_TEAPOT.level(pkg_lints, manifest.edition(), manifest.unstable_features());
|
||||
|
||||
if lint_level == LintLevel::Allow {
|
||||
return Ok(());
|
||||
|
@ -534,7 +497,6 @@ pub fn check_implicit_features(
|
|||
pkg: &Package,
|
||||
path: &Path,
|
||||
pkg_lints: &TomlToolLints,
|
||||
ws_lints: Option<&TomlToolLints>,
|
||||
error_count: &mut usize,
|
||||
gctx: &GlobalContext,
|
||||
) -> CargoResult<()> {
|
||||
|
@ -547,7 +509,7 @@ pub fn check_implicit_features(
|
|||
}
|
||||
|
||||
let (lint_level, reason) =
|
||||
IMPLICIT_FEATURES.level(pkg_lints, ws_lints, edition, manifest.unstable_features());
|
||||
IMPLICIT_FEATURES.level(pkg_lints, edition, manifest.unstable_features());
|
||||
if lint_level == LintLevel::Allow {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -611,30 +573,25 @@ const UNKNOWN_LINTS: Lint = Lint {
|
|||
};
|
||||
|
||||
fn output_unknown_lints(
|
||||
unknown_lints: Vec<(&String, SpecifiedIn)>,
|
||||
unknown_lints: Vec<&String>,
|
||||
manifest: &Manifest,
|
||||
manifest_path: &str,
|
||||
pkg_lints: &TomlToolLints,
|
||||
ws_lints: Option<&TomlToolLints>,
|
||||
ws_contents: &str,
|
||||
ws_document: &ImDocument<String>,
|
||||
ws_path: &str,
|
||||
error_count: &mut usize,
|
||||
gctx: &GlobalContext,
|
||||
) -> CargoResult<()> {
|
||||
let (lint_level, reason) = UNKNOWN_LINTS.level(
|
||||
pkg_lints,
|
||||
ws_lints,
|
||||
manifest.edition(),
|
||||
manifest.unstable_features(),
|
||||
);
|
||||
let (lint_level, reason) =
|
||||
UNKNOWN_LINTS.level(pkg_lints, manifest.edition(), manifest.unstable_features());
|
||||
if lint_level == LintLevel::Allow {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let level = lint_level.to_diagnostic_level();
|
||||
let mut emitted_source = None;
|
||||
for (lint_name, specified_in) in unknown_lints {
|
||||
for lint_name in unknown_lints {
|
||||
if lint_level == LintLevel::Forbid || lint_level == LintLevel::Deny {
|
||||
*error_count += 1;
|
||||
}
|
||||
|
@ -651,50 +608,50 @@ fn output_unknown_lints(
|
|||
let help =
|
||||
matching.map(|(name, kind)| format!("there is a {kind} with a similar name: `{name}`"));
|
||||
|
||||
let mut message = match specified_in {
|
||||
SpecifiedIn::Package => {
|
||||
let span =
|
||||
get_span(manifest.document(), &["lints", "cargo", lint_name], false).unwrap();
|
||||
let mut message = if let Some(span) =
|
||||
get_span(manifest.document(), &["lints", "cargo", lint_name], false)
|
||||
{
|
||||
level.title(&title).snippet(
|
||||
Snippet::source(manifest.contents())
|
||||
.origin(&manifest_path)
|
||||
.annotation(Level::Error.span(span))
|
||||
.fold(true),
|
||||
)
|
||||
} else {
|
||||
let lint_span = get_span(
|
||||
ws_document,
|
||||
&["workspace", "lints", "cargo", lint_name],
|
||||
false,
|
||||
)
|
||||
.expect(&format!(
|
||||
"could not find `cargo::{lint_name}` in `[lints]`, or `[workspace.lints]` "
|
||||
));
|
||||
|
||||
level.title(&title).snippet(
|
||||
let inherited_note = if let (Some(inherit_span_key), Some(inherit_span_value)) = (
|
||||
get_span(manifest.document(), &["lints", "workspace"], false),
|
||||
get_span(manifest.document(), &["lints", "workspace"], true),
|
||||
) {
|
||||
Level::Note.title(&second_title).snippet(
|
||||
Snippet::source(manifest.contents())
|
||||
.origin(&manifest_path)
|
||||
.annotation(Level::Error.span(span))
|
||||
.annotation(
|
||||
Level::Note.span(inherit_span_key.start..inherit_span_value.end),
|
||||
)
|
||||
.fold(true),
|
||||
)
|
||||
}
|
||||
SpecifiedIn::Workspace => {
|
||||
let lint_span = get_span(
|
||||
ws_document,
|
||||
&["workspace", "lints", "cargo", lint_name],
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
let inherit_span_key =
|
||||
get_span(manifest.document(), &["lints", "workspace"], false).unwrap();
|
||||
let inherit_span_value =
|
||||
get_span(manifest.document(), &["lints", "workspace"], true).unwrap();
|
||||
} else {
|
||||
Level::Note.title(&second_title)
|
||||
};
|
||||
|
||||
level
|
||||
.title(&title)
|
||||
.snippet(
|
||||
Snippet::source(ws_contents)
|
||||
.origin(&ws_path)
|
||||
.annotation(Level::Error.span(lint_span))
|
||||
.fold(true),
|
||||
)
|
||||
.footer(
|
||||
Level::Note.title(&second_title).snippet(
|
||||
Snippet::source(manifest.contents())
|
||||
.origin(&manifest_path)
|
||||
.annotation(
|
||||
Level::Note
|
||||
.span(inherit_span_key.start..inherit_span_value.end),
|
||||
)
|
||||
.fold(true),
|
||||
),
|
||||
)
|
||||
}
|
||||
level
|
||||
.title(&title)
|
||||
.snippet(
|
||||
Snippet::source(ws_contents)
|
||||
.origin(&ws_path)
|
||||
.annotation(Level::Error.span(lint_span))
|
||||
.fold(true),
|
||||
)
|
||||
.footer(inherited_note)
|
||||
};
|
||||
|
||||
if emitted_source.is_none() {
|
||||
|
@ -728,7 +685,6 @@ pub fn unused_dependencies(
|
|||
pkg: &Package,
|
||||
path: &Path,
|
||||
pkg_lints: &TomlToolLints,
|
||||
ws_lints: Option<&TomlToolLints>,
|
||||
error_count: &mut usize,
|
||||
gctx: &GlobalContext,
|
||||
) -> CargoResult<()> {
|
||||
|
@ -739,12 +695,8 @@ pub fn unused_dependencies(
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
let (lint_level, reason) = UNUSED_OPTIONAL_DEPENDENCY.level(
|
||||
pkg_lints,
|
||||
ws_lints,
|
||||
edition,
|
||||
manifest.unstable_features(),
|
||||
);
|
||||
let (lint_level, reason) =
|
||||
UNUSED_OPTIONAL_DEPENDENCY.level(pkg_lints, edition, manifest.unstable_features());
|
||||
if lint_level == LintLevel::Allow {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
@ -492,7 +492,15 @@ fn resolve_toml(
|
|||
}
|
||||
resolved_toml.target = (!resolved_target.is_empty()).then_some(resolved_target);
|
||||
|
||||
resolved_toml.lints = original_toml.lints.clone();
|
||||
let resolved_lints = original_toml
|
||||
.lints
|
||||
.clone()
|
||||
.map(|value| lints_inherit_with(value, || inherit()?.lints()))
|
||||
.transpose()?;
|
||||
resolved_toml.lints = resolved_lints.map(|lints| manifest::InheritableLints {
|
||||
workspace: false,
|
||||
lints,
|
||||
});
|
||||
|
||||
resolved_toml.badges = original_toml.badges.clone();
|
||||
} else {
|
||||
|
@ -1336,18 +1344,18 @@ fn to_real_manifest(
|
|||
}
|
||||
}
|
||||
|
||||
let resolved_lints = resolved_toml
|
||||
.lints
|
||||
.clone()
|
||||
.map(|value| {
|
||||
lints_inherit_with(value, || {
|
||||
load_inheritable_fields(gctx, manifest_file, &workspace_config)?.lints()
|
||||
})
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
verify_lints(resolved_lints.as_ref(), gctx, warnings)?;
|
||||
let rustflags = lints_to_rustflags(&resolved_lints.unwrap_or_default());
|
||||
verify_lints(
|
||||
resolved_toml.resolved_lints().expect("previously resolved"),
|
||||
gctx,
|
||||
warnings,
|
||||
)?;
|
||||
let default = manifest::TomlLints::default();
|
||||
let rustflags = lints_to_rustflags(
|
||||
resolved_toml
|
||||
.resolved_lints()
|
||||
.expect("previously resolved")
|
||||
.unwrap_or(&default),
|
||||
);
|
||||
|
||||
let metadata = ManifestMetadata {
|
||||
description: resolved_package
|
||||
|
|
|
@ -50,7 +50,7 @@ they have `required-features` that are missing.
|
|||
{{#options}}
|
||||
{{> options-target-dir }}
|
||||
|
||||
{{#option "`--out-dir` _directory_" }}
|
||||
{{#option "`--artifact-dir` _directory_" }}
|
||||
Copy final artifacts to this directory.
|
||||
|
||||
This option is unstable and available only on the
|
||||
|
|
|
@ -188,7 +188,7 @@ OPTIONS
|
|||
<https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
|
||||
target in the root of the workspace.
|
||||
|
||||
--out-dir directory
|
||||
--artifact-dir directory
|
||||
Copy final artifacts to this directory.
|
||||
|
||||
This option is unstable and available only on the nightly channel
|
||||
|
|
|
@ -222,7 +222,7 @@ specified with the <code>CARGO_TARGET_DIR</code> environment variable, or the
|
|||
Defaults to <code>target</code> in the root of the workspace.</dd>
|
||||
|
||||
|
||||
<dt class="option-term" id="option-cargo-build---out-dir"><a class="option-anchor" href="#option-cargo-build---out-dir"></a><code>--out-dir</code> <em>directory</em></dt>
|
||||
<dt class="option-term" id="option-cargo-build---artifact-dir"><a class="option-anchor" href="#option-cargo-build---artifact-dir"></a><code>--artifact-dir</code> <em>directory</em></dt>
|
||||
<dd class="option-desc">Copy final artifacts to this directory.</p>
|
||||
<p>This option is unstable and available only on the
|
||||
<a href="https://doc.rust-lang.org/book/appendix-07-nightly-rust.html">nightly channel</a>
|
||||
|
|
|
@ -28,9 +28,9 @@ how the feature works:
|
|||
|
||||
* New command-line flags, options, and subcommands require the `-Z
|
||||
unstable-options` CLI option to also be included. For example, the new
|
||||
`--out-dir` option is only available on nightly:
|
||||
`--artifact-dir` option is only available on nightly:
|
||||
|
||||
```cargo +nightly build --out-dir=out -Z unstable-options```
|
||||
```cargo +nightly build --artifact-dir=out -Z unstable-options```
|
||||
|
||||
* `-Z` command-line flags are used to enable new functionality that may not
|
||||
have an interface, or the interface has not yet been designed, or for more
|
||||
|
@ -74,7 +74,7 @@ For the latest nightly, see the [nightly version] of this page.
|
|||
* [msrv-policy](#msrv-policy) --- MSRV-aware resolver and version selection
|
||||
* [precise-pre-release](#precise-pre-release) --- Allows pre-release versions to be selected with `update --precise`
|
||||
* Output behavior
|
||||
* [out-dir](#out-dir) --- Adds a directory where artifacts are copied to.
|
||||
* [artifact-dir](#artifact-dir) --- Adds a directory where artifacts are copied to.
|
||||
* [Different binary name](#different-binary-name) --- Assign a name to the built binary that is separate from the crate name.
|
||||
* Compile behavior
|
||||
* [mtime-on-use](#mtime-on-use) --- Updates the last-modified timestamp on every dependency every time it is used, to provide a mechanism to delete unused artifacts.
|
||||
|
@ -206,27 +206,27 @@ minimum versions that you are actually using. That is, if Cargo.toml says
|
|||
Indirect dependencies are resolved as normal so as not to be blocked on their
|
||||
minimal version validation.
|
||||
|
||||
## out-dir
|
||||
## artifact-dir
|
||||
* Original Issue: [#4875](https://github.com/rust-lang/cargo/issues/4875)
|
||||
* Tracking Issue: [#6790](https://github.com/rust-lang/cargo/issues/6790)
|
||||
|
||||
This feature allows you to specify the directory where artifacts will be
|
||||
copied to after they are built. Typically artifacts are only written to the
|
||||
`target/release` or `target/debug` directories. However, determining the
|
||||
exact filename can be tricky since you need to parse JSON output. The
|
||||
`--out-dir` flag makes it easier to predictably access the artifacts. Note
|
||||
that the artifacts are copied, so the originals are still in the `target`
|
||||
directory. Example:
|
||||
This feature allows you to specify the directory where artifacts will be copied
|
||||
to after they are built. Typically artifacts are only written to the
|
||||
`target/release` or `target/debug` directories. However, determining the exact
|
||||
filename can be tricky since you need to parse JSON output. The `--artifact-dir`
|
||||
flag makes it easier to predictably access the artifacts. Note that the
|
||||
artifacts are copied, so the originals are still in the `target` directory.
|
||||
Example:
|
||||
|
||||
```sh
|
||||
cargo +nightly build --out-dir=out -Z unstable-options
|
||||
cargo +nightly build --artifact-dir=out -Z unstable-options
|
||||
```
|
||||
|
||||
This can also be specified in `.cargo/config.toml` files.
|
||||
|
||||
```toml
|
||||
[build]
|
||||
out-dir = "out"
|
||||
artifact-dir = "out"
|
||||
```
|
||||
|
||||
## doctest-xcompile
|
||||
|
|
|
@ -222,7 +222,7 @@ specified with the \fBCARGO_TARGET_DIR\fR environment variable, or the
|
|||
Defaults to \fBtarget\fR in the root of the workspace.
|
||||
.RE
|
||||
.sp
|
||||
\fB\-\-out\-dir\fR \fIdirectory\fR
|
||||
\fB\-\-artifact\-dir\fR \fIdirectory\fR
|
||||
.RS 4
|
||||
Copy final artifacts to this directory.
|
||||
.sp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! Tests for --out-dir flag.
|
||||
//! Tests for --artifact-dir flag.
|
||||
|
||||
use cargo_test_support::sleep_ms;
|
||||
use cargo_test_support::{basic_manifest, project};
|
||||
|
@ -12,8 +12,8 @@ fn binary_with_debug() {
|
|||
.file("src/main.rs", r#"fn main() { println!("Hello, World!") }"#)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z unstable-options --out-dir out")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
p.cargo("build -Z unstable-options --artifact-dir out")
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.enable_mac_dsym()
|
||||
.run();
|
||||
check_dir_contents(
|
||||
|
@ -49,8 +49,8 @@ fn static_library_with_debug() {
|
|||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z unstable-options --out-dir out")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
p.cargo("build -Z unstable-options --artifact-dir out")
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.run();
|
||||
check_dir_contents(
|
||||
&p.root().join("out"),
|
||||
|
@ -85,8 +85,8 @@ fn dynamic_library_with_debug() {
|
|||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z unstable-options --out-dir out")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
p.cargo("build -Z unstable-options --artifact-dir out")
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.enable_mac_dsym()
|
||||
.run();
|
||||
check_dir_contents(
|
||||
|
@ -121,8 +121,8 @@ fn rlib_with_debug() {
|
|||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z unstable-options --out-dir out")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
p.cargo("build -Z unstable-options --artifact-dir out")
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.run();
|
||||
check_dir_contents(
|
||||
&p.root().join("out"),
|
||||
|
@ -165,8 +165,8 @@ fn include_only_the_binary_from_the_current_package() {
|
|||
.file("utils/src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z unstable-options --bin foo --out-dir out")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
p.cargo("build -Z unstable-options --bin foo --artifact-dir out")
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.enable_mac_dsym()
|
||||
.run();
|
||||
check_dir_contents(
|
||||
|
@ -185,8 +185,8 @@ fn out_dir_is_a_file() {
|
|||
.file("out", "")
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z unstable-options --out-dir out")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
p.cargo("build -Z unstable-options --artifact-dir out")
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.with_status(101)
|
||||
.with_stderr_contains("[ERROR] failed to create directory [..]")
|
||||
.run();
|
||||
|
@ -198,8 +198,8 @@ fn replaces_artifacts() {
|
|||
.file("src/main.rs", r#"fn main() { println!("foo") }"#)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z unstable-options --out-dir out")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
p.cargo("build -Z unstable-options --artifact-dir out")
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.run();
|
||||
p.process(
|
||||
&p.root()
|
||||
|
@ -211,8 +211,8 @@ fn replaces_artifacts() {
|
|||
sleep_ms(1000);
|
||||
p.change_file("src/main.rs", r#"fn main() { println!("bar") }"#);
|
||||
|
||||
p.cargo("build -Z unstable-options --out-dir out")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
p.cargo("build -Z unstable-options --artifact-dir out")
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.run();
|
||||
p.process(
|
||||
&p.root()
|
||||
|
@ -240,8 +240,8 @@ fn avoid_build_scripts() {
|
|||
.file("b/build.rs", r#"fn main() { println!("hello-build-b"); }"#)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z unstable-options --out-dir out -vv")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
p.cargo("build -Z unstable-options --artifact-dir out -vv")
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.enable_mac_dsym()
|
||||
.with_stdout_contains("[a 0.0.1] hello-build-a")
|
||||
.with_stdout_contains("[b 0.0.1] hello-build-b")
|
||||
|
@ -263,13 +263,13 @@ fn cargo_build_out_dir() {
|
|||
".cargo/config.toml",
|
||||
r#"
|
||||
[build]
|
||||
out-dir = "out"
|
||||
artifact-dir = "out"
|
||||
"#,
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build -Z unstable-options")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.enable_mac_dsym()
|
||||
.run();
|
||||
check_dir_contents(
|
||||
|
@ -288,12 +288,12 @@ fn unsupported_short_out_dir_flag() {
|
|||
.build();
|
||||
|
||||
p.cargo("build -Z unstable-options -O")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.with_stderr(
|
||||
"\
|
||||
error: unexpected argument '-O' found
|
||||
|
||||
tip: a similar argument exists: '--out-dir'
|
||||
tip: a similar argument exists: '--artifact-dir'
|
||||
|
||||
Usage: cargo[EXE] build [OPTIONS]
|
||||
|
|
@ -1512,14 +1512,14 @@ fn cargo_default_env_metadata_env_var() {
|
|||
--emit=[..]link \
|
||||
-C prefer-dynamic[..]-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \
|
||||
--emit=[..]link[..]-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
-C extra-filename=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps \
|
||||
--extern bar=[CWD]/target/debug/deps/{prefix}bar{suffix}`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]",
|
||||
|
@ -1540,14 +1540,14 @@ fn cargo_default_env_metadata_env_var() {
|
|||
--emit=[..]link \
|
||||
-C prefer-dynamic[..]-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \
|
||||
--emit=[..]link[..]-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
-C extra-filename=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps \
|
||||
--extern bar=[CWD]/target/debug/deps/{prefix}bar-[..]{suffix}`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
|
@ -2294,7 +2294,7 @@ fn verbose_build() {
|
|||
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \
|
||||
--emit=[..]link[..]-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
|
@ -2313,7 +2313,7 @@ fn verbose_release_build() {
|
|||
--emit=[..]link[..]\
|
||||
-C opt-level=3[..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/release/deps`
|
||||
[FINISHED] `release` profile [optimized] target(s) in [..]
|
||||
",
|
||||
|
@ -2332,7 +2332,7 @@ fn verbose_release_build_short() {
|
|||
--emit=[..]link[..]\
|
||||
-C opt-level=3[..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/release/deps`
|
||||
[FINISHED] `release` profile [optimized] target(s) in [..]
|
||||
",
|
||||
|
@ -2386,14 +2386,14 @@ fn verbose_release_build_deps() {
|
|||
-C prefer-dynamic[..]\
|
||||
-C opt-level=3[..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/release/deps`
|
||||
[COMPILING] test v0.0.0 ([CWD])
|
||||
[RUNNING] `rustc --crate-name test --edition=2015 src/lib.rs [..]--crate-type lib \
|
||||
--emit=[..]link[..]\
|
||||
-C opt-level=3[..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/release/deps \
|
||||
--extern foo=[CWD]/target/release/deps/{prefix}foo{suffix} \
|
||||
--extern foo=[CWD]/target/release/deps/libfoo.rlib`
|
||||
|
@ -6282,7 +6282,7 @@ fn build_lib_only() {
|
|||
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \
|
||||
--emit=[..]link[..]-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]",
|
||||
)
|
||||
|
|
|
@ -1827,19 +1827,19 @@ fn build_cmd_with_a_build_cmd() {
|
|||
[RUNNING] `rustc --crate-name a [..]lib.rs [..]--crate-type lib \
|
||||
--emit=[..]link[..] \
|
||||
-C metadata=[..] \
|
||||
--out-dir [..]target/debug/deps \
|
||||
--artifact-dir [..]target/debug/deps \
|
||||
-L [..]target/debug/deps`
|
||||
[COMPILING] foo v0.5.0 ([CWD])
|
||||
[RUNNING] `rustc --crate-name build_script_build --edition=2015 build.rs [..]--crate-type bin \
|
||||
--emit=[..]link[..]\
|
||||
-C metadata=[..] --out-dir [..] \
|
||||
-C metadata=[..] --artifact-dir [..] \
|
||||
-L [..]target/debug/deps \
|
||||
--extern a=[..]liba[..].rlib`
|
||||
[RUNNING] `[..]/foo-[..]/build-script-build`
|
||||
[RUNNING] `rustc --crate-name foo [..]lib.rs [..]--crate-type lib \
|
||||
--emit=[..]link[..]-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L [..]target/debug/deps`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
</tspan>
|
||||
<tspan x="10px" y="820px"><tspan> </tspan><tspan class="fg-cyan bold">--target-dir</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><DIRECTORY></tspan><tspan> Directory for all generated artifacts</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="838px"><tspan> </tspan><tspan class="fg-cyan bold">--out-dir</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><PATH></tspan><tspan> Copy final artifacts to this directory (unstable)</tspan>
|
||||
<tspan x="10px" y="838px"><tspan> </tspan><tspan class="fg-cyan bold">--artifact-dir</tspan><tspan class="fg-cyan"> </tspan><tspan class="fg-cyan"><PATH></tspan><tspan> Copy final artifacts to this directory (unstable)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="856px"><tspan> </tspan><tspan class="fg-cyan bold">--build-plan</tspan><tspan> Output the build plan in JSON (unstable)</tspan>
|
||||
</tspan>
|
||||
|
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
|
@ -96,10 +96,10 @@ This may become a hard error in the future; see <https://github.com/rust-lang/ca
|
|||
// See https://github.com/rust-lang/cargo/issues/7493
|
||||
#[cfg_attr(
|
||||
any(target_env = "msvc", target_vendor = "apple"),
|
||||
ignore = "--out-dir and examples are currently broken on MSVC and apple"
|
||||
ignore = "--artifact-dir and examples are currently broken on MSVC and apple"
|
||||
)]
|
||||
fn collision_export() {
|
||||
// `--out-dir` combines some things which can cause conflicts.
|
||||
// `--artifact-dir` combines some things which can cause conflicts.
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_manifest("foo", "1.0.0"))
|
||||
.file("examples/foo.rs", "fn main() {}")
|
||||
|
@ -108,10 +108,10 @@ fn collision_export() {
|
|||
|
||||
// -j1 to avoid issues with two processes writing to the same file at the
|
||||
// same time.
|
||||
p.cargo("build -j1 --out-dir=out -Z unstable-options --bins --examples")
|
||||
.masquerade_as_nightly_cargo(&["out-dir"])
|
||||
p.cargo("build -j1 --artifact-dir=out -Z unstable-options --bins --examples")
|
||||
.masquerade_as_nightly_cargo(&["artifact-dir"])
|
||||
.with_stderr_contains("\
|
||||
[WARNING] `--out-dir` filename collision.
|
||||
[WARNING] `--artifact-dir` filename collision.
|
||||
The example target `foo` in package `foo v1.0.0 ([..]/foo)` has the same output filename as the bin target `foo` in package `foo v1.0.0 ([..]/foo)`.
|
||||
Colliding filename is: [..]/foo/out/foo[EXE]
|
||||
The exported filenames should be unique.
|
||||
|
|
|
@ -406,7 +406,7 @@ fn linker() {
|
|||
[RUNNING] `rustc --crate-name foo --edition=2015 src/foo.rs [..]--crate-type bin \
|
||||
--emit=[..]link[..]-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [CWD]/target/{target}/debug/deps \
|
||||
--artifact-dir [CWD]/target/{target}/debug/deps \
|
||||
--target {target} \
|
||||
-C linker=my-linker-tool \
|
||||
-L dependency=[CWD]/target/{target}/debug/deps \
|
||||
|
@ -662,7 +662,7 @@ fn cross_with_a_build_script() {
|
|||
.with_stderr(&format!(
|
||||
"\
|
||||
[COMPILING] foo v0.0.0 ([CWD])
|
||||
[RUNNING] `rustc [..] build.rs [..] --out-dir [CWD]/target/debug/build/foo-[..]`
|
||||
[RUNNING] `rustc [..] build.rs [..] --artifact-dir [CWD]/target/debug/build/foo-[..]`
|
||||
[RUNNING] `[CWD]/target/debug/build/foo-[..]/build-script-build`
|
||||
[RUNNING] `rustc [..] src/main.rs [..] --target {target} [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
|
@ -762,7 +762,7 @@ fn build_script_needed_for_host_and_target() {
|
|||
.arg(&target)
|
||||
.with_stderr_contains(&"[COMPILING] d1 v0.0.0 ([CWD]/d1)")
|
||||
.with_stderr_contains(
|
||||
"[RUNNING] `rustc [..] d1/build.rs [..] --out-dir [CWD]/target/debug/build/d1-[..]`",
|
||||
"[RUNNING] `rustc [..] d1/build.rs [..] --artifact-dir [CWD]/target/debug/build/d1-[..]`",
|
||||
)
|
||||
.with_stderr_contains("[RUNNING] `[CWD]/target/debug/build/d1-[..]/build-script-build`")
|
||||
.with_stderr_contains("[RUNNING] `rustc [..] d1/src/lib.rs [..]`")
|
||||
|
@ -773,7 +773,7 @@ fn build_script_needed_for_host_and_target() {
|
|||
))
|
||||
.with_stderr_contains("[COMPILING] foo v0.0.0 ([CWD])")
|
||||
.with_stderr_contains(&format!(
|
||||
"[RUNNING] `rustc [..] build.rs [..] --out-dir [CWD]/target/debug/build/foo-[..] \
|
||||
"[RUNNING] `rustc [..] build.rs [..] --artifact-dir [CWD]/target/debug/build/foo-[..] \
|
||||
-L /path/to/{host}`",
|
||||
host = host
|
||||
))
|
||||
|
|
|
@ -1773,7 +1773,7 @@ fn dirty_both_lib_and_test() {
|
|||
Command::new(rustc)
|
||||
.args(&[
|
||||
"--crate-type=staticlib",
|
||||
"--out-dir",
|
||||
"--artifact-dir",
|
||||
out_dir.to_str().unwrap(),
|
||||
"slib.rs"
|
||||
])
|
||||
|
|
|
@ -975,7 +975,7 @@ error: `im_a_teapot` is specified
|
|||
13 | im-a-teapot = true
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `cargo::im_a_teapot` is set to `forbid` in `[workspace.lints]`
|
||||
= note: `cargo::im_a_teapot` is set to `forbid` in `[lints]`
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
|
|
@ -8,6 +8,7 @@ extern crate cargo_test_macro;
|
|||
mod advanced_env;
|
||||
mod alt_registry;
|
||||
mod artifact_dep;
|
||||
mod artifact_dir;
|
||||
mod bad_config;
|
||||
mod bad_manifest_path;
|
||||
mod bench;
|
||||
|
@ -129,7 +130,6 @@ mod new;
|
|||
mod offline;
|
||||
mod old_cargos;
|
||||
mod open_namespaces;
|
||||
mod out_dir;
|
||||
mod owner;
|
||||
mod package;
|
||||
mod package_features;
|
||||
|
|
|
@ -35,7 +35,7 @@ fn profile_overrides() {
|
|||
-C debug-assertions=on \
|
||||
-C metadata=[..] \
|
||||
-C rpath \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[FINISHED] `dev` profile [optimized] target(s) in [..]
|
||||
",
|
||||
|
@ -70,7 +70,7 @@ fn opt_level_override_0() {
|
|||
--emit=[..]link[..]\
|
||||
-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[FINISHED] [..] target(s) in [..]
|
||||
",
|
||||
|
@ -104,7 +104,7 @@ fn debug_override_1() {
|
|||
--emit=[..]link[..]\
|
||||
-C debuginfo=1 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[FINISHED] [..] target(s) in [..]
|
||||
",
|
||||
|
@ -143,7 +143,7 @@ fn check_opt_level_override(profile_level: &str, rustc_level: &str) {
|
|||
-C debuginfo=2 [..]\
|
||||
-C debug-assertions=on \
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[FINISHED] [..] target(s) in [..]
|
||||
",
|
||||
|
@ -220,7 +220,7 @@ fn top_level_overrides_deps() {
|
|||
-C opt-level=1[..]\
|
||||
-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [CWD]/target/release/deps \
|
||||
--artifact-dir [CWD]/target/release/deps \
|
||||
-L dependency=[CWD]/target/release/deps`
|
||||
[COMPILING] test v0.0.0 ([CWD])
|
||||
[RUNNING] `rustc --crate-name test --edition=2015 src/lib.rs [..]--crate-type lib \
|
||||
|
@ -228,7 +228,7 @@ fn top_level_overrides_deps() {
|
|||
-C opt-level=1[..]\
|
||||
-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/release/deps \
|
||||
--extern foo=[CWD]/target/release/deps/\
|
||||
{prefix}foo[..]{suffix} \
|
||||
|
|
|
@ -798,7 +798,7 @@ fn example_with_release_flag() {
|
|||
--emit=[..]link \
|
||||
-C opt-level=3[..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [CWD]/target/release/deps \
|
||||
--artifact-dir [CWD]/target/release/deps \
|
||||
-C strip=debuginfo \
|
||||
-L dependency=[CWD]/target/release/deps`
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
|
@ -806,7 +806,7 @@ fn example_with_release_flag() {
|
|||
--emit=[..]link \
|
||||
-C opt-level=3[..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [CWD]/target/release/examples \
|
||||
--artifact-dir [CWD]/target/release/examples \
|
||||
-C strip=debuginfo \
|
||||
-L dependency=[CWD]/target/release/deps \
|
||||
--extern bar=[CWD]/target/release/deps/libbar-[..].rlib`
|
||||
|
@ -829,14 +829,14 @@ fast2",
|
|||
--emit=[..]link[..]\
|
||||
-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [CWD]/target/debug/deps \
|
||||
--artifact-dir [CWD]/target/debug/deps \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[RUNNING] `rustc --crate-name a --edition=2015 examples/a.rs [..]--crate-type bin \
|
||||
--emit=[..]link[..]\
|
||||
-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [CWD]/target/debug/examples \
|
||||
--artifact-dir [CWD]/target/debug/examples \
|
||||
-L dependency=[CWD]/target/debug/deps \
|
||||
--extern bar=[CWD]/target/debug/deps/libbar-[..].rlib`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
|
|
|
@ -20,7 +20,7 @@ fn build_lib_for_foo() {
|
|||
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib \
|
||||
--emit=[..]link[..]-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
|
@ -43,7 +43,7 @@ fn lib() {
|
|||
--emit=[..]link[..]-C debuginfo=2 [..]\
|
||||
-C debug-assertions=off \
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
|
@ -65,13 +65,13 @@ fn build_main_and_allow_unstable_options() {
|
|||
[RUNNING] `rustc --crate-name {name} --edition=2015 src/lib.rs [..]--crate-type lib \
|
||||
--emit=[..]link[..]-C debuginfo=2 [..]\
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps`
|
||||
[RUNNING] `rustc --crate-name {name} --edition=2015 src/main.rs [..]--crate-type bin \
|
||||
--emit=[..]link[..]-C debuginfo=2 [..]\
|
||||
-C debug-assertions \
|
||||
-C metadata=[..] \
|
||||
--out-dir [..] \
|
||||
--artifact-dir [..] \
|
||||
-L dependency=[CWD]/target/debug/deps \
|
||||
--extern {name}=[CWD]/target/debug/deps/lib{name}-[..].rlib`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
|
@ -110,7 +110,7 @@ fn build_with_args_to_one_of_multiple_binaries() {
|
|||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]\
|
||||
-C debuginfo=2 [..]-C metadata=[..] \
|
||||
--out-dir [..]`
|
||||
--artifact-dir [..]`
|
||||
[RUNNING] `rustc --crate-name bar --edition=2015 src/bin/bar.rs [..]--crate-type bin --emit=[..]link[..]\
|
||||
-C debuginfo=2 [..]-C debug-assertions [..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
|
@ -388,7 +388,7 @@ fn build_with_args_to_one_of_multiple_tests() {
|
|||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]--crate-type lib --emit=[..]link[..]\
|
||||
-C debuginfo=2 [..]-C metadata=[..] \
|
||||
--out-dir [..]`
|
||||
--artifact-dir [..]`
|
||||
[RUNNING] `rustc --crate-name bar --edition=2015 tests/bar.rs [..]--emit=[..]link[..]-C debuginfo=2 [..]\
|
||||
-C debug-assertions [..]--test[..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
|
|
Loading…
Reference in New Issue