diff --git a/CMakeLists.txt b/CMakeLists.txt index c6dacec..bc1661d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,8 @@ endif() project(EchoionCore VERSION "${ECHOION_PRODUCT_VERSION}" LANGUAGES CXX) if(PROJECT_IS_TOP_LEVEL) + set(BUILD_SHARED_LIBS ON CACHE BOOL + "Build shared component dependencies" FORCE) file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.8/CPM.cmake "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake" @@ -41,7 +43,11 @@ file(GLOB_RECURSE CORE_SOURCES ) add_library(EchoionCore SHARED ${CORE_SOURCES}) target_compile_definitions(EchoionCore PRIVATE - ECHOION_CORE_VERSION="${ECHOION_COMPONENT_VERSION}") + ECHOION_CORE_VERSION="${ECHOION_COMPONENT_VERSION}" + ECHOION_MODULE_BUILD + ECHOION_COMPONENT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} + ECHOION_COMPONENT_VERSION_MINOR=${PROJECT_VERSION_MINOR} + ECHOION_COMPONENT_VERSION_PATCH=${PROJECT_VERSION_PATCH}) add_library(Echoion::Core ALIAS EchoionCore) @@ -68,6 +74,7 @@ target_link_libraries(EchoionCore PUBLIC Echoion::ApiPluginInterface Echoion::ApiCoreInterface Echoion::ApiUtils + Echoion::ApiModuleAbi ) find_package(PkgConfig REQUIRED) @@ -244,6 +251,9 @@ install(EXPORT EchoionCoreTargets DESTINATION lib/cmake/EchoionCore ) +install(FILES abi/module.json + DESTINATION share/echoion/components/EchoionCore/${PROJECT_VERSION}/abi) + # Package config files include(CMakePackageConfigHelpers) write_basic_package_version_file( diff --git a/abi/module.json b/abi/module.json new file mode 100644 index 0000000..f3bf37b --- /dev/null +++ b/abi/module.json @@ -0,0 +1,14 @@ +{ + "schemaVersion": 1, + "contractId": "echoion.module.core", + "descriptor": "Void::Plugin::ModuleDescriptor", + "moduleId": "EchoionCore", + "activation": "reloadable", + "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..a30e0fb --- /dev/null +++ b/src/Module.cpp @@ -0,0 +1,61 @@ +#include + +#include +#include + +namespace Echoion::CoreModule +{ + namespace + { + class LifecycleModule final : public Void::Plugin::IModule + { + public: + [[nodiscard]] std::string_view name() const noexcept override + { + return "EchoionCore"; + } + }; + + std::unique_ptr createCoreModule() + { + return std::make_unique(); + } + } // namespace + + const Void::Plugin::ModuleDescriptor& coreModuleDescriptor() + { + static const Void::Plugin::ModuleDescriptor descriptor{ + .module_id = "EchoionCore", + .component_version = { + .major = ECHOION_COMPONENT_VERSION_MAJOR, + .minor = ECHOION_COMPONENT_VERSION_MINOR, + .patch = ECHOION_COMPONENT_VERSION_PATCH, + .pre_release = {}, + .build = {}, + }, + .abi_hash = + "sha256:b421d9e3dc304c5bc31c8fd2d2fc52f62f9055aa90eef8d072c9c99e3b461a20", + .abi_contract = Void::Json::object({ + {"schemaVersion", 1}, + {"contractId", "echoion.module.core"}, + {"descriptor", "Void::Plugin::ModuleDescriptor"}, + }), + .dependencies = { + { + .module_id = "EchoionApi", + .version_range = "^2.0.0", + .abi_hash = "sha256:336492a52097dd12f222bb6d9acab19e8eb6a502eab45bb78127bce6d733fbd3", + }, + }, + .activation_policy = Void::Plugin::ActivationPolicy::Reloadable, + .create = createCoreModule, + }; + return descriptor; + } +} // namespace Echoion::CoreModule + +extern "C" ECHOION_MODULE_EXPORT const Void::Plugin::ModuleDescriptor* +echoion_module_query() +{ + return &Echoion::CoreModule::coreModuleDescriptor(); +}