pub fn GetTauriTargetTriple() -> StringExpand description
Gets the Tauri-compatible target triple for the current build environment.
This function determines the appropriate target triple string based on the current operating system and CPU architecture. Target triples are used to identify platform binaries and ensure compatibility with Tauri’s bundling system.
§Target Triple Format
Target triples follow the format: {arch}-{vendor}-{os}-{environment}
Supported combinations:
- Windows x86_64:
x86_64-pc-windows-msvc - Linux x86_64:
x86_64-unknown-linux-gnu - Linux aarch64:
aarch64-unknown-linux-gnu - macOS x86_64:
x86_64-apple-darwin - macOS aarch64 (Apple Silicon):
aarch64-apple-darwin
§Returns
A string containing the target triple for the current platform.
§Panics
This function will panic if the current platform is not supported. The panic message indicates the unsupported OS-Arch combination and the build system should be extended to support new platforms as needed.
§Platform Detection
The function uses std::env::consts to detect:
OS- The operating system (windows, linux, macos, etc.)ARCH- The CPU architecture (x86_64, aarch64, etc.)
These are compile-time constants determined when the Rust compiler builds the binary, so this function always returns consistent results for a given build.
§Usage Example
Constructing a path to a Node.js sidecar binary:
use crate::Maintain::Source::Build::GetTauriTargetTriple;
let triple = GetTauriTargetTriple();
let version = "22";
let node_path = PathBuf::from(format!(
"./Element/SideCar/{}/NODE/{}/node.exe",
triple, version
));
println!("Node.js path: {:?}", node_path);§Platform Support
Currently supported platforms:
| OS | Architecture | Target Triple |
|---|---|---|
| Windows | x86_64 | x86_64-pc-windows-msvc |
| Linux | x86_64 | x86_64-unknown-linux-gnu |
| Linux | aarch64 | aarch64-unknown-linux-gnu |
| macOS | x86_64 | x86_64-apple-darwin |
| macOS | aarch64 | aarch64-apple-darwin |
To add support for a new platform:
- Add a match arm for the OS-Arch combination
- Return the appropriate target triple string
- Ensure Node.js binaries are available at the corresponding paths