Skip to content

Commit

Permalink
support various graphics and platform args
Browse files Browse the repository at this point in the history
  • Loading branch information
redthing1 committed Nov 10, 2022
1 parent 78bc045 commit 7cdd6f4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 40 deletions.
67 changes: 33 additions & 34 deletions build-raylib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,41 @@ SOURCETREE_DIR="raylib_source"
SOURCETREE_BRANCH="4.2.0_patch"
LIB_FILE_1="libraylib.a"

BUILD_ARGS=$@

PACKAGE_DIR=$(dirname "$0")
cd "$PACKAGE_DIR"
pushd .
if [ ! -f $LIB_FILE_1 ] || [ "$1" == "-f" ]; then
echo "[$HOST] building $LIB_NAME library..."

# delete $SOURCETREE_DIR to force re-fetch source
if [ -d $SOURCETREE_DIR ]
then
echo "[$HOST] source folder already exists, using it."
else
echo "[$HOST] getting source to build $LIB_NAME"
# git clone $SOURCETREE_URL $SOURCETREE_DIR
git clone --depth 1 --branch $SOURCETREE_BRANCH $SOURCETREE_URL $SOURCETREE_DIR
fi

cd $SOURCETREE_DIR
git submodule update --init --recursive

echo "[$HOST] starting build of $LIB_NAME"
#
# START BUILD
#
# build the library
cd src
make -j$(nproc)
#
# END BUILD
#

echo "[$HOST] finished build of $LIB_NAME"

echo "[$HOST] copying $LIB_NAME binary ($LIB_FILE_1) to $PACKAGE_DIR"
cp -v $(pwd)/$LIB_FILE_1 $PACKAGE_DIR/$LIB_FILE_1
popd

echo "[$HOST] building $LIB_NAME library..."

# delete $SOURCETREE_DIR to force re-fetch source
if [ -d $SOURCETREE_DIR ]
then
echo "[$HOST] source folder already exists, using it."
else
# delete $LIB_FILE_1 to force rebuild
echo "[$HOST] library $LIB_NAME already built."
echo "[$HOST] getting source to build $LIB_NAME"
# git clone $SOURCETREE_URL $SOURCETREE_DIR
git clone --depth 1 --branch $SOURCETREE_BRANCH $SOURCETREE_URL $SOURCETREE_DIR
fi

cd $SOURCETREE_DIR
git submodule update --init --recursive

echo "[$HOST] starting build of $LIB_NAME"
#
# START BUILD
#
# build the library
cd src
make clean
make -j$(nproc) $BUILD_ARGS
#
# END BUILD
#

echo "[$HOST] finished build of $LIB_NAME"

echo "[$HOST] copying $LIB_NAME binary ($LIB_FILE_1) to $PACKAGE_DIR"
ln -vrfs $(pwd)/$LIB_FILE_1 $PACKAGE_DIR/$LIB_FILE_1
popd
24 changes: 18 additions & 6 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@ license "apache-2.0"
dependency "fluent-asserts" version="~>0.13.3"
targetType "library"

configuration "default" {
# on posix platforms, link to raylib static library
configuration "desktop-gl33" {
lflags "-L$PACKAGE_DIR" "$PACKAGE_DIR/libraylib.a" platform="posix"
preGenerateCommands "bash $PACKAGE_DIR/build-raylib.sh" platform="posix"
preBuildCommands "bash $PACKAGE_DIR/build-raylib.sh PLATFORM=PLATFORM_DESKTOP GRAPHICS=GRAPHICS_API_OPENGL_33" platform="posix"
}

configuration "desktop-gl21" {
lflags "-L$PACKAGE_DIR" "$PACKAGE_DIR/libraylib.a" platform="posix"
preBuildCommands "bash $PACKAGE_DIR/build-raylib.sh PLATFORM=PLATFORM_DESKTOP GRAPHICS=GRAPHICS_API_OPENGL_21" platform="posix"
}

configuration "desktop-gles2" {
lflags "-L$PACKAGE_DIR" "$PACKAGE_DIR/libraylib.a" platform="posix"
preBuildCommands "bash $PACKAGE_DIR/build-raylib.sh PLATFORM=PLATFORM_DESKTOP GRAPHICS=GRAPHICS_API_OPENGL_ES2" platform="posix"
}

configuration "drm-gles2" {
lflags "-L$PACKAGE_DIR" "$PACKAGE_DIR/libraylib.a" platform="posix"
preBuildCommands "bash $PACKAGE_DIR/build-raylib.sh PLATFORM=PLATFORM_DRM GRAPHICS=GRAPHICS_API_OPENGL_ES2" platform="posix"
}

configuration "windows" {
Expand All @@ -19,9 +33,7 @@ configuration "windows" {

configuration "windows-cross" {
# on windows platforms, link to raylib static library
// lflags "-L$PACKAGE_DIR" "$PACKAGE_DIR/libraylib.lib" platform="windows"
lflags "-L$WINLIB_BASE" "-L$WINLIB_MINGW" platform="windows"
sourceFiles "$PACKAGE_DIR/raylib.lib" platform="windows"
sourceFiles "$PACKAGE_DIR/WinMM.lib" platform="windows"
// preGenerateCommands "$PACKAGE_DIR/build-raylib.bat" platform="windows"
}
}

0 comments on commit 7cdd6f4

Please sign in to comment.