fix: add source scrubbing step to remove failed patch attempts and fix redefinition errors
This commit is contained in:
@ -244,7 +244,12 @@ cd "$REAL_HOME/openFrameworks/addons"
|
|||||||
|
|
||||||
# Apply patches to the addon before building
|
# Apply patches to the addon before building
|
||||||
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper"
|
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)
|
# 1. Fix highlight patch (Heredoc fix)
|
||||||
if [ -f src/Osc/OscControl.cpp ] && ! grep -q "ofxPiMapper/surface/highlight" src/Osc/OscControl.cpp; then
|
if [ -f src/Osc/OscControl.cpp ] && ! grep -q "ofxPiMapper/surface/highlight" src/Osc/OscControl.cpp; then
|
||||||
@ -260,7 +265,7 @@ EOF_PATCH
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# 2. Fix unique_ptr and missing memory headers globally (Idempotent)
|
# 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/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' {} +
|
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
|
#endif
|
||||||
EOF_COMPAT
|
EOF_COMPAT
|
||||||
|
|
||||||
# Include the compat header in the main addon header
|
# Include the compat header in the main addon header ONLY
|
||||||
grep -q "cpp11_compat.h" src/ofxPiMapper.h || sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h
|
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' {} +
|
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
|
for f in $(find src -type f -name "*.h"); do
|
||||||
grep -q "<memory>" "$f" || sed -i '1i #include <memory>' "$f"
|
grep -q "<memory>" "$f" || sed -i '1i #include <memory>' "$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Build Example (Force C++11 for binary symbol compatibility with OF core)
|
# Build Example
|
||||||
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"
|
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"
|
||||||
echo "Cleaning old objects..."
|
echo "Cleaning old objects..."
|
||||||
sudo -u "$REAL_USER" make clean
|
sudo -u "$REAL_USER" make clean
|
||||||
|
|
||||||
echo "Starting compilation (Forcing C++11 for Symbol Compatibility)..."
|
echo "Starting compilation (Global Flags)..."
|
||||||
# Revert to C++11 to match the pre-compiled OF core library symbols
|
# Using PLATFORM_CFLAGS ensures these flags propagate to the addon source as well
|
||||||
GLOBAL_FLAGS="-Wno-error -std=c++11"
|
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"
|
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
|
cp bin/example_basic /usr/local/bin/ofxPiMapper
|
||||||
chmod +x /usr/local/bin/ofxPiMapper
|
chmod +x /usr/local/bin/ofxPiMapper
|
||||||
|
|||||||
Reference in New Issue
Block a user