22
33set -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
648if [ -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
1152fi
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
3477fi
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
3982fi
4083
5194cd ..
5295cd 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!"
72117fi
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!"
94141fi
95142
96143echo " Done!"
0 commit comments