Compare commits

..

2 Commits

View File

@ -240,21 +240,15 @@ fi
echo "Downloading and building ofxPiMapper Addon..."
cd "$REAL_HOME/openFrameworks/addons"
[ ! -d "ofxPiMapper" ] && sudo -u "$REAL_USER" git clone --depth 1 https://github.com/kr15h/ofxPiMapper.git
# FORCE CLEAN CLONE to fix corrupted source files from previous failed runs
rm -rf ofxPiMapper
sudo -u "$REAL_USER" git clone --depth 1 https://github.com/kr15h/ofxPiMapper.git
# Apply patches to the addon before building
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper"
echo "Performing surgical cleanup and applying clean Global Compatibility Patches..."
echo "Applying clean Global Compatibility Patches..."
# 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
# 1. Fix highlight patch
cat <<'EOF_PATCH' > /tmp/highlight.patch
if (m.getAddress() == "/ofxPiMapper/surface/highlight"){
int surfaceIndex = m.getArgAsInt32(0);
@ -264,14 +258,12 @@ if [ -f src/Osc/OscControl.cpp ] && ! grep -q "ofxPiMapper/surface/highlight" sr
EOF_PATCH
sed -i '/if (m.getAddress() == "\/ofxPiMapper\/surface\/select"){/r /tmp/highlight.patch' src/Osc/OscControl.cpp
rm -f /tmp/highlight.patch
fi
# 2. Fix unique_ptr and missing memory headers globally (Idempotent)
echo "Fixing namespaces and missing headers..."
find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/std::std::/std::/g' {} +
# 2. Fix unique_ptr and make_unique globally (Only if std:: is missing)
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' {} +
# Create a single compatibility header
# 3. Create a single compatibility header for C++11
cat <<'EOF_COMPAT' > src/cpp11_compat.h
#ifndef OFXPIMAPPER_CPP11_COMPAT_H
#define OFXPIMAPPER_CPP11_COMPAT_H
@ -288,17 +280,12 @@ namespace std {
#endif
EOF_COMPAT
# Include the compat header in the main addon header ONLY (Top of file)
if ! grep -q "cpp11_compat.h" src/ofxPiMapper.h; then
# 4. Include the compat header in the main addon header
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 only if missing
for f in $(find src -type f -name "*.h"); do
grep -q "<memory>" "$f" || sed -i '1i #include <memory>' "$f"
# 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
@ -306,9 +293,9 @@ cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"
echo "Cleaning old objects..."
sudo -u "$REAL_USER" make clean
echo "Starting compilation (Global Flags)..."
# Using PLATFORM_CFLAGS ensures these flags propagate to the addon source as well
GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11"
echo "Starting compilation (Forcing C++11 for Symbol Compatibility)..."
# Use -O2 and -fno-tree-vrp to prevent Internal Compiler Errors (ICE) on ARM
GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11 -O2 -fno-tree-vrp"
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
chmod +x /usr/local/bin/ofxPiMapper