From 3331a121aebaf2742197d7ffa2579f3e6ed55d97 Mon Sep 17 00:00:00 2001 From: faumaray Date: Tue, 28 Jul 2026 23:32:31 +0300 Subject: [PATCH] Host: publish module descriptor --- CMakeLists.txt | 9 +++++++ abi/module.json | 14 +++++++++++ src/Module.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 abi/module.json create mode 100644 src/Module.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 258e7bc..c739a9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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:: diff --git a/abi/module.json b/abi/module.json new file mode 100644 index 0000000..239b68e --- /dev/null +++ b/abi/module.json @@ -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" + } + ] +} diff --git a/src/Module.cpp b/src/Module.cpp new file mode 100644 index 0000000..564dacb --- /dev/null +++ b/src/Module.cpp @@ -0,0 +1,62 @@ +#include + +#include +#include + +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 createHostModule() + { + return std::make_unique(); + } + } // 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(); +}