forked from JustArchiNET/ArchiSteamFarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cc.sh
executable file
·66 lines (52 loc) · 1.46 KB
/
cc.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/bash
set -eu
MAIN_PROJECT="ArchiSteamFarm"
TESTS_PROJECT="${MAIN_PROJECT}.Tests"
SOLUTION="${MAIN_PROJECT}.sln"
CONFIGURATION="Release"
OUT="out/source"
CLEAN=0
TEST=1
cd "$(dirname "$(readlink -f "$0")")"
for ARG in "$@"; do
case "$ARG" in
release|Release) CONFIGURATION="Release" ;;
debug|Debug) CONFIGURATION="Debug" ;;
--clean) CLEAN=1 ;;
--no-test) TEST=0 ;;
*) echo "Usage: $0 [--clean] [--no-test] [debug/release]"; exit 1
esac
done
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
if ! hash dotnet 2>/dev/null; then
echo "ERROR: dotnet CLI tools are not installed!"
exit 1
fi
dotnet --info
if [[ -d ".git" ]] && hash git 2>/dev/null; then
git pull || true
fi
if [[ ! -f "$SOLUTION" ]]; then
echo "ERROR: $SOLUTION could not be found!"
exit 1
fi
SETUP_FLAGS=(-c "$CONFIGURATION" -o "$OUT")
BUILD_FLAGS=(--no-restore /nologo /p:LinkDuringPublish=false)
if [[ "$TEST" -eq 1 ]]; then
if [[ "$CLEAN" -eq 1 ]]; then
dotnet clean "${SETUP_FLAGS[@]}"
rm -rf "${MAIN_PROJECT:?}/${OUT}" "${TESTS_PROJECT:?}/${OUT}"
fi
dotnet restore
dotnet publish "${SETUP_FLAGS[@]}" "${BUILD_FLAGS[@]}"
dotnet test "$TESTS_PROJECT" "${SETUP_FLAGS[@]}" --no-build "${BUILD_FLAGS[@]}"
else
if [[ "$CLEAN" -eq 1 ]]; then
dotnet clean "$MAIN_PROJECT" "${SETUP_FLAGS[@]}"
rm -rf "${MAIN_PROJECT:?}/${OUT}"
fi
dotnet restore "$MAIN_PROJECT"
dotnet publish "$MAIN_PROJECT" "${SETUP_FLAGS[@]}" "${BUILD_FLAGS[@]}"
fi
echo
echo "Compilation finished successfully! :)"