Files
hm 6f44d48d29
Build & Test / build-and-test (push) Canceled after 0s
VDE Build & Test / build-and-test (push) Canceled after 0s
Build & Test / python-bindings (push) Canceled after 0s
feat: P2-5c 圆角盒 seam 归零 + P3-4/5/6/7 收口(1.0.68)
### P2-5c 圆角盒残余 seam 96→0
- 根因:平面单环耳切剔除共线中间点,与共享采样 3 段边界不一致;新增 restore_ring_boundary_points 把共享边界点逐点补回;
- 26 面圆角盒 open 96→0(Plane/Cylinder/Sphere 全 0),tris 6396,box 类保持 0;平面面与曲面相邻时 10 tris/面(纯平面 box 仍 2),
  测试断言按新语义更新;

### P3-4 外部服务 OS 级沙箱
- vde-service.json limits(max_memory_mb/max_cpu_seconds/max_processes/kill_on_close);Windows Job Object(挂起创建→Assign→Resume、
  KILL_ON_JOB_CLOSE、内存/CPU/进程数限制事件)+ POSIX setsid/rlimit;结果 limit_exceeded/limit_kind;
- test_plugin_external_service 18/18(内存/CPU/进程数超限、kill_on_close 回收、旧行为、非法清单);docs 更新;

### P3-5 插件 DLL 工件哈希 + 密钥轮换/吊销
- manifest artifacts[{path,sha256}]/key_id;SHA-256 自实现 + 路径白名单;Policy require_artifact_hashes/trusted_keys/revoked_key_ids;
  新错误码;evaluate 扩展 + manager hook 已接线;tool verify --hash/--key-id;test_plugin_security 42/42;docs plugin-security §4.5/§4.6;

### P3-6 C++ 跨 DLL ABI 边界定稿(opt-in 实验)
- VDE_BUILD_CPP_SHARED(默认 OFF)12 内核模块 SHARED + consumer smoke(CPP_SHARED_CONSUMER_PASS faces=6 volume=6000);
- 决策:保持 C++ 静态 + 纯 C ABI + 插件默认;跨 DLL 单例/STL/RTTI/导出规模风险,实验仅 opt-in;architecture §7.8/design §13;

### P3-7 MSVC/Linux 跨平台验证收口
- .github/workflows/ci.yml 新增 windows-msvc job(YAML 校验通过);vde_platform UTF-8 宽 API/error/自守卫修复;
- 可移植性审计 12 类;docs/guides/cross-platform-validation.md;本机无 MSVC/WSL/docker,实机由 CI 反馈;

### VDE-1249 / 工程
- 反馈单更新:圆角盒 open 960→96→0,1.0.68 预算 Normal≈6396,宿主复测指引改 1.0.68;
- 版本 1.0.68;全量构建 0 error(340 targets);全量 ctest 7472 注册、7377/7377 PASS(0 failed,25 skipped,560.68s)。
2026-10-28 20:49:27 +08:00

78 lines
3.3 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
/// 平台抽象层
/// 跨平台兼容宏 + M_PI 补丁 (MSVC 未定义)
///
/// Windows / POSIX 差异约定(P3-7 跨平台收口):
/// - 动态库:Windows 走 LoadLibraryA(失败时 UTF-8→UTF-16 用 LoadLibraryW 重试),
/// POSIX 走 dlopen/dlsym/dlclose;
/// - 文件路径:Windows 优先 ANSI 窄 API,失败时用 UTF-8→UTF-16 宽 API 重试
/// (load_library/delete_file/make_temp_file/read_file_bytes 均如此),
/// 因此调用方统一传 UTF-8 字符串即可;
/// - 错误信息:Windows 用 FormatMessageW 取系统消息并转 UTF-8;POSIX 用 dlerror;
/// - 进程:run_command 在 Windows 用 cmd.exe /C(带超时版本 CreateProcessA +
/// TerminateProcess/taskkill),POSIX 用 fork/exec + SIGKILL;
/// 命令字符串中的非 ASCII 字符在 Windows 上受 ANSI 代码页限制(已知限制);
/// - 临时目录:Windows 读 TEMP,POSIX 读 TMPDIR(缺省 /tmp);
/// - MSVC 下 M_PI 需要本头或 _USE_MATH_DEFINES(本头在包含处兜底定义)。
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#include <string>
namespace vde::platform {
/// 动态库句柄
using LibHandle = void*;
/// 加载动态库 (.so / .dll / .dylib / .so.hmos)
/// @return 非空 → 成功,nullptr → 失败
LibHandle load_library(const std::string& path);
/// 卸载
void unload_library(LibHandle h);
/// 查找符号
void* find_symbol(LibHandle h, const std::string& name);
/// 获取最后一次加载错误信息
std::string last_error();
/// 创建临时文件(跨平台安全)
///
/// 文件名包含 PID + 原子计数器 + 单调纳秒 + 随机分量,并以「独占创建」
/// (Windows CREATE_NEW / POSIX O_CREAT|O_EXCL)保证并发进程、并发线程之间
/// 路径唯一且不会复用已存在文件(K-11:修复旧实现「秒级时间戳 + 进程内
/// 计数器」在并行测试/服务下跨进程撞名、互相删除的缺陷)。
/// 清理语义:本函数只创建空文件,删除由调用方 `delete_file` 负责。
/// @param prefix 文件名前缀
/// @param suffix 文件扩展名(如 ".dxf")
/// @param[out] path 返回临时文件完整路径
/// @return true 成功
bool make_temp_file(const std::string& prefix, const std::string& suffix, std::string& path);
/// 删除文件
bool delete_file(const std::string& path);
/// 读取整个文件(二进制,不做换行转换)
/// @param path 文件路径。Windows 下先按当前 ANSI 代码页解释;若文件打不开,
/// 再按 UTF-8 → UTF-16 宽字符重试,以支持 ANSI 无法表示的字符(如 Ø)
/// @param[out] out 文件内容
/// @return true 成功
bool read_file_bytes(const std::string& path, std::string& out);
/// 读取文件前 max_bytes 字节(二进制)
/// @return true 成功(文件短于 max_bytes 时返回实际长度)
bool read_file_head(const std::string& path, std::size_t max_bytes, std::string& out);
/// 执行系统命令
/// @return 0 成功;超时返回 124(Windows 实现会终止进程)
int run_command(const std::string& cmd);
/// 执行系统命令,带超时(Windows:CreateProcess + WaitForSingleObject)
/// @param timeout_ms 0 表示不超时;超时返回 124
int run_command(const std::string& cmd, unsigned timeout_ms);
} // namespace vde::platform