2022-08-02 00:11:51 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# shellcheck disable=SC1004
|
|
|
|
|
|
|
|
#
|
|
|
|
# Copyright 2022 Signal Messenger, LLC.
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
#
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
SCRIPT_DIR=$(dirname "$0")
|
|
|
|
cd "${SCRIPT_DIR}"/..
|
|
|
|
|
|
|
|
DOCKER_IMAGE=libsignal-node-builder
|
|
|
|
|
2022-08-23 21:42:03 +02:00
|
|
|
IS_TTY=""
|
|
|
|
if [[ -t 0 ]]; then
|
|
|
|
IS_TTY="yes"
|
|
|
|
fi
|
|
|
|
|
2024-06-21 02:35:29 +02:00
|
|
|
docker build --build-arg "UID=${UID:-501}" --build-arg "GID=${GID:-501}" --build-arg "NODE_VERSION=$(cat .nvmrc)" -t ${DOCKER_IMAGE} -f node/Dockerfile .
|
2022-08-02 00:11:51 +02:00
|
|
|
|
|
|
|
# We build both architectures in the same run action to save on intermediates
|
|
|
|
# (including downloading dependencies)
|
2024-01-11 01:14:40 +01:00
|
|
|
# We run `yarn install` to make sure the correct prebuildify version is used.
|
2022-08-23 21:42:03 +02:00
|
|
|
docker run ${IS_TTY:+ -it} --init --rm -v "${PWD}":/home/libsignal/src ${DOCKER_IMAGE} sh -c '
|
2022-08-02 00:11:51 +02:00
|
|
|
cd ~/src/node &&
|
node: Remove "install" script that invokes node-gyp-build
- For local development, this built the Rust library automatically
when you invoked `yarn install`, whether you wanted it to or not.
- For the published package, this either did nothing (if the correct
prebuilds were present) or produced a weird error (if they weren't).
You can't use the published package without prebuilds, so maybe this
was useful, but you'd find that out pretty quickly when loading the
module failed.
- If you used the "link" feature to build Signal Desktop with a local
checkout of libsignal, this would build the Rust library
automatically when you `install`ed in the *Desktop* directory,
whether you wanted it to or not.
- If you pointed Signal Desktop at a local checkout by copy instead of
link, this would just fail, because the Rust parts wouldn't be
copied with it.
Overall, it's simpler to just have this step be explicit.
2024-07-10 02:13:40 +02:00
|
|
|
npx yarn install --frozen-lockfile &&
|
2022-08-02 00:11:51 +02:00
|
|
|
env CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
|
|
|
|
CC=aarch64-linux-gnu-gcc \
|
|
|
|
CXX=aarch64-linux-gnu-g++ \
|
|
|
|
CPATH=/usr/aarch64-linux-gnu/include \
|
2024-06-21 02:35:29 +02:00
|
|
|
npx prebuildify --napi -t $(cat ../.nvmrc) --arch arm64 &&
|
2024-06-22 00:55:20 +02:00
|
|
|
mv build/Release/*-debuginfo.* . &&
|
|
|
|
npx prebuildify --napi -t $(cat ../.nvmrc) --arch x64 &&
|
|
|
|
mv build/Release/*-debuginfo.* .
|
2022-08-02 00:11:51 +02:00
|
|
|
'
|