Skip to content

Commit

Permalink
feat: electron build v32.2.5 complete
Browse files Browse the repository at this point in the history
  • Loading branch information
darkyzhou committed Nov 21, 2024
1 parent c0cea46 commit 16c7db8
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 9 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ on:
required: true
default: "14.2.0"
description: Gcc version to compile
libffiVersion:
type: string
required: true
default: "3.4.6"
description: Libffi version to compile
imageTag:
type: string
required: true
Expand Down Expand Up @@ -56,6 +61,32 @@ jobs:
name: libgcc
path: dist/libgcc.tar.gz

libffi:
runs-on: self-hosted
container:
image: ghcr.io/darkyzhou/electron-build-runner:latest
steps:
- uses: actions/checkout@v4
- name: Build libffi
uses: docker/build-push-action@v5
with:
load: true
tags: libffi:latest
file: Dockerfile.libffi
build-args: |
GCC_VERSION=${{ inputs.gccVersion }}
- name: Extract libffi Artifact
uses: shrink/actions-docker-extract@v3
with:
image: libffi:latest
path: /root/build/libffi.tar.gz
destination: dist
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: libffi
path: dist/libffi.tar.gz

rustc:
runs-on: self-hosted
container:
Expand Down Expand Up @@ -88,6 +119,7 @@ jobs:
builder:
needs:
- libgcc
- libffi
- rustc
runs-on: self-hosted
container:
Expand Down
23 changes: 15 additions & 8 deletions .github/workflows/electron.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Build Electron

env:
ROOT_PATH: /home/builduser/buildroot
SRC_PATH: /home/builduser/buildroot/src
OUT_PATH: /home/builduser/buildroot/src/out/Release

on:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -27,9 +32,9 @@ jobs:
run: |
set -ex
export REPO_PATH=`pwd`
cd /home/builduser/buildroot
cd "$ROOT_PATH"
if [ ! -d "src/electron" ]; then
npx e init -i release -r /home/builduser/buildroot electron-loong64
npx e init -i release -r "$ROOT_PATH" electron-loong64
git clone https://github.com/electron/electron.git src/electron
fi
git -C src clean -fd || true
Expand Down Expand Up @@ -65,9 +70,10 @@ jobs:
- name: Build Electron
run: |
set -ex
cd /home/builduser/buildroot/src
gn gen out/Release --args="import(\"//electron/build/args/release.gn\")" --script-executable=/usr/bin/python3
ninja -C out/Release/ electron
cd "$SRC_PATH"
rm -f "$OUT_PATH"/electron
gn gen "$OUT_PATH" --args="import(\"//electron/build/args/release.gn\")" --script-executable=/usr/bin/python3
ninja -C "$OUT_PATH" electron
env:
CC: clang
CXX: clang++
Expand All @@ -77,12 +83,13 @@ jobs:
- name: Package Electron
run: |
set -ex
cd /home/builduser/buildroot/src
ninja -C out/Release/ electron:electron_dist_zip
cd "$SRC_PATH"
electron/script/strip-binaries.py -d "$OUT_PATH"
ninja -C "$OUT_PATH" electron:electron_dist_zip
- name: Upload Artifact
uses: svenstaro/upload-release-action@v2
with:
file: /home/builduser/buildroot/src/out/Release/dist.zip
file: ${{ env.OUT_PATH }}/dist.zip
asset_name: electron-v${{ inputs.electronVersion }}-linux-loong64.zip
release_name: Electron v${{ inputs.electronVersion }} port for LoongArch64
overwrite: true
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,15 @@ RUN curl -L -O https://unofficial-builds.nodejs.org/download/release/v${NODE_VER
rm -rf node-v${NODE_VERSION}-linux-loong64* && \
npm i -g yarn @esbuild/linux-loong64@0.14.54

COPY libgcc.tar.gz rustc.tar.gz .
COPY libgcc.tar.gz libffi.tar.gz rustc.tar.gz .
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN mkdir libgcc && \
tar -xzvf libgcc.tar.gz -C libgcc && \
# Replacing the crtbeginS.o is hacky, we might need to build the whole gcc instead
cp libgcc/gcc/loongarch64-unknown-linux-gnu/*/crtbeginS.o /usr/lib/gcc/loongarch64-linux-gnu/*/ && \
tar -xzvf libffi.tar.gz -C libffi && \
# Also hacky here
cp libffi/libffi_convenience.a /usr/lib/loongarch64-linux-gnu/libffi_pic.a && \
tar -xzvf rustc.tar.gz -C /usr && \
# Chromium seems to require that bindgen binary lives together with llvm
cargo install bindgen-cli@0.69.1 --root /usr/lib/llvm-19
Expand Down
29 changes: 29 additions & 0 deletions Dockerfile.libffi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM ghcr.io/darkyzhou/loong64-debian:latest

ARG LIBFFI_VERSION="3.4.6"

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
build-essential \
binutils \
autoconf \
automake \
libtool \
pkg-config

WORKDIR /root
RUN curl -LO https://github.com/libffi/libffi/releases/download/v${LIBFFI_VERSION}/libffi-${LIBFFI_VERSION}.tar.gz && \
tar xf libffi-${LIBFFI_VERSION}.tar.gz

WORKDIR /root/build
RUN /root/libffi-${LIBFFI_VERSION}/configure \
CFLAGS="-mcmodel=medium" \
--prefix=/root/build/out \
--enable-pax_emutramp \
--enable-static \
--disable-docs && \
make libffi_convenience.la && \
tar czf libffi.tar.gz --directory=.libs .

0 comments on commit 16c7db8

Please sign in to comment.