fix: implement lightning-fast engine setup by utilizing pre-compiled OpenFrameworks correctly and avoiding core re-compilation
This commit is contained in:
@ -101,7 +101,18 @@ 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 unzip
|
DEBIAN_FRONTEND=noninteractive apt-get install -y git hostapd dnsmasq avahi-daemon curl ffmpeg build-essential libzmq3-dev libavahi-compat-libdnssd-dev wget unzip \
|
||||||
|
libmpg123-dev libsndfile1-dev libopenal-dev libassimp-dev \
|
||||||
|
libglew-dev libglfw3-dev liburiparser-dev \
|
||||||
|
libcurl4-openssl-dev libpugixml-dev libasound2-dev \
|
||||||
|
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
|
||||||
|
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
|
||||||
|
gstreamer1.0-plugins-ugly gstreamer1.0-libav \
|
||||||
|
libgtk-3-dev libboost-filesystem-dev \
|
||||||
|
libfontconfig1-dev libfreetype-dev libx11-dev \
|
||||||
|
libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev \
|
||||||
|
libpulse-dev libudev-dev libfreeimage-dev librtaudio-dev \
|
||||||
|
freeglut3-dev libxxf86vm-dev
|
||||||
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 unzip
|
pacman -S --noconfirm git hostapd dnsmasq avahi curl ffmpeg base-devel zeromq wget unzip
|
||||||
fi
|
fi
|
||||||
@ -205,7 +216,7 @@ MPVJ_MEDIA_DIR=$REAL_HOME/media
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# 4.5 THE PRE-BUILT ENGINE SOLUTION
|
# 4.5 THE PRE-BUILT ENGINE SOLUTION
|
||||||
echo "Installing Pre-compiled OpenFrameworks (FAST)..."
|
echo "Installing Pre-compiled OpenFrameworks (FAST TRACK)..."
|
||||||
cd "$REAL_HOME"
|
cd "$REAL_HOME"
|
||||||
if [ ! -d "openFrameworks" ]; then
|
if [ ! -d "openFrameworks" ]; then
|
||||||
echo "Downloading OpenFrameworks v0.12.1..."
|
echo "Downloading OpenFrameworks v0.12.1..."
|
||||||
@ -221,38 +232,16 @@ if [ ! -d "openFrameworks" ]; then
|
|||||||
sudo -u "$REAL_USER" rm "$OF_FILE"
|
sudo -u "$REAL_USER" rm "$OF_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ALWAYS verify dependencies, even if OF is already present
|
echo "Downloading and patching ofxPiMapper..."
|
||||||
echo "Ensuring modern dependencies for Debian Trixie..."
|
|
||||||
if command -v apt-get > /dev/null; then
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
|
||||||
libmpg123-dev libsndfile1-dev libopenal-dev libassimp-dev \
|
|
||||||
libglew-dev libglfw3-dev liburiparser-dev \
|
|
||||||
libcurl4-openssl-dev libpugixml-dev libasound2-dev \
|
|
||||||
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
|
|
||||||
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
|
|
||||||
gstreamer1.0-plugins-ugly gstreamer1.0-libav \
|
|
||||||
libgtk-3-dev libboost-filesystem-dev \
|
|
||||||
libfontconfig1-dev libfreetype-dev libx11-dev \
|
|
||||||
libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev \
|
|
||||||
libpulse-dev libudev-dev libfreeimage-dev librtaudio-dev \
|
|
||||||
freeglut3-dev libxxf86vm-dev
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Downloading and building ofxPiMapper Addon..."
|
|
||||||
cd "$REAL_HOME/openFrameworks/addons"
|
cd "$REAL_HOME/openFrameworks/addons"
|
||||||
# FORCE CLEAN CLONE to fix corrupted source files from previous failed runs
|
|
||||||
rm -rf ofxPiMapper
|
rm -rf ofxPiMapper
|
||||||
sudo -u "$REAL_USER" git clone --depth 1 https://github.com/kr15h/ofxPiMapper.git
|
sudo -u "$REAL_USER" git clone --depth 1 https://github.com/kr15h/ofxPiMapper.git
|
||||||
|
|
||||||
# Apply patches to the addon before building
|
# Apply patches locally to addon ONLY
|
||||||
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper"
|
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper"
|
||||||
echo "Applying clean Global Compatibility Patches..."
|
# 1. Highlight Patch
|
||||||
|
|
||||||
# 1. Locate OscControl.cpp and apply highlight patch
|
|
||||||
# Use 'find' to handle different subfolder structures
|
|
||||||
OSC_FILE=$(find src -name "OscControl.cpp" | head -n 1)
|
OSC_FILE=$(find src -name "OscControl.cpp" | head -n 1)
|
||||||
if [ -n "$OSC_FILE" ]; then
|
if [ -n "$OSC_FILE" ]; then
|
||||||
echo "Patching $OSC_FILE..."
|
|
||||||
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,58 +253,19 @@ EOF_PATCH
|
|||||||
rm -f /tmp/highlight.patch
|
rm -f /tmp/highlight.patch
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2. Create a single compatibility header for C++11
|
# 2. Namespace Patches (Idempotent)
|
||||||
cat <<'EOF_COMPAT' > src/cpp11_compat.h
|
|
||||||
#ifndef OFXPIMAPPER_CPP11_COMPAT_H
|
|
||||||
#define OFXPIMAPPER_CPP11_COMPAT_H
|
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#if __cplusplus < 201402L
|
|
||||||
namespace std {
|
|
||||||
template<typename T, typename... Args>
|
|
||||||
std::unique_ptr<T> make_unique(Args&&... args) {
|
|
||||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#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
|
|
||||||
EOF_COMPAT
|
|
||||||
|
|
||||||
# 3. Include the compat header in the main addon header
|
|
||||||
sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h
|
|
||||||
|
|
||||||
# 4. Fix unique_ptr and make_unique globally (Using relative paths and avoiding std::std::)
|
|
||||||
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' {} +
|
find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\([^:a-zA-Z0-9]\)make_unique\b/\1std::make_unique/g' {} +
|
||||||
|
|
||||||
# 5. Add memory header only where needed
|
# 3. Add memory headers to addon files only
|
||||||
for f in $(grep -l "unique_ptr" src/*.h 2>/dev/null || true); do
|
for f in $(grep -l "unique_ptr" src/*.h 2>/dev/null || true); do
|
||||||
grep -q "<memory>" "$f" || sed -i '1i #include <memory>' "$f"
|
sed -i '1i #include <memory>' "$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Build Example
|
# Build Example (NO GLOBAL FLAGS to avoid re-compiling the core)
|
||||||
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"
|
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"
|
||||||
echo "Cleaning old objects..."
|
echo "Compiling Engine (This should only take 5-10 minutes)..."
|
||||||
sudo -u "$REAL_USER" make clean
|
sudo -u "$REAL_USER" make -j1
|
||||||
|
|
||||||
echo "Starting compilation (Nuclear Stability Mode: -O0 + C++11 + VRP disabled)..."
|
|
||||||
GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11 -O0 -fno-tree-vrp"
|
|
||||||
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" \
|
|
||||||
OF_PROJECT_OPTIMIZATION_FLAGS="-O0"
|
|
||||||
|
|
||||||
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