-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
build_nativescript.sh
executable file
·197 lines (174 loc) · 7.72 KB
/
build_nativescript.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/bash
set -e
source "$(dirname "$0")/build_utils.sh"
function to_bool() {
local arg="$1"
case "$(echo "$arg" | tr '[:upper:]' '[:lower:]')" in
[0-9]+)
if [ $arg -eq 0 ]; then
echo false
else
echo true
fi
;;
n|no|f|false) echo false ;;
y|yes|t|true) echo true ;;
* )
if [ -n "$arg" ]; then
echo "warning: invalid boolean argument ('$arg'). Expected true or false" >&2
fi
echo false
;;
esac;
}
BUILD_CATALYST=$(to_bool ${BUILD_CATALYST:=true})
BUILD_IPHONE=$(to_bool ${BUILD_IPHONE:=true})
BUILD_SIMULATOR=$(to_bool ${BUILD_SIMULATOR:=true})
BUILD_VISION=$(to_bool ${BUILD_VISION:=true})
VERBOSE=$(to_bool ${VERBOSE:=false})
for arg in $@; do
case $arg in
--catalyst|--maccatalyst) BUILD_CATALYST=true ;;
--no-catalyst|--no-maccatalyst) BUILD_CATALYST=false ;;
--sim|--simulator) BUILD_SIMULATOR=true ;;
--no-sim|--no-simulator) BUILD_SIMULATOR=false ;;
--iphone|--device) BUILD_IPHONE=true ;;
--no-iphone|--no-device) BUILD_IPHONE=false ;;
--xr|--vision) BUILD_VISION=true ;;
--no-xr|--no-vision) BUILD_VISION=false ;;
--verbose|-v) VERBOSE=true ;;
*) ;;
esac
done
QUIET=
if ! $VERBOSE; then
QUIET=-quiet
fi
DEV_TEAM=${DEVELOPMENT_TEAM:-}
DIST=$(PWD)/dist
mkdir -p $DIST
mkdir -p $DIST/intermediates
checkpoint "Cleanup NativeScript"
xcodebuild -project v8ios.xcodeproj \
-target "NativeScript" \
-configuration Release clean \
$QUIET
if $BUILD_CATALYST; then
checkpoint "Building NativeScript for Mac Catalyst"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "NativeScript" \
-configuration Release \
-destination "platform=macOS,variant=Mac Catalyst" \
$QUIET \
EXCLUDED_ARCHS="x86_64" \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES \
INCLUDE_DEFAULT_METADATA=$INCLUDE_DEFAULT_METADATA\
-archivePath $DIST/intermediates/NativeScript.maccatalyst.xcarchive
fi
if $BUILD_SIMULATOR; then
checkpoint "Building NativeScript for iphone simulators (multi-arch)"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "NativeScript" \
-configuration Release \
-destination "generic/platform=iOS Simulator" \
$QUIET \
EXCLUDED_ARCHS="i386" \
DEVELOPMENT_TEAM=$DEV_TEAM \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES \
INCLUDE_DEFAULT_METADATA=$INCLUDE_DEFAULT_METADATA\
-archivePath $DIST/intermediates/NativeScript.iphonesimulator.xcarchive
fi
if $BUILD_IPHONE; then
checkpoint "Building NativeScript for ARM64 device"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "NativeScript" \
-configuration Release \
-destination "generic/platform=iOS" \
$QUIET \
EXCLUDED_ARCHS="armv7" \
DEVELOPMENT_TEAM=$DEV_TEAM \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES \
INCLUDE_DEFAULT_METADATA=$INCLUDE_DEFAULT_METADATA\
-archivePath $DIST/intermediates/NativeScript.iphoneos.xcarchive
fi
if $BUILD_CATALYST; then
checkpoint "Building NativeScript for Mac Catalyst"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "NativeScript" \
-configuration Release \
-destination "generic/platform=macOS,variant=Mac Catalyst" \
$QUIET \
EXCLUDED_ARCHS="x86_64" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
-archivePath $DIST/intermediates/NativeScript.maccatalyst.xcarchive
fi
if $BUILD_VISION; then
checkpoint "Building NativeScript for visionOS Device"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "NativeScript" \
-configuration Release \
-destination "generic/platform=visionOS" \
$QUIET \
EXCLUDED_ARCHS="i386 x86_64" \
VALID_ARCHS=arm64 \
DEVELOPMENT_TEAM=$DEV_TEAM \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
-archivePath $DIST/intermediates/NativeScript.xros.xcarchive
checkpoint "Building NativeScript for visionOS Simulators"
xcodebuild archive -project v8ios.xcodeproj \
-scheme "NativeScript" \
-configuration Release \
-destination "generic/platform=visionOS Simulator" \
$QUIET \
EXCLUDED_ARCHS="i386 x86_64" \
VALID_ARCHS=arm64 \
DEVELOPMENT_TEAM=$DEV_TEAM \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
-archivePath $DIST/intermediates/NativeScript.xrsimulator.xcarchive
fi
XCFRAMEWORKS=()
if $BUILD_CATALYST; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.maccatalyst.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
-debug-symbols "$DIST/intermediates/NativeScript.maccatalyst.xcarchive/dSYMs/NativeScript.framework.dSYM" )
fi
if $BUILD_SIMULATOR; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.iphonesimulator.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
-debug-symbols "$DIST/intermediates/NativeScript.iphonesimulator.xcarchive/dSYMs/NativeScript.framework.dSYM" )
fi
if $BUILD_IPHONE; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.iphoneos.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
-debug-symbols "$DIST/intermediates/NativeScript.iphoneos.xcarchive/dSYMs/NativeScript.framework.dSYM" )
fi
if $BUILD_VISION; then
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.xros.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
-debug-symbols "$DIST/intermediates/NativeScript.xros.xcarchive/dSYMs/NativeScript.framework.dSYM" )
XCFRAMEWORKS+=( -framework "$DIST/intermediates/NativeScript.xrsimulator.xcarchive/Products/Library/Frameworks/NativeScript.framework" \
-debug-symbols "$DIST/intermediates/NativeScript.xrsimulator.xcarchive/dSYMs/NativeScript.framework.dSYM" )
fi
checkpoint "Creating NativeScript.xcframework"
OUTPUT_DIR="$DIST/NativeScript.xcframework"
rm -rf $OUTPUT_DIR
xcodebuild -create-xcframework ${XCFRAMEWORKS[@]} -output "$OUTPUT_DIR"
rm -rf "$DIST/intermediates"
# DSYM_OUTPUT_DIR="$DIST/NativeScript.framework.dSYM"
# cp -r "$DIST/NativeScript.iphoneos.xcarchive/dSYMs/NativeScript.framework.dSYM/" $DSYM_OUTPUT_DIR
# lipo -create \
# "$DIST/NativeScript.iphonesimulator.xcarchive/dSYMs/NativeScript.framework.dSYM/Contents/Resources/DWARF/NativeScript" \
# "$DIST/NativeScript.iphoneos.xcarchive/dSYMs/NativeScript.framework.dSYM/Contents/Resources/DWARF/NativeScript" \
# -output "$DSYM_OUTPUT_DIR/Contents/Resources/DWARF/NativeScript"
# pushd $DIST
# zip -qr "NativeScript.framework.dSYM.zip" "NativeScript.framework.dSYM"
# zip -qr "NativeScript.macos.framework.dSYM.zip" "NativeScript.maccatalyst.xcarchive/dSYMs/NativeScript.framework.dSYM"
# rm -rf "NativeScript.framework.dSYM"
# popd
# rm -rf "$DIST/NativeScript.maccatalyst.xcarchive"
# rm -rf "$DIST/NativeScript.x86_64-iphonesimulator.xcarchive"
# rm -rf "$DIST/NativeScript.arm64-iphonesimulator.xcarchive"
# rm -rf "$DIST/NativeScript.iphonesimulator.xcarchive"
# rm -rf "$DIST/NativeScript.iphoneos.xcarchive"