Skip to content

Commit 6aec53b

Browse files
docs(sidecar): recommend rustc --print host-tuple for rust >= 1.84.0 (#3676)
Co-authored-by: Fabian-Lars <[email protected]>
1 parent d33418a commit 6aec53b

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

src/content/docs/develop/sidecar.mdx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,27 @@ So `binaries/my-sidecar` would represent `<PROJECT ROOT>/src-tauri/binaries/my-s
3434
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.
3535
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.
3636

37-
You can find your **current** platform's `-$TARGET_TRIPLE` suffix by looking at the `host:` property reported by the following command:
37+
You can find your **current** platform's `-$TARGET_TRIPLE` suffix by running the following command:
3838

3939
```sh
40-
rustc -Vv
40+
rustc --print host-tuple
4141
```
4242

43-
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:
43+
This directly outputs your host's target triple (e.g., `x86_64-unknown-linux-gnu` or `aarch64-apple-darwin`).
4444

45-
```shell
46-
rustc -Vv | grep host | cut -f2 -d' '
47-
```
45+
:::note
46+
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:
4847

49-
On Windows you can use PowerShell instead:
48+
```sh
49+
# Unix (Linux/macOS)
50+
rustc -Vv | grep host | cut -f2 -d' '
5051

51-
```powershell
52+
# Windows PowerShell
5253
rustc -Vv | Select-String "host:" | ForEach-Object {$_.Line.split(" ")[1]}
5354
```
5455

56+
:::
57+
5558
Here's a Node.js script to append the target triple to a binary:
5659

5760
```javascript
@@ -60,8 +63,7 @@ import fs from 'fs';
6063

6164
const extension = process.platform === 'win32' ? '.exe' : '';
6265

63-
const rustInfo = execSync('rustc -vV');
64-
const targetTriple = /host: (\S+)/g.exec(rustInfo)[1];
66+
const targetTriple = execSync('rustc --print host-tuple').toString().trim();
6567
if (!targetTriple) {
6668
console.error('Failed to determine platform target triple');
6769
}

src/content/docs/learn/sidecar-nodejs.mdx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ Without the plugin being initialized and configured the example won't work.
123123

124124
const ext = process.platform === 'win32' ? '.exe' : '';
125125

126-
const rustInfo = execSync('rustc -vV');
127-
const targetTriple = /host: (\S+)/g.exec(rustInfo)[1];
126+
const targetTriple = execSync('rustc --print host-tuple').toString().trim();
128127
if (!targetTriple) {
129128
console.error('Failed to determine platform target triple');
130129
}
@@ -135,6 +134,16 @@ Without the plugin being initialized and configured the example won't work.
135134
);
136135
```
137136

137+
:::note
138+
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:
139+
140+
```js
141+
const rustInfo = execSync('rustc -vV');
142+
const targetTriple = /host: (\S+)/g.exec(rustInfo)[1];
143+
```
144+
145+
:::
146+
138147
And run `node rename.js` from the `sidecar-app` directory.
139148

140149
At this step the `/src-tauri/binaries` directory should contain the renamed sidecar binary.

0 commit comments

Comments
 (0)