-
Notifications
You must be signed in to change notification settings - Fork 4
/
entrypoint
executable file
·53 lines (44 loc) · 1.13 KB
/
entrypoint
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
#!/usr/bin/env bash
CONFIG=$1
LIVE=$2
build() {
swift build -Xswiftc -O --configuration ${CONFIG}
}
install_application() {
cp ./.build/${CONFIG}/libSTSLibrary.so /usr/lib/libSTSLibrary.so
cp ./.build/${CONFIG}/STSLibrary.swiftmodule /usr/lib/STSLibrary.swiftmodule
cp ./.build/${CONFIG}/STSApplication /usr/bin/STSApplication
}
run_application() {
/usr/bin/STSApplication
}
build_and_run() {
build && install_application && run_application
}
watch_files() {
inotifywait --quiet --recursive --monitor --event modify --format "%w%f" . \
| while read file change; do
if [[ ${file} = *".swift" ]] ; then
echo "Changes in file: $file, building..."
if [[ ${file} = *"Package.swift" ]] ; then
swift package update
fi
build_and_run
echo "Waiting for changes to run application again."
fi
done
}
entrypoint() {
build_and_run
}
live_entrypoint() {
run_application
echo "Waiting for changes to run application again."
watch_files &
wait
}
if [ ${LIVE} = true ] ; then
live_entrypoint
else
entrypoint
fi