Skip to content

Commit c0cea46

Browse files
committed
feat: electron building steps
1 parent d5a7bc4 commit c0cea46

File tree

6 files changed

+79
-39
lines changed

6 files changed

+79
-39
lines changed

.github/workflows/builder.yaml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
hostRustVersion:
1212
type: string
1313
required: true
14-
default: "18.2.0"
14+
default: "1.82.0"
1515
description: Host rustc version
1616
targetRustBranch:
1717
type: string
@@ -44,13 +44,13 @@ jobs:
4444
file: Dockerfile.libgcc
4545
build-args: |
4646
GCC_VERSION=${{ inputs.gccVersion }}
47-
- name: Extract libgcc artifact
47+
- name: Extract libgcc Artifact
4848
uses: shrink/actions-docker-extract@v3
4949
with:
5050
image: libgcc:latest
5151
path: /root/build/libgcc.tar.gz
5252
destination: dist
53-
- name: Upload artifact
53+
- name: Upload Artifact
5454
uses: actions/upload-artifact@v4
5555
with:
5656
name: libgcc
@@ -72,14 +72,14 @@ jobs:
7272
RUSTUP_VERSION=${{ inputs.rustupVersion }}
7373
HOST_RUST_VERSION=${{ inputs.hostRustVersion }}
7474
TARGET_RUST_BRANCH=${{ inputs.targetRustBranch }}
75-
- name: Extract artifact
75+
- name: Extract Artifact
7676
uses: shrink/actions-docker-extract@v3
7777
id: extract
7878
with:
7979
image: rustc:latest
8080
path: /root/rust/rustc.tar.gz
8181
destination: dist
82-
- name: Upload artifact
82+
- name: Upload Artifact
8383
uses: actions/upload-artifact@v4
8484
with:
8585
name: rustc
@@ -92,12 +92,26 @@ jobs:
9292
runs-on: self-hosted
9393
container:
9494
image: ghcr.io/darkyzhou/electron-build-runner:latest
95+
permissions:
96+
contents: read
97+
packages: write
9598
steps:
9699
- uses: actions/checkout@v4
97-
- name: Download artifacts
100+
- name: Download Artifacts
98101
uses: actions/download-artifact@v4
99-
- name: Build and push builder image
102+
with:
103+
path: .
104+
merge-multiple: true
105+
- name: Login to GitHub Container Registry
106+
uses: docker/login-action@v3
107+
with:
108+
registry: ghcr.io
109+
username: ${{ github.actor }}
110+
password: ${{ secrets.GITHUB_TOKEN }}
111+
- name: Build and Push Builder Image
100112
uses: docker/build-push-action@v6
101113
with:
102-
tags: darkyzhou/electron-loong64-builder:${{ inputs.imageTag }}
114+
push: true
115+
context: .
103116
file: Dockerfile.builder
117+
tags: ghcr.io/darkyzhou/electron-builder:${{ inputs.imageTag }}

.github/workflows/electron.yaml

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,87 @@ name: Build Electron
33
on:
44
workflow_dispatch:
55
inputs:
6-
electronBranch:
6+
builderImageTag:
77
type: string
88
required: true
9-
default: "v32.2.5"
10-
description: Branch of electron to build
9+
default: "electron-v32"
10+
description: Builder image tag
11+
electronVersion:
12+
type: string
13+
required: true
14+
default: "32.2.5"
15+
description: Version of electron to build
1116

