Skip to content

Instantly share code, notes, and snippets.

@dyeo
Created September 9, 2023 22:05
Show Gist options
  • Save dyeo/bc5dc883c237a1bf977468dcb0d3dd96 to your computer and use it in GitHub Desktop.
Save dyeo/bc5dc883c237a1bf977468dcb0d3dd96 to your computer and use it in GitHub Desktop.
Raylib Build Scripts
@echo off
:: Drop it in the root directory of a freshly cloned raylib. Run, and enjoy.
set "OUT=./out"
if not exist "%OUT%" mkdir "%OUT%"
cd "%OUT%"
set "cwd=%cd%"
:: Detect OS type and set the appropriate generator
set "uname=%OS%"
if "%uname%"=="Windows_NT" (
set "generator=MSYS Makefiles"
) else (
echo ERROR: Unknown OS
exit /b 1
)
:: Define configurations
set "configs[0]=Debug"
set "configs[1]=Release"
:: Uncomment below lines for additional configurations
:: set "configs[2]=RelWithDebInfo"
:: set "configs[3]=MinSizeRel"
:: Loop through configurations and run CMake commands
for /L %%i in (0, 1, 1) do (
if defined configs[%%i] (
set "config=!configs[%%i]!"
if exist "CMakeCache.txt" del "CMakeCache.txt"
cmake ^
-G "!generator!" ^
-DCMAKE_BUILD_TYPE=!config! ^
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=!cwd!/bin/!config! ^
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=!cwd!/lib/!config! ^
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=!cwd!/lib/!config! ^
-DCMAKE_PDB_OUTPUT_DIRECTORY:PATH=!cwd!/lib/!config! ^
-DCUSTOMIZE_BUILD=ON ^
-DUSE_EXTERNAL_GLFW=IF_POSSIBLE ^
-DBUILD_SHARED_LIBS=OFF ^
-DWITH_PIC=ON ^
-DINCLUDE_EVERYTHING=ON ^
-DBUILD_EXAMPLES=OFF ^
..
cmake --build .
)
)
:: Copy header files
if not exist "%cwd%/include" mkdir "%cwd%/include"
xcopy /Y ..\src\ray*.h "%cwd%/include"
xcopy /Y ..\src\rlgl.h "%cwd%/include"
:: Remove unwanted files/folders, except include, lib, and bin directories
for /D %%D in (*) do (
if not "%%D"=="include" if not "%%D"=="lib" if not "%%D"=="bin" (
rmdir /S /Q "%%D"
)
)
for %%F in (*) do (
del "%%F"
)
echo Script executed successfully.
pause
#!/usr/bin/env bash
# Drop it in the root directory of a freshly cloned raylib. Run, and enjoy.
set -xe
configs=(
"Debug"
"Release"
#"RelWithDebInfo"
#"MinSizeRel"
)
OUT="./out"
mkdir -p $OUT
cd $OUT
cwd=$(pwd)
case "$(uname)" in
Darwin* | Linux*)
generator="Unix Makefiles"
;;
MINGW* | CYGWIN* | MSYS*)
generator="MSYS Makefiles"
;;
*)
echo "ERROR: Unknown OS"
exit 1
;;
esac
for config in ${configs[@]}; do
rm -rf CMakeCache.txt 2>/dev/null
cmake \
-G "$generator" \
-DCMAKE_BUILD_TYPE=$config \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=$cwd/bin/$config \
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=$cwd/lib/$config \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=$cwd/lib/$config \
-DCMAKE_PDB_OUTPUT_DIRECTORY:PATH=$cwd/lib/$config \
-DCUSTOMIZE_BUILD=ON \
-DUSE_EXTERNAL_GLFW=IF_POSSIBLE \
-DBUILD_SHARED_LIBS=OFF \
-DWITH_PIC=ON \
-DINCLUDE_EVERYTHING=ON \
-DBUILD_EXAMPLES=OFF \
..
cmake --build .
done
mkdir -p $cwd/include
cp ../src/ray*.h ../src/rlgl.h $cwd/include
find . -mindepth 1 -maxdepth 1 \! -name include \! -name lib \! -name bin -exec rm -rf {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment