build(gateway): use @discordjs/opus prebuilt instead of compiling from source
Drop npm_config_build_from_source=true so node-pre-gyp downloads the published prebuilt .node for Node 22 (ABI node-v127, linux-x64-glibc-2.35) instead of compiling libopus C++ every build. Replace the hardcoded 'npm run install' (node-gyp compile) loop with 'pnpm rebuild @discordjs/opus' which runs the package's own install script (prebuilt fetch, source build only as fallback). sharp already uses @img prebuilt packages (its install script failure is non-fatal), so only opus was actually compiling.
This commit is contained in:
@@ -48,8 +48,8 @@
|
|||||||
export GIT_SSL_CAINFO=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
export GIT_SSL_CAINFO=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
||||||
export NIX_SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
export NIX_SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
||||||
|
|
||||||
# pnpm uses node-gyp for native addons — provide build tools
|
# pnpm uses node-gyp for native addons — provide build tools (kept for
|
||||||
export npm_config_build_from_source=true
|
# the rare case a prebuilt is unavailable and it falls back to compile).
|
||||||
export CPPFLAGS="-I${pkgs.lib.getDev pkgs.openssl}/include"
|
export CPPFLAGS="-I${pkgs.lib.getDev pkgs.openssl}/include"
|
||||||
export LDFLAGS="-L${pkgs.lib.getLib pkgs.openssl}/lib"
|
export LDFLAGS="-L${pkgs.lib.getLib pkgs.openssl}/lib"
|
||||||
|
|
||||||
@@ -180,15 +180,15 @@ WRAPPER
|
|||||||
# pnpm rebuild aborts on the first failing package and runs scripts
|
# pnpm rebuild aborts on the first failing package and runs scripts
|
||||||
# from the wrong cwd — build each native dep explicitly with its own
|
# from the wrong cwd — build each native dep explicitly with its own
|
||||||
# install script. Each failure is tolerated (|| true); the packages
|
# install script. Each failure is tolerated (|| true); the packages
|
||||||
# that matter (opus) are verified at runtime.
|
# @discordjs/opus ships prebuilt binaries for Node 22 (ABI node-v127,
|
||||||
for pkg in \
|
# linux-x64-glibc-2.35) — node-pre-gyp downloads the prebuilt .node
|
||||||
node_modules/.pnpm/@discordjs+opus@*/node_modules/@discordjs/opus
|
# instead of compiling C++ from source. With build_from_source unset
|
||||||
do
|
# (above), `pnpm rebuild` runs the package's own install script which
|
||||||
if [ -d "$pkg" ]; then
|
# fetches the matching prebuilt; it only falls back to a source build
|
||||||
echo "--- native build: $pkg ---"
|
# if the download fails. This keeps voice working without a per-build
|
||||||
(cd "$pkg" && npm run install 2>&1 || true)
|
# native compile.
|
||||||
fi
|
echo "=== Rebuilding @discordjs/opus (prebuilt download) ==="
|
||||||
done
|
pnpm rebuild @discordjs/opus 2>&1 || true
|
||||||
echo "=== Compiling TypeScript ===="
|
echo "=== Compiling TypeScript ===="
|
||||||
npx tsc 2>&1
|
npx tsc 2>&1
|
||||||
echo "=== Fixing @/ path aliases to relative paths ==="
|
echo "=== Fixing @/ path aliases to relative paths ==="
|
||||||
|
|||||||
Reference in New Issue
Block a user