fix: enforce clean ofxPiMapper addon state and implement high-powered global compatibility header to resolve syntax and namespace errors

This commit is contained in:
Timothy Hofland
2026-03-15 09:04:01 +01:00
parent c0589b6c5e
commit e0e06978b2

View File

@ -101,9 +101,9 @@ fi
# 2.3 Install Dependencies # 2.3 Install Dependencies
echo "Installing Core Dependencies..." echo "Installing Core Dependencies..."
if command -v apt-get > /dev/null; then if command -v apt-get > /dev/null; then
DEBIAN_FRONTEND=noninteractive apt-get install -y git hostapd dnsmasq avahi-daemon curl ffmpeg build-essential libzmq3-dev libavahi-compat-libdnssd-dev wget DEBIAN_FRONTEND=noninteractive apt-get install -y git hostapd dnsmasq avahi-daemon curl ffmpeg build-essential libzmq3-dev libavahi-compat-libdnssd-dev wget unzip
elif command -v pacman > /dev/null; then elif command -v pacman > /dev/null; then
pacman -S --noconfirm git hostapd dnsmasq avahi curl ffmpeg base-devel zeromq wget pacman -S --noconfirm git hostapd dnsmasq avahi curl ffmpeg base-devel zeromq wget unzip
fi fi
# Install Node.js if missing # Install Node.js if missing
@ -248,7 +248,9 @@ sudo -u "$REAL_USER" git clone --depth 1 https://github.com/kr15h/ofxPiMapper.gi
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper" cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper"
echo "Applying clean Global Compatibility Patches..." echo "Applying clean Global Compatibility Patches..."
# 1. Fix highlight patch # 1. Locate OscControl.cpp and apply highlight patch
OSC_CTRL=$(find src -name OscControl.cpp | head -n 1)
if [ -n "$OSC_CTRL" ]; then
cat <<'EOF_PATCH' > /tmp/highlight.patch cat <<'EOF_PATCH' > /tmp/highlight.patch
if (m.getAddress() == "/ofxPiMapper/surface/highlight"){ if (m.getAddress() == "/ofxPiMapper/surface/highlight"){
int surfaceIndex = m.getArgAsInt32(0); int surfaceIndex = m.getArgAsInt32(0);
@ -256,19 +258,20 @@ cat <<'EOF_PATCH' > /tmp/highlight.patch
return; return;
} }
EOF_PATCH EOF_PATCH
sed -i '/if (m.getAddress() == "\/ofxPiMapper\/surface\/select"){/r /tmp/highlight.patch' src/Osc/OscControl.cpp sed -i '/if (m.getAddress() == "\/ofxPiMapper\/surface\/select"){/r /tmp/highlight.patch' "$OSC_CTRL"
rm -f /tmp/highlight.patch rm -f /tmp/highlight.patch
fi
# 2. Fix unique_ptr and make_unique globally (Only if std:: is missing) # 2. Create a high-powered compatibility header
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' {} +
# 3. Create a single compatibility header for C++11
cat <<'EOF_COMPAT' > src/cpp11_compat.h cat <<'EOF_COMPAT' > src/cpp11_compat.h
#ifndef OFXPIMAPPER_CPP11_COMPAT_H #ifndef OFXPIMAPPER_CPP11_COMPAT_H
#define OFXPIMAPPER_CPP11_COMPAT_H #define OFXPIMAPPER_CPP11_COMPAT_H
#include <memory> #include <memory>
#include <utility> #include <utility>
#include <vector>
#include <string>
#include <algorithm>
#if __cplusplus < 201402L #if __cplusplus < 201402L
namespace std { namespace std {
template<typename T, typename... Args> template<typename T, typename... Args>
@ -277,26 +280,27 @@ namespace std {
} }
} }
#endif #endif
// Explicitly bridge common namespaces to bypass C++20 strictness
using std::unique_ptr;
using std::make_unique;
using std::vector;
using std::string;
#endif #endif
EOF_COMPAT EOF_COMPAT
# 4. Include the compat header in the main addon header # 3. Inject the compatibility header into ALL headers
sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h find src -name "*.h" -not -name "cpp11_compat.h" -exec sed -i '1i #include "cpp11_compat.h"' {} +
# 5. Add memory header to all headers where unique_ptr is used
for f in $(grep -l "unique_ptr" src/*.h 2>/dev/null); do
sed -i '1i #include <memory>' "$f"
done
# Build Example # 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 (Stability Mode: -O1 + C++11)..."
# Use -O2 and -fno-tree-vrp to prevent Internal Compiler Errors (ICE) on ARM # Use -O1 to prevent the compiler Segfault/Internal Error seen on Pi 3B with g++ 14
GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11 -O2 -fno-tree-vrp" GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11 -O1"
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 -I$REAL_HOME/openFrameworks/addons/ofxPiMapper/src" 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