forked from DimaRU/Libssh2Prebuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-xcframework.sh
executable file
·147 lines (119 loc) · 4.18 KB
/
build-xcframework.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
#!/bin/zsh
#
# build_xctframework.sh
# Copyright © 2023 Dmitriy Borovikov. All rights reserved.
#
#Functions
fetchSource () {
local url=$1
local filename=$2
local dstpath=$3
local file=$BUILD/$filename
mkdir -p "$dstpath"
echo "Downloading $filename"
curl -L -S -s "$url" --output "$file"
local md5
md5=$(md5 -q "$file")
echo "MD5: $md5"
tar -zxkf "$file" -C "$dstpath" --strip-components 1 2>&-
rm -f "$file"
}
buildLibrary () {
export BUILT_PRODUCTS_DIR=$1
export SDK_PLATFORM=$2
export PLATFORM=$3
export EFFECTIVE_PLATFORM_NAME=$4
export ARCHS=$5
export MIN_VERSION=$6
"$ROOT_PATH/script/build-openssl.sh"
"$ROOT_PATH/script/build-libssh2.sh"
rm -rf "$TEMPPATH"
}
#====================================================================#
set -e
#Config
BUILD_THREADS=$(sysctl hw.ncpu | awk '{print $2}')
export BUILD_THREADS
LIBSSH_TAG=$1
LIBSSL_TAG=$2
DATE=$3
set +e
xcodebuild -showsdks | grep -sq visionOS
VISION_OS=$?
set -e
if [[ $VISION_OS == 0 ]]; then
echo Vision OS available
fi
TAG=$LIBSSH_TAG-$LIBSSL_TAG
TAG=${TAG//_/-}
ZIPNAME=CSSH-$TAG.xcframework.zip
GIT_REMOTE_URL_UNFINISHED=$(git config --get remote.origin.url|sed "s=^ssh://==; s=^https://==; s=:=/=; s/git@//; s/.git$//;")
DOWNLOAD_URL=https://$GIT_REMOTE_URL_UNFINISHED/releases/download/$TAG/$ZIPNAME
ROOT_PATH=$(cd "$(dirname "$0")/.."; pwd -P)
export ROOT_PATH
pushd "$ROOT_PATH" > /dev/null
export BUILD=$ROOT_PATH/build
export TEMPPATH=$ROOT_PATH/temp
export LIBSSLDIR="$TEMPPATH/openssl"
export LIBSSHDIR="$TEMPPATH/libssh2"
export OPENSSL_SOURCE="$BUILD/openssl/src/"
export LIBSSH_SOURCE="$BUILD/libssh2/src/"
#Download
if [[ -d "$OPENSSL_SOURCE" ]] && [[ -d "$LIBSSH_SOURCE" ]]; then
echo "Sources already downloaded"
else
fetchSource "https://github.com/libssh2/libssh2/releases/download/libssh2-$LIBSSH_TAG/libssh2-$LIBSSH_TAG.tar.gz" "libssh2.tar.gz" "$LIBSSH_SOURCE"
fetchSource "https://github.com/openssl/openssl/archive/$LIBSSL_TAG.tar.gz" "openssl.tar.gz" "$OPENSSL_SOURCE"
fi
#Build
#buildLibrary () {
#export BUILT_PRODUCTS_DIR=$1
#export SDK_PLATFORM=$2
#export PLATFORM=$3
#export EFFECTIVE_PLATFORM_NAME=$4
#export ARCHS=$5
#export MIN_VERSION=$6
buildLibrary "$BUILD/iphoneos" "iphoneos" "iPhoneOS" "" "arm64" "9.0"
buildLibrary "$BUILD/iphonesimulator" "iphonesimulator" "iPhoneSimulator" "" "x86_64 arm64" "9.0"
buildLibrary "$BUILD/macosx" "macosx" "MacOSX" "" "x86_64 arm64" "10.10"
buildLibrary "$BUILD/maccatalyst" "macosx" "MacOSX" "-maccatalyst" "x86_64 arm64" "10.15"
buildLibrary "$BUILD/appletvsimulator" "appletvsimulator" "AppleTVSimulator" "" "x86_64 arm64" "9.0"
buildLibrary "$BUILD/appletvos" "appletvos" "AppleTVOS" "" "arm64" "9.0"
if [[ $VISION_OS == 0 ]]; then
buildLibrary "$BUILD/xros" "xros" "XROS" "" "arm64" ""
buildLibrary "$BUILD/xrsimulator" "xrsimulator" "XRSimulator" "" "arm64" ""
xcodebuild -create-xcframework \
-library "$BUILD/macosx/lib/libssh2.a" \
-headers "$BUILD/macosx/include" \
-library "$BUILD/iphoneos/lib/libssh2.a" \
-headers "$BUILD/iphoneos/include" \
-library "$BUILD/iphonesimulator/lib/libssh2.a" \
-headers "$BUILD/iphonesimulator/include" \
-library "$BUILD/maccatalyst/lib/libssh2.a" \
-headers "$BUILD/maccatalyst/include" \
-library "$BUILD/appletvsimulator/lib/libssh2.a" \
-headers "$BUILD/appletvsimulator/include" \
-library "$BUILD/appletvos/lib/libssh2.a" \
-headers "$BUILD/appletvos/include" \
-library "$BUILD/xros/lib/libssh2.a" \
-headers "$BUILD/xros/include" \
-library "$BUILD/xrsimulator/lib/libssh2.a" \
-headers "$BUILD/xrsimulator/include" \
-output $BUILD/CSSH.xcframework
else
xcodebuild -create-xcframework \
-library "$BUILD/macosx/lib/libssh2.a" \
-headers "$BUILD/macosx/include" \
-library "$BUILD/iphoneos/lib/libssh2.a" \
-headers "$BUILD/iphoneos/include" \
-library "$BUILD/iphonesimulator/lib/libssh2.a" \
-headers "$BUILD/iphonesimulator/include" \
-library "$BUILD/maccatalyst/lib/libssh2.a" \
-headers "$BUILD/maccatalyst/include" \
-library "$BUILD/appletvsimulator/lib/libssh2.a" \
-headers "$BUILD/appletvsimulator/include" \
-library "$BUILD/appletvos/lib/libssh2.a" \
-headers "$BUILD/appletvos/include" \
-output $BUILD/CSSH.xcframework
fi
popd > /dev/null