Skip to content
This repository was archived by the owner on May 23, 2021. It is now read-only.

ARM compilation support #25

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,17 @@ before_install:
matrix:
include:
- os: linux
arch: amd64
env:
- TARGET="alpine"
- os: linux
arch: amd64
env:
- TARGET="armv7hf-alpine"
- os: linux
env:
- TARGET="aarch64-alpine"
- os: linux
env:
- TARGET="aarch64"
- os: linux
env:
- TARGET="armv7hf"
- TARGET="centos"
- os: linux
arch: arm64
env:
- TARGET="centos"
- TARGET="raspbian"
- os: osx
script: scripts/ci.sh
deploy:
Expand Down
7 changes: 0 additions & 7 deletions aarch64-alpine.dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions aarch64.dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions armhf-alpine.dockerfile

This file was deleted.

7 changes: 0 additions & 7 deletions armhf.dockerfile

This file was deleted.

14 changes: 14 additions & 0 deletions raspbian.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# WARNING: This requires qemu-user-static.
# Please grab that docker image first before building it on a x86 host!

FROM raspbian/jessie:latest

ENV PATH "$PATH:/root/node/bin"

RUN apt-get update && \
apt-get install build-essential;

RUN mkdir -p /root/node && \
cd /root/node && curl https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz | tar xJ --strip-components=1 -- && \
ln -s /root/node/bin/node /usr/bin/node && \
npm i -g yarn;
114 changes: 42 additions & 72 deletions scripts/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,83 +5,53 @@ set -eoux pipefail
cd "$(dirname "$0")"
source ./vars.sh

ARCH=$(uname -m)

# Variables to be set:
# $CACHE_DIR
# $IMAGE
# $PREBUILD_COMMAND
# $BINARY_NAME
function docker_build() {
case "$IMAGE" in
*armv7hf* | armv7hf | aarch64 | *aarch64*)
containerID=$(docker create -it -v $HOME/$CACHE_DIR:/ccache $IMAGE)
docker start $containerID
docker exec $containerID mkdir /src

function exec() {
docker exec $containerID bash -c "$@"
}

docker cp ../. $containerID:/src
exec "cross-build-start"
exec "$PREBUILD_COMMAND/src/lib/node/build.sh"
exec "cd /src && npm rebuild"
exec "cd /src && npm test"
exec "cross-build-end"
docker cp $containerID:/src/lib/node/out/Release/node ../build/$PACKAGE_VERSION/$BINARY_NAME
;;
*)
containerID=$(docker create -it -v $HOME/$CACHE_DIR:/ccache $IMAGE)
docker start $containerID
docker exec $containerID mkdir /src

function exec() {
docker exec $containerID bash -c "$@"
}

docker cp ../. $containerID:/src
exec "$PREBUILD_COMMAND/src/lib/node/build.sh"
exec "cd /src && npm rebuild"
exec "cd /src && npm test"
docker cp $containerID:/src/lib/node/out/Release/node ../build/$PACKAGE_VERSION/$BINARY_NAME
;;
esac
containerID=$(docker create -it -v $HOME/$CACHE_DIR:/ccache $IMAGE)
docker start $containerID
docker exec $containerID mkdir /src

function exec() {
docker exec $containerID bash -c "$@"
}

docker cp ../. $containerID:/src
exec "$PREBUILD_COMMAND/src/lib/node/build.sh"
exec "cd /src && npm rebuild"
exec "cd /src && npm test"
docker cp $containerID:/src/lib/node/out/Release/node ../build/$PACKAGE_VERSION/$BINARY_NAME
}

if [[ "$TARGET" == "alpine" ]]; then
CACHE_DIR=".ccache-alpine"
IMAGE="codercom/nbin-alpine"
PREBUILD_COMMAND=""
BINARY_NAME="node-${NODE_VERSION}-alpine-x64"
docker_build
elif [[ "$TARGET" == "aarch64-alpine" ]]; then
CACHE_DIR=".ccache-alpine"
IMAGE="codercom/nbin-alpine-aarch64-alpine"
PREBUILD_COMMAND=""
BINARY_NAME="node-${NODE_VERSION}-alpine-aarch64"
docker_build
elif [[ "$TARGET" == "armv7hf-alpine" ]]; then
CACHE_DIR=".ccache-alpine"
IMAGE="codercom/nbin-alpine-armv7hf-alpine"
PREBUILD_COMMAND=""
BINARY_NAME="node-${NODE_VERSION}-alpine-armv7hf"
docker_build
elif [[ "$TARGET" == "aarch64" ]]; then
CACHE_DIR=".ccache-aarch64"
IMAGE="codercom/nbin-aarch64"
PREBUILD_COMMAND=""
BINARY_NAME="node-${NODE_VERSION}-aarch64"
docker_build
elif [[ "$TARGET" == "armv7hf" ]]; then
CACHE_DIR=".ccache-armv7hf"
IMAGE="codercom/nbin-armv7hf"
PREBUILD_COMMAND=""
BINARY_NAME="node-${NODE_VERSION}-armv7hf"
docker_build
else
CACHE_DIR=".ccache-centos"
IMAGE="codercom/nbin-centos"
PREBUILD_COMMAND="source /opt/rh/devtoolset-6/enable &&"
BINARY_NAME="node-${NODE_VERSION}-linux-x64"
docker_build
fi

case "$TARGET" in
alpine)
CACHE_DIR=".ccache-alpine"
IMAGE="codercom/nbin-alpine"
PREBUILD_COMMAND=""
BINARY_NAME="node-${NODE_VERSION}-${ARCH}"
docker_build
;;
centos)
CACHE_DIR=".ccache-centos"
IMAGE="codercom/nbin-centos"
PREBUILD_COMMAND="source /opt/rh/devtoolset-6/enable &&"
BINARY_NAME="node-${NODE_VERSION}-${ARCH}"
docker_build
;;
raspbian)
CACHE_DIR=".ccache-raspbian"
IMAGE="codercom/nbin-raspbian"
PREBUILD_COMMAND=""
BINARY_NAME="node-${NODE_VERSION}-${ARCH}"
docker_build
;;
*)
echo "Unsupported TARGET"
exit 127
;;
esac