Skip to content

Commit 41e7c0c

Browse files
committed
chore(ci): build filament first
1 parent 9e84f67 commit 41e7c0c

3 files changed

Lines changed: 157 additions & 52 deletions

File tree

.github/workflows/build-android.yml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,33 @@ on:
2020
- 'bun.lock'
2121

2222
jobs:
23-
build-bullet3:
24-
name: Build bullet3 for Android
23+
build-filament:
24+
name: Build Filament for Android
2525
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@v4
2828
with:
2929
submodules: recursive
3030

31-
- name: Setup Bun
32-
uses: oven-sh/setup-bun@v2
31+
- name: Build Filament
32+
working-directory: package/
33+
run: bash scripts/build-filament.sh debug --platform android
34+
35+
- name: Upload Filament libraries
36+
uses: actions/upload-artifact@v4
3337
with:
34-
bun-version: latest
38+
name: filament-android
39+
path: package/android/libs/filament/
40+
retention-days: 1
41+
42+
build-bullet3:
43+
name: Build bullet3 for Android
44+
runs-on: ubuntu-latest
45+
needs: build-filament
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
submodules: recursive
3550

3651
- name: Setup Android SDK
3752
uses: android-actions/setup-android@v3
@@ -40,20 +55,9 @@ jobs:
4055
run: |
4156
sdkmanager --install "ndk;27.1.12297006"
4257
43-
# - name: Restore bun cache
44-
# uses: actions/cache@v4
45-
# with:
46-
# path: ~/.bun/install/cache
47-
# key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
48-
# restore-keys: |
49-
# ${{ runner.os }}-bun-
50-
51-
# - name: Install dependencies
52-
# run: bun install --frozen-lockfile
53-
5458
- name: Build bullet3
5559
working-directory: package/
56-
run: bun build-bullet3 --platform android
60+
run: bash scripts/build-bullet3.sh --platform android
5761

5862
- name: Upload bullet3 libraries
5963
uses: actions/upload-artifact@v4
@@ -65,7 +69,7 @@ jobs:
6569
build:
6670
name: Build ${{ matrix.app }} (${{ matrix.variant }})
6771
runs-on: ubuntu-latest
68-
needs: build-bullet3
72+
needs: [build-filament, build-bullet3]
6973
strategy:
7074
matrix:
7175
app: [AppExampleFabric, ExpoExample]
@@ -98,6 +102,12 @@ jobs:
98102
- name: Install dependencies
99103
run: bun install --frozen-lockfile
100104

105+
- name: Download Filament libraries
106+
uses: actions/download-artifact@v4
107+
with:
108+
name: filament-android
109+
path: package/android/libs/filament/
110+
101111
- name: Download bullet3 libraries
102112
uses: actions/download-artifact@v4
103113
with:

.github/workflows/build-ios.yml

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,49 @@ on:
1919
- "examples/**/ios/**"
2020

2121
jobs:
22+
build-filament:
23+
name: Build Filament for iOS
24+
runs-on: macOS-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
submodules: recursive
29+
30+
- name: Build Filament
31+
working-directory: package/
32+
run: bash scripts/build-filament.sh debug --platform ios
33+
34+
- name: Upload Filament libraries
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: filament-ios
38+
path: package/ios/libs/filament/
39+
retention-days: 1
40+
41+
build-bullet3:
42+
name: Build bullet3 for iOS
43+
runs-on: macOS-latest
44+
needs: build-filament
45+
steps:
46+
- uses: actions/checkout@v4
47+
with:
48+
submodules: recursive
49+
50+
- name: Build bullet3
51+
working-directory: package/
52+
run: bash scripts/build-bullet3.sh --platform ios
53+
54+
- name: Upload bullet3 libraries
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: bullet3-ios
58+
path: package/ios/libs/bullet3/
59+
retention-days: 1
60+
2261
build:
2362
name: Build iOS Example App
2463
runs-on: macOS-latest
64+
needs: [build-filament, build-bullet3]
2565
steps:
2666
- uses: actions/checkout@v4
2767
with:
@@ -43,6 +83,18 @@ jobs:
4383
- name: Install dependencies
4484
run: bun install --frozen-lockfile
4585

86+
- name: Download Filament libraries
87+
uses: actions/download-artifact@v4
88+
with:
89+
name: filament-ios
90+
path: package/ios/libs/filament/
91+
92+
- name: Download bullet3 libraries
93+
uses: actions/download-artifact@v4
94+
with:
95+
name: bullet3-ios
96+
path: package/ios/libs/bullet3/
97+
4698
- name: Restore buildcache
4799
uses: mikehardy/buildcache-action@v2
48100
continue-on-error: true
@@ -69,10 +121,6 @@ jobs:
69121
- name: Install xcpretty
70122
run: gem install xcpretty
71123

72-
- name: Build bullet3
73-
working-directory: package/
74-
run: bun build-bullet3 --platform ios
75-
76124
- name: Build App
77125
working-directory: examples/AppExampleFabric/ios
78126
run: |

package/scripts/build-filament.sh

Lines changed: 77 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,82 @@
22

33
set -e
44

