fix(rustbinarylocator): support resolving platform-suffixed local Rust binaries
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
@@ -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<string, string> = { x64: 'amd64', arm64: 'arm64' };
|
||||
const platformMap: Record<string, string> = { 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<string | null> {
|
||||
const pathDirs = (process.env.PATH || '').split(plugins.path.delimiter);
|
||||
for (const dir of pathDirs) {
|
||||
|
||||
Reference in New Issue
Block a user