diff --git a/scripts/setup.sh b/scripts/setup.sh index 2e3ff44..1a4b8bc 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -244,12 +244,14 @@ cd "$REAL_HOME/openFrameworks/addons" # Apply patches to the addon before building cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper" -echo "Cleaning up previous patches and applying clean Global Compatibility Patches..." +echo "Performing surgical cleanup 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' {} + +# SURGICAL SCRUB: Remove EXACT lines injected previously without breaking braces find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i '/#include "cpp11_compat.h"/d' {} + +find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i '/template/d' {} + +find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i '/unique_ptr make_unique(Args&&... args)/d' {} + +find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i '/return unique_ptr(new T(std::forward(args)...));/d' {} + +find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i '/#if __cplusplus < 201402L/,/#endif/d' {} + # 1. Fix highlight patch (Heredoc fix) if [ -f src/Osc/OscControl.cpp ] && ! grep -q "ofxPiMapper/surface/highlight" src/Osc/OscControl.cpp; then @@ -286,13 +288,15 @@ namespace std { #endif EOF_COMPAT -# Include the compat header in the main addon header ONLY -sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h +# Include the compat header in the main addon header ONLY (Top of file) +if ! grep -q "cpp11_compat.h" src/ofxPiMapper.h; then + sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h +fi # 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 to all headers to be safe +# Add memory header to all headers only if missing for f in $(find src -type f -name "*.h"); do grep -q "" "$f" || sed -i '1i #include ' "$f" done