-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·84 lines (74 loc) · 2.17 KB
/
start.sh
File metadata and controls
executable file
·84 lines (74 loc) · 2.17 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
set -euo pipefail
show_usage() {
echo "Usage: $0 [build_type] [options]"
echo "Build types:"
echo " d - Debug"
echo " r - Release"
echo " rd - RelWithDebInfo"
echo ""
echo "Options:"
echo " -clean Clean CMake cache before build"
echo " -build Only build, don't run"
echo " -debug Run with debugger (gdb/lldb)"
echo ""
echo "Examples:"
echo " ./start.sh d -clean # Clean build debug and run"
echo " ./start.sh r -build # Build release only"
echo " ./start.sh d -debug # Build debug and run with debugger"
}
# Default values
BUILD_TYPE=""
CLEAN_CACHE=false
BUILD_ONLY=false
RUN_WITH_DEBUGGER=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
d|r|rd) BUILD_TYPE="$1" ;;
-clean) CLEAN_CACHE=true ;;
-build) BUILD_ONLY=true ;;
-debug) RUN_WITH_DEBUGGER=true ;;
-h|--help) show_usage; exit 0 ;;
*) echo "Unknown option: $1"; show_usage; exit 1 ;;
esac
shift
done
# Validate build type
if [[ -z "$BUILD_TYPE" ]]; then
echo "Error: Build type required"
show_usage
exit 1
fi
# Build the project
echo "=== Building project ==="
BUILD_ARGS="$BUILD_TYPE"
[[ "$CLEAN_CACHE" == true ]] && BUILD_ARGS="$BUILD_ARGS -clean"
if ! ./build.sh $BUILD_ARGS; then
echo "Build failed!"
exit 1
fi
# Run if not build-only
if [[ "$BUILD_ONLY" == false ]]; then
echo "=== Starting application ==="
# Determine executable path
case $BUILD_TYPE in
d) EXEC_PATH="./autobuild/Debug/App/NextStudio_artefacts/Debug/NextStudio" ;;
r) EXEC_PATH="./autobuild/Release/App/NextStudio_artefacts/Release/NextStudio" ;;
rd) EXEC_PATH="./autobuild/RelWithDebInfo/App/NextStudio_artefacts/RelWithDebInfo/NextStudio" ;;
esac
# Run with or without debugger
if [[ "$RUN_WITH_DEBUGGER" == true ]]; then
if [[ "$OSTYPE" == "darwin"* ]]; then
lldb -o run "$EXEC_PATH.app"
else
gdb -ex=r --args "$EXEC_PATH"
fi
else
if [[ "$OSTYPE" == "darwin"* ]]; then
open "$EXEC_PATH.app"
else
"$EXEC_PATH"
fi
fi
fi