### P2-3 STEP/IGES/DXF 官方格式插件
- plugins/official/{step,iges,dxf}(纯 C ABI,宿主 body_from_mesh 建体);import_cad 沿用内置优先/显式/回退策略;
STEP 盒体内置/插件体积 bbox 一致(全三角面时面数一致)、IGES 闭合体积 24000/bbox 一致、DXF 合成 12 tri/24000;
- test_plugin_official_cad_formats 5/5;插件 ctest 65/65。
### P2-4 vde-service 进程外服务接入 + 沙箱/超时
- PluginManager:vde-service.json 发现/扫描、invoke_external_service(request/response、env/cwd 白名单、
超时 kill、输出/响应上限、protocol 校验、outputs 越界拒绝、崩溃隔离);官方 STL→OBJ 端到端;
- test_plugin_external_service 12/12;docs/design/vde-service-protocol.md + plugin-development §12。
### P3-1 插件签名/许可/权限(分层正确)
- plugin_security.h/cpp(vde_plugin,仅 foundation;宿主注入 SignatureVerifier,不依赖 vde_license);
canonical manifest payload、ed25519 签名、Policy(require_signature/allow_unsigned/publisher 白名单/权限默认拒绝)、
manager 钩子(默认关闭,行为不变)、vde_plugin_tool verify;test_plugin_security 28/28 + tool 真实验签 7 类;
docs/design/plugin-security.md。
### P3-2 VDE_MODULES_MODE shared/plugin 真实实现
- 四值真实生效:shared = C ABI 共享内核 + 官方/示例插件共享库;plugin = shared + 插件部署/加载;
缺 CAPI/PLUGIN FATAL、非法值 FATAL;plugins/shared_mode smoke + plugins/abi_matrix(1.0/1.1/1.2 接受,1.3/2.0 拒绝);
- shared ctest 97/97、plugin ctest 98/98、ABI_MATRIX accepted=3 rejected=2 failures=0;SDK 插件 install 布局。
### 工程
- .gitignore 修复后本批新增 CMakeLists 全部纳入版本库;版本 1.0.48(CMake/version.h/test_version/README/docs index/module-manual);
- 全量构建 0 error(357 targets);全量 ctest 7441 注册、7346/7346 PASS(0 failed,24 skipped,153.25s)。
102 lines
3.3 KiB
C++
102 lines
3.3 KiB
C++
/**
|
||
* @file capi_dll_smoke.cpp
|
||
* @brief 微内核 P3-2 shared 模式 smoke:动态加载 C ABI 共享库(libvde_capi)并调用入口
|
||
*
|
||
* 目的:验证 VDE_MODULES_MODE=shared 的部署产物(纯 C ABI DLL)可被宿主/独立进程
|
||
* 动态加载并使用;不链接任何 C++ 内核符号(仅用头文件类型 + 运行时 GetProcAddress)。
|
||
* 成功输出含 SHARED_CAPI_SMOKE_PASS(CTest PASS_REGULAR_EXPRESSION)。
|
||
*/
|
||
#include "vde/capi/vde_capi.h"
|
||
|
||
#include <cstdio>
|
||
#include <cstring>
|
||
|
||
#if defined(_WIN32)
|
||
#include <windows.h>
|
||
static void* vde_smoke_load_library(const char* path) {
|
||
return reinterpret_cast<void*>(LoadLibraryA(path));
|
||
}
|
||
static void* vde_smoke_get_symbol(void* lib, const char* name) {
|
||
return reinterpret_cast<void*>(
|
||
GetProcAddress(reinterpret_cast<HMODULE>(lib), name));
|
||
}
|
||
static const char* vde_smoke_last_error_text() {
|
||
return "LoadLibrary/GetProcAddress failed";
|
||
}
|
||
#else
|
||
#include <dlfcn.h>
|
||
static void* vde_smoke_load_library(const char* path) { return dlopen(path, RTLD_NOW); }
|
||
static void* vde_smoke_get_symbol(void* lib, const char* name) {
|
||
return dlsym(lib, name);
|
||
}
|
||
static const char* vde_smoke_last_error_text() { return dlerror(); }
|
||
#endif
|
||
|
||
namespace {
|
||
|
||
template <typename Fn>
|
||
bool load_fn(void* lib, const char* name, Fn* out) {
|
||
void* sym = vde_smoke_get_symbol(lib, name);
|
||
if (!sym) {
|
||
std::fprintf(stderr, "missing symbol %s: %s\n", name,
|
||
vde_smoke_last_error_text());
|
||
return false;
|
||
}
|
||
*out = reinterpret_cast<Fn>(sym);
|
||
return true;
|
||
}
|
||
|
||
} // namespace
|
||
|
||
int main() {
|
||
const char* path = VDE_CAPI_SHARED_PATH;
|
||
void* lib = vde_smoke_load_library(path);
|
||
if (!lib) {
|
||
std::fprintf(stderr, "cannot load C ABI shared library '%s': %s\n", path,
|
||
vde_smoke_last_error_text());
|
||
return 1;
|
||
}
|
||
using CreateFn = VdeHandle (*)();
|
||
using DestroyFn = void (*)(VdeHandle);
|
||
using CreateBoxFn = VdeBodyHandle (*)(VdeHandle, double, double, double);
|
||
using FaceCountFn = int (*)(VdeBodyHandle);
|
||
using LastErrorFn = const char* (*)(VdeHandle);
|
||
using BodyFreeFn = void (*)(VdeBodyHandle);
|
||
|
||
CreateFn create = nullptr;
|
||
DestroyFn destroy = nullptr;
|
||
CreateBoxFn create_box = nullptr;
|
||
FaceCountFn face_count = nullptr;
|
||
LastErrorFn last_error = nullptr;
|
||
BodyFreeFn body_free = nullptr;
|
||
if (!load_fn(lib, "vde_create", &create) ||
|
||
!load_fn(lib, "vde_destroy", &destroy) ||
|
||
!load_fn(lib, "vde_body_create_box", &create_box) ||
|
||
!load_fn(lib, "vde_body_get_face_count", &face_count) ||
|
||
!load_fn(lib, "vde_last_error", &last_error) ||
|
||
!load_fn(lib, "vde_body_free", &body_free)) {
|
||
return 1;
|
||
}
|
||
VdeHandle ctx = create();
|
||
if (!ctx) {
|
||
std::fprintf(stderr, "vde_create returned null\n");
|
||
return 1;
|
||
}
|
||
VdeBodyHandle box = create_box(ctx, 2.0, 2.0, 2.0);
|
||
if (!box) {
|
||
std::fprintf(stderr, "vde_body_create_box failed: %s\n",
|
||
last_error ? last_error(ctx) : "?");
|
||
destroy(ctx);
|
||
return 1;
|
||
}
|
||
const int faces = face_count(box);
|
||
body_free(box);
|
||
destroy(ctx);
|
||
if (faces != 6) {
|
||
std::fprintf(stderr, "expected 6 faces, got %d\n", faces);
|
||
return 1;
|
||
}
|
||
std::printf("SHARED_CAPI_SMOKE_PASS lib=%s faces=%d\n", path, faces);
|
||
return 0;
|
||
}
|