-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_linux.sh
More file actions
executable file
·97 lines (83 loc) · 3.16 KB
/
Copy pathbuild_linux.sh
File metadata and controls
executable file
·97 lines (83 loc) · 3.16 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
# --- StayPutVR Linux development build script ---
#
# Builds the overlay GUI application (no SteamVR driver) for local development
# and OSC simulation. The GUI runs; PiShock/Twitch/audio are stubbed on Linux.
#
# Usage:
# ./build_linux.sh [Debug|Release] [run]
# Debug|Release build type (default: Release)
# run launch the app after a successful build
#
# Requirements: cmake, a C++20 compiler, and the GLFW runtime (libglfw.so.3)
# plus an OpenGL/Mesa runtime. On Fedora/Bazzite: sudo dnf install glfw mesa-libGL
# (only the runtime libraries are needed; headers are fetched automatically).
set -euo pipefail
# Resolve and enter the repo root (directory containing this script).
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
BUILD_DIR="build-linux"
BUILD_TYPE="Release"
DO_RUN=0
DO_CLEAN=0
for arg in "$@"; do
case "$arg" in
Debug|Release) BUILD_TYPE="$arg" ;;
run|--run) DO_RUN=1 ;;
clean|--clean) DO_CLEAN=1 ;;
*) echo "Unknown argument: $arg (expected Debug|Release|run|clean)" >&2; exit 1 ;;
esac
done
JOBS="$(nproc 2>/dev/null || echo 4)"
# A clean build was requested explicitly...
if [[ "$DO_CLEAN" -eq 1 ]]; then
echo "Cleaning $BUILD_DIR (requested)"
rm -rf "$BUILD_DIR"
fi
# ...or the build type changed since the last configure. Switching build type in
# place can leave objects compiled with mismatched flags, so start fresh.
if [[ -f "$BUILD_DIR/CMakeCache.txt" ]]; then
CACHED_TYPE="$(grep -E '^CMAKE_BUILD_TYPE:' "$BUILD_DIR/CMakeCache.txt" | cut -d= -f2)"
if [[ -n "$CACHED_TYPE" && "$CACHED_TYPE" != "$BUILD_TYPE" ]]; then
echo "Build type changed ($CACHED_TYPE -> $BUILD_TYPE); cleaning $BUILD_DIR"
rm -rf "$BUILD_DIR"
fi
fi
echo "=== StayPutVR Linux build ==="
echo "Build type : $BUILD_TYPE"
echo "Build dir : $BUILD_DIR"
echo "Jobs : $JOBS"
echo
# --- Configure ---
if ! cmake -S . -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -Wno-dev; then
echo
echo "CMAKE CONFIGURE FAILED" >&2
exit 1
fi
# --- Build ---
if ! cmake --build "$BUILD_DIR" -j "$JOBS"; then
echo
echo "BUILD FAILED" >&2
exit 1
fi
APP="$BUILD_DIR/application/stayputvr_app"
echo
echo "BUILD SUCCEEDED ($BUILD_TYPE)"
echo "Output: $SCRIPT_DIR/$APP"
# --- Sync resources into the data dir the app reads at runtime ---
# The app resolves assets from GetAppDataPath()/resources (XDG_DATA_HOME or
# ~/.local/share/StayPutVR). Copy the repo's resources there so edits to
# whats_new.md, logo.png, fonts, etc. are picked up on the next launch.
DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/StayPutVR/resources"
mkdir -p "$DATA_DIR"
cp -f "$SCRIPT_DIR"/application/resources/* "$DATA_DIR"/ 2>/dev/null || true
echo "Synced resources -> $DATA_DIR"
if [[ "$DO_RUN" -eq 1 ]]; then
echo
echo "=== Launching $APP ==="
# Help the dynamic loader find the GLFW runtime in distrobox/toolbox setups
# where it lives under the host mount. Harmless on a native host.
export LD_LIBRARY_PATH="/usr/lib64:/run/host/usr/lib64:${LD_LIBRARY_PATH:-}"
exec "./$APP"
fi
echo "Run it with: ./build_linux.sh $BUILD_TYPE run (or) ./$APP"