@huaqiu/js-gerbv 0.0.0-stage → 0.1.15

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.
Files changed (37) hide show
  1. package/CMakeLists.txt +151 -0
  2. package/LICENSE +674 -0
  3. package/README.md +105 -2
  4. package/include/config.h +34 -0
  5. package/include/gettext.h +9 -0
  6. package/index.js +382 -0
  7. package/package.json +46 -4
  8. package/prebuilds/darwin-arm64/gerbv_node.node +0 -0
  9. package/prebuilds/darwin-arm64/libglib-2.0.0.dylib +0 -0
  10. package/prebuilds/darwin-arm64/libintl.8.dylib +0 -0
  11. package/prebuilds/darwin-arm64/libpcre2-8.0.dylib +0 -0
  12. package/prebuilds/darwin-arm64/meta.json +9 -0
  13. package/prebuilds/win32-x64/gerbv_node.node +0 -0
  14. package/prebuilds/win32-x64/libffi-8.dll +0 -0
  15. package/prebuilds/win32-x64/libgcc_s_seh-1.dll +0 -0
  16. package/prebuilds/win32-x64/libgio-2.0-0.dll +0 -0
  17. package/prebuilds/win32-x64/libglib-2.0-0.dll +0 -0
  18. package/prebuilds/win32-x64/libgmodule-2.0-0.dll +0 -0
  19. package/prebuilds/win32-x64/libgobject-2.0-0.dll +0 -0
  20. package/prebuilds/win32-x64/libiconv-2.dll +0 -0
  21. package/prebuilds/win32-x64/libintl-8.dll +0 -0
  22. package/prebuilds/win32-x64/libpcre2-8-0.dll +0 -0
  23. package/prebuilds/win32-x64/libstdc++-6.dll +0 -0
  24. package/prebuilds/win32-x64/libwinpthread-1.dll +0 -0
  25. package/prebuilds/win32-x64/meta.json +9 -0
  26. package/prebuilds/win32-x64/zlib1.dll +0 -0
  27. package/scripts/cmake-build.js +231 -0
  28. package/scripts/ensure-gerbv.js +42 -0
  29. package/scripts/pack-prebuild.js +208 -0
  30. package/scripts/smoke.js +74 -0
  31. package/shim/gdk/gdk.h +15 -0
  32. package/shim/gdk/gdkkeysyms.h +3 -0
  33. package/shim/gtk/gtk.h +7 -0
  34. package/src/addon.cc +740 -0
  35. package/src/gerber_min.c +67 -0
  36. package/src/gerbv_stubs.c +79 -0
  37. package/vcpkg.json +8 -0
