From dbed62a6c40ad29d9c9ec394812a06b781e06c47 Mon Sep 17 00:00:00 2001 From: Timothy Hofland Date: Sat, 14 Mar 2026 10:44:57 +0100 Subject: [PATCH] fix: add source scrubbing step to remove failed patch attempts and fix redefinition errors --- scripts/setup.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index c6dbc47..2e3ff44 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -244,7 +244,12 @@ cd "$REAL_HOME/openFrameworks/addons" # Apply patches to the addon before building cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper" -echo "Applying Global Compatibility Patches..." +echo "Cleaning up previous patches and applying clean Global Compatibility Patches..." + +# SCRUB: Remove any previous injections of make_unique or cpp11_compat +find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i '/namespace std {/,/}/d' {} + +find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i '/#if __cplusplus < 201402L/,/#endif/d' {} + +find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i '/#include "cpp11_compat.h"/d' {} + # 1. Fix highlight patch (Heredoc fix) if [ -f src/Osc/OscControl.cpp ] && ! grep -q "ofxPiMapper/surface/highlight" src/Osc/OscControl.cpp; then @@ -260,7 +265,7 @@ EOF_PATCH fi # 2. Fix unique_ptr and missing memory headers globally (Idempotent) -echo "Fixing namespaces and missing headers for C++11 compatibility..." +echo "Fixing namespaces and missing headers..." find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/std::std::/std::/g' {} + find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\([^:a-zA-Z0-9]\)unique_ptr\b/\1std::unique_ptr/g' {} + @@ -281,25 +286,25 @@ namespace std { #endif EOF_COMPAT -# Include the compat header in the main addon header -grep -q "cpp11_compat.h" src/ofxPiMapper.h || sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h +# Include the compat header in the main addon header ONLY +sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h -# Also ensure make_unique is namespaced in the source +# Also ensure unique_ptr and make_unique are namespaced in the source find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\([^:a-zA-Z0-9]\)make_unique\b/\1std::make_unique/g' {} + -# Add memory header only where missing +# Add memory header to all headers to be safe for f in $(find src -type f -name "*.h"); do grep -q "" "$f" || sed -i '1i #include ' "$f" done -# Build Example (Force C++11 for binary symbol compatibility with OF core) +# Build Example cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic" echo "Cleaning old objects..." sudo -u "$REAL_USER" make clean -echo "Starting compilation (Forcing C++11 for Symbol Compatibility)..." -# Revert to C++11 to match the pre-compiled OF core library symbols -GLOBAL_FLAGS="-Wno-error -std=c++11" +echo "Starting compilation (Global Flags)..." +# Using PLATFORM_CFLAGS ensures these flags propagate to the addon source as well +GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11" sudo -u "$REAL_USER" make -j1 PLATFORM_CFLAGS="$GLOBAL_FLAGS" USER_CFLAGS="$GLOBAL_FLAGS" USER_CPPFLAGS="-std=c++11" cp bin/example_basic /usr/local/bin/ofxPiMapper chmod +x /usr/local/bin/ofxPiMapper