-
Notifications
You must be signed in to change notification settings - Fork 3
/
make_dist.sh
executable file
·66 lines (54 loc) · 1.92 KB
/
make_dist.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
#!/bin/sh
PROJECT_ROOT=$(cd `dirname $0` && pwd)
BUILD_DIR="${PROJECT_ROOT}/DerivedData/CZiti/Build/Products"
DERIVED_BUILD_DIR="${PROJECT_ROOT}/DerivedData/CZiti/Build/Intermediates.noindex/CZiti.build"
DIST_DIR="${PROJECT_ROOT}/dist"
PROJECT_NAME="CZiti"
LIB_NAME="libCZiti.a"
SWIFTMODULE_NAME="CZiti.swiftmodule"
: ${CONFIGURATION:="Release"}
# make for iOS, macOS, or All
: ${FOR:="All"}
function edit_interfaces {
module_dir="$1"
# Edit the .swiftinterface files to remove import of CZitiPrivate
find ${module_dir} -name '*.swiftinterface' -print0 |
while IFS= read -r -d '' i; do
echo "Editing file: $i"
sed 's/^import CZitiPrivate$/\/\/ import CZitiPrivate/' $i > $i.bak && mv $i.bak $i
if [ $? -ne 0 ] ; then
echo "Unable to edit ${i}"
exit 1
fi
done
}
# accrue these based on $FOR value
xcframework_args=""
#
# iOS
#
if [ "${FOR}" = "All" ] || [ "${FOR}" = "iOS" ] ; then
xcframework_args+=" -library ${BUILD_DIR}/${CONFIGURATION}-iphoneos/${LIB_NAME}"
xcframework_args+=" -headers ${DERIVED_BUILD_DIR}/${CONFIGURATION}-iphoneos/CZiti-iOS.build/DerivedSources"
xcframework_args+=" -library ${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${LIB_NAME}"
xcframework_args+=" -headers ${DERIVED_BUILD_DIR}/${CONFIGURATION}-iphonesimulator/CZiti-iOS.build/DerivedSources"
fi
#
# macOS
#
if [ "${FOR}" = "All" ] || [ "${FOR}" = "macOS" ] ; then
xcframework_args+=" -library ${BUILD_DIR}/${CONFIGURATION}/${LIB_NAME}"
xcframework_args+=" -headers ${DERIVED_BUILD_DIR}/${CONFIGURATION}/CZiti-macOS.build/DerivedSources"
fi
#
# xcframework
#
echo "Creating xcframework"
echo "xcframework_args: ${xcframework_args}"
xcodebuild -create-xcframework ${xcframework_args} -output ${DIST_DIR}/CZiti.xcframework
if [ $? -ne 0 ] ; then
echo "Unable to create xcframework"
exit 1
fi
edit_interfaces ${DIST_DIR}/CZiti.xcframework
echo "Done creating ${DIST_DIR}/CZiti.xcframework"