fix: implement surgical cleanup of old patches to resolve C++ syntax errors in ofxPiMapper
This commit is contained in:
@ -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<typename T, typename... Args>/d' {} +
|
||||
find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i '/unique_ptr<T> make_unique(Args&&... args)/d' {} +
|
||||
find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i '/return unique_ptr<T>(new T(std::forward<Args>(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 "<memory>" "$f" || sed -i '1i #include <memory>' "$f"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user