From 6380b8325d6c026503f5052f142c25d3e3f8e055 Mon Sep 17 00:00:00 2001 From: Timothy Hofland Date: Fri, 13 Mar 2026 12:44:16 +0100 Subject: [PATCH] fix: make setup script patches idempotent to prevent double-namespace bugs --- scripts/setup.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 7607019..353cacd 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -260,13 +260,20 @@ EOF_PATCH rm -f /tmp/highlight.patch fi -# 2. Fix unique_ptr and missing memory headers globally -find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\bunique_ptr\b/std::unique_ptr/g' {} + -find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\bmake_unique\b/std::make_unique/g' {} + -find src -type f -name "*.h" -exec sed -i '1i #include ' {} + +# 2. Fix unique_ptr and missing memory headers globally (Idempotent) +echo "Fixing namespaces and missing headers..." +# First, clean up any previous double-patching bugs +find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/std::std::/std::/g' {} + + +# Apply patch only if not already namespaced +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' {} + + +# Add memory header only if not present +find src -type f -name "*.h" -exec grep -q "" {} || sed -i '1i #include ' {} + # 3. Fix missing algorithms (std::find, etc) -find src -type f -name "*.cpp" -exec sed -i '1i #include ' {} + +find src -type f -name "*.cpp" -exec grep -q "" {} || sed -i '1i #include ' {} + # Build Example (Force C++17 for better compatibility with this addon) cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"