Fix and update projects/scripts
This commit is contained in:
parent
5d3905d4d4
commit
228f86d3ca
4 changed files with 250 additions and 49 deletions
|
@ -2,13 +2,13 @@
|
|||
# Change your executable name here
|
||||
GAME_NAME="game"
|
||||
|
||||
# Set your sources here (relative to the ./builds/osx 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: ./osx-build.sh [-hdurcqq]"
|
||||
echo "Usage: ./osx-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,17 +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/osx"
|
||||
COMPILATION_FLAGS="-std=c99 -O2 -flto"
|
||||
FINAL_COMPILE_FLAGS="-s"
|
||||
WARNING_FLAGS="-Wall -Wextra -Wpedantic"
|
||||
LINK_FLAGS="-framework OpenGL -framework OpenAL -framework IOKit -framework CoreVideo -framework Cocoa"
|
||||
LINK_FLAGS="-flto -framework OpenGL -framework OpenAL -framework IOKit -framework CoreVideo -framework Cocoa"
|
||||
# Debug changes to flags
|
||||
if [ -n "$BUILD_DEBUG" ]; then
|
||||
OUTPUT_DIR="builds-debug/osx"
|
||||
COMPILATION_FLAGS="-std=c99 -O0 -g"
|
||||
FINAL_COMPILE_FLAGS=""
|
||||
LINK_FLAGS="-framework OpenGL -framework OpenAL -framework IOKit -framework CoreVideo -framework Cocoa"
|
||||
fi
|
||||
|
||||
# Display what we're doing
|
||||
|
@ -93,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"
|
||||
|
@ -127,15 +139,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 $SOURCES $COMPILATION_FLAGS $WARNING_FLAGS > /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 $SOURCES $COMPILATION_FLAGS $WARNING_FLAGS
|
||||
$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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue