forked from uber/mockolo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-script.sh
executable file
·85 lines (69 loc) · 1.57 KB
/
install-script.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
#!/bin/bash
# Causes the shell to exit if any subcommand returns a non-zero status
set -e
showhelp() {
echo "Description: Builds and installs target specified
Usage: -s/--source-dir [source dir], -t/--target [name of target to build/install], -d/--destination-dir [destination dir], -o/--output [output file name in tar.gz]"
exit
}
if [[ $1 == "" ]]
then
showhelp
fi
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD"
}
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-s|--source-dir)
SRCDIR=$(realpath "$2")
shift # past argument
shift # past value
;;
-d|--destination-dir)
DESTDIR=$(realpath "$2")
shift # past argument
shift # past value
;;
-t|--target)
TARGET="$2"
shift # past argument
shift # past value
;;
-o|--output)
OUTFILE="$2"
shift # past argument
shift # past value
;;
-h|--help)
showhelp
;;
*)
showhelp
;;
esac
done
CUR=$PWD
echo "** Clean/Build..."
echo "SOURCE DIR = ${SRCDIR}"
echo "TARGET = ${TARGET}"
echo "DESTINATION DIR = ${DESTDIR}"
echo "OUTPUT FILE = ${OUTFILE}"
cd "$SRCDIR"
rm -rf .build
case $(uname -s) in
Linux*) swift build --static-swift-stdlib -c release
cd .build/release;;
Darwin*) swift build -c release --arch arm64 --arch x86_64
cd .build/apple/Products/Release;;
*) echo "unknown destination"
exit;;
esac
echo "** Install..."
tar -cvzf "$OUTFILE" "$TARGET"
mv "$OUTFILE" "$DESTDIR"
cd "$CUR"
echo "** Output file is at $DESTDIR/$OUTFILE"
echo "** Done."