-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·49 lines (42 loc) · 1.23 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
#!/bin/bash
set -e
debug_build() {
case "$platform" in
macOS) swift build -Xswiftc -DDEBUG -Xswiftc -DDEVELOPER -Xswiftc "-target" -Xswiftc "x86_64-apple-macosx$MACOSX_DEPLOYMENT_TARGET" ;;
linux) swift build -Xswiftc -DDEBUG -Xswiftc -DDEVELOPER -Xswiftc "-target" -Xswiftc "x86_64-pc-linux-gnu" ;;
esac
}
unsupportedCommand() {
echo "Unsupported command $1"
exit 1
}
case "$OSTYPE" in
darwin*) platform="macOS" ;;
linux*) platform="linux" ;;
*)
echo "unknown OS build script will need updating for support"
exit 1
;;
esac
MACOSX_DEPLOYMENT_TARGET=10.13
case "$1" in
xcode)
if [ "$platform" != "macOS" ]; then
unsupportedCommand "xcode"
fi
swift package generate-xcodeproj
;;
release)
case "$platform" in
macOS) swift build -Xswiftc -DDEBUG -Xswiftc -static-stdlib -Xswiftc "-target" -Xswiftc "x86_64-apple-macosx$MACOSX_DEPLOYMENT_TARGET" -c release ;;
linux) swift build -Xswiftc -DDEBUG -Xswiftc -static-stdlib -Xswiftc "-target" -Xswiftc "x86_64-pc-linux-gnu" -c release ;;
*)
unsupportedCommand "release"
esac
cp .build/release/kai /usr/local/bin/
;;
*)
debug_build
cp .build/debug/kai /usr/local/bin/
esac
echo "done"