From 35d3f6dcb0b72295c219b30d9e0d9bc3fd0d3998 Mon Sep 17 00:00:00 2001 From: bl2e <53062696+bl2e@users.noreply.github.com> Date: Thu, 18 Jun 2020 16:21:04 -0700 Subject: [PATCH 1/5] Enable `--target-dir` support in `install` subcommand --- src/bin/cargo/commands/install.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bin/cargo/commands/install.rs b/src/bin/cargo/commands/install.rs index b26c0cc6d..88c75fbc5 100644 --- a/src/bin/cargo/commands/install.rs +++ b/src/bin/cargo/commands/install.rs @@ -57,6 +57,7 @@ pub fn cli() -> App { "Install all examples", ) .arg_target_triple("Build for the target triple") + .arg_target_dir() .arg(opt("root", "Directory to install packages into").value_name("DIR")) .arg( opt("index", "Registry index to install from") From 1f2de1e0a7f5178fe957c46c7ff44db4e9e19d59 Mon Sep 17 00:00:00 2001 From: bl2e <53062696+bl2e@users.noreply.github.com> Date: Sat, 20 Jun 2020 17:13:10 -0700 Subject: [PATCH 2/5] Add test for `cargo install` option `--target-dir` --- tests/testsuite/install.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 842844819..bd942ee82 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -308,6 +308,32 @@ fn install_path() { .run(); } +#[cargo_test] +fn install_target_dir() { + let p = project().file("src/main.rs", "fn main() {}").build(); + + p.cargo("install --target-dir td_test") + .with_stderr( + "\ +[WARNING] Using `cargo install` [..] +[INSTALLING] foo v0.0.1 [..] +[COMPILING] foo v0.0.1 [..] +[FINISHED] release [..] +[INSTALLING] [..]foo +[INSTALLED] package `foo v0.0.1 [..]foo[..]` (executable `foo[EXE]`) +[WARNING] be sure to add [..] +", + ) + .run(); + + let mut path = p.root(); + path.push("td_test"); + assert!(path.exists()); + + path.push("release/foo"); + assert!(path.exists()); +} + #[cargo_test] fn multiple_crates_error() { let p = git::repo(&paths::root().join("foo")) From 291fb4166507c0c0f0dd1a3b5be218ed2d4c6916 Mon Sep 17 00:00:00 2001 From: bl2e <53062696+bl2e@users.noreply.github.com> Date: Sat, 20 Jun 2020 21:29:02 -0700 Subject: [PATCH 3/5] Reference options-target-dir in `cargo install` documentation --- src/doc/man/cargo-install.adoc | 2 ++ src/doc/man/generated/cargo-install.html | 7 +++++++ src/etc/man/cargo-install.1 | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/doc/man/cargo-install.adoc b/src/doc/man/cargo-install.adoc index 4c33e264b..6c96fdcf9 100644 --- a/src/doc/man/cargo-install.adoc +++ b/src/doc/man/cargo-install.adoc @@ -143,6 +143,8 @@ include::options-features.adoc[] include::options-target-triple.adoc[] +include::options-target-dir.adoc[] + *--debug*:: Build with the `dev` profile instead the `release` profile. diff --git a/src/doc/man/generated/cargo-install.html b/src/doc/man/generated/cargo-install.html index 0dee05d2a..8f143f046 100644 --- a/src/doc/man/generated/cargo-install.html +++ b/src/doc/man/generated/cargo-install.html @@ -258,6 +258,13 @@ target artifacts are placed in a separate directory. See the build cache documentation for more details.

+
--target-dir DIRECTORY
+
+

Directory for all generated artifacts and intermediate files. May also be +specified with the CARGO_TARGET_DIR environment variable, or the +build.target-dir config value. Defaults +to target in the root of the workspace.

+
--debug

Build with the dev profile instead the release profile.

diff --git a/src/etc/man/cargo-install.1 b/src/etc/man/cargo-install.1 index 8ad897030..74751ec32 100644 --- a/src/etc/man/cargo-install.1 +++ b/src/etc/man/cargo-install.1 @@ -2,12 +2,12 @@ .\" Title: cargo-install .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.10 -.\" Date: 2020-06-14 +.\" Date: 2020-06-20 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "CARGO\-INSTALL" "1" "2020-06-14" "\ \&" "\ \&" +.TH "CARGO\-INSTALL" "1" "2020-06-20" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 @@ -345,6 +345,16 @@ target artifacts are placed in a separate directory. See the documentation for more details. .RE .sp +\fB\-\-target\-dir\fP \fIDIRECTORY\fP +.RS 4 +Directory for all generated artifacts and intermediate files. May also be +specified with the \fBCARGO_TARGET_DIR\fP environment variable, or the +\fBbuild.target\-dir\fP \c +.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." +Defaults +to \fBtarget\fP in the root of the workspace. +.RE +.sp \fB\-\-debug\fP .RS 4 Build with the \fBdev\fP profile instead the \fBrelease\fP profile. From bb3754276a79468f879563dacca615edcc6353f7 Mon Sep 17 00:00:00 2001 From: bl2e <53062696+bl2e@users.noreply.github.com> Date: Sat, 20 Jun 2020 23:00:55 -0700 Subject: [PATCH 4/5] Fix test compatibility for Windows --- tests/testsuite/install.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index bd942ee82..f7d93fb56 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -319,7 +319,7 @@ fn install_target_dir() { [INSTALLING] foo v0.0.1 [..] [COMPILING] foo v0.0.1 [..] [FINISHED] release [..] -[INSTALLING] [..]foo +[INSTALLING] [..]foo[EXE] [INSTALLED] package `foo v0.0.1 [..]foo[..]` (executable `foo[EXE]`) [WARNING] be sure to add [..] ", From 538d9259203175aebef2d1f26663944675797d2c Mon Sep 17 00:00:00 2001 From: bl2e <53062696+bl2e@users.noreply.github.com> Date: Sat, 20 Jun 2020 23:37:56 -0700 Subject: [PATCH 5/5] Fix post-execution path checks to be compatible with Windows --- tests/testsuite/install.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index f7d93fb56..9c5a1e726 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -330,7 +330,10 @@ fn install_target_dir() { path.push("td_test"); assert!(path.exists()); + #[cfg(not(windows))] path.push("release/foo"); + #[cfg(windows)] + path.push("release/foo.exe"); assert!(path.exists()); }