Merge pull request #855 from neonmoe/patch-buildscripts

Fix and update projects/scripts
This commit is contained in:
Ray 2019-05-29 17:41:25 +02:00 committed by GitHub
commit f9888d15ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 250 additions and 49 deletions

View File

@ -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/llvm-bugs@lists.llvm.org/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

View File

@ -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

169
projects/scripts/build-rpi.sh Executable file
View File

@ -0,0 +1,169 @@
#!/bin/sh
# Change your executable name here
GAME_NAME="game"
# Set your sources here (relative paths!)
# Example with two source folders:
# SOURCES="src/*.c src/submodule/*.c"
SOURCES="core_basic_window.c"
# 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
# is not done always, see logic by searching "Build raylib"), building
# src/*.c files, and linking together those two. Each invocation is
# 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 ":hdusrcq" opt; do
case $opt in
h)
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"
echo " -qq Suppress all prints, complete silence (> /dev/null 2>&1)"
echo ""
echo "* This is mostly here to make building simple \"shipping\" versions"
echo " easier, and it's a very small bit in the build scripts. The option"
echo " requires that you have upx installed and on your path, of course."
echo ""
echo "Examples:"
echo " Build a release build: ./linux-build.sh"
echo " Build a release build, full recompile: ./linux-build.sh -c"
echo " Build a debug build and run: ./linux-build.sh -d -r"
echo " Build in debug, run, don't print at all: ./linux-build.sh -drqq"
exit 0
;;
d)
BUILD_DEBUG="1"
;;
u)
UPX_IT="1"
;;
s)
STRIP_IT="1"
;;
r)
RUN_AFTER_BUILD="1"
;;
c)
BUILD_ALL="1"
;;
q)
if [ -n "$QUIET" ]; then
REALLY_QUIET="1"
else
QUIET="1"
fi
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
# Set CC if it's not set already
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"
FINAL_COMPILE_FLAGS="-s"
WARNING_FLAGS="-Wall -Wextra -Wpedantic"
LINK_FLAGS="-flto -lm -ldl -lrt -lpthread -lv4l2 -lbrcmGLESv2 -lbrcmEGL -lbcm_host -L/opt/vc/lib"
# 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 -lrt -lpthread -lv4l2 -lbrcmGLESv2 -lbrcmEGL -lbcm_host -L/opt/vc/lib"
fi
# Display what we're doing
if [ -n "$BUILD_DEBUG" ]; then
[ -z "$QUIET" ] && echo "COMPILE-INFO: Compiling in debug mode. ($COMPILATION_FLAGS $WARNING_FLAGS)"
else
[ -z "$QUIET" ] && echo "COMPILE-INFO: Compiling in release mode. ($COMPILATION_FLAGS $FINAL_COMPILE_FLAGS)"
fi
# Create the raylib cache directory
TEMP_DIR="temp/release"
if [ -n "$BUILD_DEBUG" ]; then
TEMP_DIR="temp/debug"
fi
# If there's a -c flag, remove the cache
if [ -d "$TEMP_DIR" ] && [ -n "$BUILD_ALL" ]; then
[ -z "$QUIET" ] && echo "COMPILE-INFO: Found cached raylib, rebuilding."
rm -r "$TEMP_DIR"
fi
# If temp directory doesn't exist, build raylib
if [ ! -d "$TEMP_DIR" ]; then
mkdir -p $TEMP_DIR
cd $TEMP_DIR
RAYLIB_DEFINES="-D_DEFAULT_SOURCE -DPLATFORM_RPI -DGRAPHICS_API_OPENGL_ES2"
RAYLIB_C_FILES="$RAYLIB_SRC/core.c $RAYLIB_SRC/shapes.c $RAYLIB_SRC/textures.c $RAYLIB_SRC/text.c $RAYLIB_SRC/models.c $RAYLIB_SRC/utils.c $RAYLIB_SRC/raudio.c"
RAYLIB_INCLUDE_FLAGS="-I$RAYLIB_SRC -I/opt/vc/include"
if [ -n "$REALLY_QUIET" ]; then
$CC -c $RAYLIB_DEFINES $RAYLIB_INCLUDE_FLAGS $COMPILATION_FLAGS $RAYLIB_C_FILES > /dev/null 2>&1
else
$CC -c $RAYLIB_DEFINES $RAYLIB_INCLUDE_FLAGS $COMPILATION_FLAGS $RAYLIB_C_FILES
fi
[ -z "$QUIET" ] && echo "COMPILE-INFO: Raylib compiled into object files in: $TEMP_DIR/"
cd $ROOT_DIR
fi
# Build the actual game
mkdir -p $OUTPUT_DIR
cd $OUTPUT_DIR
[ -z "$QUIET" ] && echo "COMPILE-INFO: Compiling game code."
if [ -n "$REALLY_QUIET" ]; then
$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 -I$RAYLIB_SRC $COMPILATION_FLAGS $WARNING_FLAGS $SOURCES
$CC -o $GAME_NAME $ROOT_DIR/$TEMP_DIR/*.o *.o $LINK_FLAGS
fi
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
fi
if [ -n "$RUN_AFTER_BUILD" ]; then
[ -z "$QUIET" ] && echo "COMPILE-INFO: Running."
if [ -n "$REALLY_QUIET" ]; then
./$GAME_NAME > /dev/null 2>&1
else
./$GAME_NAME
fi
fi
cd $ROOT_DIR
[ -z "$QUIET" ] && echo "COMPILE-INFO: All done."

View File

@ -2,13 +2,13 @@
REM Change your executable name here
set GAME_NAME=game.exe
REM Set your sources here (relative to the builds\windows directory)
REM Set your sources here (relative paths!)
REM Example with two source folders:
REM set SOURCES=..\..\src\*.c ..\..\src\submodule\*.c
set SOURCES=..\..\core_basic_window.c
REM set SOURCES=src\*.c src\submodule\*.c
set SOURCES=core_basic_window.c
REM Set your raylib/src location here, relative to the ./temp/x directory
set RAYLIB_SRC=..\..\..\..\src
REM Set your raylib\src location here (relative path!)
set RAYLIB_SRC=..\..\src
REM About this build script: it does many things, but in essence, it's
REM very simple. It has 3 compiler invocations: building raylib (which
@ -111,13 +111,18 @@ IF DEFINED VERBOSE (
:BUILD
REM Directories
set "ROOT_DIR=%CD%"
set "SOURCES=!ROOT_DIR!\!SOURCES!"
set "RAYLIB_SRC=!ROOT_DIR!\!RAYLIB_SRC!"
REM Flags
set OUTPUT_FLAG=/Fe: "!GAME_NAME!"
set COMPILATION_FLAGS=/O1 /GL
set WARNING_FLAGS=
set SUBSYSTEM_FLAGS=/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup
set LINK_FLAGS=/link /LTCG kernel32.lib user32.lib shell32.lib winmm.lib gdi32.lib opengl32.lib
set OUTPUT_DIR=builds\windows
set OUTPUT_DIR=builds\windows-msvc
REM Debug changes to flags
IF DEFINED BUILD_DEBUG (
set OUTPUT_FLAG=/Fe: "!GAME_NAME!"
@ -125,7 +130,7 @@ IF DEFINED BUILD_DEBUG (
set WARNING_FLAGS=/Wall
set SUBSYSTEM_FLAGS=
set LINK_FLAGS=/link kernel32.lib user32.lib shell32.lib winmm.lib gdi32.lib opengl32.lib
set OUTPUT_DIR=builds-debug\windows
set OUTPUT_DIR=builds-debug\windows-msvc
)
IF NOT DEFINED VERBOSE (
set VERBOSITY_FLAG=/nologo
@ -139,7 +144,6 @@ IF DEFINED BUILD_DEBUG (
)
REM Create the temp directory for raylib
set "ROOT_DIR=%CD%"
set "TEMP_DIR=temp\release"
IF DEFINED BUILD_DEBUG (
set "TEMP_DIR=temp\debug"
@ -163,9 +167,9 @@ IF NOT EXIST !TEMP_DIR!\ (
set RAYLIB_INCLUDE_FLAGS=/I"!RAYLIB_SRC!" /I"!RAYLIB_SRC!\external\glfw\include"
IF DEFINED REALLY_QUIET (
cl.exe /w /c !RAYLIB_DEFINES! !RAYLIB_INCLUDE_FLAGS! !COMPILATION_FLAGS! !RAYLIB_C_FILES! > NUL 2>&1
cl.exe /w /c !RAYLIB_DEFINES! !RAYLIB_INCLUDE_FLAGS! !COMPILATION_FLAGS! !RAYLIB_C_FILES! > NUL 2>&1 || exit /B
) ELSE (
cl.exe /w /c !VERBOSITY_FLAG! !RAYLIB_DEFINES! !RAYLIB_INCLUDE_FLAGS! !COMPILATION_FLAGS! !RAYLIB_C_FILES!
cl.exe /w /c !VERBOSITY_FLAG! !RAYLIB_DEFINES! !RAYLIB_INCLUDE_FLAGS! !COMPILATION_FLAGS! !RAYLIB_C_FILES! || exit /B
)
IF NOT DEFINED QUIET echo COMPILE-INFO: Raylib compiled into object files in: !TEMP_DIR!\
@ -180,13 +184,13 @@ cd !OUTPUT_DIR!
REM Build the actual game
IF NOT DEFINED QUIET echo COMPILE-INFO: Compiling game code.
IF DEFINED REALLY_QUIET (
cl.exe !VERBOSITY_FLAG! /Fo"main.obj" !COMPILATION_FLAGS! !WARNING_FLAGS! /c /I"!RAYLIB_SRC!" !SOURCES! > NUL 2>&1
cl.exe !VERBOSITY_FLAG! !OUTPUT_FLAG! "!ROOT_DIR!\!TEMP_DIR!\*.obj" main.obj !LINK_FLAGS! !SUBSYSTEM_FLAGS! > NUL 2>&1
cl.exe !VERBOSITY_FLAG! !COMPILATION_FLAGS! !WARNING_FLAGS! /c /I"!RAYLIB_SRC!" !SOURCES! > NUL 2>&1 || exit /B
cl.exe !VERBOSITY_FLAG! !OUTPUT_FLAG! "!ROOT_DIR!\!TEMP_DIR!\*.obj" *.obj !LINK_FLAGS! !SUBSYSTEM_FLAGS! > NUL 2>&1 || exit /B
) ELSE (
cl.exe !VERBOSITY_FLAG! /Fo"main.obj" !COMPILATION_FLAGS! !WARNING_FLAGS! /c /I"!RAYLIB_SRC!" !SOURCES!
cl.exe !VERBOSITY_FLAG! !OUTPUT_FLAG! "!ROOT_DIR!\!TEMP_DIR!\*.obj" main.obj !LINK_FLAGS! !SUBSYSTEM_FLAGS!
cl.exe !VERBOSITY_FLAG! !COMPILATION_FLAGS! !WARNING_FLAGS! /c /I"!RAYLIB_SRC!" !SOURCES! || exit /B
cl.exe !VERBOSITY_FLAG! !OUTPUT_FLAG! "!ROOT_DIR!\!TEMP_DIR!\*.obj" *.obj !LINK_FLAGS! !SUBSYSTEM_FLAGS! || exit /B
)
del main.obj
del *.obj
IF NOT DEFINED QUIET echo COMPILE-INFO: Game compiled into an executable in: !OUTPUT_DIR!\
REM Run upx