From 82813baa58da115a5e6e5306609b28fbe37f0207 Mon Sep 17 00:00:00 2001 From: Timothy Hofland Date: Sun, 15 Mar 2026 15:56:17 +0100 Subject: [PATCH] fix: implement path-agnostic source patching and refine global compatibility header logic --- scripts/setup.sh | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index fd462fe..ffad08e 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -248,22 +248,23 @@ sudo -u "$REAL_USER" git clone --depth 1 https://github.com/kr15h/ofxPiMapper.gi cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper" echo "Applying clean Global Compatibility Patches..." -# 1. Fix highlight patch -cat <<'EOF_PATCH' > /tmp/highlight.patch +# 1. Locate OscControl.cpp and apply highlight patch +# Use 'find' to handle different subfolder structures +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); mapper->getSurfaceManager()->selectSurface(surfaceIndex); return; } EOF_PATCH -sed -i '/if (m.getAddress() == "\/ofxPiMapper\/surface\/select"){/r /tmp/highlight.patch' src/Osc/OscControl.cpp -rm -f /tmp/highlight.patch + sed -i '/if (m.getAddress() == "\/ofxPiMapper\/surface\/select"){/r /tmp/highlight.patch' "$OSC_FILE" + rm -f /tmp/highlight.patch +fi -# 2. Fix unique_ptr and make_unique globally (Only if std:: is missing) -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' {} + - -# 3. Create a single compatibility header for C++11 +# 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 @@ -290,12 +291,16 @@ using std::string; #endif EOF_COMPAT -# 4. Include the compat header in the main addon header +# 3. Include the compat header in the main addon header sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h -# 5. Add memory header to all headers where unique_ptr is used -for f in $(grep -l "unique_ptr" src/*.h 2>/dev/null); do - sed -i '1i #include ' "$f" +# 4. Fix unique_ptr and make_unique globally (Using relative paths and avoiding std::std::) +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 +for f in $(grep -l "unique_ptr" src/*.h 2>/dev/null || true); do + grep -q "" "$f" || sed -i '1i #include ' "$f" done # Build Example @@ -304,8 +309,6 @@ echo "Cleaning old objects..." sudo -u "$REAL_USER" make clean echo "Starting compilation (Nuclear Stability Mode: -O0 + C++11 + VRP disabled)..." -# Force -O0 and disable VRP pass completely. -# Also use OF_PROJECT variables to ensure these flags override the core makefile defaults. 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" \