-
Notifications
You must be signed in to change notification settings - Fork 483
Expand file tree
/
Copy pathbuild-native-lib.sh
More file actions
executable file
·93 lines (68 loc) · 2.46 KB
/
build-native-lib.sh
File metadata and controls
executable file
·93 lines (68 loc) · 2.46 KB
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
#!/bin/sh
set -e
MODULE_NAME="shared-storage"
RN_MODULE_DIR="packages/async-storage"
ANDROID_BUILD_TASK="bundleAndroidMainAar"
ANDROID_OUTPUT_NAME="local_repo" # Maven local repo
ANDROID_OUTPUT_DIR="$MODULE_NAME/build"
ANDROID_RN_OUTPUT_DIR="$RN_MODULE_DIR/android"
ANDROID_PUBLISH_TASK="publishAndroidPublicationToLocalRepoRepository"
APPLE_BUILD_TASK="assembleSharedAsyncStorageReleaseXCFramework"
APPLE_OUTPUT_NAME="SharedAsyncStorage.xcframework"
APPLE_OUTPUT_DIR="$MODULE_NAME/build/XCFrameworks/release"
APPLE_RN_OUTPUT_DIR="$RN_MODULE_DIR/apple-frameworks"
build_android() {
log "👷 Assembling android shared-storage"
./gradlew :$MODULE_NAME:$ANDROID_BUILD_TASK
log "Publishing binaries to local repo"
./gradlew :$MODULE_NAME:$ANDROID_PUBLISH_TASK
log "Remove old local repo"
rm -rf $ANDROID_RN_OUTPUT_DIR/$ANDROID_OUTPUT_NAME
log "Moving local repo to RN target"
mv $ANDROID_OUTPUT_DIR/$ANDROID_OUTPUT_NAME $ANDROID_RN_OUTPUT_DIR/$ANDROID_OUTPUT_NAME
log "🚀 all done"
}
build_apple() {
log "👷 Assembling apple shared-storage"
./gradlew :$MODULE_NAME:$APPLE_BUILD_TASK
log "recreate Frameworks dir"
rm -rf $APPLE_RN_OUTPUT_DIR
mkdir $APPLE_RN_OUTPUT_DIR
log "move xcframework to RN module"
mv $APPLE_OUTPUT_DIR/$APPLE_OUTPUT_NAME $APPLE_RN_OUTPUT_DIR/$APPLE_OUTPUT_NAME
# because osx is using symlinks for versioning, distributing its framework via
# npm won't work - compression via tar breaks the link.
# therefore this script resolves the symlinks into actual folders, to match
# expected structure by macos.
MAC_OS_FRAMEWORK="$APPLE_RN_OUTPUT_DIR/SharedAsyncStorage.xcframework/macos-arm64_x86_64/SharedAsyncStorage.framework"
log "fixing macos symlinks"
# symlinks
rm "$MAC_OS_FRAMEWORK/Headers" "$MAC_OS_FRAMEWORK/Modules" "$MAC_OS_FRAMEWORK/Resources" "$MAC_OS_FRAMEWORK/SharedAsyncStorage"
cp -rL "$MAC_OS_FRAMEWORK/Versions/A/Headers" "$MAC_OS_FRAMEWORK/"
cp -rL "$MAC_OS_FRAMEWORK/Versions/A/Modules" "$MAC_OS_FRAMEWORK/"
cp -rL "$MAC_OS_FRAMEWORK/Versions/A/Resources" "$MAC_OS_FRAMEWORK/"
cp -L "$MAC_OS_FRAMEWORK/Versions/A/SharedAsyncStorage" "$MAC_OS_FRAMEWORK/"
# clear versions, not needed
rm -r "$MAC_OS_FRAMEWORK/Versions"
log "🚀 all done"
}
log() {
local message="$1"
echo "[AsyncStorage] $message"
}
TARGET=$1
case "$TARGET" in
android)
build_android
;;
apple)
build_apple
;;
all)
build_all
;;
*)
echo "Usage: $0 {android|apple}"
exit 1
;;
esac