fix: enforce clean ofxPiMapper clone and robust global patching to resolve corrupted syntax errors
This commit is contained in:
@ -240,21 +240,15 @@ fi
|
|||||||
|
|
||||||
echo "Downloading and building ofxPiMapper Addon..."
|
echo "Downloading and building ofxPiMapper Addon..."
|
||||||
cd "$REAL_HOME/openFrameworks/addons"
|
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
|
# Apply patches to the addon before building
|
||||||
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper"
|
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
|
# 1. Fix highlight patch
|
||||||
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
|
|
||||||
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);
|
||||||
@ -264,14 +258,12 @@ if [ -f src/Osc/OscControl.cpp ] && ! grep -q "ofxPiMapper/surface/highlight" sr
|
|||||||
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' src/Osc/OscControl.cpp
|
||||||
rm -f /tmp/highlight.patch
|
rm -f /tmp/highlight.patch
|
||||||
fi
|
|
||||||
|
|
||||||
# 2. Fix unique_ptr and missing memory headers globally (Idempotent)
|
# 2. Fix unique_ptr and make_unique globally (Only if std:: is missing)
|
||||||
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/\([^: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' {} +
|
||||||
|
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
|
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
|
||||||
@ -288,17 +280,12 @@ namespace std {
|
|||||||
#endif
|
#endif
|
||||||
EOF_COMPAT
|
EOF_COMPAT
|
||||||
|
|
||||||
# Include the compat header in the main addon header ONLY (Top of file)
|
# 4. Include the compat header in the main addon header
|
||||||
if ! grep -q "cpp11_compat.h" src/ofxPiMapper.h; then
|
|
||||||
sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h
|
sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h
|
||||||
fi
|
|
||||||
|
|
||||||
# Also ensure unique_ptr and make_unique are namespaced in the source
|
# 5. Add memory header to all headers where unique_ptr is used
|
||||||
find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\([^:a-zA-Z0-9]\)make_unique\b/\1std::make_unique/g' {} +
|
for f in $(grep -l "unique_ptr" src/*.h 2>/dev/null); do
|
||||||
|
sed -i '1i #include <memory>' "$f"
|
||||||
# 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
|
done
|
||||||
|
|
||||||
# Build Example
|
# Build Example
|
||||||
@ -306,8 +293,7 @@ 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 (Global Flags)..."
|
echo "Starting compilation (Forcing C++11 for Symbol Compatibility)..."
|
||||||
# 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"
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user