forked from chipp/iSSH2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·137 lines (99 loc) · 4.61 KB
/
build.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
#!/bin/bash
composeFramework() {
framework=$1
headers=$2
lib=$3
sdk=$4
bundle_id=$5
framework_path=$sdk/$framework.framework
mkdir -p $framework_path/Headers
cp -RL $headers $framework_path/Headers/
cp -RL $lib $framework_path/$framework
cp Info.plist $framework_path/
plutil -replace CFBundleName -string $framework $framework_path/Info.plist
plutil -replace DTPlatformName -string $sdk $framework_path/Info.plist
plutil -replace CFBundleIdentifier -string $bundle_id $framework_path/Info.plist
if [[ $sdk == "iphoneos" ]]; then
plutil -replace MinimumOSVersion -string 14.0 $framework_path/Info.plist
plutil -replace DTSDKName -string $sdk16.2 $framework_path/Info.plist
plutil -replace CFBundleSupportedPlatforms.0 -string iPhoneOS $framework_path/Info.plist
elif [[ $sdk == "iphonesimulator" ]]; then
plutil -replace MinimumOSVersion -string 14.0 $framework_path/Info.plist
plutil -replace DTSDKName -string $sdk16.2 $framework_path/Info.plist
plutil -replace CFBundleSupportedPlatforms.0 -string iPhoneSimulator $framework_path/Info.plist
else
plutil -replace MinimumOSVersion -string 11.0 $framework_path/Info.plist
plutil -replace DTSDKName -string $sdk13.1 $framework_path/Info.plist
plutil -replace CFBundleSupportedPlatforms.0 -string MacOSX $framework_path/Info.plist
fi
plutil -remove CFBundleSupportedPlatforms.1 $framework_path/Info.plist
generateModuleMap $framework $framework_path
}
generateModuleMap() {
framework=$1
framework_path=$2
mkdir $framework_path/Modules
module_map=$framework_path/Modules/module.modulemap
headers=($(find $framework_path/Headers -name "*.h"))
echo "framework module $framework {" > $module_map
for header in "${headers[@]}"
do
echo " header \"$(basename $header)\"" >> $module_map
done
echo " export *" >> $module_map
# echo " module * { export * }" >> $module_map
echo "}" >> $module_map
}
rm -rf *.xcframework openssl_* libssh_* libssh2_* libssl_* $TMPDIR/iSSH2
# iphoneos
./iSSH2.sh --platform=iphoneos --min-version=14 -a "arm64 arm64e" --no-clean
composeFramework "libssl" "openssl_iphoneos/include/openssl/*.h" \
"openssl_iphoneos/lib/libssl.a" "iphoneos" "org.openssl.libssl"
composeFramework "libcrypto" "openssl_iphoneos/include/crypto/*.h" \
"openssl_iphoneos/lib/libcrypto.a" "iphoneos" "org.openssl.libcrypto"
composeFramework "libssh2" "libssh2_iphoneos/include/*.h" \
"libssh2_iphoneos/lib/libssh2.a" "iphoneos" "org.libssh2.libssh2"
composeFramework "libssh" "libssh_iphoneos/include/*.h" \
"libssh_iphoneos/lib/libssh.a" "iphoneos" "org.libssh.libssh"
# iphonesimulator
./iSSH2.sh --platform=iphonesimulator --min-version=14 -a "arm64 arm64e x86_64" --no-clean
composeFramework "libssl" "openssl_iphonesimulator/include/openssl/*.h" \
"openssl_iphonesimulator/lib/libssl.a" "iphonesimulator" "org.openssl.libssl"
composeFramework "libcrypto" "openssl_iphonesimulator/include/crypto/*.h" \
"openssl_iphonesimulator/lib/libcrypto.a" "iphonesimulator" "org.openssl.libcrypto"
composeFramework "libssh2" "libssh2_iphonesimulator/include/*.h" \
"libssh2_iphonesimulator/lib/libssh2.a" "iphonesimulator" "org.libssh2.libssh2"
composeFramework "libssh" "libssh_iphonesimulator/include/*.h" \
"libssh_iphonesimulator/lib/libssh.a" "iphonesimulator" "org.libssh.libssh"
# macOS
./iSSH2.sh --platform=macosx --min-version=11.0 -a "arm64 x86_64" --no-clean
composeFramework "libssl" "openssl_macosx/include/openssl/*.h" \
"openssl_macosx/lib/libssl.a" "macosx" "org.openssl.libssl"
composeFramework "libcrypto" "openssl_macosx/include/crypto/*.h" \
"openssl_macosx/lib/libcrypto.a" "macosx" "org.openssl.libcrypto"
composeFramework "libssh2" "libssh2_macosx/include/*.h" \
"libssh2_macosx/lib/libssh2.a" "macosx" "org.libssh2.libssh2"
composeFramework "libssh" "libssh_macosx/include/*.h" \
"libssh_macosx/lib/libssh.a" "macosx" "org.libssh.libssh"
# xcframeworks
xcodebuild -create-xcframework \
-framework iphoneos/libssl.framework \
-framework iphonesimulator/libssl.framework \
-framework macosx/libssl.framework \
-output libssl.xcframework
xcodebuild -create-xcframework \
-framework iphoneos/libcrypto.framework \
-framework iphonesimulator/libcrypto.framework \
-framework macosx/libcrypto.framework \
-output libcrypto.xcframework
xcodebuild -create-xcframework \
-framework iphoneos/libssh2.framework \
-framework iphonesimulator/libssh2.framework \
-framework macosx/libssh2.framework \
-output libssh2.xcframework
xcodebuild -create-xcframework \
-framework iphoneos/libssh.framework \
-framework iphonesimulator/libssh.framework \
-framework macosx/libssh.framework \
-output libssh.xcframework
rm -r iphoneos iphonesimulator macosx