forked from x2on/OpenSSL-for-iPhone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-xcframework.sh
executable file
·89 lines (76 loc) · 1.75 KB
/
create-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
#!/bin/sh
set -u
XFWNAME=OpenSSL.xcframework
if [ ! -d lib ]; then
echo "Please run build-libssl.sh first!"
exit 1
fi
if [ -d $XFWNAME ]; then
echo "* Removing existing $XFWNAME copy"
rm -rf $XFWNAME
fi
LIBS=""
LIBTOOL_FLAGS="-no_warning_for_no_symbols -static"
# Copy include files into temporary dir
make_include_dir()
{
mkdir xfwinclude
if [ $? -ne 0 ]; then
exit 1
fi
cp -r include/openssl xfwinclude/
if [ $? -ne 0 ]; then
exit 1
fi
}
make_module_map()
{
MODULE_HEADERS=`ls include/openssl 2>/dev/null`
MODULEMAP="xfwinclude/openssl/module.modulemap"
BLACKLISTED="asn1_mac.h"
echo "module OpenSSL {" > $MODULEMAP
for MODULE_HEADER in $MODULE_HEADERS
do
if ! [[ "$BLACKLISTED" =~ .*"$MODULE_HEADER".* ]]; then
echo $MODULE_HEADER | sed -E 's/^.*$/ header \"&\"/' >> $MODULEMAP
fi
done
echo "\n export *\n}" >> $MODULEMAP
}
# Combine libssl and libcrypto into single per-platform library
make_platform_lib()
{
SLICE_LIBS=`ls lib/lib*-$SLICE.a 2>/dev/null`
SLICE_OUT="lib/OpenSSL-$SLICE.a"
if [ ${#SLICE_LIBS} -gt 0 ]; then
echo "* Creating library for $SLICE"
libtool $LIBTOOL_FLAGS -o $SLICE_OUT $SLICE_LIBS
if [ $? -ne 0 ]; then
exit 1
fi
LIBS="$LIBS -library $SLICE_OUT -headers xfwinclude"
else
echo "* Skipping $SLICE. No libraries found."
fi
}
# Remove temporary files
remove_temp_files()
{
rm lib/OpenSSL-*.a 2>/dev/null
rm -r xfwinclude 2>/dev/null
}
remove_temp_files
make_include_dir
make_module_map
PLATFORMS="iOS tvOS watchOS Catalyst"
for PLATFORM in $PLATFORMS
do
SLICE="$PLATFORM"
make_platform_lib
SLICE="$PLATFORM-Sim"
make_platform_lib
done
echo "* Creating $XFWNAME"
xcodebuild -create-xcframework $LIBS -output $XFWNAME
remove_temp_files
echo "Done!"