1217
jobs:
13-
prepare-src:
18+
prepare:
1419
runs-on: self-hosted
1520
container:
1621
image: ghcr.io/darkyzhou/electron-buildtools:latest
1722
volumes:
18-
- /home/darkyzhou/data/build/electron-loong64:/home/builduser/buildroot
23+
- /home/darkyzhou/data/build/electron-loong64:/home/builduser
1924
steps:
2025
- uses: actions/checkout@v4
21-
with:
22-
path: repo
23-
- name: Sync sources
26+
- name: Patch Sources
2427
run: |
2528
set -ex
29+
export REPO_PATH=`pwd`
2630
cd /home/builduser/buildroot
2731
if [ ! -d "src/electron" ]; then
2832
npx e init -i release -r /home/builduser/buildroot electron-loong64
29-
git clone -b ${{ inputs.electronBranch }} https://github.com/electron/electron src/electron
33+
git clone https://github.com/electron/electron.git src/electron
3034
fi
3135
git -C src clean -fd || true
3236
git -C src am --abort || true
37+
git -C src/electron clean -fd
38+
git -C src/electron reset --hard HEAD
3339
git -C src/electron fetch origin --tags
34-
git -C src/electron switch --detach ${{ inputs.electronBranch }}
35-
git -C src/electron apply repo/electron.patch
36-
npx e sync -vvvv
40+
git -C src/electron switch --detach v${{ inputs.electronVersion }}
41+
git -C src/electron apply $REPO_PATH/electron.patch
42+
- name: Sync Dependencies
43+
run: |
44+
set -ex
45+
cd /home/builduser/buildroot
46+
rm -rf src/build/linux/debian_bullseye*
47+
npx e sync
3748
build:
38-
needs: prepare-src
49+
needs: prepare
3950
runs-on: self-hosted
51+
permissions:
52+
contents: read
53+
packages: write
4054
container:
41-
image: ghcr.io/darkyzhou/electron-builder:latest
55+
image: ghcr.io/darkyzhou/electron-builder:${{ inputs.builderImageTag }}
4256
volumes:
43-
- /home/darkyzhou/data/build/electron-loong64:/home/builduser/buildroot
57+
- /home/darkyzhou/data/build/electron-loong64:/home/builduser
4458
steps:
45-
- name: Replace binaries
59+
- name: Replace Binaries
4660
run: |
4761
set -ex
48-
cp /usr/local/lib/node_modules/@esbuild/linux-loong64/bin/esbuild /home/builduser/buildroot/src/third_party/devtools-frontend/src/third_party/esbuild/esbuild
4962
cp /usr/local/bin/node /home/builduser/buildroot/src/third_party/node/linux/node-linux-x64/bin/node
50-
- name: Generate ninja
63+
chmod +w /home/builduser/buildroot/src/third_party/devtools-frontend/src/third_party/esbuild/esbuild
64+
cp /usr/local/lib/node_modules/@esbuild/linux-loong64/bin/esbuild /home/builduser/buildroot/src/third_party/devtools-frontend/src/third_party/esbuild/esbuild
65+
- name: Build Electron
5166
run: |
5267
set -ex
5368
cd /home/builduser/buildroot/src
5469
gn gen out/Release --args="import(\"//electron/build/args/release.gn\")" --script-executable=/usr/bin/python3
70+
ninja -C out/Release/ electron
5571
env:
5672
CC: clang
5773
CXX: clang++
5874
AR: ar
5975
NM: nm
6076
RUSTC_BOOTSTRAP: 1
61-
- name: Build electron
77+
- name: Package Electron
6278
run: |
6379
set -ex
6480
cd /home/builduser/buildroot/src
81+
ninja -C out/Release/ electron:electron_dist_zip
82+
- name: Upload Artifact
83+
uses: svenstaro/upload-release-action@v2
84+
with:
85+
file: /home/builduser/buildroot/src/out/Release/dist.zip
86+
asset_name: electron-v${{ inputs.electronVersion }}-linux-loong64.zip
87+
release_name: Electron v${{ inputs.electronVersion }} port for LoongArch64
88+
overwrite: true
89+
tag: v${{ inputs.electronVersion }}

Dockerfile.builder

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ RUN apt-get update && \
3636
clang \
3737
llvm \
3838
llvm-dev \
39+
generate-ninja \
40+
ninja-build \
3941
lld \
4042
libclang-dev \
4143
libclang-rt-dev \
@@ -175,25 +177,23 @@ RUN apt-get update && \
175177
xcb \
176178
libdav1d-dev \
177179
libyuv-dev \
178-
179-
generate-ninja \
180-
ninja-build
180+
mesa-common-dev
181181

182182
RUN curl -L -O https://unofficial-builds.nodejs.org/download/release/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-loong64.tar.gz && \
183183
tar -xzf node-v${NODE_VERSION}-linux-loong64.tar.gz && \
184184
cp -R node-v${NODE_VERSION}-linux-loong64/* /usr/local/ && \
185185
rm -rf node-v${NODE_VERSION}-linux-loong64* && \
186186
npm i -g yarn @esbuild/linux-loong64@0.14.54
187187

188-
ADD libgcc rustc .
188+
COPY libgcc.tar.gz rustc.tar.gz .
189189
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
190190
RUN mkdir libgcc && \
191-
tar -xzvf libgcc -C libgcc && \
191+
tar -xzvf libgcc.tar.gz -C libgcc && \
192192
# Replacing the crtbeginS.o is hacky, we might need to build the whole gcc instead
193-
mv libgcc/gcc/loongarch64-unknown-linux-gnu/*/crtbeginS.o /usr/lib/gcc/loongarch64-linux-gnu/*/ && \
194-
rm -rf libgcc && \
195-
tar -xzvf rustc -C /usr && \
196-
cargo install bindgen-cli@0.69.1 --root /usr
193+
cp libgcc/gcc/loongarch64-unknown-linux-gnu/*/crtbeginS.o /usr/lib/gcc/loongarch64-linux-gnu/*/ && \
194+
tar -xzvf rustc.tar.gz -C /usr && \
195+
# Chromium seems to require that bindgen binary lives together with llvm
196+
cargo install bindgen-cli@0.69.1 --root /usr/lib/llvm-19
197197

198198
RUN echo 'builduser ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-builduser && \
199199
echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep

Dockerfile.buildtools

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ RUN apt-get update && \
99
ca-certificates \
1010
curl \
1111
git \
12+
sudo \
1213
xz-utils \
13-
sudo
1414

1515
RUN curl --silent --location https://deb.nodesource.com/setup_20.x | bash - && \
1616
apt-get update && \

Dockerfile.rustc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ RUN apt-get update && \
1010
ca-certificates \
1111
curl \
1212
git \
13+
cmake \
1314
python3 \
1415
ninja-build \
1516
libffi-dev \

config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ python = "/usr/bin/python3"
66
extended = true
77
tools = [ "cargo" ]
88
verbose = 1
9-
sanitizers = false
10-
profiler = false
9+
sanitizers = true
10+
profiler = true
1111
docs = false
1212
print-step-timings = true
1313

0 commit comments

Comments
 (0)