5-
target="$1"
5+
# Default values
6+
BUILD_ANDROID=${BUILD_ANDROID:-true}
7+
BUILD_IOS=${BUILD_IOS:-true}
8+
target=""
9+
10+
# Parse command-line arguments
11+
while [[ $# -gt 0 ]]; do
12+
case $1 in
13+
--platform)
14+
case $2 in
15+
android)
16+
BUILD_ANDROID=true
17+
BUILD_IOS=false
18+
;;
19+
ios)
20+
BUILD_ANDROID=false
21+
BUILD_IOS=true
22+
;;
23+
all)
24+
BUILD_ANDROID=true
25+
BUILD_IOS=true
26+
;;
27+
*)
28+
echo "Unknown platform: $2"
29+
echo "Usage: $0 [debug|release] [--platform android|ios|all]"
30+
exit 1
31+
;;
32+
esac
33+
shift 2
34+
;;
35+
debug|release)
36+
target=$1
37+
shift
38+
;;
39+
*)
40+
echo "Unknown option: $1"
41+
echo "Usage: $0 [debug|release] [--platform android|ios|all]"
42+
exit 1
43+
;;
44+
esac
45+
done
46+
47+
# Validate build type
648
if [ -z "$target" ]; then
7-
# Exit and print error message
8-
echo "Missing build type (debug|release)"
9-
echo "Usage: $0 <buildType>"
10-
exit 1
49+
echo "Missing build type (debug|release)"
50+
echo "Usage: $0 [debug|release] [--platform android|ios|all]"
51+
exit 1
1152
fi
1253

13-
# Check if the library exists for ios, if so, ask to skip with Y/N question
14-
if [ -d "../package/ios/libs/filament" ]; then
15-
echo "[Filament] iOS libraries already exist in react-native-filament package. Do you want to skip building them? (Y/N) (y)"
16-
read -r skip_ios
17-
if [ "$skip_ios" = "N" ] || [ "$skip_ios" = "n" ]; then
18-
skip_ios=false
19-
else
20-
echo "Skipping iOS build..."
21-
skip_ios=true
54+
# Interactive mode: ask to skip if libraries already exist (only if not in CI)
55+
if [ "$CI" != "true" ]; then
56+
if [ "$BUILD_IOS" = "true" ] && [ -d "../package/ios/libs/filament" ]; then
57+
echo "[Filament] iOS libraries already exist in react-native-filament package. Do you want to skip building them? (Y/N) (y)"
58+
read -r skip_ios
59+
if [ "$skip_ios" = "N" ] || [ "$skip_ios" = "n" ]; then
60+
BUILD_IOS=true
61+
else
62+
echo "Skipping iOS build..."
63+
BUILD_IOS=false
64+
fi
2265
fi
23-
fi
24-
# Same for android:
25-
if [ -d "../package/android/libs/filament" ]; then
26-
echo "[Filament] Android libraries already exist in react-native-filament package. Do you want to skip building them? (Y/N) (y)"
27-
read -r skip_android
28-
if [ "$skip_android" = "N" ] || [ "$skip_android" = "n" ]; then
29-
skip_android=false
30-
else
31-
echo "Skipping Android build..."
32-
skip_android=true
66+
67+
if [ "$BUILD_ANDROID" = "true" ] && [ -d "../package/android/libs/filament" ]; then
68+
echo "[Filament] Android libraries already exist in react-native-filament package. Do you want to skip building them? (Y/N) (y)"
69+
read -r skip_android
70+
if [ "$skip_android" = "N" ] || [ "$skip_android" = "n" ]; then
71+
BUILD_ANDROID=true
72+
else
73+
echo "Skipping Android build..."
74+
BUILD_ANDROID=false
75+
fi
3376
fi
3477
fi
3578

36-
if [ "$skip_ios" = true ] && [ "$skip_android" = true ]; then
37-
echo "Both iOS and Android libraries already exist. Nothing to do."
79+
if [ "$BUILD_IOS" = "false" ] && [ "$BUILD_ANDROID" = "false" ]; then
80+
echo "[Filament] Both iOS and Android builds are skipped. Nothing to do."
3881
exit 0
3982
fi
4083

@@ -51,9 +94,9 @@ cd ..
5194
cd ..
5295
cd filament
5396

54-
if [ "$skip_ios" = false ]; then
97+
if [ "$BUILD_IOS" = "true" ]; then
5598
# On iOS, we already use Filament from CocoaPods.
56-
echo "Building Filament for iOS ($target)..."
99+
echo "[Filament] Building Filament for iOS ($target)..."
57100
# -s = iOS simulator support
58101
# -l = Build fat universal library (x86_64 + arm64), needed to easily include library from podspec
59102
./build.sh -s -l -p ios -i "$target"
@@ -69,11 +112,13 @@ if [ "$skip_ios" = false ]; then
69112
echo "Copying Filament private backend headers..."
70113
mkdir -p ../package/ios/libs/filament/include/private/backend
71114
cp filament/backend/include/private/backend/VirtualMachineEnv.h ../package/ios/libs/filament/include/private/backend/
115+
116+
echo "[Filament] iOS libraries built successfully!"
72117
fi
73118

74-
if [ "$skip_android" = false ]; then
119+
if [ "$BUILD_ANDROID" = "true" ]; then
75120
# TODO(Marc): Use Filament from the Maven/Gradle library, to avoid shipping this huge dependency over npm.
76-
echo "Building Filament for Android ($target)"
121+
echo "[Filament] Building Filament for Android ($target)"
77122
# -v = Exclude Vulkan support
78123
./build.sh -p android "$target"
79124

@@ -91,6 +136,8 @@ if [ "$skip_android" = false ]; then
91136
echo "Copying Filament private backend headers..."
92137
mkdir -p ../package/android/libs/filament/include/private/backend
93138
cp filament/backend/include/private/backend/VirtualMachineEnv.h ../package/android/libs/filament/include/private/backend/
139+
140+
echo "[Filament] Android libraries built successfully!"
94141
fi
95142

96143
echo "Done!"

0 commit comments

Comments
 (0)