2016-03-29 20:58:18 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
BUILD="Release"
|
2016-07-11 17:07:17 +00:00
|
|
|
AOT=0
|
2016-03-29 20:58:18 +00:00
|
|
|
CLEAN=0
|
|
|
|
|
2016-06-02 22:16:31 +00:00
|
|
|
MONO_ARGS=("--aot" "--llvm" "--server" "-O=all")
|
2016-03-29 20:58:18 +00:00
|
|
|
XBUILD_ARGS=("/nologo")
|
|
|
|
BINARIES=("ArchiSteamFarm/bin/Release/ArchiSteamFarm.exe")
|
|
|
|
SOLUTION="ArchiSteamFarm.sln"
|
|
|
|
|
|
|
|
PRINT_USAGE() {
|
2016-07-11 17:08:08 +00:00
|
|
|
echo "Usage: $0 [--clean] [--aot] [debug/release]"
|
2016-03-29 20:58:18 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
for ARG in "$@"; do
|
|
|
|
case "$ARG" in
|
|
|
|
release|Release) BUILD="Release" ;;
|
|
|
|
debug|Debug) BUILD="Debug" ;;
|
2016-07-11 17:07:17 +00:00
|
|
|
--aot) AOT=1 ;;
|
2016-03-29 20:58:18 +00:00
|
|
|
--clean) CLEAN=1 ;;
|
|
|
|
*) PRINT_USAGE
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
XBUILD_ARGS+=("/p:Configuration=$BUILD")
|
|
|
|
|
|
|
|
cd "$(dirname "$(readlink -f "$0")")"
|
|
|
|
|
2016-03-29 21:32:12 +00:00
|
|
|
if [[ -d ".git" ]] && hash git &>/dev/null; then
|
2016-07-15 19:48:39 +00:00
|
|
|
git pull || true
|
2016-03-29 20:58:18 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -f "$SOLUTION" ]]; then
|
|
|
|
echo "ERROR: $SOLUTION could not be found!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-03-29 21:32:12 +00:00
|
|
|
if hash nuget &>/dev/null; then
|
2016-07-15 19:48:39 +00:00
|
|
|
nuget restore "$SOLUTION" || true
|
2016-03-29 21:32:12 +00:00
|
|
|
fi
|
|
|
|
|
2016-03-29 20:58:18 +00:00
|
|
|
if [[ "$CLEAN" -eq 1 ]]; then
|
|
|
|
rm -rf out
|
|
|
|
xbuild "${XBUILD_ARGS[@]}" "/t:Clean" "$SOLUTION"
|
|
|
|
fi
|
|
|
|
|
|
|
|
xbuild "${XBUILD_ARGS[@]}" "$SOLUTION"
|
|
|
|
|
|
|
|
if [[ ! -f "${BINARIES[0]}" ]]; then
|
|
|
|
echo "ERROR: ${BINARIES[0]} binary could not be found!"
|
|
|
|
fi
|
|
|
|
|
2016-07-11 17:07:17 +00:00
|
|
|
# Use Mono AOT for output binaries if needed
|
|
|
|
if [[ "$AOT" -eq 1 && "$BUILD" = "Release" ]]; then
|
2016-03-29 20:58:18 +00:00
|
|
|
for BINARY in "${BINARIES[@]}"; do
|
|
|
|
if [[ ! -f "$BINARY" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
mono "${MONO_ARGS[@]}" "$BINARY"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Compilation finished successfully! :)"
|