@@ -0,0 +1,231 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 跨平台 CMake 配置并编译 gerbv_node。
4
+ * 环境变量:
5
+ * CMAKE_BUILD_TYPE / GERBV_BUILD_TYPE — Debug|Release(默认 Release)
6
+ * CMAKE_PREFIX_PATH / VCPKG_ROOT — Windows 找 glib
7
+ * NODE_INC — 覆盖 node 头路径
8
+ */
9
+ "use strict";
10
+
11
+ const { spawnSync } = require("child_process");
12
+ const fs = require("fs");
13
+ const path = require("path");
14
+ const os = require("os");
15
+
16
+ const root = path.resolve(__dirname, "..");
17
+ const buildDir = path.join(root, "build");
18
+ const buildType =
19
+ process.env.GERBV_BUILD_TYPE || process.env.CMAKE_BUILD_TYPE || "Release";
20
+
21
+ function run(cmd, args, opts = {}) {
22
+ console.log("+", cmd, args.join(" "));
23
+ // Do not use shell:true — Windows would split arguments containing spaces
24
+ // (e.g. -DCMAKE_JS_INC=C:\Program Files\nodejs\include\node).
25
+ const r = spawnSync(cmd, args, {
26
+ stdio: "inherit",
27
+ shell: false,
28
+ env: process.env,
29
+ ...opts,
30
+ });
31
+ if (r.status !== 0) {
32
+ process.exit(r.status == null ? 1 : r.status);
33
+ }
34
+ }
35
+
36
+ function which(bin) {
37
+ const r = spawnSync(
38
+ process.platform === "win32" ? "where" : "which",
39
+ [bin],
40
+ { encoding: "utf8", shell: process.platform === "win32" }
41
+ );
42
+ return r.status === 0 ? String(r.stdout).split(/\r?\n/)[0].trim() : "";
43
+ }
44
+
45
+ function nodeInc() {
46
+ if (process.env.NODE_INC) return process.env.NODE_INC;
47
+ try {
48
+ return require("path").dirname(process.execPath) === process.execPath
49
+ ? ""
50
+ : require("child_process")
51
+ .execSync('node -p "require(\'path\').dirname(process.execPath)"', {
52
+ encoding: "utf8",
53
+ })
54
+ .trim();
55
+ } catch (_) {
56
+ return "";
57
+ }
58
+ }
59
+
60
+ function resolveNodeInc() {
61
+ if (process.env.NODE_INC) return process.env.NODE_INC;
62
+ // Prefer headers next to the running node binary (official installers).
63
+ const candidates = [
64
+ path.join(path.dirname(process.execPath), "include", "node"),
65
+ path.join(path.dirname(process.execPath), "..", "include", "node"),
66
+ ];
67
+ // Homebrew node@20 etc.
68
+ if (process.platform === "darwin") {
69
+ candidates.push("/opt/homebrew/include/node");
70
+ candidates.push("/usr/local/include/node");
71
+ }
72
+ if (process.platform === "linux") {
73
+ candidates.push("/usr/include/node");
74
+ }
75
+ for (const c of candidates) {
76
+ if (fs.existsSync(path.join(c, "node_api.h")) || fs.existsSync(path.join(c, "node.h"))) {
77
+ return c;
78
+ }
79
+ }
80
+ // Let CMake fall back to the `node-api-headers` npm package.
81
+ return "";
82
+ }
83
+
84
+ /**
85
+ * Windows without vcpkg: use MSYS2 mingw64 glib (matches the MinGW toolchain).
86
+ * Mutates PATH / pkg-config env and returns extra CMake args.
87
+ */
88
+ function setupMsys2() {
89
+ if (process.platform !== "win32" || process.env.VCPKG_ROOT) return [];
90
+ const root = process.env.MSYS2_ROOT || "C:/msys64";
91
+ const mingw = path.join(root, "mingw64");
92
+ const bin = path.join(mingw, "bin");
93
+ if (!fs.existsSync(path.join(bin, "gcc.exe"))) return [];
94
+ process.env.PATH = bin + path.delimiter + (process.env.PATH || "");
95
+ const prefix = process.env.CMAKE_PREFIX_PATH;
96
+ process.env.CMAKE_PREFIX_PATH = prefix ? mingw + path.delimiter + prefix : mingw;
97
+ const pc = path.join(mingw, "lib", "pkgconfig");
98
+ if (fs.existsSync(pc)) {
99
+ const prev = process.env.PKG_CONFIG_PATH;
100
+ process.env.PKG_CONFIG_PATH = prev ? pc + path.delimiter + prev : pc;
101
+ }
102
+ const pkgconf = path.join(bin, "pkg-config.exe");
103
+ if (fs.existsSync(pkgconf)) return ["-DPKG_CONFIG_EXECUTABLE=" + pkgconf];
104
+ return [];
105
+ }
106
+
107
+ /**
108
+ * Windows: link against node.lib so N-API symbols resolve at link time.
109
+ * node-gyp caches it under %LOCALAPPDATA%/node-gyp/Cache/<version>/<arch>/node.lib.
110
+ */
111
+ function resolveNodeLib() {
112
+ if (process.env.CMAKE_JS_LIB) return process.env.CMAKE_JS_LIB;
113
+ const candidates = [path.join(path.dirname(process.execPath), "node.lib")];
114
+ const local =
115
+ process.env.LOCALAPPDATA || path.join(os.homedir(), "AppData", "Local");
116
+ candidates.push(
117
+ path.join(
118
+ local,
119
+ "node-gyp",
120
+ "Cache",
121
+ process.versions.node,
122
+ process.arch,
123
+ "node.lib"
124
+ )
125
+ );
126
+ for (const c of candidates) {
127
+ if (fs.existsSync(c)) return c;
128
+ }
129
+ return "";
130
+ }
131
+
132
+ function cmakeGeneratorArgs() {
133
+ if (process.platform !== "win32") return [];
134
+ // Prefer Ninja if present; else VS 2022.
135
+ if (which("ninja")) {
136
+ return ["-G", "Ninja"];
137
+ }
138
+ return ["-G", "Visual Studio 17 2022", "-A", "x64"];
139
+ }
140
+
141
+ function cmakePrefixArgs() {
142
+ const args = [];
143
+ const prefixes = [];
144
+ if (process.env.CMAKE_PREFIX_PATH) {
145
+ prefixes.push(process.env.CMAKE_PREFIX_PATH);
146
+ }
147
+ if (process.env.VCPKG_ROOT) {
148
+ const triplet = process.env.VCPKG_DEFAULT_TRIPLET || "x64-windows";
149
+ const installed = path.join(process.env.VCPKG_ROOT, "installed", triplet);
150
+ prefixes.push(installed);
151
+ args.push(
152
+ "-DCMAKE_TOOLCHAIN_FILE=" +
153
+ path.join(process.env.VCPKG_ROOT, "scripts", "buildsystems", "vcpkg.cmake")
154
+ );
155
+ // 让 PkgConfig 能找到 vcpkg 的 glib .pc
156
+ const pc = path.join(installed, "lib", "pkgconfig");
157
+ if (fs.existsSync(pc)) {
158
+ const prev = process.env.PKG_CONFIG_PATH || "";
159
+ process.env.PKG_CONFIG_PATH = prev ? pc + path.delimiter + prev : pc;
160
+ }
161
+ const pkgconfBin = path.join(installed, "tools", "pkgconf");
162
+ if (fs.existsSync(pkgconfBin)) {
163
+ process.env.PATH = pkgconfBin + path.delimiter + (process.env.PATH || "");
164
+ }
165
+ }
166
+ if (prefixes.length) {
167
+ args.push("-DCMAKE_PREFIX_PATH=" + prefixes.join(";"));
168
+ }
169
+ return args;
170
+ }
171
+
172
+ function main() {
173
+ const msys2Args = setupMsys2();
174
+ const cmake = which("cmake");
175
+ if (!cmake) {
176
+ console.error("error: cmake not found in PATH");
177
+ process.exit(1);
178
+ }
179
+ fs.mkdirSync(buildDir, { recursive: true });
180
+
181
+ const nodeIncPath = resolveNodeInc();
182
+ const configure = [
183
+ "-S",
184
+ root,
185
+ "-B",
186
+ buildDir,
187
+ "-DCMAKE_BUILD_TYPE=" + buildType,
188
+ ...cmakeGeneratorArgs(),
189
+ ...cmakePrefixArgs(),
190
+ ...msys2Args,
191
+ ];
192
+ if (nodeIncPath) {
193
+ configure.push("-DCMAKE_JS_INC=" + nodeIncPath);
194
+ }
195
+ if (process.platform === "win32") {
196
+ const nodeLib = resolveNodeLib();
197
+ if (nodeLib) configure.push("-DCMAKE_JS_LIB=" + nodeLib);
198
+ }
199
+
200
+ run(cmake, configure);
201
+
202
+ const buildArgs = ["--build", buildDir, "--config", buildType];
203
+ // Parallel
204
+ const jobs = Math.max(2, (os.cpus() || []).length || 2);
205
+ if (process.platform === "win32") {
206
+ buildArgs.push("--parallel", String(jobs));
207
+ } else {
208
+ buildArgs.push("--parallel", String(jobs));
209
+ }
210
+ run(cmake, buildArgs);
211
+
212
+ // Normalize: ensure build/gerbv_node.node exists (VS puts it under Release/)
213
+ const flat = path.join(buildDir, "gerbv_node.node");
214
+ if (!fs.existsSync(flat)) {
215
+ for (const sub of ["Release", "Debug", "RelWithDebInfo"]) {
216
+ const p = path.join(buildDir, sub, "gerbv_node.node");
217
+ if (fs.existsSync(p)) {
218
+ fs.copyFileSync(p, flat);
219
+ console.log("normalized", p, "->", flat);
220
+ break;
221
+ }
222
+ }
223
+ }
224
+ if (!fs.existsSync(flat)) {
225
+ console.error("error: gerbv_node.node missing after build");
226
+ process.exit(1);
227
+ }
228
+ console.log("built", flat);
229
+ }
230
+
231
+ main();
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 确保 vendor/gerbv 存在(浅克隆 efa/gerbv)。
4
+ * 可用 GERBV_SRC 指向已有源码树以跳过克隆。
5
+ */
6
+ "use strict";
7
+
8
+ const { spawnSync } = require("child_process");
9
+ const fs = require("fs");
10
+ const path = require("path");
11
+
12
+ const root = path.resolve(__dirname, "..");
13
+ const dest = process.env.GERBV_SRC
14
+ ? path.resolve(process.env.GERBV_SRC)
15
+ : path.join(root, "vendor", "gerbv");
16
+ const header = path.join(dest, "src", "gerbv.h");
17
+
18
+ function main() {
19
+ if (fs.existsSync(header)) {
20
+ console.log("gerbv ok", dest);
21
+ return;
22
+ }
23
+ if (process.env.GERBV_SRC) {
24
+ console.error("error: GERBV_SRC set but missing", header);
25
+ process.exit(1);
26
+ }
27
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
28
+ console.log("[gerbv] cloning https://github.com/efa/gerbv …");
29
+ const r = spawnSync(
30
+ "git",
31
+ ["clone", "--depth", "1", "https://github.com/efa/gerbv.git", dest],
32
+ { stdio: "inherit" }
33
+ );
34
+ if (r.status !== 0) process.exit(r.status == null ? 1 : r.status);
35
+ if (!fs.existsSync(header)) {
36
+ console.error("error: clone finished but missing", header);
37
+ process.exit(1);
38
+ }
39
+ console.log("gerbv ok", dest);
40
+ }
41
+
42
+ main();
@@ -0,0 +1,208 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 将 build 产物打进 prebuilds/<platform>-<arch>/。
4
+ * Windows:拷贝 glib 等 DLL;macOS:拷贝 glib/intl/pcre2 并改写 @loader_path。
5
+ */
6
+ "use strict";
7
+
8
+ const { spawnSync } = require("child_process");
9
+ const fs = require("fs");
10
+ const path = require("path");
11
+
12
+ const root = path.resolve(__dirname, "..");
13
+ const platform = process.platform;
14
+ const arch = process.arch;
15
+ const key = platform + "-" + arch;
16
+ const outDir = path.join(root, "prebuilds", key);
17
+
18
+ const addonCandidates = [
19
+ path.join(root, "build", "gerbv_node.node"),
20
+ path.join(root, "build", "Release", "gerbv_node.node"),
21
+ path.join(root, "build", "Debug", "gerbv_node.node"),
22
+ ];
23
+
24
+ function findAddon() {
25
+ for (const p of addonCandidates) {
26
+ if (fs.existsSync(p)) return p;
27
+ }
28
+ return null;
29
+ }
30
+
31
+ function copyFile(src, dst) {
32
+ fs.mkdirSync(path.dirname(dst), { recursive: true });
33
+ fs.copyFileSync(src, dst);
34
+ console.log(" +", path.relative(root, dst));
35
+ }
36
+
37
+ function run(cmd, args, opts = {}) {
38
+ const r = spawnSync(cmd, args, { encoding: "utf8" });
39
+ if (r.status !== 0) {
40
+ if (opts.allowFail) return r;
41
+ console.error(cmd, args.join(" "), r.stderr || r.stdout);
42
+ process.exit(r.status == null ? 1 : r.status);
43
+ }
44
+ return r;
45
+ }
46
+
47
+ function copyWinRuntimeDlls() {
48
+ const dllNames = [
49
+ // vcpkg-style names
50
+ "glib-2.0-0.dll",
51
+ "gobject-2.0-0.dll",
52
+ "gio-2.0-0.dll",
53
+ "gmodule-2.0-0.dll",
54
+ "intl-8.dll",
55
+ "pcre2-8.dll",
56
+ "iconv-2.dll",
57
+ "ffi-8.dll",
58
+ "zlib1.dll",
59
+ // MSYS2 mingw64 names
60
+ "libglib-2.0-0.dll",
61
+ "libgobject-2.0-0.dll",
62
+ "libgio-2.0-0.dll",
63
+ "libgmodule-2.0-0.dll",
64
+ "libintl-8.dll",
65
+ "libpcre2-8-0.dll",
66
+ "libiconv-2.dll",
67
+ "libffi-8.dll",
68
+ "libstdc++-6.dll",
69
+ "libgcc_s_seh-1.dll",
70
+ "libwinpthread-1.dll",
71
+ ];
72
+ const searchDirs = [];
73
+ if (process.env.VCPKG_ROOT) {
74
+ searchDirs.push(
75
+ path.join(process.env.VCPKG_ROOT, "installed", "x64-windows", "bin"),
76
+ path.join(process.env.VCPKG_ROOT, "installed", "x86-windows", "bin")
77
+ );
78
+ }
79
+ const msys2Root = process.env.MSYS2_ROOT || "C:/msys64";
80
+ searchDirs.push(path.join(msys2Root, "mingw64", "bin"));
81
+ if (process.env.GERBV_RUNTIME_DIR) {
82
+ searchDirs.push(process.env.GERBV_RUNTIME_DIR);
83
+ }
84
+ searchDirs.push(path.join(root, "build"));
85
+
86
+ for (const name of dllNames) {
87
+ let found = null;
88
+ for (const dir of searchDirs) {
89
+ const p = path.join(dir, name);
90
+ if (fs.existsSync(p)) {
91
+ found = p;
92
+ break;
93
+ }
94
+ }
95
+ if (found) copyFile(found, path.join(outDir, name));
96
+ }
97
+ }
98
+
99
+ /**
100
+ * 解析 otool -L 输出中的非系统依赖路径。
101
+ */
102
+ function otoolDeps(file) {
103
+ const out = run("otool", ["-L", file]).stdout || "";
104
+ const deps = [];
105
+ for (const line of out.split("\n").slice(1)) {
106
+ const m = line.trim().match(/^(\S+)\s+\(/);
107
+ if (!m) continue;
108
+ const p = m[1];
109
+ if (p.startsWith("/usr/lib/") || p.startsWith("/System/")) continue;
110
+ if (p.startsWith("@")) continue;
111
+ deps.push(p);
112
+ }
113
+ return deps;
114
+ }
115
+
116
+ /**
117
+ * 打包 macOS 运行时 dylib,并把安装名改成 @loader_path。
118
+ */
119
+ function bundleMacDylibs(addonDst) {
120
+ const queue = otoolDeps(addonDst);
121
+ const seen = new Set();
122
+ const bundled = []; // { src, name }
123
+
124
+ while (queue.length) {
125
+ const src = queue.shift();
126
+ if (!src || seen.has(src)) continue;
127
+ seen.add(src);
128
+ if (!fs.existsSync(src)) {
129
+ console.warn(" warn: missing dylib", src);
130
+ continue;
131
+ }
132
+ const name = path.basename(src);
133
+ const dst = path.join(outDir, name);
134
+ copyFile(src, dst);
135
+ bundled.push({ src, name, dst });
136
+ for (const d of otoolDeps(src)) {
137
+ if (!seen.has(d)) queue.push(d);
138
+ }
139
+ }
140
+
141
+ // 自身 id → @loader_path/name
142
+ for (const b of bundled) {
143
+ run("install_name_tool", ["-id", "@loader_path/" + b.name, b.dst]);
144
+ }
145
+
146
+ // 重写 addon 与各 dylib 的依赖引用(-change 对不存在的旧路径会失败,允许忽略)
147
+ const rewriteTargets = [addonDst, ...bundled.map((b) => b.dst)];
148
+ for (const target of rewriteTargets) {
149
+ for (const b of bundled) {
150
+ run(
151
+ "install_name_tool",
152
+ ["-change", b.src, "@loader_path/" + b.name, target],
153
+ { allowFail: true }
154
+ );
155
+ const alt = b.src.replace(/\.(\d+)\.dylib$/, ".dylib");
156
+ if (alt !== b.src) {
157
+ run(
158
+ "install_name_tool",
159
+ ["-change", alt, "@loader_path/" + b.name, target],
160
+ { allowFail: true }
161
+ );
162
+ }
163
+ }
164
+ }
165
+
166
+ // 确保从 .node 所在目录找 dylib(已存在 rpath 时允许失败)
167
+ run("install_name_tool", ["-add_rpath", "@loader_path", addonDst], {
168
+ allowFail: true,
169
+ });
170
+
171
+ // 改写装载名后必须重签,否则 SIP/amfid 会直接 SIGKILL(exit 137)
172
+ for (const f of [...bundled.map((b) => b.dst), addonDst]) {
173
+ run("codesign", ["--force", "--sign", "-", f]);
174
+ }
175
+
176
+ console.log(
177
+ " mac runtime:",
178
+ bundled.map((b) => b.name).join(", ") || "(none)"
179
+ );
180
+ }
181
+
182
+ function main() {
183
+ const addon = findAddon();
184
+ if (!addon) {
185
+ console.error("error: gerbv_node.node not found under build/");
186
+ process.exit(1);
187
+ }
188
+ fs.rmSync(outDir, { recursive: true, force: true });
189
+ fs.mkdirSync(outDir, { recursive: true });
190
+ const addonDst = path.join(outDir, "gerbv_node.node");
191
+ copyFile(addon, addonDst);
192
+ if (platform === "win32") copyWinRuntimeDlls();
193
+ if (platform === "darwin") bundleMacDylibs(addonDst);
194
+
195
+ const meta = {
196
+ platform,
197
+ arch,
198
+ key,
199
+ node: process.version,
200
+ modules: process.versions.modules,
201
+ napi: process.versions.napi || null,
202
+ packedAt: new Date().toISOString(),
203
+ };
204
+ fs.writeFileSync(path.join(outDir, "meta.json"), JSON.stringify(meta, null, 2) + "\n");
205
+ console.log("packed prebuilds/" + key);
206
+ }
207
+
208
+ main();
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ /** 冒烟:create*(x,y) 起点;polyline;addCircleHole / addCircleRing。 */
3
+ "use strict";
4
+
5
+ const gerbv = require("../index.js");
6
+
7
+ {
8
+ const img = gerbv.createImage();
9
+ const pl = img.createPolyline(0, 0, 0.01);
10
+ pl.addPolylineLine(0.5, 0).addPolylineLine(0.5, 0.2);
11
+ pl.endPolyline();
12
+ const buf = img.exportRs274x();
13
+ if (!buf || buf.length < 32) {
14
+ console.error("inch polyline failed");
15
+ process.exit(1);
16
+ }
17
+ }
18
+
19
+ const img = gerbv.createImage({ unit: "mm", precision: 6 });
20
+
21
+ const pl = img.createPolyline(0, 0, 0.25);
22
+ pl.addPolylineLine(12.7, 0);
23
+ pl.addPolylineArc(6.35, 0, 6.35, 6.35, false);
24
+ pl.endPolyline();
25
+
26
+ const poly = img.createPolygon(0, 0);
27
+ poly.addPolygonLine(12.7, 0);
28
+ poly.addPolygonLine(12.7, 10);
29
+ poly.addPolygonLine(0, 10);
30
+
31
+ const hole = poly.createHole(2.5, 2.5);
32
+ hole.addPolygonArc(3.8, 3.8, 5.0, 2.5, false);
33
+ hole.addPolygonBezier2(4.5, 5.5, 2.5, 5.0);
34
+ hole.endHole();
35
+
36
+ poly.addCircleHole(9, 6, 2);
37
+ poly.endArea();
38
+
39
+ img.addRect(15, 0, 10, 8).addCircleHole(20, 4, 2.5).endArea();
40
+ img.addCircle(30, 4, 6).endArea();
41
+ img.addCircleRing(40, 4, 8, 1.5);
42
+
43
+ const buf = img.exportRs274x();
44
+ if (!buf || buf.length < 32) {
45
+ console.error("export too small", buf && buf.length);
46
+ process.exit(1);
47
+ }
48
+ const text = buf.toString("utf8");
49
+ if (!text.includes("G36") || !text.includes("LPC") || !text.includes("MOIN")) {
50
+ console.error("missing G36/LPC/MOIN");
51
+ process.exit(2);
52
+ }
53
+ try {
54
+ img.createPolygon();
55
+ console.error("createPolygon without point should throw");
56
+ process.exit(3);
57
+ } catch (_) {
58
+ /* ok */
59
+ }
60
+ try {
61
+ poly.createHole();
62
+ console.error("createHole without point should throw");
63
+ process.exit(4);
64
+ } catch (_) {
65
+ /* ok */
66
+ }
67
+ console.log(
68
+ "smoke ok backend=",
69
+ gerbv.backend,
70
+ "path=",
71
+ gerbv.__addonPath,
72
+ "bytes=",
73
+ buf.length
74
+ );
package/shim/gdk/gdk.h ADDED
@@ -0,0 +1,15 @@
1
+ /* GDK stub for headless libgerbv (export-only). */
2
+ #ifndef GERBV_SHIM_GDK_H
3
+ #define GERBV_SHIM_GDK_H
4
+ #include <glib.h>
5
+ typedef struct {
6
+ guint16 red;
7
+ guint16 green;
8
+ guint16 blue;
9
+ guint16 pixel;
10
+ } GdkColor;
11
+ typedef struct _GdkPixmap GdkPixmap;
12
+ typedef struct _GdkDrawable GdkDrawable;
13
+ typedef struct _GdkGC GdkGC;
14
+ typedef struct _GdkWindow GdkWindow;
15
+ #endif
@@ -0,0 +1,3 @@
1
+ #ifndef GERBV_SHIM_GDKKEYSYMS_H
2
+ #define GERBV_SHIM_GDKKEYSYMS_H
3
+ #endif
package/shim/gtk/gtk.h ADDED
@@ -0,0 +1,7 @@
1
+ /* GTK stub for headless libgerbv (export-only). */
2
+ #ifndef GERBV_SHIM_GTK_H
3
+ #define GERBV_SHIM_GTK_H
4
+ #include <glib.h>
5
+ typedef struct _GtkWidget GtkWidget;
6
+ typedef struct _GtkWindow GtkWindow;
7
+ #endif