File size: 2,349 Bytes
5ac6c6e
 
 
 
 
f3db0f3
 
 
 
 
 
 
5ac6c6e
379e9dd
5ac6c6e
 
 
f3db0f3
5ac6c6e
 
 
379e9dd
 
 
5ac6c6e
379e9dd
 
 
 
5ac6c6e
 
379e9dd
 
 
f3db0f3
5ac6c6e
379e9dd
f3db0f3
5ac6c6e
 
 
 
f3db0f3
5ac6c6e
379e9dd
 
 
 
 
 
 
 
 
f3db0f3
 
5ac6c6e
f3db0f3
5ac6c6e
f3db0f3
 
5ac6c6e
f3db0f3
5ac6c6e
f3db0f3
 
5ac6c6e
 
 
 
 
f3db0f3
 
379e9dd
 
 
5ac6c6e
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <juce_audio_processors/juce_audio_processors.h>
#include <juce_gui_basics/juce_gui_basics.h>
#include <juce_events/juce_events.h>

#include "HelperPluginHost.h"

// PluginBridgeHelper — TEST MODE ONLY
// Spawned by PluginBridge to test if a plugin can load safely.
// If the plugin crashes, only this process dies. Ableton survives.
//
// Usage: PluginBridgeHelper --test "/path/to/plugin.vst3"
// Exit code 0 = safe, exit code 1 = failed to load, crash = unsafe

class HelperApplication : public juce::JUCEApplication, private juce::Timer
{
public:
    const juce::String getApplicationName() override { return "PluginBridgeHelper"; }
    const juce::String getApplicationVersion() override { return "0.3.0"; }

    void initialise(const juce::String& commandLine) override
    {
        // Parse --test flag. Everything after --test is the path (may contain spaces).
        auto testFlagPos = commandLine.indexOf("--test");
        if (testFlagPos < 0)
        {
            DBG("HelperApplication: Usage: --test \"/path/to/plugin.vst3\"");
            setApplicationReturnValue(1);
            quit();
            return;
        }

        // Extract path: skip "--test " (7 chars), trim quotes
        pluginPath = commandLine.substring(testFlagPos + 7).trim().unquoted();

        if (pluginPath.isEmpty())
        {
            DBG("HelperApplication: No plugin path provided");
            setApplicationReturnValue(1);
            quit();
            return;
        }

        DBG("HelperApplication: Testing plugin: " + pluginPath);

        // Start test on a timer so the message loop is running
        // (some plugins need it for VST3 validation)
        startTimer(100);
    }

    void timerCallback() override
    {
        stopTimer();

        HelperPluginHost host;
        bool success = host.testLoad(pluginPath);

        if (success)
        {
            DBG("HelperApplication: Plugin loaded successfully — SAFE");
            setApplicationReturnValue(0);
        }
        else
        {
            DBG("HelperApplication: Plugin failed to load — UNSAFE");
            setApplicationReturnValue(1);
        }

        quit();
    }

    void shutdown() override {}
    void systemRequestedQuit() override { quit(); }

private:
    juce::String pluginPath;
};

START_JUCE_APPLICATION(HelperApplication)