fix: apply global C++17/20 compatibility patches to ofxPiMapper source

This commit is contained in:
Timothy Hofland
2026-03-12 21:52:19 +01:00
parent 6cc9d88842
commit 4c655a0512

View File

@ -244,11 +244,10 @@ cd "$REAL_HOME/openFrameworks/addons"
# Apply patches to the addon before building
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper"
if [ -f src/Osc/OscControl.cpp ]; then
echo "Applying highlight patch..."
if ! grep -q "ofxPiMapper/surface/highlight" src/Osc/OscControl.cpp; then
# Create a temporary patch file
# terminator MUST NOT be indented
echo "Applying Global Compatibility Patches..."
# 1. Fix highlight patch (Heredoc fix)
if [ -f src/Osc/OscControl.cpp ] && ! grep -q "ofxPiMapper/surface/highlight" src/Osc/OscControl.cpp; then
cat <<'EOF_PATCH' > /tmp/highlight.patch
if (m.getAddress() == "/ofxPiMapper/surface/highlight"){
int surfaceIndex = m.getArgAsInt32(0);
@ -258,18 +257,19 @@ if [ -f src/Osc/OscControl.cpp ]; then
EOF_PATCH
sed -i '/if (m.getAddress() == "\/ofxPiMapper\/surface\/select"){/r /tmp/highlight.patch' src/Osc/OscControl.cpp
rm -f /tmp/highlight.patch
fi
fi
if [ -f src/Sources/VideoSource.h ]; then
echo "Applying std:: namespace patch to VideoSource.h..."
sed -i 's/unique_ptr/std::unique_ptr/g' src/Sources/VideoSource.h
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" -exec sed -i '1i #include <memory>' {} +
# Build Example
# 3. Fix missing algorithms (std::find, etc)
find src -type f -name "*.cpp" -exec sed -i '1i #include <algorithm>' {} +
# Build Example (Force C++17 for better compatibility with this addon)
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"
echo "Starting compilation..."
sudo -u "$REAL_USER" make -j1 USER_CFLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor"
echo "Starting compilation (Forcing C++17)..."
sudo -u "$REAL_USER" make -j1 USER_CFLAGS="-Wno-error -std=c++17" USER_CPPFLAGS="-std=c++17"
cp bin/example_basic /usr/local/bin/ofxPiMapper
chmod +x /usr/local/bin/ofxPiMapper