docs(sidecar): recommend rustc --print host-tuple for rust >= 1.84.0 (#3676)

Co-authored-by: Fabian-Lars <github@fabianlars.de>
This commit is contained in:
Marshal Hayes
2026-01-07 03:35:35 -06:00
committed by GitHub
parent d33418a8c7
commit 6aec53bc9c
2 changed files with 23 additions and 12 deletions

View File

@@ -34,24 +34,27 @@ So `binaries/my-sidecar` would represent `<PROJECT ROOT>/src-tauri/binaries/my-s
To make the external binary work on each supported architecture, a binary with the same name and a `-$TARGET_TRIPLE` suffix must exist on the specified path.
For instance, `"externalBin": ["binaries/my-sidecar"]` requires a `src-tauri/binaries/my-sidecar-x86_64-unknown-linux-gnu` executable on Linux or `src-tauri/binaries/my-sidecar-aarch64-apple-darwin` on Mac OS with Apple Silicon.
You can find your **current** platform's `-$TARGET_TRIPLE` suffix by looking at the `host:` property reported by the following command:
You can find your **current** platform's `-$TARGET_TRIPLE` suffix by running the following command:
```sh
rustc -Vv
rustc --print host-tuple
```
If the `grep` and `cut` commands are available, as they should on most Unix systems, you can extract the target triple directly with the following command:
This directly outputs your host's target triple (e.g., `x86_64-unknown-linux-gnu` or `aarch64-apple-darwin`).
```shell
:::note
The `--print host-tuple` flag was added in Rust 1.84.0. If you're using an older version, you'll need to parse the output of `rustc -Vv` instead:
```sh
# Unix (Linux/macOS)
rustc -Vv | grep host | cut -f2 -d' '
```
On Windows you can use PowerShell instead:
```powershell
# Windows PowerShell
rustc -Vv | Select-String "host:" | ForEach-Object {$_.Line.split(" ")[1]}
```
:::
Here's a Node.js script to append the target triple to a binary:
```javascript
@@ -60,8 +63,7 @@ import fs from 'fs';
const extension = process.platform === 'win32' ? '.exe' : '';
const rustInfo = execSync('rustc -vV');
const targetTriple = /host: (\S+)/g.exec(rustInfo)[1];
const targetTriple = execSync('rustc --print host-tuple').toString().trim();
if (!targetTriple) {
console.error('Failed to determine platform target triple');
}

View File

@@ -123,8 +123,7 @@ Without the plugin being initialized and configured the example won't work.
const ext = process.platform === 'win32' ? '.exe' : '';
const rustInfo = execSync('rustc -vV');
const targetTriple = /host: (\S+)/g.exec(rustInfo)[1];
const targetTriple = execSync('rustc --print host-tuple').toString().trim();
if (!targetTriple) {
console.error('Failed to determine platform target triple');
}
@@ -135,6 +134,16 @@ Without the plugin being initialized and configured the example won't work.
);
```
:::note
The `--print host-tuple` flag was added in Rust 1.84.0. If you're using an older version, you'll need to parse the output of `rustc -Vv` instead:
```js
const rustInfo = execSync('rustc -vV');
const targetTriple = /host: (\S+)/g.exec(rustInfo)[1];
```
:::
And run `node rename.js` from the `sidecar-app` directory.
At this step the `/src-tauri/binaries` directory should contain the renamed sidecar binary.