ArchiSteamFarm/cc.sh

107 lines
2.3 KiB
Bash
Raw Normal View History

2019-02-18 23:59:26 +00:00
#!/usr/bin/env bash
set -euo pipefail
2016-03-29 20:58:18 +00:00
TARGET_FRAMEWORK="netcoreapp3.0"
2019-01-11 15:48:40 +00:00
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"
OUT="out"
2019-01-10 23:55:15 +00:00
ASF_UI=1
2016-03-29 20:58:18 +00:00
CLEAN=0
PUBLISH_TRIMMED=0
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
2019-01-11 15:48:40 +00:00
PRINT_USAGE() {
echo "Usage: $0 [--clean] [--publish-trimmed] [--no-asf-ui] [--no-pull] [--no-shared-compilation] [--no-test] [debug/release]"
2019-01-11 15:48:40 +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
debug|Debug) CONFIGURATION="Debug" ;;
2018-05-13 18:33:44 +00:00
release|Release) CONFIGURATION="Release" ;;
2019-01-10 23:55:15 +00:00
--asf-ui) ASF_UI=1 ;;
--no-asf-ui) ASF_UI=0 ;;
2016-03-29 20:58:18 +00:00
--clean) CLEAN=1 ;;
2018-05-13 18:33:44 +00:00
--no-clean) CLEAN=0 ;;
--publish-trimmed) PUBLISH_TRIMMED=1 ;;
--no-publish-trimmed) PUBLISH_TRIMMED=0 ;;
2018-05-13 18:33:44 +00:00
--pull) PULL=1 ;;
2018-02-26 18:58:25 +00:00
--no-pull) PULL=0 ;;
2018-05-13 18:33:44 +00:00
--shared-compilation) SHARED_COMPILATION=1 ;;
2018-02-07 05:37:21 +00:00
--no-shared-compilation) SHARED_COMPILATION=0 ;;
2018-05-13 18:33:44 +00:00
--test) TEST=1 ;;
2017-10-18 13:03:52 +00:00
--no-test) TEST=0 ;;
2019-01-11 15:48:40 +00:00
--help) PRINT_USAGE; exit 0 ;;
*) PRINT_USAGE; exit 1
2016-03-29 20:58:18 +00:00
esac
done
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
dotnet --info
2018-02-26 18:58:25 +00:00
if [[ "$PULL" -eq 1 && -d ".git" ]] && hash git 2>/dev/null; then
2018-12-26 01:53:06 +00:00
git pull --recurse-submodules=on-demand || 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
2019-01-10 23:55:15 +00:00
if [[ "$ASF_UI" -eq 1 ]]; then
if [[ -f "ASF-ui/package.json" ]] && hash npm 2>/dev/null; then
echo "Building ASF-ui..."
2019-01-10 23:55:15 +00:00
# ASF-ui doesn't clean itself after old build
rm -rf "ASF-ui/dist"
2018-12-05 22:17:09 +00:00
(
cd ASF-ui
npm ci
npm run-script deploy
)
2018-12-05 22:23:59 +00:00
2019-01-10 23:55:15 +00:00
# ASF's output www folder needs cleaning as well
rm -rf "${OUT}/www"
2019-01-10 23:55:15 +00:00
else
echo "WARNING: ASF-ui dependencies are missing, skipping build of ASF-ui..."
2019-01-10 23:55:15 +00:00
fi
fi
DOTNET_FLAGS=(-c "$CONFIGURATION" -f "$TARGET_FRAMEWORK" '/nologo')
2018-02-07 05:37:21 +00:00
if [[ "$PUBLISH_TRIMMED" -eq 0 ]]; then
DOTNET_FLAGS+=('/p:PublishTrimmed=false')
2018-03-17 18:00:31 +00:00
fi
2018-02-07 05:37:21 +00:00
if [[ "$SHARED_COMPILATION" -eq 0 ]]; then
2018-05-13 18:33:44 +00:00
DOTNET_FLAGS+=('/p:UseSharedCompilation=false')
fi
if [[ "$CLEAN" -eq 1 ]]; then
dotnet clean "${DOTNET_FLAGS[@]}"
rm -rf "$OUT"
2018-02-07 05:37:21 +00:00
fi
2017-10-18 13:03:52 +00:00
if [[ "$TEST" -eq 1 ]]; then
2018-05-13 18:33:44 +00:00
dotnet test "$TESTS_PROJECT" "${DOTNET_FLAGS[@]}"
2017-10-18 13:03:52 +00:00
fi
2016-03-29 20:58:18 +00:00
2019-09-26 20:13:50 +00:00
dotnet publish "$MAIN_PROJECT" -o "$OUT" "${DOTNET_FLAGS[@]}"
2018-05-13 18:33:44 +00:00
2016-03-29 20:58:18 +00:00
echo
echo "SUCCESS: Compilation finished successfully! :)"