-
Notifications
You must be signed in to change notification settings - Fork 140
/
RunExamplesMacOS.command
executable file
·64 lines (55 loc) · 1.92 KB
/
RunExamplesMacOS.command
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
DEFAULT_BUILD_DIRS=("build_macos/build" "build_macos/build/Debug" "bin/macOS-x64/build")
SOURCE_DIR="$(dirname $0)"
BUILD_DIR="$SOURCE_DIR/${DEFAULT_BUILD_DIRS[0]}"
# When this .command script is launched from Finder, we have to change to the source directory explicitly
cd $SOURCE_DIR
if [ "$#" -eq 1 ]; then
BUILD_DIR=$1
else
for DIR in "${DEFAULT_BUILD_DIRS[@]}"; do
if [ -d "$DIR" ]; then
if [ -f "$DIR/libLLGL.dylib" ] || [ -f "$DIR/libLLGLD.dylib" ] || [ -f "$DIR/libLLGL.a" ] || [ -f "$DIR/libLLGLD.a" ]; then
BUILD_DIR="$DIR"
break
fi
fi
done
fi
# Validate build folder: Check for libLLGL.dylib/.a or libLLGLD.dylib/.a files
if [ -d "$BUILD_DIR" ]; then
if [ -f "$BUILD_DIR/libLLGL.dylib" ] || [ -f "$BUILD_DIR/libLLGLD.dylib" ] || [ -f "$BUILD_DIR/libLLGL.a" ] || [ -f "$BUILD_DIR/libLLGLD.a" ]; then
echo "Run examples from build directory: $BUILD_DIR"
else
echo "Error: Missing LLGL base lib (libLLGL.dylib/.a or libLLGLD.dylib/.a) in build folder: $BUILD_DIR"
exit 1
fi
else
echo "Error: Build folder not found: $BUILD_DIR"
exit 1
fi
list_examples()
{
EXCLUDED=() # List any examples that are specifically excluded on Mac
EXAMPLE_DIRS=($(ls examples/Cpp))
for DIR in "${EXAMPLE_DIRS[@]}"; do
if ! echo "${EXCLUDED[@]}}" | grep -qw "$DIR"; then
# Include example if its source and binary files exist
if [ -f "examples/Cpp/$DIR/Example.cpp" ] && [ -f "$BUILD_DIR/Example_${DIR}.app/Contents/MacOS/Example_${DIR}" ]; then
echo "$DIR"
fi
fi
done
}
run_example()
(
EXAMPLE=$1
EXE="../../../$BUILD_DIR/Example_${EXAMPLE}.app/Contents/MacOS/Example_${EXAMPLE}"
cd examples/Cpp/$EXAMPLE
eval $EXE
)
EXAMPLES=($(list_examples))
PS3="Select example: "
select OPT in "${EXAMPLES[@]}"; do
run_example $OPT
done