Initial build tools for linux

This commit is contained in:
JustArchi 2017-06-26 05:14:44 +02:00
parent c787beb655
commit fb59a37346
2 changed files with 27 additions and 51 deletions

54
cc.sh
View file

@ -1,16 +1,15 @@
#!/bin/bash #!/bin/bash
set -eu set -eu
PROJECT="ArchiSteamFarm"
OUT="out"
MSBUILD_ARGS=("/nologo")
BUILD="Release" BUILD="Release"
AOT=0
CLEAN=0 CLEAN=0
XBUILD_ARGS=("/nologo")
BINARIES=("ArchiSteamFarm/bin/Release/ArchiSteamFarm.exe")
SOLUTION="ArchiSteamFarm.sln"
PRINT_USAGE() { PRINT_USAGE() {
echo "Usage: $0 [--clean] [--aot] [debug/release]" echo "Usage: $0 [--clean] [debug/release]"
exit 1 exit 1
} }
@ -18,57 +17,34 @@ for ARG in "$@"; do
case "$ARG" in case "$ARG" in
release|Release) BUILD="Release" ;; release|Release) BUILD="Release" ;;
debug|Debug) BUILD="Debug" ;; debug|Debug) BUILD="Debug" ;;
--aot) AOT=1 ;;
--clean) CLEAN=1 ;; --clean) CLEAN=1 ;;
*) PRINT_USAGE *) PRINT_USAGE
esac esac
done done
XBUILD_ARGS+=("/p:Configuration=$BUILD") if ! hash dotnet &>/dev/null; then
echo "ERROR: dotnet CLI tools are not installed!"
exit 1
fi
cd "$(dirname "$(readlink -f "$0")")" cd "$(dirname "$(readlink -f "$0")")"
if [[ -f "mono_envsetup.sh" ]]; then
set +u
source "mono_envsetup.sh"
set -u
fi
if [[ -d ".git" ]] && hash git &>/dev/null; then if [[ -d ".git" ]] && hash git &>/dev/null; then
git pull || true git pull || true
fi fi
if [[ ! -f "$SOLUTION" ]]; then if [[ ! -f "${PROJECT}.sln" ]]; then
echo "ERROR: $SOLUTION could not be found!" echo "ERROR: ${PROJECT}.sln could not be found!"
exit 1 exit 1
fi fi
# Not needed for ASF, we have packages in-tree
#if hash nuget &>/dev/null; then
# nuget restore "$SOLUTION" || true
#fi
if [[ "$CLEAN" -eq 1 ]]; then if [[ "$CLEAN" -eq 1 ]]; then
rm -rf out dotnet clean -c "$BUILD" -o "$OUT"
xbuild "${XBUILD_ARGS[@]}" "/t:Clean" "$SOLUTION" rm -rf "$OUT"
fi fi
xbuild "${XBUILD_ARGS[@]}" "$SOLUTION" dotnet restore
dotnet build -c "$BUILD" -o "$OUT" "${MSBUILD_ARGS[@]}"
if [[ ! -f "${BINARIES[0]}" ]]; then
echo "ERROR: ${BINARIES[0]} binary could not be found!"
fi
# Use Mono AOT for output binaries if needed
if [[ "$AOT" -eq 1 && "$BUILD" = "Release" ]]; then
for BINARY in "${BINARIES[@]}"; do
if [[ ! -f "$BINARY" ]]; then
continue
fi
mono --aot "$BINARY"
done
fi
echo echo
echo "Compilation finished successfully! :)" echo "Compilation finished successfully! :)"

24
run.sh
View file

@ -1,11 +1,13 @@
#!/bin/bash #!/bin/bash
set -eu set -eu
BUILD="Release" PROJECT="ArchiSteamFarm"
OUT="out"
UNTIL_CLEAN_EXIT=0 BINARY="${OUT}/${PROJECT}.dll"
ASF_ARGS=("") ASF_ARGS=("")
BUILD="Release"
UNTIL_CLEAN_EXIT=0
PRINT_USAGE() { PRINT_USAGE() {
echo "Usage: $0 [--until-clean-exit] [--cryptkey=] [--path=] [--server] [debug/release]" echo "Usage: $0 [--until-clean-exit] [--cryptkey=] [--path=] [--server] [debug/release]"
@ -24,15 +26,12 @@ for ARG in "$@"; do
esac esac
done done
cd "$(dirname "$(readlink -f "$0")")" if ! hash dotnet &>/dev/null; then
echo "ERROR: dotnet CLI tools are not installed!"
if [[ -f "mono_envsetup.sh" ]]; then exit 1
set +u
source "mono_envsetup.sh"
set -u
fi fi
BINARY="ArchiSteamFarm/bin/$BUILD/ArchiSteamFarm.exe" cd "$(dirname "$(readlink -f "$0")")"
if [[ ! -f "$BINARY" ]]; then if [[ ! -f "$BINARY" ]]; then
echo "ERROR: $BINARY could not be found!" echo "ERROR: $BINARY could not be found!"
@ -40,13 +39,14 @@ if [[ ! -f "$BINARY" ]]; then
fi fi
if [[ "$UNTIL_CLEAN_EXIT" -eq 0 ]]; then if [[ "$UNTIL_CLEAN_EXIT" -eq 0 ]]; then
mono "$BINARY" "${ASF_ARGS[@]}" dotnet exec "$BINARY" "${ASF_ARGS[@]}"
exit $? exit $?
fi fi
while [[ -f "$BINARY" ]]; do while [[ -f "$BINARY" ]]; do
if mono "$BINARY" "${ASF_ARGS[@]}"; then if dotnet exec "$BINARY" "${ASF_ARGS[@]}"; then
break break
fi fi
sleep 1 sleep 1
done done