diff --git a/scripts/setup.sh b/scripts/setup.sh index ffad08e..c77985e 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -101,7 +101,18 @@ fi # 2.3 Install Dependencies echo "Installing Core Dependencies..." if command -v apt-get > /dev/null; then - DEBIAN_FRONTEND=noninteractive apt-get install -y git hostapd dnsmasq avahi-daemon curl ffmpeg build-essential libzmq3-dev libavahi-compat-libdnssd-dev wget unzip + DEBIAN_FRONTEND=noninteractive apt-get install -y git hostapd dnsmasq avahi-daemon curl ffmpeg build-essential libzmq3-dev libavahi-compat-libdnssd-dev wget unzip \ + libmpg123-dev libsndfile1-dev libopenal-dev libassimp-dev \ + libglew-dev libglfw3-dev liburiparser-dev \ + libcurl4-openssl-dev libpugixml-dev libasound2-dev \ + libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ + gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \ + gstreamer1.0-plugins-ugly gstreamer1.0-libav \ + libgtk-3-dev libboost-filesystem-dev \ + libfontconfig1-dev libfreetype-dev libx11-dev \ + libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev \ + libpulse-dev libudev-dev libfreeimage-dev librtaudio-dev \ + freeglut3-dev libxxf86vm-dev elif command -v pacman > /dev/null; then pacman -S --noconfirm git hostapd dnsmasq avahi curl ffmpeg base-devel zeromq wget unzip fi @@ -205,7 +216,7 @@ MPVJ_MEDIA_DIR=$REAL_HOME/media EOF # 4.5 THE PRE-BUILT ENGINE SOLUTION -echo "Installing Pre-compiled OpenFrameworks (FAST)..." +echo "Installing Pre-compiled OpenFrameworks (FAST TRACK)..." cd "$REAL_HOME" if [ ! -d "openFrameworks" ]; then echo "Downloading OpenFrameworks v0.12.1..." @@ -221,38 +232,16 @@ if [ ! -d "openFrameworks" ]; then sudo -u "$REAL_USER" rm "$OF_FILE" fi -# ALWAYS verify dependencies, even if OF is already present -echo "Ensuring modern dependencies for Debian Trixie..." -if command -v apt-get > /dev/null; then - DEBIAN_FRONTEND=noninteractive apt-get install -y \ - libmpg123-dev libsndfile1-dev libopenal-dev libassimp-dev \ - libglew-dev libglfw3-dev liburiparser-dev \ - libcurl4-openssl-dev libpugixml-dev libasound2-dev \ - libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \ - gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \ - gstreamer1.0-plugins-ugly gstreamer1.0-libav \ - libgtk-3-dev libboost-filesystem-dev \ - libfontconfig1-dev libfreetype-dev libx11-dev \ - libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev \ - libpulse-dev libudev-dev libfreeimage-dev librtaudio-dev \ - freeglut3-dev libxxf86vm-dev -fi - -echo "Downloading and building ofxPiMapper Addon..." +echo "Downloading and patching ofxPiMapper..." cd "$REAL_HOME/openFrameworks/addons" -# FORCE CLEAN CLONE to fix corrupted source files from previous failed runs rm -rf ofxPiMapper sudo -u "$REAL_USER" git clone --depth 1 https://github.com/kr15h/ofxPiMapper.git -# Apply patches to the addon before building +# Apply patches locally to addon ONLY cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper" -echo "Applying clean Global Compatibility Patches..." - -# 1. Locate OscControl.cpp and apply highlight patch -# Use 'find' to handle different subfolder structures +# 1. Highlight Patch OSC_FILE=$(find src -name "OscControl.cpp" | head -n 1) if [ -n "$OSC_FILE" ]; then - echo "Patching $OSC_FILE..." cat <<'EOF_PATCH' > /tmp/highlight.patch if (m.getAddress() == "/ofxPiMapper/surface/highlight"){ int surfaceIndex = m.getArgAsInt32(0); @@ -264,58 +253,19 @@ EOF_PATCH rm -f /tmp/highlight.patch fi -# 2. Create a single compatibility header for C++11 -cat <<'EOF_COMPAT' > src/cpp11_compat.h -#ifndef OFXPIMAPPER_CPP11_COMPAT_H -#define OFXPIMAPPER_CPP11_COMPAT_H -#include -#include -#include -#include -#include - -#if __cplusplus < 201402L -namespace std { - template - std::unique_ptr make_unique(Args&&... args) { - return std::unique_ptr(new T(std::forward(args)...)); - } -} -#endif - -// Explicitly bridge common namespaces to bypass C++20 strictness -using std::unique_ptr; -using std::make_unique; -using std::vector; -using std::string; -#endif -EOF_COMPAT - -# 3. Include the compat header in the main addon header -sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h - -# 4. Fix unique_ptr and make_unique globally (Using relative paths and avoiding std::std::) +# 2. Namespace Patches (Idempotent) find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\([^:a-zA-Z0-9]\)unique_ptr\b/\1std::unique_ptr/g' {} + find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\([^:a-zA-Z0-9]\)make_unique\b/\1std::make_unique/g' {} + -# 5. Add memory header only where needed +# 3. Add memory headers to addon files only for f in $(grep -l "unique_ptr" src/*.h 2>/dev/null || true); do - grep -q "" "$f" || sed -i '1i #include ' "$f" + sed -i '1i #include ' "$f" done -# Build Example +# Build Example (NO GLOBAL FLAGS to avoid re-compiling the core) cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic" -echo "Cleaning old objects..." -sudo -u "$REAL_USER" make clean - -echo "Starting compilation (Nuclear Stability Mode: -O0 + C++11 + VRP disabled)..." -GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11 -O0 -fno-tree-vrp" -sudo -u "$REAL_USER" make -j1 \ - PLATFORM_CFLAGS="$GLOBAL_FLAGS -I$REAL_HOME/openFrameworks/addons/ofxPiMapper/src" \ - USER_CFLAGS="$GLOBAL_FLAGS" \ - USER_CPPFLAGS="-std=c++11" \ - OF_PROJECT_OPTIMIZATION_FLAGS="-O0" - +echo "Compiling Engine (This should only take 5-10 minutes)..." +sudo -u "$REAL_USER" make -j1 cp bin/example_basic /usr/local/bin/ofxPiMapper chmod +x /usr/local/bin/ofxPiMapper