Add stable C module ABI and component releases
This commit is contained in:
8 files changed
+535
-70
No files matched your search
@@ -0,0 +1,56 @@
|
||||
name: Independent component release
|
||||
on:
|
||||
push:
|
||||
tags: [v*]
|
||||
schedule:
|
||||
- cron: '17 2 * * *'
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: echoion-release-serial
|
||||
steps:
|
||||
- name: Check out component
|
||||
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ssh-key: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
|
||||
persist-credentials: false
|
||||
- name: Check out pinned public release tools
|
||||
uses: https://github.com/actions/checkout@11d5960a326750d5838078e36cf38b85af677262
|
||||
with:
|
||||
repository: Void/Echoion
|
||||
ref: ${{ vars.ECHOION_RELEASE_TOOLS_REF }}
|
||||
path: .echoion-release-tools
|
||||
fetch-depth: 0
|
||||
ssh-key: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
|
||||
persist-credentials: false
|
||||
- name: Build, publish, and merge feed transaction
|
||||
shell: bash
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.COMPONENT_OBJECT_STORAGE_ACCESS_KEY }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.COMPONENT_OBJECT_STORAGE_SECRET_KEY }}
|
||||
AWS_DEFAULT_REGION: ${{ vars.COMPONENT_OBJECT_STORAGE_REGION }}
|
||||
ECHOION_COMPONENT_SSH_KEY: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
|
||||
ECHOION_DISTRIBUTION_BASE_URL: ${{ vars.ECHOION_DISTRIBUTION_BASE_URL }}
|
||||
ECHOION_FEED_BASE_URL: ${{ vars.ECHOION_FEED_BASE_URL }}
|
||||
ECHOION_FEED_COMMIT_SIGNING_KEY: ${{ secrets.RELEASE_FEED_GIT_SIGNING_KEY }}
|
||||
ECHOION_FEED_PRIVATE_KEY: ${{ secrets.RELEASE_FEED_ED25519_PRIVATE_KEY }}
|
||||
ECHOION_FEED_REPOSITORY: ssh://gitea@git.faumaray.ru/Void/Echoion.git
|
||||
ECHOION_FEED_SIGNING_KEY_ID: ${{ vars.ECHOION_FEED_SIGNING_KEY_ID }}
|
||||
ECHOION_OBJECT_STORAGE_BUCKET: ${{ vars.COMPONENT_OBJECT_STORAGE_BUCKET }}
|
||||
ECHOION_OBJECT_STORAGE_ENDPOINT: ${{ vars.COMPONENT_OBJECT_STORAGE_ENDPOINT }}
|
||||
ECHOION_OBJECT_STORAGE_PREFIX: ${{ vars.COMPONENT_OBJECT_STORAGE_PREFIX }}
|
||||
ECHOION_RELEASE_TAG_ALLOWED_SIGNERS: ${{ secrets.RELEASE_TAG_ALLOWED_SIGNERS }}
|
||||
GITEA_API_URL: ${{ gitea.api_url }}
|
||||
GITEA_EVENT_NAME: ${{ gitea.event_name }}
|
||||
GITEA_REF_NAME: ${{ gitea.ref_name }}
|
||||
GITEA_RUN_NUMBER: ${{ gitea.run_number }}
|
||||
GITEA_SHA: ${{ gitea.sha }}
|
||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
|
||||
RELEASE_TOOLS_REF: ${{ vars.ECHOION_RELEASE_TOOLS_REF }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
[[ "$RELEASE_TOOLS_REF" =~ ^[0-9a-f]{40}$ ]]
|
||||
test "$(git -C .echoion-release-tools rev-parse HEAD)" = "$RELEASE_TOOLS_REF"
|
||||
.echoion-release-tools/scripts/release-component.sh component.release.json
|
||||
+8
-2
@@ -1,8 +1,11 @@
|
||||
cmake_minimum_required(VERSION 4.0.0)
|
||||
if(NOT DEFINED ECHOION_PRODUCT_VERSION)
|
||||
set(ECHOION_PRODUCT_VERSION 2.0.0)
|
||||
set(ECHOION_PRODUCT_VERSION 0.0.0)
|
||||
endif()
|
||||
project(EchoionApi VERSION "${ECHOION_PRODUCT_VERSION}" LANGUAGES CXX)
|
||||
if(NOT DEFINED ECHOION_COMPONENT_VERSION)
|
||||
set(ECHOION_COMPONENT_VERSION "${ECHOION_PRODUCT_VERSION}")
|
||||
endif()
|
||||
project(EchoionApi VERSION "${ECHOION_COMPONENT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
file(DOWNLOAD
|
||||
@@ -369,5 +372,8 @@ if(BUILD_TESTS)
|
||||
add_test(NAME echoion_module_abi_contract_tests
|
||||
COMMAND "${Python3_EXECUTABLE}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tests/test_abi_contract.py")
|
||||
add_test(NAME echoion_module_abi_c_header_tests
|
||||
COMMAND "${Python3_EXECUTABLE}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tests/test_module_abi_c.py")
|
||||
endif()
|
||||
endif()
|
||||
+56
-68
@@ -1,84 +1,72 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"contractId": "echoion.module",
|
||||
"descriptor": "Void::Plugin::ModuleDescriptor",
|
||||
"querySymbol": "echoion_module_query",
|
||||
"language": "C",
|
||||
"header": "echoion/api/module/ModuleAbi.h",
|
||||
"querySymbol": "echoion_module_abi_query",
|
||||
"entryPoints": [
|
||||
{
|
||||
"name": "echoion_module_query",
|
||||
"returns": "const Void::Plugin::ModuleDescriptor*"
|
||||
"name": "echoion_module_abi_query",
|
||||
"returns": "const echoion_module_descriptor_v1*",
|
||||
"ownership": "static-borrowed"
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"name": "Void::Plugin::ModuleDescriptor",
|
||||
"name": "echoion_module_descriptor_v1",
|
||||
"version": 1,
|
||||
"sizeVersioned": true,
|
||||
"fields": [
|
||||
{
|
||||
"name": "struct_size",
|
||||
"type": "std::size_t"
|
||||
},
|
||||
{
|
||||
"name": "descriptor_version",
|
||||
"type": "std::uint32_t"
|
||||
},
|
||||
{
|
||||
"name": "module_id",
|
||||
"type": "std::string"
|
||||
},
|
||||
{
|
||||
"name": "component_version",
|
||||
"type": "Void::Semver::Version"
|
||||
},
|
||||
{
|
||||
"name": "abi_hash",
|
||||
"type": "std::string"
|
||||
},
|
||||
{
|
||||
"name": "abi_contract",
|
||||
"type": "Void::Json::Value"
|
||||
},
|
||||
{
|
||||
"name": "dependencies",
|
||||
"type": "std::vector<Void::Plugin::ModuleDependency>"
|
||||
},
|
||||
{
|
||||
"name": "activation_policy",
|
||||
"type": "Void::Plugin::ActivationPolicy"
|
||||
},
|
||||
{
|
||||
"name": "create",
|
||||
"type": "Void::Plugin::module_factory_fn"
|
||||
}
|
||||
{"name": "struct_size", "type": "size_t"},
|
||||
{"name": "abi_version", "type": "uint32_t"},
|
||||
{"name": "component_id", "type": "echoion_string_view_v1"},
|
||||
{"name": "version_major", "type": "uint32_t"},
|
||||
{"name": "version_minor", "type": "uint32_t"},
|
||||
{"name": "version_patch", "type": "uint32_t"},
|
||||
{"name": "version_prerelease", "type": "echoion_string_view_v1"},
|
||||
{"name": "abi_hash", "type": "echoion_string_view_v1"},
|
||||
{"name": "dependencies", "type": "const echoion_module_dependency_v1*"},
|
||||
{"name": "dependency_count", "type": "size_t"},
|
||||
{"name": "activation_policy", "type": "echoion_activation_policy_v1"},
|
||||
{"name": "api", "type": "const echoion_module_api_v1*"},
|
||||
{"name": "reserved", "type": "const void*[8]"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Void::Plugin::IModule",
|
||||
"methods": [
|
||||
{
|
||||
"name": "activate",
|
||||
"type": "Void::Result::Result<void>(Void::Plugin::ModuleHost&)"
|
||||
},
|
||||
{
|
||||
"name": "quiesce",
|
||||
"type": "Void::Result::Result<void>(std::chrono::steady_clock::time_point)"
|
||||
},
|
||||
{
|
||||
"name": "checkpoint",
|
||||
"type": "Void::Json::Value() const"
|
||||
},
|
||||
{
|
||||
"name": "restore",
|
||||
"type": "Void::Result::Result<void>(const Void::Json::Value&)"
|
||||
},
|
||||
{
|
||||
"name": "readiness",
|
||||
"type": "Void::Plugin::ModuleReadiness() const"
|
||||
},
|
||||
{
|
||||
"name": "deactivate",
|
||||
"type": "Void::Result::Result<void>()"
|
||||
}
|
||||
"name": "echoion_module_api_v1",
|
||||
"version": 1,
|
||||
"sizeVersioned": true,
|
||||
"fields": [
|
||||
{"name": "struct_size", "type": "size_t"},
|
||||
{"name": "abi_version", "type": "uint32_t"},
|
||||
{"name": "create", "type": "echoion_status_v1 (*)(const echoion_module_host_v1*, echoion_module_instance_v1*)"},
|
||||
{"name": "destroy", "type": "void (*)(echoion_module_instance_v1)"},
|
||||
{"name": "activate", "type": "echoion_status_v1 (*)(echoion_module_instance_v1)"},
|
||||
{"name": "quiesce", "type": "echoion_status_v1 (*)(echoion_module_instance_v1, int64_t)"},
|
||||
{"name": "checkpoint", "type": "echoion_status_v1 (*)(echoion_module_instance_v1, echoion_write_bytes_fn_v1, void*)"},
|
||||
{"name": "restore", "type": "echoion_status_v1 (*)(echoion_module_instance_v1, echoion_bytes_view_v1)"},
|
||||
{"name": "readiness", "type": "echoion_status_v1 (*)(echoion_module_instance_v1, echoion_module_readiness_v1*)"},
|
||||
{"name": "deactivate", "type": "echoion_status_v1 (*)(echoion_module_instance_v1)"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "echoion_module_host_v1",
|
||||
"version": 1,
|
||||
"sizeVersioned": true,
|
||||
"fields": [
|
||||
{"name": "struct_size", "type": "size_t"},
|
||||
{"name": "abi_version", "type": "uint32_t"},
|
||||
{"name": "context", "type": "void*"},
|
||||
{"name": "query_service", "type": "echoion_query_service_fn_v1"},
|
||||
{"name": "log", "type": "echoion_log_fn_v1"}
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
"rules": {
|
||||
"opaqueHandles": true,
|
||||
"explicitOwnership": true,
|
||||
"exceptionsCrossBoundary": false,
|
||||
"cppTypesCrossBoundary": false,
|
||||
"appendOnlyCompatibility": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"componentId": "EchoionApi",
|
||||
"productCompatibility": ">=2.0.0 <3.0.0",
|
||||
"publishNightly": true,
|
||||
"cmakeOptions": {}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
#pragma once
|
||||
|
||||
#include <echoion/api/module/Module.hpp>
|
||||
#include <echoion/api/module/ModuleAbi.h>
|
||||
|
||||
#include <Void/Data/Json.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace Echoion::Api::Module
|
||||
{
|
||||
namespace Detail
|
||||
{
|
||||
inline echoion_string_view_v1
|
||||
stringView(const std::string_view value) noexcept
|
||||
{
|
||||
return {.data = value.data(), .size = value.size()};
|
||||
}
|
||||
|
||||
inline echoion_status_v1
|
||||
status(const Void::Result::Result<void>& result) noexcept
|
||||
{
|
||||
return result ? ECHOION_STATUS_OK_V1 : ECHOION_STATUS_INTERNAL_V1;
|
||||
}
|
||||
} // namespace Detail
|
||||
|
||||
// Transitional adapter for existing C++ lifecycle implementations. The
|
||||
// exported descriptor and calls are pure C. C++ ownership and exceptions
|
||||
// remain confined to the module that created the opaque instance.
|
||||
template <Void::Plugin::module_factory_fn Factory>
|
||||
struct LegacyModuleAbi final {
|
||||
struct Instance {
|
||||
std::unique_ptr<Void::Plugin::IModule> module;
|
||||
std::string readinessDetail;
|
||||
};
|
||||
|
||||
static echoion_status_v1
|
||||
create(const echoion_module_host_v1* host,
|
||||
echoion_module_instance_v1* output) noexcept
|
||||
{
|
||||
static_cast<void>(host);
|
||||
if (output == nullptr) {
|
||||
return ECHOION_STATUS_INVALID_ARGUMENT_V1;
|
||||
}
|
||||
try {
|
||||
auto module = Factory();
|
||||
if (!module) {
|
||||
return ECHOION_STATUS_INTERNAL_V1;
|
||||
}
|
||||
auto instance = std::make_unique<Instance>(Instance{
|
||||
.module = std::move(module), .readinessDetail = {}});
|
||||
*output = instance.release();
|
||||
return ECHOION_STATUS_OK_V1;
|
||||
} catch (...) {
|
||||
return ECHOION_STATUS_INTERNAL_V1;
|
||||
}
|
||||
}
|
||||
|
||||
static void destroy(echoion_module_instance_v1 value) noexcept
|
||||
{
|
||||
std::unique_ptr<Instance> instance{
|
||||
static_cast<Instance*>(value)};
|
||||
}
|
||||
|
||||
static echoion_status_v1
|
||||
activate(echoion_module_instance_v1 value) noexcept
|
||||
{
|
||||
Instance* instance = checked(value);
|
||||
if (instance == nullptr) {
|
||||
return ECHOION_STATUS_INVALID_ARGUMENT_V1;
|
||||
}
|
||||
try {
|
||||
instance->module->on_load();
|
||||
return ECHOION_STATUS_OK_V1;
|
||||
} catch (...) {
|
||||
return ECHOION_STATUS_INTERNAL_V1;
|
||||
}
|
||||
}
|
||||
|
||||
static echoion_status_v1
|
||||
quiesce(echoion_module_instance_v1 value,
|
||||
const std::int64_t deadlineNanoseconds) noexcept
|
||||
{
|
||||
Instance* instance = checked(value);
|
||||
if (instance == nullptr || deadlineNanoseconds < 0) {
|
||||
return ECHOION_STATUS_INVALID_ARGUMENT_V1;
|
||||
}
|
||||
try {
|
||||
const auto deadline = std::chrono::steady_clock::time_point{
|
||||
std::chrono::nanoseconds{deadlineNanoseconds}};
|
||||
return Detail::status(instance->module->quiesce(deadline));
|
||||
} catch (...) {
|
||||
return ECHOION_STATUS_INTERNAL_V1;
|
||||
}
|
||||
}
|
||||
|
||||
static echoion_status_v1
|
||||
checkpoint(echoion_module_instance_v1 value,
|
||||
echoion_write_bytes_fn_v1 writer,
|
||||
void* writerContext) noexcept
|
||||
{
|
||||
Instance* instance = checked(value);
|
||||
if (instance == nullptr || writer == nullptr) {
|
||||
return ECHOION_STATUS_INVALID_ARGUMENT_V1;
|
||||
}
|
||||
try {
|
||||
const std::string encoded =
|
||||
Void::Json::serialize(instance->module->checkpoint());
|
||||
return writer(
|
||||
writerContext,
|
||||
{.data = reinterpret_cast<const std::uint8_t*>(
|
||||
encoded.data()),
|
||||
.size = encoded.size()});
|
||||
} catch (...) {
|
||||
return ECHOION_STATUS_INTERNAL_V1;
|
||||
}
|
||||
}
|
||||
|
||||
static echoion_status_v1
|
||||
restore(echoion_module_instance_v1 value,
|
||||
const echoion_bytes_view_v1 state) noexcept
|
||||
{
|
||||
Instance* instance = checked(value);
|
||||
if (instance == nullptr ||
|
||||
(state.data == nullptr && state.size != 0)) {
|
||||
return ECHOION_STATUS_INVALID_ARGUMENT_V1;
|
||||
}
|
||||
try {
|
||||
const std::string_view encoded =
|
||||
state.size == 0
|
||||
? std::string_view{}
|
||||
: std::string_view{
|
||||
reinterpret_cast<const char*>(state.data),
|
||||
state.size};
|
||||
const auto parsed = Void::Json::parse(encoded);
|
||||
if (!parsed) {
|
||||
return ECHOION_STATUS_INVALID_ARGUMENT_V1;
|
||||
}
|
||||
return Detail::status(instance->module->restore(*parsed));
|
||||
} catch (...) {
|
||||
return ECHOION_STATUS_INTERNAL_V1;
|
||||
}
|
||||
}
|
||||
|
||||
static echoion_status_v1
|
||||
readiness(echoion_module_instance_v1 value,
|
||||
echoion_module_readiness_v1* output) noexcept
|
||||
{
|
||||
Instance* instance = checked(value);
|
||||
if (instance == nullptr || output == nullptr ||
|
||||
output->struct_size < sizeof(echoion_module_readiness_v1)) {
|
||||
return ECHOION_STATUS_INVALID_ARGUMENT_V1;
|
||||
}
|
||||
try {
|
||||
const auto result = instance->module->readiness();
|
||||
instance->readinessDetail = result.detail;
|
||||
output->ready = result.ready ? 1U : 0U;
|
||||
output->detail =
|
||||
Detail::stringView(instance->readinessDetail);
|
||||
return ECHOION_STATUS_OK_V1;
|
||||
} catch (...) {
|
||||
return ECHOION_STATUS_INTERNAL_V1;
|
||||
}
|
||||
}
|
||||
|
||||
static echoion_status_v1
|
||||
deactivate(echoion_module_instance_v1 value) noexcept
|
||||
{
|
||||
Instance* instance = checked(value);
|
||||
if (instance == nullptr) {
|
||||
return ECHOION_STATUS_INVALID_ARGUMENT_V1;
|
||||
}
|
||||
try {
|
||||
return Detail::status(instance->module->deactivate());
|
||||
} catch (...) {
|
||||
return ECHOION_STATUS_INTERNAL_V1;
|
||||
}
|
||||
}
|
||||
|
||||
inline static const echoion_module_api_v1 api{
|
||||
.struct_size = sizeof(echoion_module_api_v1),
|
||||
.abi_version = ECHOION_MODULE_ABI_VERSION,
|
||||
.create = create,
|
||||
.destroy = destroy,
|
||||
.activate = activate,
|
||||
.quiesce = quiesce,
|
||||
.checkpoint = checkpoint,
|
||||
.restore = restore,
|
||||
.readiness = readiness,
|
||||
.deactivate = deactivate,
|
||||
.reserved = {},
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
[[nodiscard]] static Instance*
|
||||
checked(echoion_module_instance_v1 value) noexcept
|
||||
{
|
||||
return static_cast<Instance*>(value);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Echoion::Api::Module
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <echoion/api/module/ModuleAbi.h>
|
||||
|
||||
#include <Void/Plugin/Module.hpp>
|
||||
|
||||
#if defined(_WIN32)
|
||||
@@ -26,6 +28,8 @@ namespace Echoion::Api::Module
|
||||
inline constexpr auto descriptorVersion =
|
||||
Void::Plugin::MODULE_DESCRIPTOR_VERSION;
|
||||
inline constexpr const char* querySymbol = "echoion_module_query";
|
||||
inline constexpr const char* stableQuerySymbol =
|
||||
ECHOION_MODULE_ABI_QUERY_SYMBOL;
|
||||
|
||||
} // namespace Echoion::Api::Module
|
||||
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
#ifndef ECHOION_API_MODULE_MODULE_ABI_H
|
||||
#define ECHOION_API_MODULE_MODULE_ABI_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(ECHOION_MODULE_BUILD)
|
||||
#define ECHOION_MODULE_ABI_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define ECHOION_MODULE_ABI_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define ECHOION_MODULE_ABI_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ECHOION_MODULE_ABI_VERSION 1U
|
||||
#define ECHOION_MODULE_ABI_QUERY_SYMBOL "echoion_module_abi_query"
|
||||
|
||||
typedef struct echoion_string_view_v1 {
|
||||
const char* data;
|
||||
size_t size;
|
||||
} echoion_string_view_v1;
|
||||
|
||||
typedef struct echoion_bytes_view_v1 {
|
||||
const uint8_t* data;
|
||||
size_t size;
|
||||
} echoion_bytes_view_v1;
|
||||
|
||||
typedef enum echoion_status_v1 {
|
||||
ECHOION_STATUS_OK_V1 = 0,
|
||||
ECHOION_STATUS_INVALID_ARGUMENT_V1 = 1,
|
||||
ECHOION_STATUS_INCOMPATIBLE_V1 = 2,
|
||||
ECHOION_STATUS_UNAVAILABLE_V1 = 3,
|
||||
ECHOION_STATUS_INTERNAL_V1 = 4
|
||||
} echoion_status_v1;
|
||||
|
||||
typedef enum echoion_activation_policy_v1 {
|
||||
ECHOION_ACTIVATION_RELOADABLE_V1 = 0,
|
||||
ECHOION_ACTIVATION_RESTART_REQUIRED_V1 = 1,
|
||||
ECHOION_ACTIVATION_INSTALLER_REQUIRED_V1 = 2
|
||||
} echoion_activation_policy_v1;
|
||||
|
||||
typedef void* echoion_module_instance_v1;
|
||||
|
||||
typedef echoion_status_v1 (*echoion_write_bytes_fn_v1)(
|
||||
void* context, echoion_bytes_view_v1 value);
|
||||
|
||||
typedef echoion_status_v1 (*echoion_query_service_fn_v1)(
|
||||
void* context, echoion_string_view_v1 service_id, uint32_t minimum_version,
|
||||
const void** service);
|
||||
|
||||
typedef void (*echoion_log_fn_v1)(void* context, uint32_t level,
|
||||
echoion_string_view_v1 message);
|
||||
|
||||
typedef struct echoion_module_host_v1 {
|
||||
size_t struct_size;
|
||||
uint32_t abi_version;
|
||||
void* context;
|
||||
echoion_query_service_fn_v1 query_service;
|
||||
echoion_log_fn_v1 log;
|
||||
const void* reserved[8];
|
||||
} echoion_module_host_v1;
|
||||
|
||||
typedef struct echoion_module_readiness_v1 {
|
||||
size_t struct_size;
|
||||
uint8_t ready;
|
||||
uint8_t reserved_bytes[7];
|
||||
echoion_string_view_v1 detail;
|
||||
} echoion_module_readiness_v1;
|
||||
|
||||
typedef struct echoion_module_api_v1 {
|
||||
size_t struct_size;
|
||||
uint32_t abi_version;
|
||||
echoion_status_v1 (*create)(const echoion_module_host_v1* host,
|
||||
echoion_module_instance_v1* instance);
|
||||
void (*destroy)(echoion_module_instance_v1 instance);
|
||||
echoion_status_v1 (*activate)(echoion_module_instance_v1 instance);
|
||||
echoion_status_v1 (*quiesce)(echoion_module_instance_v1 instance,
|
||||
int64_t steady_clock_deadline_nanoseconds);
|
||||
echoion_status_v1 (*checkpoint)(echoion_module_instance_v1 instance,
|
||||
echoion_write_bytes_fn_v1 writer,
|
||||
void* writer_context);
|
||||
echoion_status_v1 (*restore)(echoion_module_instance_v1 instance,
|
||||
echoion_bytes_view_v1 state);
|
||||
echoion_status_v1 (*readiness)(echoion_module_instance_v1 instance,
|
||||
echoion_module_readiness_v1* readiness);
|
||||
echoion_status_v1 (*deactivate)(echoion_module_instance_v1 instance);
|
||||
const void* reserved[8];
|
||||
} echoion_module_api_v1;
|
||||
|
||||
typedef struct echoion_module_dependency_v1 {
|
||||
size_t struct_size;
|
||||
echoion_string_view_v1 component_id;
|
||||
echoion_string_view_v1 version_range;
|
||||
echoion_string_view_v1 abi_hash;
|
||||
uint8_t optional;
|
||||
uint8_t reserved_bytes[7];
|
||||
} echoion_module_dependency_v1;
|
||||
|
||||
typedef struct echoion_module_descriptor_v1 {
|
||||
size_t struct_size;
|
||||
uint32_t abi_version;
|
||||
echoion_string_view_v1 component_id;
|
||||
uint32_t version_major;
|
||||
uint32_t version_minor;
|
||||
uint32_t version_patch;
|
||||
echoion_string_view_v1 version_prerelease;
|
||||
echoion_string_view_v1 abi_hash;
|
||||
const echoion_module_dependency_v1* dependencies;
|
||||
size_t dependency_count;
|
||||
echoion_activation_policy_v1 activation_policy;
|
||||
const echoion_module_api_v1* api;
|
||||
const void* reserved[8];
|
||||
} echoion_module_descriptor_v1;
|
||||
|
||||
typedef const echoion_module_descriptor_v1* (*echoion_module_abi_query_fn_v1)(
|
||||
void);
|
||||
|
||||
ECHOION_MODULE_ABI_EXPORT const echoion_module_descriptor_v1*
|
||||
echoion_module_abi_query(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compile the public module ABI as both C and C++."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
HEADER = ROOT / "include"
|
||||
|
||||
|
||||
class ModuleAbiCTests(unittest.TestCase):
|
||||
def compile(self, compiler: str, suffix: str, standard: str) -> None:
|
||||
with tempfile.TemporaryDirectory(
|
||||
prefix="echoion-module-abi."
|
||||
) as directory:
|
||||
source = Path(directory) / f"consumer.{suffix}"
|
||||
source.write_text(
|
||||
"""
|
||||
#include <echoion/api/module/ModuleAbi.h>
|
||||
|
||||
int main(void) {
|
||||
#ifdef __cplusplus
|
||||
echoion_module_descriptor_v1 descriptor = {};
|
||||
#else
|
||||
echoion_module_descriptor_v1 descriptor = {0};
|
||||
#endif
|
||||
descriptor.struct_size = sizeof(descriptor);
|
||||
descriptor.abi_version = ECHOION_MODULE_ABI_VERSION;
|
||||
return descriptor.api == 0 ? 0 : 1;
|
||||
}
|
||||
"""
|
||||
)
|
||||
result = subprocess.run(
|
||||
[
|
||||
compiler,
|
||||
standard,
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wpedantic",
|
||||
"-Werror",
|
||||
"-I",
|
||||
str(HEADER),
|
||||
"-fsyntax-only",
|
||||
str(source),
|
||||
],
|
||||
check=False,
|
||||
text=True,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
|
||||
def test_header_is_c11(self) -> None:
|
||||
self.compile("cc", "c", "-std=c11")
|
||||
|
||||
def test_header_is_cpp20(self) -> None:
|
||||
self.compile("c++", "cpp", "-std=c++20")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user