@customize-agent/cad-native 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CMakeLists.txt
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
cmake_minimum_required(VERSION 3.20)
|
|
2
2
|
project(cad-native C)
|
|
3
3
|
|
|
4
|
+
# Windows 用户机不一定安装 VC++ 2015-2022 运行库;动态 CRT 会让 sidecar 在加载阶段
|
|
5
|
+
# 直接失败(0xC0000135,进程不产生 stderr,只能看到空错误)。静态 CRT 后 exe 只依赖
|
|
6
|
+
# KERNEL32 + 随包的 libredwg-0.dll。
|
|
7
|
+
if(MSVC)
|
|
8
|
+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
9
|
+
endif()
|
|
10
|
+
|
|
4
11
|
set(CMAKE_C_STANDARD 99)
|
|
5
12
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
6
13
|
|
package/README.md
CHANGED
|
@@ -49,6 +49,11 @@ Visual Studio 2022, and copies `libredwg-0.dll` and its runtime DLLs beside the
|
|
|
49
49
|
.\build-windows.ps1 -LibreDwgWin64Zip C:\path\to\libredwg-0.14-win64.zip
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
The sidecar links the **static** MSVC CRT (`CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded`). It must not
|
|
53
|
+
depend on `VCRUNTIME140.dll` or the UCRT: end-user machines without the VC++ 2015-2022
|
|
54
|
+
Redistributable would fail to start it at load time (exit `0xC0000135`, no stderr). The build script
|
|
55
|
+
verifies the dependency table with `dumpbin /dependents` and fails on any MSVC/UCRT runtime DLL.
|
|
56
|
+
|
|
52
57
|
The build scripts write the result to the platform directory:
|
|
53
58
|
|
|
54
59
|
- macOS: `native/darwin-arm64/cad-native` or `native/darwin-x64/cad-native`
|
package/build-windows.ps1
CHANGED
|
@@ -40,4 +40,12 @@ cmake --build $build --config Release --parallel
|
|
|
40
40
|
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
|
|
41
41
|
Copy-Item (Join-Path $build 'Release\cad-native.exe') (Join-Path $OutDir 'cad-native.exe') -Force
|
|
42
42
|
Get-ChildItem -Path $work -Filter '*.dll' | Copy-Item -Destination $OutDir -Force
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
# 发布门禁:exe 不得依赖 MSVC/UCRT 运行库。用户机未装 VC++ 运行库时,动态 CRT
|
|
45
|
+
# 会在加载阶段失败(0xC0000135),进程不产生 stderr,现场只能看到空错误。
|
|
46
|
+
$exe = Join-Path $OutDir 'cad-native.exe'
|
|
47
|
+
$dependents = cmd /c "call `"$vcvars`" >nul && dumpbin /dependents `"$exe`""
|
|
48
|
+
if ($LASTEXITCODE -ne 0) { throw "dumpbin /dependents 执行失败:$($dependents -join '; ')" }
|
|
49
|
+
$runtime = $dependents | Select-String -Pattern 'VCRUNTIME|MSVCP|api-ms-win-crt|ucrtbase'
|
|
50
|
+
if ($runtime) { throw "cad-native.exe 仍依赖 MSVC/UCRT 运行库:$($runtime -join '; ')" }
|
|
51
|
+
Write-Host "built $OutDir\cad-native.exe (static CRT; with official libredwg runtime DLLs)"
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -25,8 +25,14 @@ if (fs.existsSync(path.join(native, 'win32-x64', 'cad-native.exe'))
|
|
|
25
25
|
&& !fs.existsSync(path.join(native, 'win32-x64', 'libredwg-0.dll'))) {
|
|
26
26
|
missing.push(['win32-x64', 'libredwg-0.dll']);
|
|
27
27
|
}
|
|
28
|
+
// 静态 CRT 门禁(跨平台生效):动态 CRT 的导入表含 VCRUNTIME140,用户机未装 VC++ 运行库时
|
|
29
|
+
// 进程在加载阶段就失败(0xC0000135 且无 stderr)。发布前不依赖 Windows 工具即可拦截。
|
|
30
|
+
const winExe = path.join(native, 'win32-x64', 'cad-native.exe');
|
|
31
|
+
if (fs.existsSync(winExe) && fs.readFileSync(winExe).includes(Buffer.from('VCRUNTIME140'))) {
|
|
32
|
+
missing.push(['win32-x64', 'cad-native.exe 依赖 VCRUNTIME140(须用静态 CRT 重建)']);
|
|
33
|
+
}
|
|
28
34
|
if (missing.length) {
|
|
29
|
-
console.error('[cad-native]
|
|
35
|
+
console.error('[cad-native] 原生 DWG sidecar 缺失或不合格:');
|
|
30
36
|
for (const [platform, name] of missing) console.error(` - native/${platform}/${name}`);
|
|
31
37
|
console.error('请在各平台用 CMake/Clang(macOS)或 CMake/MSVC(Windows)构建后再打包;禁止用 MinGW 交叉编译。');
|
|
32
38
|
process.exit(1);
|