diff --git a/CMakeLists.txt b/CMakeLists.txt index 38363c6..b63f82d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,11 @@ endif() file(GLOB_RECURSE WEB_SOURCES CONFIGURE_DEPENDS "src/**.cpp") add_library(EchoionWeb SHARED ${WEB_SOURCES}) add_library(Echoion::Web ALIAS EchoionWeb) +target_compile_definitions(EchoionWeb 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(EchoionWeb PROPERTIES EXPORT_NAME Web OUTPUT_NAME echoion-web @@ -64,6 +69,7 @@ find_package(Threads REQUIRED) target_link_libraries(EchoionWeb PUBLIC Echoion::ApiConfig + Echoion::ApiModuleAbi Void::Data Void::Log Void::Async @@ -166,6 +172,8 @@ install(TARGETS EchoionWeb ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" INCLUDES DESTINATION include) install(DIRECTORY include/ DESTINATION include) +install(FILES abi/module.json + DESTINATION "${CMAKE_INSTALL_DATADIR}/echoion/components/EchoionWeb/${PROJECT_VERSION}/abi") install(EXPORT EchoionWebTargets FILE EchoionWebTargets.cmake NAMESPACE Echoion:: diff --git a/abi/module.json b/abi/module.json new file mode 100644 index 0000000..49c6e06 --- /dev/null +++ b/abi/module.json @@ -0,0 +1,14 @@ +{ + "schemaVersion": 1, + "contractId": "echoion.module.web", + "descriptor": "Void::Plugin::ModuleDescriptor", + "moduleId": "EchoionWeb", + "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..ceb6756 --- /dev/null +++ b/src/Module.cpp @@ -0,0 +1,62 @@ +#include + +#include +#include + +namespace Echoion::Web +{ + namespace + { + class WebModule final : public Void::Plugin::IModule + { + public: + [[nodiscard]] std::string_view name() const noexcept override + { + return "EchoionWeb"; + } + }; + + std::unique_ptr createWebModule() + { + return std::make_unique(); + } + } // namespace + + const Void::Plugin::ModuleDescriptor& webModuleDescriptor() + { + static const Void::Plugin::ModuleDescriptor descriptor{ + .module_id = "EchoionWeb", + .component_version = { + .major = ECHOION_COMPONENT_VERSION_MAJOR, + .minor = ECHOION_COMPONENT_VERSION_MINOR, + .patch = ECHOION_COMPONENT_VERSION_PATCH, + .pre_release = {}, + .build = {}, + }, + .abi_hash = + "sha256:858dfd3a19804e42a63fa8694a70ebe07ee90485a886df1ac07cf91bb5d34316", + .abi_contract = Void::Json::object({ + {"schemaVersion", 1}, + {"contractId", "echoion.module.web"}, + {"descriptor", "Void::Plugin::ModuleDescriptor"}, + }), + .dependencies = { + { + .module_id = "EchoionApi", + .version_range = "^2.0.0", + .abi_hash = "sha256:336492a52097dd12f222bb6d9acab19e8eb6a502eab45bb78127bce6d733fbd3", + }, + }, + .activation_policy = + Void::Plugin::ActivationPolicy::RestartRequired, + .create = createWebModule, + }; + return descriptor; + } +} // namespace Echoion::Web + +extern "C" ECHOION_MODULE_EXPORT const Void::Plugin::ModuleDescriptor* +echoion_module_query() +{ + return &Echoion::Web::webModuleDescriptor(); +}