ArchiSteamFarm/mono_envsetup.sh

75 lines
1.8 KiB
Bash
Raw Normal View History

MONO_DEBUG_IF_AVAILABLE() {
2017-01-16 02:03:19 +00:00
echo "INFO: Appending $1 to MONO_DEBUG..."
local PREVIOUS_MONO_DEBUG="$MONO_DEBUG"
# Add change if needed
2016-09-02 16:57:13 +00:00
if [ -z "$PREVIOUS_MONO_DEBUG" ]; then
export MONO_DEBUG="$1"
elif echo "$PREVIOUS_MONO_DEBUG" | grep -Fq "$1"; then
2017-01-16 02:03:19 +00:00
echo "DONE: $1 already exists"
return 0
else
export MONO_DEBUG="${PREVIOUS_MONO_DEBUG},${1}"
fi
# If we did a change, check if Mono supports that option
# If not, it will be listed as invalid option on line 1
if mono "" 2>&1 | head -n 1 | grep -Fq "$1"; then
2017-01-16 02:03:19 +00:00
echo "FAILED: $1"
export MONO_DEBUG="$PREVIOUS_MONO_DEBUG"
return 1
fi
2017-01-16 02:03:19 +00:00
echo "DONE: $1"
return 0
}
2017-01-16 02:03:19 +00:00
VERSION_GREATER_THAN() {
2016-09-02 16:57:13 +00:00
if [ "$1" = "$2" ]; then
return 1
fi
2017-01-16 02:03:19 +00:00
! VERSION_LESS_EQUAL_THAN "$1" "$2"
}
2017-01-16 02:03:19 +00:00
VERSION_GREATER_EQUAL_THAN() {
! VERSION_LESS_THAN "$1" "$2"
}
2017-01-16 02:03:19 +00:00
VERSION_LESS_THAN() {
2016-09-02 16:57:13 +00:00
if [ "$1" = "$2" ]; then
return 1
fi
2017-01-16 02:03:19 +00:00
VERSION_LESS_EQUAL_THAN "$1" "$2"
}
2017-01-16 02:03:19 +00:00
VERSION_LESS_EQUAL_THAN() {
2016-09-02 16:57:13 +00:00
[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n 1)" ]
}
2017-01-16 02:03:19 +00:00
echo "INFO: Mono environment setup executed!"
2017-01-16 02:03:19 +00:00
MINIMUM_MONO_VERSION="4.6.0" # Bump as needed
CURRENT_MONO_VERSION="$(mono -V | head -n 1 | cut -d ' ' -f 5)"
2017-01-16 02:03:19 +00:00
echo "INFO: Mono version: $CURRENT_MONO_VERSION | Required: ${MINIMUM_MONO_VERSION}+"
2016-08-27 07:45:55 +00:00
2017-01-16 02:03:19 +00:00
if VERSION_LESS_THAN "$CURRENT_MONO_VERSION" "$MINIMUM_MONO_VERSION"; then
echo "ERROR: You've attempted to build ASF with unsupported Mono version!"
return 1
fi
2016-08-27 07:45:55 +00:00
2017-01-16 02:03:19 +00:00
MONO_DEBUG_IF_AVAILABLE "no-compact-seq-points"
MONO_DEBUG_IF_AVAILABLE "no-gdb-backtrace"
2016-09-12 19:01:09 +00:00
if [ -z "$MONO_ENV_OPTIONS" ]; then
echo "INFO: Setting MONO_ENV_OPTIONS to: --server -O=all"
export MONO_ENV_OPTIONS="--server -O=all"
else
echo "INFO: Skipping setting of MONO_ENV_OPTIONS as it's already declared with value: $MONO_ENV_OPTIONS"
fi
2016-09-12 18:52:30 +00:00
2017-01-16 02:03:19 +00:00
echo "INFO: Mono environment setup finished!"