Explorar o código

fix(cli.rs): check default arch at runtime, closes #3067 (#3078)

Lucas Fernandes Nogueira %!s(int64=3) %!d(string=hai) anos
pai
achega
35588b2e04

+ 5 - 0
.changes/cli.rs-fix-windows-x86.md

@@ -0,0 +1,5 @@
+---
+"cli.rs": patch
+---
+
+Fix `build` command when executed on a 32-bit Windows machine when pulling from the `binary-releases` repo.

+ 4 - 4
examples/api/src-tauri/Cargo.lock

@@ -345,9 +345,9 @@ dependencies = [
 
 [[package]]
 name = "clap"
-version = "3.0.0-rc.0"
+version = "3.0.0-rc.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "79b70f999da60e6619a29b131739d2211ed4d4301f40372e94a8081422e9d6c7"
+checksum = "967965e82fc46fee1a88147a7a977a66d615ed5f83eb95b18577b342c08f90ff"
 dependencies = [
  "atty",
  "bitflags",
@@ -1821,9 +1821,9 @@ dependencies = [
 
 [[package]]
 name = "once_cell"
-version = "1.8.0"
+version = "1.9.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
+checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
 
 [[package]]
 name = "open"

+ 9 - 14
tooling/cli.rs/src/build.rs

@@ -174,22 +174,17 @@ pub fn command(options: Options) -> Result<()> {
     // move merge modules to the out dir so the bundler can load it
     #[cfg(windows)]
     {
-      let arch = if let Some(t) = &options.target {
-        if t.starts_with("x86_64") {
-          "x86_64"
-        } else if t.starts_with('i') {
-          "x86"
-        } else if t.starts_with("arm") {
-          "arm"
-        } else if t.starts_with("aarch64") {
-          "aarch64"
-        } else {
-          panic!("Unexpected target triple {}", t)
-        }
-      } else if cfg!(target_arch = "x86") {
+      let target = options.target.clone().unwrap_or_else(|| std::env::consts::ARCH.into());
+      let arch = if target.starts_with("x86_64") {
+        "x86_64"
+      } else if target.starts_with('i') || target.starts_with("x86") {
         "x86"
+      } else if target.starts_with("arm") {
+        "arm"
+      } else if target.starts_with("aarch64") {
+        "aarch64"
       } else {
-        "x86_64"
+        panic!("Unexpected target architecture {}", target.split("_").next().unwrap())
       };
       let (filename, vcruntime_msm) = if arch == "x86" {
         let _ = std::fs::remove_file(out_dir.join("Microsoft_VC142_CRT_x64.msm"));