2016-03-29 20:58:18 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
|
2017-11-13 01:13:29 +00:00
|
|
|
MAIN_PROJECT="ArchiSteamFarm"
|
|
|
|
TESTS_PROJECT="${MAIN_PROJECT}.Tests"
|
|
|
|
SOLUTION="${MAIN_PROJECT}.sln"
|
2017-10-18 13:03:52 +00:00
|
|
|
CONFIGURATION="Release"
|
2017-08-31 05:54:07 +00:00
|
|
|
OUT="out/source"
|
|
|
|
|
2016-03-29 20:58:18 +00:00
|
|
|
CLEAN=0
|
2018-03-17 18:00:31 +00:00
|
|
|
LINK_DURING_PUBLISH=1
|
2018-02-26 18:58:25 +00:00
|
|
|
PULL=1
|
2018-02-07 05:37:21 +00:00
|
|
|
SHARED_COMPILATION=1
|
2017-10-18 13:03:52 +00:00
|
|
|
TEST=1
|
2016-03-29 20:58:18 +00:00
|
|
|
|
2017-10-18 13:03:52 +00:00
|
|
|
cd "$(dirname "$(readlink -f "$0")")"
|
2016-03-29 20:58:18 +00:00
|
|
|
|
|
|
|
for ARG in "$@"; do
|
|
|
|
case "$ARG" in
|
2017-08-31 05:54:07 +00:00
|
|
|
release|Release) CONFIGURATION="Release" ;;
|
|
|
|
debug|Debug) CONFIGURATION="Debug" ;;
|
2016-03-29 20:58:18 +00:00
|
|
|
--clean) CLEAN=1 ;;
|
2018-03-17 18:00:31 +00:00
|
|
|
--no-link-during-publish) LINK_DURING_PUBLISH=0 ;;
|
2018-02-26 18:58:25 +00:00
|
|
|
--no-pull) PULL=0 ;;
|
2018-02-07 05:37:21 +00:00
|
|
|
--no-shared-compilation) SHARED_COMPILATION=0 ;;
|
2017-10-18 13:03:52 +00:00
|
|
|
--no-test) TEST=0 ;;
|
2018-03-17 18:00:31 +00:00
|
|
|
*) echo "Usage: $0 [--clean] [--no-link-during-publish] [--no-pull] [--no-shared-compilation] [--no-test] [debug/release]"; exit 1
|
2016-03-29 20:58:18 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2017-10-18 13:10:32 +00:00
|
|
|
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM
|
2017-10-18 13:03:52 +00:00
|
|
|
|
|
|
|
if ! hash dotnet 2>/dev/null; then
|
2017-06-26 03:14:44 +00:00
|
|
|
echo "ERROR: dotnet CLI tools are not installed!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-03-29 20:58:18 +00:00
|
|
|
|
2017-08-31 05:54:07 +00:00
|
|
|
dotnet --info
|
|
|
|
|
2018-02-26 18:58:25 +00:00
|
|
|
if [[ "$PULL" -eq 1 && -d ".git" ]] && hash git 2>/dev/null; then
|
2016-07-15 19:48:39 +00:00
|
|
|
git pull || true
|
2016-03-29 20:58:18 +00:00
|
|
|
fi
|
|
|
|
|
2017-08-31 05:54:25 +00:00
|
|
|
if [[ ! -f "$SOLUTION" ]]; then
|
|
|
|
echo "ERROR: $SOLUTION could not be found!"
|
2016-03-29 20:58:18 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-11-13 01:13:29 +00:00
|
|
|
SETUP_FLAGS=(-c "$CONFIGURATION" -o "$OUT")
|
2018-03-17 16:15:32 +00:00
|
|
|
BUILD_FLAGS=(--no-restore '/nologo')
|
2018-02-07 05:37:21 +00:00
|
|
|
|
2018-03-17 18:00:31 +00:00
|
|
|
if [[ "$LINK_DURING_PUBLISH" -eq 0 ]]; then
|
|
|
|
BUILD_FLAGS+=('/p:LinkDuringPublish=false')
|
|
|
|
fi
|
|
|
|
|
2018-02-07 05:37:21 +00:00
|
|
|
if [[ "$SHARED_COMPILATION" -eq 0 ]]; then
|
|
|
|
BUILD_FLAGS+=('/p:UseSharedCompilation=false')
|
|
|
|
fi
|
2017-08-31 05:54:07 +00:00
|
|
|
|
2017-10-18 13:03:52 +00:00
|
|
|
if [[ "$TEST" -eq 1 ]]; then
|
2017-11-13 01:13:29 +00:00
|
|
|
if [[ "$CLEAN" -eq 1 ]]; then
|
|
|
|
dotnet clean "${SETUP_FLAGS[@]}"
|
|
|
|
rm -rf "${MAIN_PROJECT:?}/${OUT}" "${TESTS_PROJECT:?}/${OUT}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
dotnet restore
|
2017-12-07 13:39:41 +00:00
|
|
|
dotnet publish "${SETUP_FLAGS[@]}" "${BUILD_FLAGS[@]}"
|
|
|
|
dotnet test "$TESTS_PROJECT" "${SETUP_FLAGS[@]}" --no-build "${BUILD_FLAGS[@]}"
|
2017-11-13 01:13:29 +00:00
|
|
|
else
|
|
|
|
if [[ "$CLEAN" -eq 1 ]]; then
|
|
|
|
dotnet clean "$MAIN_PROJECT" "${SETUP_FLAGS[@]}"
|
|
|
|
rm -rf "${MAIN_PROJECT:?}/${OUT}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
dotnet restore "$MAIN_PROJECT"
|
2017-12-07 13:39:41 +00:00
|
|
|
dotnet publish "$MAIN_PROJECT" "${SETUP_FLAGS[@]}" "${BUILD_FLAGS[@]}"
|
2017-10-18 13:03:52 +00:00
|
|
|
fi
|
2016-03-29 20:58:18 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Compilation finished successfully! :)"
|