From eb2bf4ba983de453a0dbd961634f98159b438e86 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Sat, 14 Mar 2026 23:42:26 +0000 Subject: [PATCH] fix(rustbinarylocator): support resolving platform-suffixed local Rust binaries --- changelog.md | 6 ++++++ ts/00_commitinfo_data.ts | 2 +- ts/classes.rustbinarylocator.ts | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 8fca7e1..139465e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2026-03-14 - 1.3.2 - fix(rustbinarylocator) +support resolving platform-suffixed local Rust binaries + +- Checks local Rust build paths for binaries with platform suffixes such as _linux_amd64 in addition to unsuffixed names +- Adds platform and architecture suffix mapping for linux, darwin, windows, x64, and arm64 + ## 2026-02-26 - 1.3.1 - fix(readme) document socket transport and clarify stdio/socket differences in README diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index c6755dc..89d4a0f 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartrust', - version: '1.3.1', + version: '1.3.2', description: 'a bridge between JS engines and rust' } diff --git a/ts/classes.rustbinarylocator.ts b/ts/classes.rustbinarylocator.ts index 4cb3ce3..e946358 100644 --- a/ts/classes.rustbinarylocator.ts +++ b/ts/classes.rustbinarylocator.ts @@ -81,11 +81,18 @@ export class RustBinaryLocator { plugins.path.resolve(process.cwd(), `rust/target/release/${binaryName}`), plugins.path.resolve(process.cwd(), `rust/target/debug/${binaryName}`), ]; + const platformSuffix = this.getPlatformSuffix(); for (const localPath of localPaths) { if (await this.isExecutable(localPath)) { this.logger.log('info', `Binary found at local path: ${localPath}`); return localPath; } + // Also try with platform suffix (tsrust convention: binaryName_linux_amd64) + const suffixedPath = `${localPath}_${platformSuffix}`; + if (await this.isExecutable(suffixedPath)) { + this.logger.log('info', `Binary found at local path (platform-suffixed): ${suffixedPath}`); + return suffixedPath; + } } // 5. System PATH @@ -137,6 +144,14 @@ export class RustBinaryLocator { } } + private getPlatformSuffix(): string { + const archMap: Record = { x64: 'amd64', arm64: 'arm64' }; + const platformMap: Record = { linux: 'linux', darwin: 'darwin', win32: 'windows' }; + const platform = platformMap[process.platform] || process.platform; + const arch = archMap[process.arch] || process.arch; + return `${platform}_${arch}`; + } + private async findInPath(binaryName: string): Promise { const pathDirs = (process.env.PATH || '').split(plugins.path.delimiter); for (const dir of pathDirs) {