fix(rustbinarylocator): support resolving platform-suffixed local Rust binaries
This commit is contained in:
@@ -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