server: Allow modules that don't contain C++ files if meta.disable_cpp is set
This commit is contained in:
parent
623ba0b67b
commit
60874360d9
@ -25,6 +25,7 @@ static interface::ModuleDependency load_module_dependency(const json::Value &v)
|
|||||||
static interface::ModuleMeta load_module_meta(const json::Value &v)
|
static interface::ModuleMeta load_module_meta(const json::Value &v)
|
||||||
{
|
{
|
||||||
interface::ModuleMeta r;
|
interface::ModuleMeta r;
|
||||||
|
r.disable_cpp = v.get("disable_cpp").as_boolean();
|
||||||
r.cxxflags = v.get("cxxflags").as_string();
|
r.cxxflags = v.get("cxxflags").as_string();
|
||||||
r.ldflags = v.get("ldflags").as_string();
|
r.ldflags = v.get("ldflags").as_string();
|
||||||
r.cxxflags_windows = v.get("cxxflags_windows").as_string();
|
r.cxxflags_windows = v.get("cxxflags_windows").as_string();
|
||||||
|
@ -13,6 +13,7 @@ namespace interface
|
|||||||
|
|
||||||
struct ModuleMeta
|
struct ModuleMeta
|
||||||
{
|
{
|
||||||
|
bool disable_cpp = false;
|
||||||
ss_ cxxflags;
|
ss_ cxxflags;
|
||||||
ss_ ldflags;
|
ss_ ldflags;
|
||||||
ss_ cxxflags_linux;
|
ss_ cxxflags_linux;
|
||||||
|
@ -356,15 +356,9 @@ struct CState: public State, public interface::Server
|
|||||||
return m_shutdown_requested;
|
return m_shutdown_requested;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool load_module(const interface::ModuleInfo &info)
|
// Call with m_modules_mutex and m_magic_mutex locked
|
||||||
|
interface::Module* build_module_u(const interface::ModuleInfo &info)
|
||||||
{
|
{
|
||||||
interface::MutexScope ms(m_modules_mutex);
|
|
||||||
interface::MutexScope ms_magic(m_magic_mutex);
|
|
||||||
|
|
||||||
log_i(MODULE, "Loading module %s from %s", cs(info.name), cs(info.path));
|
|
||||||
|
|
||||||
m_module_info[info.name] = info;
|
|
||||||
|
|
||||||
ss_ init_cpp_path = info.path+"/"+info.name+".cpp";
|
ss_ init_cpp_path = info.path+"/"+info.name+".cpp";
|
||||||
|
|
||||||
// Set up file watch
|
// Set up file watch
|
||||||
@ -458,24 +452,41 @@ struct CState: public State, public interface::Server
|
|||||||
|
|
||||||
if(!build_ok){
|
if(!build_ok){
|
||||||
log_w(MODULE, "Failed to build module %s", cs(info.name));
|
log_w(MODULE, "Failed to build module %s", cs(info.name));
|
||||||
return false;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct instance
|
// Construct instance
|
||||||
|
|
||||||
interface::Module *m = static_cast<interface::Module*>(
|
interface::Module *m = static_cast<interface::Module*>(
|
||||||
m_compiler->construct(info.name.c_str(), this));
|
m_compiler->construct(info.name.c_str(), this));
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool load_module(const interface::ModuleInfo &info)
|
||||||
|
{
|
||||||
|
interface::MutexScope ms(m_modules_mutex);
|
||||||
|
interface::MutexScope ms_magic(m_magic_mutex);
|
||||||
|
|
||||||
|
log_i(MODULE, "Loading module %s from %s", cs(info.name), cs(info.path));
|
||||||
|
|
||||||
|
m_module_info[info.name] = info;
|
||||||
|
|
||||||
|
interface::Module *m = nullptr;
|
||||||
|
if(!info.meta.disable_cpp){
|
||||||
|
m = build_module_u(info);
|
||||||
|
|
||||||
if(m == nullptr){
|
if(m == nullptr){
|
||||||
log_w(MODULE, "Failed to construct module %s instance",
|
log_w(MODULE, "Failed to construct module %s instance",
|
||||||
cs(info.name));
|
cs(info.name));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
m_modules[info.name] = ModuleContainer(m, info);
|
m_modules[info.name] = ModuleContainer(m, info);
|
||||||
m_module_load_order.push_back(info.name);
|
m_module_load_order.push_back(info.name);
|
||||||
|
|
||||||
// Call init()
|
// Call init()
|
||||||
|
|
||||||
{
|
if(m){
|
||||||
ModuleContainer &mc = m_modules[info.name];
|
ModuleContainer &mc = m_modules[info.name];
|
||||||
interface::MutexScope ms2(mc.mutex);
|
interface::MutexScope ms2(mc.mutex);
|
||||||
mc.module->init();
|
mc.module->init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user