fix(rust-bridge): map Node.js platform/arch to tsrust-style suffix and add platform-specific and dev localPaths for RustBridge

This commit is contained in:
2026-02-11 16:23:43 +00:00
parent 08c5145d20
commit c3d4c4abb5
3 changed files with 35 additions and 6 deletions

View File

@@ -375,18 +375,39 @@ export class RustSecurityBridge extends EventEmitter {
private _deliberateStop = false;
private _smtpServerConfig: ISmtpServerConfig | null = null;
/**
* Map Node.js process.platform / process.arch to the tsrust-style suffix
* used for cross-compiled binaries, e.g. mailer-bin_linux_amd64.
*/
private static getPlatformSuffix(): string | null {
const archMap: Record<string, string> = { x64: 'amd64', arm64: 'arm64' };
const os = process.platform; // 'linux', 'darwin', 'win32', …
const arch = archMap[process.arch];
if (!arch) return null;
return `${os}_${arch}`;
}
private constructor() {
super();
const suffix = RustSecurityBridge.getPlatformSuffix();
const localPaths: string[] = [];
// dist_rust/ candidates (tsrust cross-compiled output)
if (suffix) {
localPaths.push(plugins.path.join(paths.packageDir, 'dist_rust', `mailer-bin_${suffix}`));
}
localPaths.push(plugins.path.join(paths.packageDir, 'dist_rust', 'mailer-bin'));
// Local dev build paths
localPaths.push(plugins.path.join(paths.packageDir, 'rust', 'target', 'release', 'mailer-bin'));
localPaths.push(plugins.path.join(paths.packageDir, 'rust', 'target', 'debug', 'mailer-bin'));
this.bridge = new plugins.smartrust.RustBridge<TMailerCommands>({
binaryName: 'mailer-bin',
cliArgs: ['--management'],
requestTimeoutMs: 30_000,
readyTimeoutMs: 10_000,
localPaths: [
plugins.path.join(paths.packageDir, 'dist_rust', 'mailer-bin'),
plugins.path.join(paths.packageDir, 'rust', 'target', 'release', 'mailer-bin'),
plugins.path.join(paths.packageDir, 'rust', 'target', 'debug', 'mailer-bin'),
],
localPaths,
searchSystemPath: false,
});