Skip to content

Commit 4cbb379

Browse files
committed
Add GitHub Actions workflow for building Blender on Linux ARM64
1 parent 6ce457d commit 4cbb379

1 file changed

Lines changed: 212 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
name: Build Blender (Linux ARM64)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
blender_version:
7+
description: 'Blender version tag'
8+
required: true
9+
default: 'v5.0.1'
10+
build_type:
11+
description: 'Build type'
12+
required: true
13+
default: 'release'
14+
type: choice
15+
options:
16+
- release
17+
- debug
18+
rebuild_deps:
19+
description: 'Force rebuild dependencies'
20+
required: false
21+
default: false
22+
type: boolean
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-24.04-arm
27+
container:
28+
image: rockylinux:8
29+
options: --privileged --user root
30+
31+
steps:
32+
- name: Install base dependencies
33+
run: |
34+
dnf makecache
35+
dnf install -y epel-release
36+
dnf install -y git git-lfs gcc-toolset-14 ccache
37+
38+
# Fix sudo PAM issue: create a sudo wrapper that bypasses password and PAM authentication
39+
# Since the container has the root user already, simply let sudo execute commands directly
40+
mv /usr/bin/sudo /usr/bin/sudo.orig || true
41+
cat > /usr/bin/sudo << 'EOF'
42+
#!/bin/bash
43+
# Skip sudo for root user, just execute the command directly
44+
if [ "$1" = "-y" ] || [ "$1" = "-n" ] || [ "$1" = "-E" ]; then
45+
shift
46+
fi
47+
exec "$@"
48+
EOF
49+
chmod +x /usr/bin/sudo
50+
51+
- name: Setup Git LFS
52+
run: git-lfs install
53+
54+
- name: Clone Blender repository
55+
run: |
56+
mkdir -p ~/blender-git
57+
cd ~/blender-git
58+
GIT_LFS_SKIP_SMUDGE=1 git clone -b ${{ github.event.inputs.blender_version }} --depth 1 https://github.com/blender/blender.git
59+
60+
- name: Clone patches repository
61+
run: |
62+
cd ~/blender-git
63+
git clone -b ci --depth 1 https://github.com/lfdevs/blender-linux-arm64.git patches-repo
64+
65+
- name: Apply patches
66+
run: |
67+
cd ~/blender-git/blender
68+
git config user.email "actions@github.com"
69+
git config user.name "GitHub Actions"
70+
PATCH_DIR=~/blender-git/patches-repo/patches/${{ github.event.inputs.blender_version }}
71+
if [ -d "$PATCH_DIR" ]; then
72+
echo "Found patches directory: $PATCH_DIR"
73+
for patch in $(ls -1 "$PATCH_DIR"/*.patch 2>/dev/null | sort); do
74+
echo "Applying patch: $patch"
75+
git apply --verbose "$patch"
76+
done
77+
git add -A
78+
git commit -m "Apply patches for ${{ github.event.inputs.blender_version }}" || echo "No changes to commit"
79+
echo "All patches applied successfully"
80+
else
81+
echo "No patches directory found for ${{ github.event.inputs.blender_version }}, skipping..."
82+
fi
83+
84+
- name: Install build dependencies
85+
run: |
86+
chmod +x ~/blender-git/blender/build_files/build_environment/linux/linux_rocky8_setup.sh
87+
~/blender-git/blender/build_files/build_environment/linux/linux_rocky8_setup.sh
88+
echo "Cleaning dnf cache..."
89+
dnf clean all
90+
91+
- name: Cache Blender dependencies
92+
uses: actions/cache@v4
93+
id: cache-deps
94+
with:
95+
path: ~/blender-git/blender/lib/linux_arm64
96+
key: blender-deps-${{ github.event.inputs.blender_version }}-${{ runner.os }}-${{ runner.arch }}-v1
97+
restore-keys: |
98+
blender-deps-${{ github.event.inputs.blender_version }}-${{ runner.os }}-${{ runner.arch }}-
99+
100+
- name: Cache ccache
101+
uses: actions/cache@v4
102+
with:
103+
path: /root/.ccache
104+
key: ccache-${{ runner.os }}-${{ runner.arch }}-v1
105+
restore-keys: |
106+
ccache-${{ runner.os }}-${{ runner.arch }}-
107+
108+
- name: Configure ccache
109+
run: |
110+
export CCACHE_DIR=/root/.ccache
111+
ccache --max-size=5G
112+
ccache --show-config
113+
ccache --zero-stats
114+
ccache --show-stats
115+
116+
- name: Build dependencies
117+
if: steps.cache-deps.outputs.cache-hit != 'true' || github.event.inputs.rebuild_deps == true
118+
shell: bash
119+
run: |
120+
source /opt/rh/gcc-toolset-14/enable
121+
export CCACHE_DIR=/root/.ccache
122+
cd ~/blender-git/blender
123+
124+
# Fix CUDA build error for OIDN
125+
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
126+
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
127+
128+
# Fix FLAC extract error
129+
export LANG=en_US.UTF-8
130+
131+
export CC=/opt/rh/gcc-toolset-14/root/usr/bin/gcc
132+
export CXX=/opt/rh/gcc-toolset-14/root/usr/bin/g++
133+
make deps
134+
unset CC CXX
135+
136+
- name: Save Blender dependencies cache
137+
if: steps.cache-deps.outputs.cache-hit != 'true' || github.event.inputs.rebuild_deps == true
138+
uses: actions/cache/save@v4
139+
with:
140+
path: ~/blender-git/blender/lib/linux_arm64
141+
key: blender-deps-${{ github.event.inputs.blender_version }}-${{ runner.os }}-${{ runner.arch }}-v1
142+
143+
- name: Clean dependencies build artifacts
144+
if: steps.cache-deps.outputs.cache-hit != 'true' || github.event.inputs.rebuild_deps == true
145+
run: |
146+
echo "Cleaning dependencies build directory to save space..."
147+
rm -rf ~/blender-git/build_linux
148+
echo "Dependencies build directory cleaned"
149+
150+
- name: Verify dependencies
151+
run: |
152+
echo "Checking dependencies directory..."
153+
ls -lah ~/blender-git/blender/lib/linux_arm64/ || echo "Dependencies not found!"
154+
155+
- name: Build Blender
156+
shell: bash
157+
run: |
158+
source /opt/rh/gcc-toolset-14/enable
159+
export CCACHE_DIR=/root/.ccache
160+
161+
mkdir -p ~/blender-git/build_linux_${{ github.event.inputs.build_type }}
162+
cd ~/blender-git/build_linux_${{ github.event.inputs.build_type }}
163+
164+
if [ "${{ github.event.inputs.build_type }}" == "release" ]; then
165+
cmake -C ../blender/build_files/cmake/config/blender_release.cmake \
166+
-G Ninja \
167+
-DCMAKE_BUILD_TYPE=Release \
168+
-DWITH_LIBS_PRECOMPILED=ON \
169+
-DLIBDIR=$HOME/blender-git/blender/lib/linux_arm64 \
170+
-DWITH_INSTALL_PORTABLE=ON \
171+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
172+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
173+
../blender
174+
else
175+
cmake -G Ninja \
176+
-DCMAKE_BUILD_TYPE=Debug \
177+
-DWITH_LIBS_PRECOMPILED=ON \
178+
-DLIBDIR=$HOME/blender-git/blender/lib/linux_arm64 \
179+
-DWITH_INSTALL_PORTABLE=ON \
180+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
181+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
182+
../blender
183+
fi
184+
185+
echo "Building Blender..."
186+
ninja
187+
188+
echo "Build completed successfully!"
189+
echo "ccache statistics:"
190+
ccache --show-stats
191+
192+
- name: Save ccache
193+
uses: actions/cache/save@v4
194+
if: always()
195+
with:
196+
path: /root/.ccache
197+
key: ccache-${{ runner.os }}-${{ runner.arch }}-v1
198+
199+
- name: Package Blender
200+
shell: bash
201+
run: |
202+
source /opt/rh/gcc-toolset-14/enable
203+
cd ~/blender-git/build_linux_${{ github.event.inputs.build_type }}
204+
cpack
205+
echo "Packaging completed successfully!"
206+
207+
- name: Upload build artifacts
208+
uses: actions/upload-artifact@v4
209+
with:
210+
name: blender-linux-arm64-${{ github.event.inputs.blender_version }}-${{ github.event.inputs.build_type }}
211+
path: ~/blender-git/build_linux_${{ github.event.inputs.build_type }}/*.tar.gz
212+
retention-days: 90

0 commit comments

Comments
 (0)