diff options
Diffstat (limited to 'projects/scripts/build-linux.sh')
| -rw-r--r-- | projects/scripts/build-linux.sh | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/projects/scripts/build-linux.sh b/projects/scripts/build-linux.sh index 965542ce..5a004ddd 100644 --- a/projects/scripts/build-linux.sh +++ b/projects/scripts/build-linux.sh @@ -2,13 +2,13 @@ # Change your executable name here GAME_NAME="game" -# Set your sources here (relative to the ./builds/linux directory) +# Set your sources here (relative paths!) # Example with two source folders: -# SOURCES="../../src/*.c ../../src/submodule/*.c" -SOURCES="../../core_basic_window.c" +# SOURCES="src/*.c src/submodule/*.c" +SOURCES="core_basic_window.c" -# Set your raylib/src location here, relative to the ./temp/x directory -RAYLIB_SRC="../../../../src" +# Set your raylib/src location here (relative path!) +RAYLIB_SRC="../../src" # About this build script: it does many things, but in essence, it's # very simple. It has 3 compiler invocations: building raylib (which @@ -17,14 +17,18 @@ RAYLIB_SRC="../../../../src" # wrapped in an if statement to make the -qq flag work, it's pretty # verbose, sorry. +# Stop the script if a compilation (or something else?) fails +set -e + # Get arguments -while getopts ":hdurcq" opt; do +while getopts ":hdusrcq" opt; do case $opt in h) - echo "Usage: ./linux-build.sh [-hdurcqq]" + echo "Usage: ./linux-build.sh [-hdusrcqq]" echo " -h Show this information" echo " -d Faster builds that have debug symbols, and enable warnings" echo " -u Run upx* on the executable after compilation (before -r)" + echo " -s Run strip on the executable after compilation (before -r)" echo " -r Run the executable after compilation" echo " -c Remove the temp/(debug|release) directory, ie. full recompile" echo " -q Suppress this script's informational prints" @@ -47,6 +51,9 @@ while getopts ":hdurcq" opt; do u) UPX_IT="1" ;; + s) + STRIP_IT="1" + ;; r) RUN_AFTER_BUILD="1" ;; @@ -72,23 +79,23 @@ if [ -z "$CC" ]; then CC=cc fi +# Directories +ROOT_DIR=$PWD +SOURCES="$ROOT_DIR/$SOURCES" +RAYLIB_SRC="$ROOT_DIR/$RAYLIB_SRC" + # Flags OUTPUT_DIR="builds/linux" COMPILATION_FLAGS="-std=c99 -Os -flto" -if [ "$CC" = "clang" ]; then - # Clang 7.0.1 fails to compile with -Os, possibly the same bug as this: - # https://www.mail-archive.com/[email protected]/msg25771.html - COMPILATION_FLAGS="-std=c99 -O2 -flto" - [ -z "$QUIET" ] && echo "COMPILE-WARNING: \$CC is clang, using -O2 instead of -Os." -fi FINAL_COMPILE_FLAGS="-s" WARNING_FLAGS="-Wall -Wextra -Wpedantic" -LINK_FLAGS="-lm -ldl -lpthread -lX11 -lxcb -lGL -lGLX -lXext -lGLdispatch -lXau -lXdmcp" +LINK_FLAGS="-flto -lm -ldl -lpthread -lX11 -lxcb -lGL -lGLX -lXext -lGLdispatch -lXau -lXdmcp" # Debug changes to flags if [ -n "$BUILD_DEBUG" ]; then OUTPUT_DIR="builds-debug/linux" COMPILATION_FLAGS="-std=c99 -O0 -g" FINAL_COMPILE_FLAGS="" + LINK_FLAGS="-lm -ldl -lpthread -lX11 -lxcb -lGL -lGLX -lXext -lGLdispatch -lXau -lXdmcp" fi # Display what we're doing @@ -99,7 +106,6 @@ else fi # Create the raylib cache directory -ROOT_DIR=$(pwd) TEMP_DIR="temp/release" if [ -n "$BUILD_DEBUG" ]; then TEMP_DIR="temp/debug" @@ -131,15 +137,20 @@ mkdir -p $OUTPUT_DIR cd $OUTPUT_DIR [ -z "$QUIET" ] && echo "COMPILE-INFO: Compiling game code." if [ -n "$REALLY_QUIET" ]; then - $CC -c -o main.o -I$RAYLIB_SRC $COMPILATION_FLAGS $WARNING_FLAGS $SOURCES > /dev/null 2>&1 - $CC -o $GAME_NAME $ROOT_DIR/$TEMP_DIR/*.o main.o $LINK_FLAGS > /dev/null 2>&1 + $CC -c -I$RAYLIB_SRC $COMPILATION_FLAGS $WARNING_FLAGS $SOURCES > /dev/null 2>&1 + $CC -o $GAME_NAME $ROOT_DIR/$TEMP_DIR/*.o *.o $LINK_FLAGS > /dev/null 2>&1 else - $CC -c -o main.o -I$RAYLIB_SRC $COMPILATION_FLAGS $WARNING_FLAGS $SOURCES - $CC -o $GAME_NAME $ROOT_DIR/$TEMP_DIR/*.o main.o $LINK_FLAGS + $CC -c -I$RAYLIB_SRC $COMPILATION_FLAGS $WARNING_FLAGS $SOURCES + $CC -o $GAME_NAME $ROOT_DIR/$TEMP_DIR/*.o *.o $LINK_FLAGS fi -rm main.o +rm *.o [ -z "$QUIET" ] && echo "COMPILE-INFO: Game compiled into an executable in: $OUTPUT_DIR/" +if [ -n "$STRIP_IT" ]; then + [ -z "$QUIET" ] && echo "COMPILE-INFO: Stripping $GAME_NAME." + strip $GAME_NAME +fi + if [ -n "$UPX_IT" ]; then [ -z "$QUIET" ] && echo "COMPILE-INFO: Packing $GAME_NAME with upx." upx $GAME_NAME > /dev/null 2>&1 |
