Skip to content

Commit 55d00f8

Browse files
committed
getting closer to a foolproof build_all_react_native.sh
1 parent 05151e0 commit 55d00f8

File tree

4 files changed

+79
-23
lines changed

4 files changed

+79
-23
lines changed

build_all_ios.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
#!/bin/bash
22
set -e
3+
source "$(dirname "$0")/build_utils.sh"
34

45
TARGET_ENGINE=${TARGET_ENGINE:=some}
6+
BUILD_IPHONE=$(to_bool ${BUILD_IPHONE:=true})
7+
BUILD_SIMULATOR=$(to_bool ${BUILD_SIMULATOR:=true})
8+
BUILD_MACOS=$(to_bool ${BUILD_MACOS:=false})
9+
EMBED_METADATA=$(to_bool ${EMBED_METADATA:=false})
510

611
# See build_nativescript.sh for all supported flags. This parent script is only
712
# interested in intercepting --no-engine.
813
for arg in $@; do
914
case $arg in
1015
--v8|--quickjs|--jsc|--hermes) TARGET_ENGINE=some ;;
16+
--sim|--simulator) BUILD_SIMULATOR=true ;;
17+
--no-sim|--no-simulator) BUILD_SIMULATOR=false ;;
18+
--iphone|--device) BUILD_IPHONE=true ;;
19+
--no-iphone|--no-device) BUILD_IPHONE=false ;;
20+
--macos) BUILD_MACOS=true ;;
21+
--no-macos) BUILD_MACOS=false ;;
1122
--no-engine) TARGET_ENGINE=none ;;
23+
--embed-metadata) EMBED_METADATA=true ;;
1224
*) ;;
1325
esac
1426
done
@@ -20,6 +32,26 @@ rm -rf ./dist
2032
# ./update_version.sh
2133
# fi
2234
./build_metadata_generator.sh
35+
36+
if $EMBED_METADATA; then
37+
checkpoint "Generating metadata, as --embed-metadata was passed..."
38+
39+
if $BUILD_IPHONE; then
40+
checkpoint "Generating metadata for iOS (physical device)..."
41+
npm run metagen ios
42+
fi
43+
if $BUILD_SIMULATOR; then
44+
checkpoint "Generating metadata for iOS (simulator)..."
45+
npm run metagen ios-sim
46+
fi
47+
if $BUILD_MACOS; then
48+
checkpoint "Generating metadata for macOS..."
49+
npm run metagen macos
50+
fi
51+
52+
checkpoint "... All metadata generated!"
53+
fi
54+
2355
./build_nativescript.sh --no-vision $1 $2 $3 $4 $5 $6 $7 $8 $9
2456

2557
if [[ "$TARGET_ENGINE" == "none" ]]; then

build_all_react_native.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
#!/bin/bash
22

3+
# Remember to run:
4+
#
5+
# $ npm run metagen ios-sim
6+
# metadata-generator/metadata/metadata.ios-sim.arm64.h
7+
# metadata-generator/metadata/metadata.ios-sim.arm64.nsmd
8+
# metadata-generator/metadata/metadata.ios-sim.x86_64.h
9+
# metadata-generator/metadata/metadata.ios-sim.x86_64.nsmd
10+
#
11+
# $ npm run metagen ios
12+
# metadata-generator/metadata/metadata.ios.arm64.h
13+
# metadata-generator/metadata/metadata.ios.arm64.nsmd
14+
#
15+
# $ npm run metagen macos
16+
# metadata-generator/metadata/metadata.macos.arm64.h
17+
# metadata-generator/metadata/metadata.macos.arm64.nsmd
18+
# metadata-generator/metadata/metadata.macos.x86_64.h
19+
# metadata-generator/metadata/metadata.macos.x86_64.nsmd
20+
321
./build_all_ios.sh --no-engine --embed-metadata --macos

build_nativescript.sh

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -157,32 +157,36 @@ if $BUILD_VISION; then
157157
fi
158158

