Skip to content

Commit 3eef63a

Browse files
committed
Refactor CI workflow for platform-specific builds
Split the build job into separate jobs for Android, iOS, Linux, macOS, Windows, and OpenHarmony platforms. Each job now configures and builds examples for its respective platform, improving clarity and maintainability of the CI workflow. The OpenHarmony job is prepared but disabled until the SDK is available in CI.
1 parent f8a5f9f commit 3eef63a

File tree

1 file changed

+225
-29
lines changed

1 file changed

+225
-29
lines changed

.github/workflows/build.yml

Lines changed: 225 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,99 @@ on:
77
branches: [main]
88

99
jobs:
10-
build:
10+
# Android builds (ARM64, ARMv7, x86_64)
11+
build-android:
12+
strategy:
13+
matrix:
14+
abi:
15+
- arm64-v8a
16+
- armeabi-v7a
17+
- x86_64
18+
19+
runs-on: ubuntu-latest
20+
name: Build Android (${{ matrix.abi }})
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up JDK
26+
uses: actions/setup-java@v4
27+
with:
28+
distribution: "temurin"
29+
java-version: "17"
30+
31+
- name: Install Android NDK
32+
run: |
33+
ANDROID_SDK_ROOT=/usr/local/lib/android/sdk
34+
SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
35+
echo "y" | $SDKMANAGER "ndk;25.2.9519653"
36+
echo "ANDROID_NDK_HOME=${ANDROID_SDK_ROOT}/ndk/25.2.9519653" >> $GITHUB_ENV
37+
echo "ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk/25.2.9519653" >> $GITHUB_ENV
38+
39+
- name: Install dependencies
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y ninja-build
43+
44+
- name: Configure CMake for Android
45+
shell: bash
46+
run: |
47+
mkdir build-android
48+
cd build-android
49+
cmake .. \
50+
-DCMAKE_SYSTEM_NAME=Android \
51+
-DCMAKE_ANDROID_NDK=$ANDROID_NDK_ROOT \
52+
-DCMAKE_ANDROID_ARCH_ABI=${{ matrix.abi }} \
53+
-DCMAKE_BUILD_TYPE=Release
54+
55+
- name: Build Examples
56+
shell: bash
57+
run: |
58+
cd build-android
59+
cmake --build . --config Release
60+
61+
# iOS builds (device and simulator)
62+
build-ios:
1163
strategy:
1264
matrix:
13-
os:
14-
- macos-latest
15-
- ubuntu-latest
16-
- windows-latest
1765
include:
18-
- os: macos-latest
19-
platform: macos
20-
- os: ubuntu-latest
21-
platform: linux
22-
- os: windows-latest
23-
platform: windows
66+
- target: device
67+
arch: arm64
68+
sysroot: iphoneos
69+
platform_name: iOS Device
70+
- target: simulator
71+
arch: arm64
72+
sysroot: iphonesimulator
73+
platform_name: iOS Simulator
74+
75+
runs-on: macos-latest
76+
name: Build ${{ matrix.platform_name }}
77+
78+
steps:
79+
- uses: actions/checkout@v4
2480

25-
runs-on: ${{ matrix.os }}
81+
- name: Configure CMake for iOS
82+
shell: bash
83+
run: |
84+
mkdir build-ios-${{ matrix.target }}
85+
cd build-ios-${{ matrix.target }}
86+
cmake .. \
87+
-DCMAKE_SYSTEM_NAME=iOS \
88+
-DCMAKE_SYSTEM_VERSION=14.0 \
89+
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} \
90+
-DCMAKE_OSX_SYSROOT=${{ matrix.sysroot }} \
91+
-DCMAKE_BUILD_TYPE=Release
92+
93+
- name: Build Examples
94+
shell: bash
95+
run: |
96+
cd build-ios-${{ matrix.target }}
97+
cmake --build . --config Release
98+
99+
# Linux build
100+
build-linux:
101+
runs-on: ubuntu-latest
102+
name: Build Linux
26103

27104
steps:
28105
- uses: actions/checkout@v4
@@ -31,33 +108,152 @@ jobs:
31108
shell: bash
32109
run: |
33110
cmake --version
34-
if [ "${{ matrix.platform }}" = "linux" ]; then
35-
sudo apt-get update
36-
sudo apt-get install -y ninja-build libgtk-3-dev libx11-dev libxi-dev libayatana-appindicator3-dev
37-
fi
111+
sudo apt-get update
112+
sudo apt-get install -y ninja-build libgtk-3-dev libx11-dev libxi-dev libayatana-appindicator3-dev
113+
114+
- name: Configure CMake
115+
shell: bash
116+
run: |
117+
mkdir build
118+
cd build
119+
cmake .. -DCMAKE_BUILD_TYPE=Release
120+
121+
- name: Build Examples
122+
shell: bash
123+
run: |
124+
cd build
125+
cmake --build . --config Release
126+
127+
# macOS build
128+
build-macos:
129+
runs-on: macos-latest
130+
name: Build macOS
131+
132+
steps:
133+
- uses: actions/checkout@v4
134+
135+
- name: Set up CMake
136+
shell: bash
137+
run: cmake --version
38138

