From 246ae3f5e3eaeeddbfaa9256b237dffecfecbc4b Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 17 Feb 2024 23:41:42 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20build=20binaries=20for=20all=20t?= =?UTF-8?q?argets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/README.md | 10 +++++++--- pkg/build.js | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/pkg/README.md b/pkg/README.md index bffd6b148..bc0716b7d 100644 --- a/pkg/README.md +++ b/pkg/README.md @@ -8,9 +8,11 @@ The build process is otherwise defined entirely in `build.js`. ### List of native modules -- sqlite3 -- lancedb -- esbuild +- sqlite3/build/Release/node_sqlite3.node (\*) +- @lancedb/\*\* +- esbuild? +- @esbuild? +- onnxruntime-node? ### List of dynamically imported modules @@ -22,3 +24,5 @@ The build process is otherwise defined entirely in `build.js`. - tree-sitter.wasm - tree-sitter-wasms/ + +(\*) = need to download for each platform manually diff --git a/pkg/build.js b/pkg/build.js index f9b7eeb13..bd2926b0f 100644 --- a/pkg/build.js +++ b/pkg/build.js @@ -4,6 +4,11 @@ const fs = require("fs"); const ncp = require("ncp").ncp; const esbuildOutputFile = "out/index.js"; +const platforms = ["darwin", "linux", "win32"]; +const architectures = ["x64", "arm64"]; +const targets = platforms.flatMap((platform) => + architectures.map((arch) => `${platform}-${arch}`) +); let esbuildOnly = false; for (let i = 2; i < process.argv.length; i++) { @@ -86,10 +91,13 @@ for (let i = 2; i < process.argv.length; i++) { return; } - console.log("[info] Building binary with pkg..."); - execSync( - `npx pkg --no-bytecode --public-packages "*" --public pkgJson/darwin-arm64` - ); + console.log("[info] Building binaries with pkg..."); + for (const target of targets) { + console.log(`[info] Building ${target}...`); + execSync( + `npx pkg --no-bytecode --public-packages "*" --public pkgJson/${target} --out-path bin/${target}` + ); + } // execSync( // `npx pkg out/index.js --target node18-darwin-arm64 --no-bytecode --public-packages "*" --public -o bin/pkg` // );