159159
if [[ -n "${XCFRAMEWORKS[@]}" ]]; then
160-
161-
162-
if [[ "$TARGET_ENGINE" == "none" ]]; then
163-
checkpoint "Creating the XCFramework (NativeScript.apple.node)"
164-
165-
# We adhere to the prebuilds standard as described here:
166-
# https://github.com/callstackincubator/react-native-node-api/blob/9b231c14459b62d7df33360f930a00343d8c46e6/docs/PREBUILDS.md
167-
OUTPUT_DIR="packages/ios/build/$CONFIG_BUILD/NativeScript.apple.node"
168-
rm -rf $OUTPUT_DIR
169-
deno run -A ./scripts/build_xcframework.mts --output "$OUTPUT_DIR" ${XCFRAMEWORKS[@]}
170-
else
171-
checkpoint "Creating NativeScript.xcframework"
172-
173-
OUTPUT_DIR="$DIST/NativeScript.xcframework"
174-
rm -rf $OUTPUT_DIR
175-
xcodebuild -create-xcframework ${XCFRAMEWORKS[@]} -output "$OUTPUT_DIR"
176-
fi
177-
160+
if [[ "$TARGET_ENGINE" == "none" ]]; then
161+
checkpoint "Creating the XCFramework for iOS (NativeScript.apple.node)"
162+
163+
# We adhere to the prebuilds standard as described here:
164+
# https://github.com/callstackincubator/react-native-node-api/blob/9b231c14459b62d7df33360f930a00343d8c46e6/docs/PREBUILDS.md
165+
OUTPUT_DIR="packages/ios/build/$CONFIG_BUILD/NativeScript.apple.node"
166+
rm -rf $OUTPUT_DIR
167+
deno run -A ./scripts/build_xcframework.mts --output "$OUTPUT_DIR" ${XCFRAMEWORKS[@]}
168+
else
169+
checkpoint "Creating NativeScript.xcframework"
170+
171+
OUTPUT_DIR="$DIST/NativeScript.xcframework"
172+
rm -rf $OUTPUT_DIR
173+
xcodebuild -create-xcframework ${XCFRAMEWORKS[@]} -output "$OUTPUT_DIR"
174+
fi
178175
fi
179176

180177
if $BUILD_MACOS; then
181-
182-
checkpoint "Creating NativeScript.node"
183-
184-
cp -r "$DIST/intermediates/macos/$CONFIG_BUILD/libNativeScript.dylib" "$DIST/NativeScript.node"
185-
178+
if [[ "$TARGET_ENGINE" == "none" ]]; then
179+
checkpoint "Creating the XCFramework for macOS (NativeScript.apple.node)"
180+
181+
# We adhere to the prebuilds standard as described here:
182+
# https://github.com/callstackincubator/react-native-node-api/blob/9b231c14459b62d7df33360f930a00343d8c46e6/docs/PREBUILDS.md
183+
OUTPUT_DIR="packages/macos/build/$CONFIG_BUILD/NativeScript.apple.node"
184+
rm -rf $OUTPUT_DIR
185+
deno run -A ./scripts/build_xcframework.mts --output "$OUTPUT_DIR" ${XCFRAMEWORKS[@]}
186+
else
187+
checkpoint "Creating NativeScript.node for macOS"
188+
cp -r "$DIST/intermediates/macos/$CONFIG_BUILD/libNativeScript.dylib" "$DIST/NativeScript.node"
189+
fi
186190
fi
187191

188192
if $BUILD_MACOS_CLI; then

scripts/build_xcframework.mts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ async function main() {
3939
Typical usage:
4040
4141
$ deno run -A ./scripts/build_xcframework.mts --output packages/ios/build/Release/NativeScript.apple.node -framework dist/intermediates/ios/RelWithDebInfo-iphoneos/NativeScript.framework -debug-symbols dist/intermediates/ios/RelWithDebInfo-iphoneos/NativeScript.framework.dSYM
42+
43+
$ deno run -A ./scripts/build_xcframework.mts --output packages/macos/build/Release/NativeScript.apple.node -framework dist/intermediates/macos/RelWithDebInfo/NativeScript.framework -debug-symbols dist/intermediates/macos/RelWithDebInfo/NativeScript.framework.dSYM
4244
`.trim();
4345

4446
if (help) {

0 commit comments

Comments
 (0)