39139
- name: Configure CMake
40140
shell: bash
41141
run: |
42142
mkdir build
43143
cd build
44-
if [ "${{ matrix.platform }}" = "windows" ]; then
45-
cmake .. -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022"
46-
else
47-
cmake .. -DCMAKE_BUILD_TYPE=Release
48-
fi
144+
cmake .. -DCMAKE_BUILD_TYPE=Release
49145
50146
- name: Build Examples
51147
shell: bash
52148
run: |
53149
cd build
54150
cmake --build . --config Release
55151
56-
# - name: Upload artifacts
57-
# uses: actions/upload-artifact@v4
58-
# with:
59-
# name: examples-${{ matrix.platform }}
60-
# path: |
61-
# build/examples/*/
62-
# !build/examples/*/CMakeFiles/
63-
# !build/examples/*/cmake_install.cmake
152+
# OpenHarmony builds
153+
build-ohos:
154+
strategy:
155+
matrix:
156+
abi:
157+
- arm64-v8a
158+
- armeabi-v7a
159+
160+
runs-on: ubuntu-latest
161+
name: Build OpenHarmony (${{ matrix.abi }})
162+
163+
steps:
164+
- uses: actions/checkout@v4
165+
166+
- name: Install dependencies
167+
run: |
168+
sudo apt-get update
169+
sudo apt-get install -y ninja-build unzip
170+
171+
- name: Download OpenHarmony Native SDK
172+
run: |
173+
# Download OpenHarmony 5.1.0 SDK from mirror
174+
# Note: This is a split archive (.aa, .ab, .ac files)
175+
wget -q https://github.com/openharmony-rs/ohos-sdk/releases/download/v5.1.0/ohos-sdk-windows_linux-public.tar.gz.aa -O ohos-sdk.tar.gz.aa
176+
wget -q https://github.com/openharmony-rs/ohos-sdk/releases/download/v5.1.0/ohos-sdk-windows_linux-public.tar.gz.ab -O ohos-sdk.tar.gz.ab
177+
178+
# Combine split archives
179+
cat ohos-sdk.tar.gz.* > ohos-sdk.tar.gz
180+
181+
# Extract the SDK
182+
tar -xzf ohos-sdk.tar.gz
183+
184+
# The SDK should be extracted to current directory
185+
ls -la
186+
187+
# Set up OHOS_NDK_HOME environment variable
188+
# SDK structure: ohos-sdk/windows_linux/native/...
189+
export OHOS_NDK_HOME=$(pwd)/ohos-sdk/windows_linux/native
190+
echo "OHOS_NDK_HOME=$OHOS_NDK_HOME" >> $GITHUB_ENV
191+
echo "OHOS_SDK_PATH=$OHOS_NDK_HOME" >> $GITHUB_ENV
192+
193+
# Verify SDK structure
194+
echo "Checking SDK structure..."
195+
ls -la $OHOS_NDK_HOME/ || true
196+
ls -la $OHOS_NDK_HOME/build/ || true
197+
ls -la $OHOS_NDK_HOME/build/cmake/ || true
198+
199+
- name: Configure CMake for OpenHarmony
200+
shell: bash
201+
run: |
202+
# Map CMake ABIs to OpenHarmony architectures
203+
case "${{ matrix.abi }}" in
204+
arm64-v8a)
205+
OHOS_ARCH=arm64
206+
CMAKE_ANDROID_ARCH_ABI=arm64-v8a
207+
;;
208+
armeabi-v7a)
209+
OHOS_ARCH=arm
210+
CMAKE_ANDROID_ARCH_ABI=armeabi-v7a
211+
;;
212+
*)
213+
echo "Unsupported ABI: ${{ matrix.abi }}"
214+
exit 1
215+
;;
216+
esac
217+
218+
mkdir build-ohos-${{ matrix.abi }}
219+
cd build-ohos-${{ matrix.abi }}
220+
221+
# Configure CMake with OpenHarmony toolchain
222+
cmake .. \
223+
-DCMAKE_SYSTEM_NAME=OHOS \
224+
-DCMAKE_TOOLCHAIN_FILE=$OHOS_SDK_PATH/build/cmake/ohos.toolchain.cmake \
225+
-DOHOS_ARCH=$OHOS_ARCH \
226+
-DCMAKE_ANDROID_ARCH_ABI=$CMAKE_ANDROID_ARCH_ABI \
227+
-DCMAKE_BUILD_TYPE=Release \
228+
-G Ninja
229+
230+
- name: Build Examples
231+
shell: bash
232+
run: |
233+
cd build-ohos-${{ matrix.abi }}
234+
cmake --build . --config Release
235+
236+
# Windows build
237+
build-windows:
238+
runs-on: windows-latest
239+
name: Build Windows
240+
241+
steps:
242+
- uses: actions/checkout@v4
243+
244+
- name: Set up CMake
245+
shell: bash
246+
run: cmake --version
247+
248+
- name: Configure CMake
249+
shell: bash
250+
run: |
251+
mkdir build
252+
cd build
253+
cmake .. -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022"
254+
255+
- name: Build Examples
256+
shell: bash
257+
run: |
258+
cd build
259+
cmake --build . --config Release

0 commit comments

Comments
 (0)