mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-01 03:02:28 +03:00
parent
4a031add69
commit
5ebf389f6c
5
.changes/bundler-runtime-target-arch.md
Normal file
5
.changes/bundler-runtime-target-arch.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-bundler": patch
|
||||
---
|
||||
|
||||
Check target architecture at runtime running `$ RUSTC_BOOTSTRAP=1 rustc -Z unstable-options --print target-spec-json` and parsing the `llvm-target` field, fixing macOS M1 sidecar check until we can compile the CLI with M1 target on GitHub Actions.
|
@ -1,3 +1,11 @@
|
||||
use std::{io::Cursor, process::Command};
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
struct TargetSpec {
|
||||
#[serde(rename = "llvm-target")]
|
||||
llvm_target: String,
|
||||
}
|
||||
|
||||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
@ -12,18 +20,36 @@
|
||||
/// * Errors:
|
||||
/// * Unexpected system config
|
||||
pub fn target_triple() -> Result<String, crate::Error> {
|
||||
let arch = if cfg!(target_arch = "x86") {
|
||||
"i686"
|
||||
} else if cfg!(target_arch = "x86_64") {
|
||||
"x86_64"
|
||||
} else if cfg!(target_arch = "arm") {
|
||||
"armv7"
|
||||
} else if cfg!(target_arch = "aarch64") {
|
||||
"aarch64"
|
||||
let output = Command::new("rustc")
|
||||
.args(&["-Z", "unstable-options", "--print", "target-spec-json"])
|
||||
.env("RUSTC_BOOTSTRAP", "1")
|
||||
.output()?;
|
||||
let arch = if output.status.success() {
|
||||
let target_spec: TargetSpec = serde_json::from_reader(Cursor::new(output.stdout))?;
|
||||
target_spec
|
||||
.llvm_target
|
||||
.split('-')
|
||||
.next()
|
||||
.unwrap()
|
||||
.to_string()
|
||||
} else {
|
||||
return Err(crate::Error::ArchError(String::from(
|
||||
"Unable to determine target-architecture",
|
||||
)));
|
||||
super::common::print_info(&format!(
|
||||
"failed to determine target arch using rustc, error: `{}`. The fallback is the architecture of the machine that compiled this crate.",
|
||||
String::from_utf8_lossy(&output.stderr),
|
||||
))?;
|
||||
if cfg!(target_arch = "x86") {
|
||||
"i686".into()
|
||||
} else if cfg!(target_arch = "x86_64") {
|
||||
"x86_64".into()
|
||||
} else if cfg!(target_arch = "arm") {
|
||||
"armv7".into()
|
||||
} else if cfg!(target_arch = "aarch64") {
|
||||
"aarch64".into()
|
||||
} else {
|
||||
return Err(crate::Error::ArchError(String::from(
|
||||
"Unable to determine target-architecture",
|
||||
)));
|
||||
}
|
||||
};
|
||||
|
||||
let os = if cfg!(target_os = "linux") {
|
||||
|
Loading…
Reference in New Issue
Block a user