Skip to content
Open
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
35 changes: 26 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,49 @@ on:
branches:
- main

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
NODE_VERSION: "v18.16.1"

jobs:
build:
strategy:
fail-fast: false
fail-fast: true
matrix:
arch: [x64]
os: [macos-latest, ubuntu-latest, windows-2019]
include:
- arch: x64
os: macos-latest
- arch: x64
os: windows-2019
- arch: x64
os: ubuntu-latest

- arch: x86
os: windows-2019
# https://github.com/nodejs/node/issues/33019
# - arch: x86
# os: ubuntu-latest

# - arch: armv7
# os: ubuntu-latest
- arch: arm64
os: ubuntu-latest
runs-on: ${{ matrix.os }}
env:
TARGET_ARCH: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v2
- name: Download source code
shell: bash
run: ./scripts/download.sh
- name: Build
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
./scripts/build-linux.sh
elif [ "$RUNNER_OS" == "Windows" ]; then
./scripts/build-windows.sh
else
./scripts/build-macos.sh
fi
run: ./scripts/build.sh
- name: Upload artifacts
uses: actions/upload-artifact@v2.3.1
with:
Expand Down
13 changes: 13 additions & 0 deletions patches/configure.py.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/configure.py b/configure.py
index 40e0395..b70d238 100755
--- a/configure.py
+++ b/configure.py
@@ -1296,7 +1296,7 @@ def configure_node(o):

# Enable branch protection for arm64
if target_arch == 'arm64':
- o['cflags']+=['-msign-return-address=all']
+ # o['cflags']+=['-msign-return-address=all']
o['variables']['arm_fpu'] = options.arm_fpu or 'neon'

if options.node_snapshot_main is not None:
11 changes: 0 additions & 11 deletions scripts/build-linux.sh

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/build-windows.sh

This file was deleted.

18 changes: 18 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -ex

. "$(dirname "$0")"/prepare-env.sh
SCRIPTS_DIR=$WORKSPACE/scripts
cd $WORKSPACE/node

if [[ "$RUNNER_OS" == "Linux" ]]; then
TARGET_OS="linux"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
TARGET_OS="macos"
elif [[ "$RUNNER_OS" == "Windows" ]]; then
TARGET_OS="win"
else
echo "Unknown OS: $RUNNER_OS"
exit 1
fi
. $SCRIPTS_DIR/build/$TARGET_OS.sh
32 changes: 32 additions & 0 deletions scripts/build/linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -ex

export CC_host=gcc
export CXX_host=g++

if [[ "$TARGET_ARCH" == "x64" ]]; then
./configure --prefix=$OUTPUT_PREFIX --shared --no-cross-compiling
else
DEST_CPU=$TARGET_ARCH
if [[ "$TARGET_ARCH" == "armv7" ]]; then
DEST_CPU="arm"
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
# FIXME: gcc-multilib conflicts.
# libstdc++-6-dev-armhf-cross gcc-multilib g++-multilib
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
elif [[ "$TARGET_ARCH" == "x86" ]]; then
sudo apt-get install gcc-multilib g++-multilib
elif [[ "$TARGET_ARCH" == "arm64" ]]; then
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
export CC=aarch64-linux-gnu-gcc
export CXX=aarch64-linux-gnu-g++
fi
patch -p1 < $WORKSPACE/patches/configure.py.patch
./configure --prefix=$OUTPUT_PREFIX --shared \
--cross-compiling --dest-cpu=$DEST_CPU --dest-os=linux
fi

make -j`nproc`
make install
cp ./LICENSE "${OUTPUT_PREFIX}/LICENSE"
4 changes: 0 additions & 4 deletions scripts/build-macos.sh → scripts/build/macos.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/bin/bash
set -ex

brew install coreutils
. "$(dirname "$0")"/prepare-env.sh
cd ./node

./configure --prefix=$OUTPUT_PREFIX --shared

make -j`sysctl -n hw.ncpu`
Expand Down
9 changes: 9 additions & 0 deletions scripts/build/win.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -ex

choco install nasm

./vcbuild.bat release dll package ${TARGET_ARCH}

mv ./out/Release/node-${NODE_VERSION}-win-${TARGET_ARCH} "${OUTPUT_PREFIX}/"
cp ./LICENSE "${OUTPUT_PREFIX}/LICENSE"
5 changes: 5 additions & 0 deletions scripts/prepare-env.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
set -ex

if [[ "$RUNNER_OS" == "macOS" ]]; then
brew install coreutils
TARGET_OS="linux"
fi

export WORKSPACE=$(realpath "$(dirname "$0")"/..)
export OUTPUT_PREFIX="${WORKSPACE}/artifacts"
mkdir -p "${OUTPUT_PREFIX}"