update builder

This commit is contained in:
Raven Scott
2026-02-21 03:00:12 -05:00
parent eb0589fdba
commit 12dc56d940
4 changed files with 55 additions and 6 deletions
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env node
/**
* Build script for the native host.
* Generates the bridge-swarm-host launcher script.
*/
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
const nativeHostDir = path.join(__dirname, '..', 'native-host');
const launcherPath = path.join(nativeHostDir, 'bridge-swarm-host');
// Find node path
const nodeBin = process.execPath;
// Try to find bare - check common locations
let bareBin = null;
try {
bareBin = execSync('which bare', { encoding: 'utf8' }).trim();
} catch (e) {}
if (!bareBin) {
// Try common paths on macOS
for (const p of ['/opt/homebrew/bin/bare', '/usr/local/bin/bare']) {
try {
fs.accessSync(p, fs.constants.X_OK);
bareBin = p;
break;
} catch (e) {}
}
}
if (!bareBin) {
// Fall back to node's sibling
bareBin = nodeBin.replace(/node$/, 'bare');
}
const launcherContent = `#!/usr/bin/env bash
DIR="$(cd "$(dirname "$0")" && pwd)"
exec "${bareBin}" "$DIR/index.mjs" "$@"
`;
fs.writeFileSync(launcherPath, launcherContent);
fs.chmodSync(launcherPath, '755');
console.log('Native host launcher generated at:', launcherPath);
console.log('Using bare:', bareBin);