Host: publish module descriptor
This commit is contained in:
3 files changed
+85
No files matched your search
@@ -28,10 +28,16 @@ find_package(Threads REQUIRED)
|
||||
|
||||
add_library(EchoionHost SHARED
|
||||
src/CoreLoader.cpp
|
||||
src/Module.cpp
|
||||
)
|
||||
add_library(Echoion::Host ALIAS EchoionHost)
|
||||
|
||||
target_compile_features(EchoionHost PUBLIC cxx_std_26)
|
||||
target_compile_definitions(EchoionHost PRIVATE
|
||||
ECHOION_MODULE_BUILD
|
||||
ECHOION_COMPONENT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
|
||||
ECHOION_COMPONENT_VERSION_MINOR=${PROJECT_VERSION_MINOR}
|
||||
ECHOION_COMPONENT_VERSION_PATCH=${PROJECT_VERSION_PATCH})
|
||||
set_target_properties(EchoionHost PROPERTIES
|
||||
EXPORT_NAME Host
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
@@ -49,6 +55,7 @@ target_link_libraries(EchoionHost
|
||||
Echoion::ApiPlugin
|
||||
Echoion::ApiOpaque
|
||||
Echoion::ApiCoreInterface
|
||||
Echoion::ApiModuleAbi
|
||||
PRIVATE
|
||||
Echoion::ApiLogger
|
||||
Void::Data
|
||||
@@ -72,6 +79,8 @@ install(TARGETS EchoionHost
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
INCLUDES DESTINATION include)
|
||||
install(DIRECTORY include/ DESTINATION include)
|
||||
install(FILES abi/module.json
|
||||
DESTINATION "${CMAKE_INSTALL_DATADIR}/echoion/components/EchoionHost/${PROJECT_VERSION}/abi")
|
||||
install(EXPORT EchoionHostTargets
|
||||
FILE EchoionHostTargets.cmake
|
||||
NAMESPACE Echoion::
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"contractId": "echoion.module.host",
|
||||
"descriptor": "Void::Plugin::ModuleDescriptor",
|
||||
"moduleId": "EchoionHost",
|
||||
"activation": "restart-required",
|
||||
"dependencies": [
|
||||
{
|
||||
"moduleId": "EchoionApi",
|
||||
"versionRange": "^2.0.0",
|
||||
"abiHash": "sha256:336492a52097dd12f222bb6d9acab19e8eb6a502eab45bb78127bce6d733fbd3"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
#include <echoion/api/module/Module.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace Echoion::Host
|
||||
{
|
||||
namespace
|
||||
{
|
||||
class HostModule final : public Void::Plugin::IModule
|
||||
{
|
||||
public:
|
||||
[[nodiscard]] std::string_view name() const noexcept override
|
||||
{
|
||||
return "EchoionHost";
|
||||
}
|
||||
};
|
||||
|
||||
std::unique_ptr<Void::Plugin::IModule> createHostModule()
|
||||
{
|
||||
return std::make_unique<HostModule>();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
const Void::Plugin::ModuleDescriptor& hostModuleDescriptor()
|
||||
{
|
||||
static const Void::Plugin::ModuleDescriptor descriptor{
|
||||
.module_id = "EchoionHost",
|
||||
.component_version = {
|
||||
.major = ECHOION_COMPONENT_VERSION_MAJOR,
|
||||
.minor = ECHOION_COMPONENT_VERSION_MINOR,
|
||||
.patch = ECHOION_COMPONENT_VERSION_PATCH,
|
||||
.pre_release = {},
|
||||
.build = {},
|
||||
},
|
||||
.abi_hash =
|
||||
"sha256:abe1c7ab0d5decce45b06a7ab04dcea014decdf9752f6ccd833adb283749e58d",
|
||||
.abi_contract = Void::Json::object({
|
||||
{"schemaVersion", 1},
|
||||
{"contractId", "echoion.module.host"},
|
||||
{"descriptor", "Void::Plugin::ModuleDescriptor"},
|
||||
}),
|
||||
.dependencies = {
|
||||
{
|
||||
.module_id = "EchoionApi",
|
||||
.version_range = "^2.0.0",
|
||||
.abi_hash = "sha256:336492a52097dd12f222bb6d9acab19e8eb6a502eab45bb78127bce6d733fbd3",
|
||||
},
|
||||
},
|
||||
.activation_policy =
|
||||
Void::Plugin::ActivationPolicy::RestartRequired,
|
||||
.create = createHostModule,
|
||||
};
|
||||
return descriptor;
|
||||
}
|
||||
} // namespace Echoion::Host
|
||||
|
||||
extern "C" ECHOION_MODULE_EXPORT const Void::Plugin::ModuleDescriptor*
|
||||
echoion_module_query()
|
||||
{
|
||||
return &Echoion::Host::hostModuleDescriptor();
|
||||
}
|
||||
Reference in new issue
Block a user