[PATCH] Support cross-compile install
authorXimin Luo <infinity0@pwned.gg>
Fri, 29 Jun 2018 01:57:24 +0000 (18:57 -0700)
committerXimin Luo <infinity0@debian.org>
Sun, 12 Aug 2018 07:15:23 +0000 (12:45 +0530)
Gbp-Pq: Name 0774e97da3894f07ed5b6f7db175027a9bc4718b.patch

src/bin/cargo/commands/install.rs
tests/testsuite/install.rs

index f0c65515d2f2f776dad7eb4b65daa5becba53127..efac1a940c7a839180fb89973a1e81e714d3d38a 100644 (file)
@@ -32,6 +32,7 @@ pub fn cli() -> App {
             "Install only the specified example",
             "Install all examples",
         )
+        .arg_target_triple("Build for the target triple")
         .arg(opt("root", "Directory to install packages into").value_name("DIR"))
         .after_help(
             "\
index 5e6f6f6d3331d640f41fee303b6e855cfc2ad694..464efb096faa47f87ad96780ae387bfd21862631 100644 (file)
@@ -5,6 +5,7 @@ use std::io::prelude::*;
 use cargo::util::ProcessBuilder;
 use cargotest::ChannelChanger;
 use cargotest::install::{cargo_home, has_installed_exe};
+use cargotest::support::cross_compile;
 use cargotest::support::git;
 use cargotest::support::paths;
 use cargotest::support::registry::Package;
@@ -1308,6 +1309,40 @@ fn dev_dependencies_lock_file_untouched() {
     assert!(lock == lock2, "different lockfiles");
 }
 
+#[test]
+fn install_target_native() {
+    pkg("foo", "0.1.0");
+
+    assert_that(
+        cargo_process("install")
+            .arg("foo")
+            .arg("--target")
+            .arg(cargotest::rustc_host()),
+        execs()
+            .with_status(0),
+    );
+    assert_that(cargo_home(), has_installed_exe("foo"));
+}
+
+#[test]
+fn install_target_foreign() {
+    if cross_compile::disabled() {
+        return;
+    }
+
+    pkg("foo", "0.1.0");
+
+    assert_that(
+        cargo_process("install")
+            .arg("foo")
+            .arg("--target")
+            .arg(cross_compile::alternate()),
+        execs()
+            .with_status(0),
+    );
+    assert_that(cargo_home(), has_installed_exe("foo"));
+}
+
 #[test]
 fn vers_precise() {
     pkg("foo", "0.1.1");