Skip to content

Commit

Permalink
Minor improvements of Linux build and example scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBanana committed Aug 26, 2023
1 parent 6b0ead9 commit 1b2dff7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
20 changes: 11 additions & 9 deletions BuildLinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ENABLE_VULKAN="OFF"
ENABLE_EXAMPLES="ON"
ENABLE_TESTS="ON"
BUILD_TYPE="Release"
PROJECT_ONLY=0

print_help()
{
Expand All @@ -19,6 +20,7 @@ print_help()
echo " -c, --clear-cache ....... Clear CMake cache and rebuild"
echo " -s, --skip-validation ... Skip check for missing packages (X11, OpenGL etc.)"
echo " -d, --debug ............. Configure Debug build (default is Release)"
echo " -p, --project-only ...... Build project solution only (no compilation)"
echo " -null ................... Include Null renderer"
echo " -vulkan ................. Include Vulkan renderer"
echo " -no-examples ............ Exclude example projects"
Expand All @@ -38,6 +40,8 @@ for ARG in "$@"; do
SKIP_VALIDATION=1
elif [ $ARG = "-d" ] || [ $ARG = "--debug" ]; then
BUILD_TYPE="Debug"
elif [ $ARG = "-p" ] || [ $ARG = "--project-only" ]; then
PROJECT_ONLY=1
elif [ $ARG = "-null" ]; then
ENABLE_NULL="ON"
elif [ $ARG = "-vulkan" ]; then
Expand Down Expand Up @@ -77,15 +81,11 @@ GAUSSIAN_LIB_DIR="GaussianLib/include"
if [ -f "$SOURCE_DIR/external/$GAUSSIAN_LIB_DIR/Gauss/Gauss.h" ]; then
GAUSSIAN_LIB_DIR=$(realpath "$SOURCE_DIR/external/$GAUSSIAN_LIB_DIR")
elif [ ! -d "$OUTPUT_DIR/$GAUSSIAN_LIB_DIR" ]; then
pushd "$OUTPUT_DIR"
git clone https://github.com/LukasBanana/GaussianLib.git
popd
(cd "$OUTPUT_DIR" git clone https://github.com/LukasBanana/GaussianLib.git)
GAUSSIAN_LIB_DIR=$(realpath "$OUTPUT_DIR/$GAUSSIAN_LIB_DIR")
fi

# Build into output directory
cd "$OUTPUT_DIR"

# Build into output directory (this syntax requried CMake 3.13+)
cmake \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DLLGL_BUILD_RENDERER_OPENGL=ON \
Expand All @@ -95,7 +95,9 @@ cmake \
-DLLGL_BUILD_EXAMPLES=$ENABLE_EXAMPLES \
-DLLGL_BUILD_TESTS=$ENABLE_TESTS \
-DGaussLib_INCLUDE_DIR:STRING="$GAUSSIAN_LIB_DIR" \
-S "$SOURCE_DIR"

cmake --build .
-S "$SOURCE_DIR" \
-B "$OUTPUT_DIR"

if [ $PROJECT_ONLY -eq 0 ]; then
cmake --build "$OUTPUT_DIR"
fi
13 changes: 8 additions & 5 deletions RunExamplesLinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
BUILD_DIR="build_linux/build"

if [ "$#" -eq 1 ]; then
HELLO_EXAMPLE="Example_HelloTriangle"
BUILD_DIR=$1
elif [ -f "build_linux/build/Example_HelloTriangle" ]; then
BUILD_DIR="build_linux/build"
elif [ -f "bin/x64/Linux/Example_HelloTriangle" ]; then
BUILD_DIR="bin/x64/Linux"
else
if [[ "$BUILD_DIR" == */ ]]; then
BUILD_DIR="${BUILD_DIR::-1}" # Remove trailing '/' character from path
fi
if [ -f "$BUILD_DIR/build/$HELLO_EXAMPLE" ] || [ -f "$BUILD_DIR/build/${HELLO_EXAMPLE}D" ]; then
BUILD_DIR="$BUILD_DIR/build"
fi
elif [ ! -d "$BUILD_DIR" ]; then
echo "error: build folder not found: $BUILD_DIR"
exit 1
fi
Expand Down

0 comments on commit 1b2dff7

Please sign in to comment.