2016-11-23 03:37:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-12-14 01:00:55 +00:00
|
|
|
# If any command errors, stop the script
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Set up directories (mirrors build.bat)
|
|
|
|
ME="$(readlink -f "$0")"
|
|
|
|
LOCATION="$(dirname "$ME")"
|
|
|
|
SRC_ROOT="$(dirname "$LOCATION")"
|
|
|
|
PROJECT_ROOT="$(dirname "$SRC_ROOT")"
|
|
|
|
if [ ! -d "$PROJECT_ROOT/build" ]; then
|
|
|
|
mkdir "$PROJECT_ROOT/build"
|
|
|
|
fi
|
|
|
|
BUILD_ROOT="$PROJECT_ROOT/build"
|
|
|
|
BIN_ROOT="$SRC_ROOT/bin"
|
|
|
|
CUSTOM_ROOT="$SRC_ROOT/custom"
|
|
|
|
CUSTOM_BIN="$CUSTOM_ROOT/bin"
|
2017-06-30 00:34:11 +00:00
|
|
|
|
|
|
|
# Get the build mode
|
2017-02-26 20:13:06 +00:00
|
|
|
BUILD_MODE="$1"
|
|
|
|
if [ -z "$BUILD_MODE" ]; then
|
|
|
|
BUILD_MODE="-DDEV_BUILD"
|
|
|
|
fi
|
|
|
|
|
2017-06-30 00:34:11 +00:00
|
|
|
# Get the OS specific flags
|
2019-12-14 01:00:55 +00:00
|
|
|
chmod +rx "$BIN_ROOT/detect_os.sh"
|
|
|
|
os=$("$BIN_ROOT/detect_os.sh")
|
2017-06-29 23:37:48 +00:00
|
|
|
|
|
|
|
if [[ "$os" == "linux" ]]; then
|
2019-12-14 01:00:55 +00:00
|
|
|
WARNINGS="-Wno-write-strings -Wno-comment"
|
2017-06-29 23:37:48 +00:00
|
|
|
elif [[ "$os" == "mac" ]]; then
|
2017-06-29 23:41:39 +00:00
|
|
|
WARNINGS="-Wno-write-strings -Wno-comment -Wno-logical-op-parentheses -Wno-null-dereference -Wno-switch"
|
2017-06-29 23:37:48 +00:00
|
|
|
fi
|
|
|
|
|
2017-02-26 20:13:06 +00:00
|
|
|
FLAGS="-D_GNU_SOURCE -fPIC -fpermissive $BUILD_MODE"
|
2019-12-14 01:00:55 +00:00
|
|
|
INCLUDES="-I$SRC_ROOT -I$CUSTOM_ROOT"
|
2016-11-23 03:37:28 +00:00
|
|
|
|
2017-06-30 00:34:11 +00:00
|
|
|
# Execute
|
2019-12-14 01:00:55 +00:00
|
|
|
g++ $WARNINGS $FLAGS $INCLUDES "$BIN_ROOT/4ed_build.cpp" -g -o "$BUILD_ROOT/build"
|
|
|
|
pushd "$SRC_ROOT"
|
|
|
|
"$BUILD_ROOT/build"
|
|
|
|
popd
|