ci: revive cross compile
This commit is contained in:
parent
de53837679
commit
009e09e5e6
44
.github/workflows/arm64-alpine.yml
vendored
44
.github/workflows/arm64-alpine.yml
vendored
@ -1,44 +0,0 @@
|
||||
name: Build Node binaries for Alpine (arm64)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
alpine:
|
||||
runs-on: linux-arm64
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target-node: [14, 16, 18, 19]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
build-args: |
|
||||
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
|
||||
PKG_FETCH_OPTION_p=alpine
|
||||
context: .
|
||||
file: ./Dockerfile.alpine
|
||||
outputs: type=tar,dest=../out.tar
|
||||
|
||||
- name: Extract binaries from Docker image
|
||||
run: |
|
||||
tar xvf ../out.tar root/pkg-fetch/dist
|
||||
|
||||
- name: Check if binary is compiled
|
||||
id: check_file
|
||||
run: |
|
||||
(test -f root/pkg-fetch/dist/*.sha256sum && echo ::set-output name=EXISTS::true) || echo ::set-output name=EXISTS::false
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: steps.check_file.outputs.EXISTS == 'true'
|
||||
with:
|
||||
name: node${{ matrix.target-node }}-alpine-arm64
|
||||
path: root/pkg-fetch/dist/*
|
||||
43
.github/workflows/arm64-linux.yml
vendored
43
.github/workflows/arm64-linux.yml
vendored
@ -1,43 +0,0 @@
|
||||
name: Build Node binaries for Linux (arm64)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
runs-on: linux-arm64
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target-node: [14, 16, 18, 19]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
build-args: |
|
||||
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
|
||||
context: .
|
||||
file: ./Dockerfile.linux
|
||||
outputs: type=tar,dest=../out.tar
|
||||
|
||||
- name: Extract binaries from Docker image
|
||||
run: |
|
||||
tar xvf ../out.tar root/pkg-fetch/dist
|
||||
|
||||
- name: Check if binary is compiled
|
||||
id: check_file
|
||||
run: |
|
||||
(test -f root/pkg-fetch/dist/*.sha256sum && echo ::set-output name=EXISTS::true) || echo ::set-output name=EXISTS::false
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: steps.check_file.outputs.EXISTS == 'true'
|
||||
with:
|
||||
name: node${{ matrix.target-node }}-linux-arm64
|
||||
path: root/pkg-fetch/dist/*
|
||||
55
.github/workflows/arm64-linuxstatic.yml
vendored
55
.github/workflows/arm64-linuxstatic.yml
vendored
@ -1,55 +0,0 @@
|
||||
name: Build Node binaries for Linux static (arm64)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
linuxstatic:
|
||||
runs-on: linux-arm64
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target-node: [14, 16, 18, 19]
|
||||
target-arch: [arm64]
|
||||
include:
|
||||
- target-arch: arm64
|
||||
docker-platform: linux/arm64
|
||||
- target-node: 16
|
||||
target-arch: armv7
|
||||
docker-platform: linux/arm/v7
|
||||
- target-node: 18
|
||||
target-arch: armv7
|
||||
docker-platform: linux/arm/v7
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
build-args: |
|
||||
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
|
||||
PKG_FETCH_OPTION_p=linuxstatic
|
||||
context: .
|
||||
file: ./Dockerfile.alpine
|
||||
platforms: ${{ matrix.docker-platform }}
|
||||
outputs: type=tar,dest=../out.tar
|
||||
|
||||
- name: Extract binaries from Docker image
|
||||
run: |
|
||||
tar xvf ../out.tar root/pkg-fetch/dist
|
||||
|
||||
- name: Check if binary is compiled
|
||||
id: check_file
|
||||
run: |
|
||||
(test -f root/pkg-fetch/dist/*.sha256sum && echo ::set-output name=EXISTS::true) || echo ::set-output name=EXISTS::false
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: steps.check_file.outputs.EXISTS == 'true'
|
||||
with:
|
||||
name: node${{ matrix.target-node }}-linuxstatic-${{ matrix.target-arch }}
|
||||
path: root/pkg-fetch/dist/*
|
||||
35
.github/workflows/arm64-macos.yml
vendored
35
.github/workflows/arm64-macos.yml
vendored
@ -1,35 +0,0 @@
|
||||
name: Build Node binaries for macOS (arm64)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
macos-arm64:
|
||||
runs-on: macos-arm64
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: arch -arch arm64e bash -l -eo pipefail {0}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target-node: [14, 16, 18, 19]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: yarn install
|
||||
|
||||
- run: yarn start --node-range node${{ matrix.target-node }} --output dist
|
||||
|
||||
- name: Check if binary is compiled
|
||||
id: check_file
|
||||
run: |
|
||||
(test -f dist/*.sha256sum && echo ::set-output name=EXISTS::true) || echo ::set-output name=EXISTS::false
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: steps.check_file.outputs.EXISTS == 'true'
|
||||
with:
|
||||
name: node${{ matrix.target-node }}-macos-arm64
|
||||
path: dist/*
|
||||
14
.github/workflows/build-alpine.yml
vendored
14
.github/workflows/build-alpine.yml
vendored
@ -11,6 +11,14 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target-node: [14, 16, 18, 19]
|
||||
target-arch: [x64, arm64]
|
||||
include:
|
||||
- target-arch: x64
|
||||
target-triple: x86_64-linux-musl
|
||||
host-arch: x86_64
|
||||
- target-arch: arm64
|
||||
target-triple: aarch64-linux-musl
|
||||
host-arch: x86_64
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -22,10 +30,14 @@ jobs:
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
build-args: |
|
||||
HOST_ARCH=${{ matrix.host-arch }}
|
||||
TARGET_TRIPLE=${{ matrix.target-triple }}
|
||||
PKG_FETCH_OPTION_a=${{ matrix.target-arch }}
|
||||
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
|
||||
PKG_FETCH_OPTION_p=alpine
|
||||
context: .
|
||||
file: ./Dockerfile.alpine
|
||||
platforms: linux/amd64
|
||||
outputs: type=tar,dest=../out.tar
|
||||
|
||||
- name: Extract binaries from Docker image
|
||||
@ -40,5 +52,5 @@ jobs:
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: steps.check_file.outputs.EXISTS == 'true'
|
||||
with:
|
||||
name: node${{ matrix.target-node }}-alpine-x64
|
||||
name: node${{ matrix.target-node }}-alpine-${{ matrix.target-arch }}
|
||||
path: root/pkg-fetch/dist/*
|
||||
|
||||
44
.github/workflows/build-linux.yml
vendored
44
.github/workflows/build-linux.yml
vendored
@ -4,7 +4,7 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
linux-x64:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
strategy:
|
||||
@ -25,6 +25,7 @@ jobs:
|
||||
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
|
||||
context: .
|
||||
file: ./Dockerfile.linux
|
||||
platforms: linux/amd64
|
||||
outputs: type=tar,dest=../out.tar
|
||||
|
||||
- name: Extract binaries from Docker image
|
||||
@ -41,3 +42,44 @@ jobs:
|
||||
with:
|
||||
name: node${{ matrix.target-node }}-linux-x64
|
||||
path: root/pkg-fetch/dist/*
|
||||
|
||||
linux-arm64:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target-node: [14, 16, 18, 19]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
build-args: |
|
||||
TARGET_TOOLCHAIN_ARCH=aarch64
|
||||
PKG_FETCH_OPTION_a=arm64
|
||||
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
|
||||
context: .
|
||||
file: ./Dockerfile.linuxcross
|
||||
platforms: linux/amd64
|
||||
outputs: type=tar,dest=../out.tar
|
||||
|
||||
- name: Extract binaries from Docker image
|
||||
run: |
|
||||
tar xvf ../out.tar root/pkg-fetch/dist
|
||||
|
||||
- name: Check if binary is compiled
|
||||
id: check_file
|
||||
run: |
|
||||
(test -f root/pkg-fetch/dist/*.sha256sum && echo ::set-output name=EXISTS::true) || echo ::set-output name=EXISTS::false
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: steps.check_file.outputs.EXISTS == 'true'
|
||||
with:
|
||||
name: node${{ matrix.target-node }}-linux-arm64
|
||||
path: root/pkg-fetch/dist/*
|
||||
|
||||
17
.github/workflows/build-linuxstatic.yml
vendored
17
.github/workflows/build-linuxstatic.yml
vendored
@ -11,6 +11,17 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target-node: [14, 16, 18, 19]
|
||||
target-arch: [x64, arm64, armv7]
|
||||
include:
|
||||
- target-arch: x64
|
||||
target-triple: x86_64-linux-musl
|
||||
host-arch: x86_64
|
||||
- target-arch: arm64
|
||||
target-triple: aarch64-linux-musl
|
||||
host-arch: x86_64
|
||||
- target-arch: armv7
|
||||
target-triple: armv7l-linux-musleabihf
|
||||
host-arch: i686
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -22,10 +33,14 @@ jobs:
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
build-args: |
|
||||
HOST_ARCH=${{ matrix.host-arch }}
|
||||
TARGET_TRIPLE=${{ matrix.target-triple }}
|
||||
PKG_FETCH_OPTION_a=${{ matrix.target-arch }}
|
||||
PKG_FETCH_OPTION_n=node${{ matrix.target-node }}
|
||||
PKG_FETCH_OPTION_p=linuxstatic
|
||||
context: .
|
||||
file: ./Dockerfile.alpine
|
||||
platforms: linux/amd64
|
||||
outputs: type=tar,dest=../out.tar
|
||||
|
||||
- name: Extract binaries from Docker image
|
||||
@ -40,5 +55,5 @@ jobs:
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: steps.check_file.outputs.EXISTS == 'true'
|
||||
with:
|
||||
name: node${{ matrix.target-node }}-linuxstatic-x64
|
||||
name: node${{ matrix.target-node }}-linuxstatic-${{ matrix.target-arch }}
|
||||
path: root/pkg-fetch/dist/*
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
FROM alpine
|
||||
ARG HOST_ARCH=x86_64
|
||||
ARG TARGET_TRIPLE=aarch64-linux-musl
|
||||
|
||||
FROM muslcc/$HOST_ARCH:$TARGET_TRIPLE
|
||||
|
||||
ARG PKG_FETCH_OPTION_a
|
||||
ARG PKG_FETCH_OPTION_n
|
||||
ARG PKG_FETCH_OPTION_p
|
||||
|
||||
@ -7,15 +11,29 @@ USER root:root
|
||||
|
||||
WORKDIR /root/pkg-fetch/
|
||||
|
||||
RUN apk add --no-cache build-base linux-headers npm pythonispython3 python3 yarn
|
||||
RUN apk add --no-cache build-base git linux-headers npm pythonispython3 python3 yarn
|
||||
|
||||
# https://gitlab.alpinelinux.org/alpine/aports/-/issues/8626
|
||||
ENV CFLAGS=-U_FORTIFY_SOURCE
|
||||
ENV CFLAGS_host=-U_FORTIFY_SOURCE
|
||||
ENV CXXFLAGS=-U_FORTIFY_SOURCE
|
||||
ENV LDFLAGS=-Wl,-no-pie
|
||||
ENV CXXFLAGS_host=-U_FORTIFY_SOURCE
|
||||
|
||||
ENV CC=/bin/gcc
|
||||
ENV CXX=/bin/g++
|
||||
ENV AR=/bin/ar
|
||||
ENV NM=/bin/nm
|
||||
ENV READELF=/bin/readelf
|
||||
ENV STRIP=/bin/strip
|
||||
|
||||
ENV CC_host=/usr/bin/gcc
|
||||
ENV CXX_host=/usr/bin/g++
|
||||
ENV AR_host=/usr/bin/ar
|
||||
ENV NM_host=/usr/bin/nm
|
||||
ENV READELF_host=/usr/bin/readelf
|
||||
|
||||
COPY . ./
|
||||
|
||||
RUN yarn install
|
||||
|
||||
RUN yarn start --node-range $PKG_FETCH_OPTION_n --platform $PKG_FETCH_OPTION_p --output dist
|
||||
RUN yarn start --arch $PKG_FETCH_OPTION_a --node-range $PKG_FETCH_OPTION_n --platform $PKG_FETCH_OPTION_p --output dist
|
||||
|
||||
42
Dockerfile.linuxcross
Normal file
42
Dockerfile.linuxcross
Normal file
@ -0,0 +1,42 @@
|
||||
FROM ubuntu:bionic
|
||||
|
||||
USER root:root
|
||||
WORKDIR /root/pkg-fetch/
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y curl software-properties-common
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
|
||||
RUN apt-get install -y nodejs
|
||||
|
||||
RUN apt-get install -y binutils g++-8 git make patch python3 python3-distutils
|
||||
|
||||
ARG TARGET_TOOLCHAIN_ARCH
|
||||
|
||||
RUN [ `uname -m` = ${TARGET_TOOLCHAIN_ARCH} ] || \
|
||||
apt-get install -y binutils-${TARGET_TOOLCHAIN_ARCH}-linux-gnu g++-8-${TARGET_TOOLCHAIN_ARCH}-linux-gnu
|
||||
|
||||
ENV CC=${TARGET_TOOLCHAIN_ARCH}-linux-gnu-gcc-8
|
||||
ENV CXX=${TARGET_TOOLCHAIN_ARCH}-linux-gnu-g++-8
|
||||
ENV AR=${TARGET_TOOLCHAIN_ARCH}-linux-gnu-ar
|
||||
ENV NM=${TARGET_TOOLCHAIN_ARCH}-linux-gnu-nm
|
||||
ENV RANLIB=${TARGET_TOOLCHAIN_ARCH}-linux-gnu-ranlib
|
||||
ENV READELF=${TARGET_TOOLCHAIN_ARCH}-linux-gnu-readelf
|
||||
ENV STRIP=${TARGET_TOOLCHAIN_ARCH}-linux-gnu-strip
|
||||
ENV CC_host=gcc-8
|
||||
ENV CXX_host=g++-8
|
||||
ENV AR_host=ar
|
||||
ENV NM_host=nm
|
||||
ENV RANLIB_host=ranlib
|
||||
ENV READELF_host=readelf
|
||||
|
||||
RUN npm install -g yarn
|
||||
|
||||
COPY . ./
|
||||
|
||||
RUN yarn install
|
||||
|
||||
ARG PKG_FETCH_OPTION_a
|
||||
ARG PKG_FETCH_OPTION_n
|
||||
|
||||
RUN yarn start --arch $PKG_FETCH_OPTION_a --node-range $PKG_FETCH_OPTION_n --output dist
|
||||
@ -238,6 +238,15 @@ async function compileOnUnix(
|
||||
args.push('--dest-cpu', cpu);
|
||||
}
|
||||
|
||||
if (targetArch === 'armv7') {
|
||||
const { CFLAGS = '', CXXFLAGS = '' } = process.env;
|
||||
process.env.CFLAGS = `${CFLAGS} -marm -mcpu=cortex-a7`;
|
||||
process.env.CXXFLAGS = `${CXXFLAGS} -marm -mcpu=cortex-a7`;
|
||||
|
||||
args.push('--with-arm-float-abi=hard');
|
||||
args.push('--with-arm-fpu=vfpv3');
|
||||
}
|
||||
|
||||
if (hostArch !== targetArch) {
|
||||
log.warn('Cross compiling!');
|
||||
log.warn('You are responsible for appropriate env like CC, CC_host, etc.');
|
||||
|
||||
@ -76,14 +76,52 @@ function getKnownPlatforms() {
|
||||
}
|
||||
|
||||
export function toFancyArch(arch: string) {
|
||||
if (arch === 'arm') return 'armv7';
|
||||
if (arch === 'ia32') return 'x86';
|
||||
if (arch === 'x86_64') return 'x64';
|
||||
return arch;
|
||||
}
|
||||
|
||||
function getArmUnameArch() {
|
||||
const uname = spawnSync('uname', ['-a']);
|
||||
|
||||
if (uname.error) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let unameOut = uname.stdout && uname.stdout.toString();
|
||||
unameOut = (unameOut || '').toLowerCase();
|
||||
|
||||
if (unameOut.includes('aarch64')) return 'arm64';
|
||||
if (unameOut.includes('arm64')) return 'arm64';
|
||||
if (unameOut.includes('armv7')) return 'armv7';
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getArmHostArch() {
|
||||
const cpu = fs.readFileSync('/proc/cpuinfo', 'utf8');
|
||||
|
||||
if (cpu.indexOf('vfpv3') >= 0) {
|
||||
return 'armv7';
|
||||
}
|
||||
|
||||
let name = cpu.split('model name')[1];
|
||||
|
||||
if (name) [, name] = name.split(':');
|
||||
if (name) [name] = name.split('\n');
|
||||
if (name && name.indexOf('ARMv7') >= 0) return 'armv7';
|
||||
|
||||
return 'armv6';
|
||||
}
|
||||
|
||||
function getHostArch() {
|
||||
return toFancyArch(process.arch);
|
||||
const { arch } = process;
|
||||
|
||||
if (arch === 'arm') {
|
||||
return getArmUnameArch() || getArmHostArch();
|
||||
}
|
||||
|
||||
return toFancyArch(arch);
|
||||
}
|
||||
|
||||
function getTargetArchs() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user