Loading...
Searching...
No Matches
AddonCompiler.hpp
1#pragma once
2
3#include <JitCpp/JitOptions.hpp>
4
5#include <QThread>
6
7#include <list>
8#include <memory>
9
10#include <score_plugin_jit_export.h>
11
12#include <verdigris>
13
14#include <score/plugins/qt_interfaces/PluginRequirements_QtInterface.hpp>
15#undef RESET
16namespace score
17{
18class Plugin_QtInterface;
19}
20
21namespace Jit
22{
23struct Driver;
24
26class AddonCompiler final : public QObject
27{
28 W_OBJECT(AddonCompiler)
29public:
31
33 void submitJob(
34 const std::string& id, std::string cpp, std::vector<std::string> flags,
35 CompilerOptions opts) W_SIGNAL(submitJob, id, cpp, flags, opts);
36 void jobCompleted(score::Plugin_QtInterface* p) W_SIGNAL(jobCompleted, p);
37 void jobFailed() W_SIGNAL(jobFailed);
38 void on_job(
39 std::string id, std::string cpp, std::vector<std::string> flags,
40 CompilerOptions opts);
41
42private:
43 QThread m_thread;
44
45 // One JIT session per add-on compiled during this run. Nothing ever takes back
46 // what a JIT add-on gave the application -- its factories, commands and plug-in
47 // object stay in the component lists -- so its code must stay mapped, and the
48 // sessions are abandoned rather than closed. See ~AddonCompiler().
49 std::list<std::unique_ptr<Driver>> m_compilers;
50};
51
52using FactoryFunction = std::function<void()>;
53using CustomCompiler = std::function<FactoryFunction(
54 const std::string&, const std::vector<std::string>&)>;
55}
56
57Q_DECLARE_METATYPE(std::string)
58W_REGISTER_ARGTYPE(std::string)
59Q_DECLARE_METATYPE(std::vector<std::string>)
60W_REGISTER_ARGTYPE(std::vector<std::string>)
61Q_DECLARE_METATYPE(Jit::CompilerOptions)
62W_REGISTER_ARGTYPE(Jit::CompilerOptions)
63Q_DECLARE_METATYPE(score::Plugin_QtInterface*)
64W_REGISTER_ARGTYPE(score::Plugin_QtInterface*)
Compiles jobs asynchronously.
Definition AddonCompiler.hpp:27
Definition PluginRequirements_QtInterface.hpp:18
Base toolkit upon which the software is built.
Definition Application.cpp:117
Definition JitOptions.hpp:7