fix: make setup script patches idempotent to prevent double-namespace bugs
This commit is contained in:
@ -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 <memory>' {} +
|
||||
# 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 "<memory>" {} || sed -i '1i #include <memory>' {} +
|
||||
|
||||
# 3. Fix missing algorithms (std::find, etc)
|
||||
find src -type f -name "*.cpp" -exec sed -i '1i #include <algorithm>' {} +
|
||||
find src -type f -name "*.cpp" -exec grep -q "<algorithm>" {} || sed -i '1i #include <algorithm>' {} +
|
||||
|
||||
# Build Example (Force C++17 for better compatibility with this addon)
|
||||
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"
|
||||
|
||||
Reference in New Issue
Block a user