Core: publish reloadable module descriptor
This commit is contained in:
3 files changed
+86
-1
No files matched your search
+11
-1
@@ -8,6 +8,8 @@ endif()
|
|||||||
project(EchoionCore VERSION "${ECHOION_PRODUCT_VERSION}" LANGUAGES CXX)
|
project(EchoionCore VERSION "${ECHOION_PRODUCT_VERSION}" LANGUAGES CXX)
|
||||||
|
|
||||||
if(PROJECT_IS_TOP_LEVEL)
|
if(PROJECT_IS_TOP_LEVEL)
|
||||||
|
set(BUILD_SHARED_LIBS ON CACHE BOOL
|
||||||
|
"Build shared component dependencies" FORCE)
|
||||||
file(DOWNLOAD
|
file(DOWNLOAD
|
||||||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.8/CPM.cmake
|
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.8/CPM.cmake
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake"
|
||||||
@@ -41,7 +43,11 @@ file(GLOB_RECURSE CORE_SOURCES
|
|||||||
)
|
)
|
||||||
add_library(EchoionCore SHARED ${CORE_SOURCES})
|
add_library(EchoionCore SHARED ${CORE_SOURCES})
|
||||||
target_compile_definitions(EchoionCore PRIVATE
|
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)
|
add_library(Echoion::Core ALIAS EchoionCore)
|
||||||
|
|
||||||
@@ -68,6 +74,7 @@ target_link_libraries(EchoionCore PUBLIC
|
|||||||
Echoion::ApiPluginInterface
|
Echoion::ApiPluginInterface
|
||||||
Echoion::ApiCoreInterface
|
Echoion::ApiCoreInterface
|
||||||
Echoion::ApiUtils
|
Echoion::ApiUtils
|
||||||
|
Echoion::ApiModuleAbi
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
@@ -244,6 +251,9 @@ install(EXPORT EchoionCoreTargets
|
|||||||
DESTINATION lib/cmake/EchoionCore
|
DESTINATION lib/cmake/EchoionCore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
install(FILES abi/module.json
|
||||||
|
DESTINATION share/echoion/components/EchoionCore/${PROJECT_VERSION}/abi)
|
||||||
|
|
||||||
# Package config files
|
# Package config files
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file(
|
||||||
|
|||||||
@@ -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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
#include <echoion/api/module/Module.hpp>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
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<Void::Plugin::IModule> createCoreModule()
|
||||||
|
{
|
||||||
|
return std::make_unique<LifecycleModule>();
|
||||||
|
}
|
||||||
|
} // 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();
|
||||||
|
}
|
||||||
Reference in new issue
Block a user