breeze-bindgen 1.0.0 → 1.0.1
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/dist/cli.mjs +17 -227
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
@@ -1,226 +1,16 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
2
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
9
3
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
10
4
|
}) : x)(function(x) {
|
11
5
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
12
6
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
13
7
|
});
|
14
|
-
var __commonJS = (cb, mod) => function __require2() {
|
15
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
16
|
-
};
|
17
|
-
var __copyProps = (to, from, except, desc) => {
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
19
|
-
for (let key of __getOwnPropNames(from))
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
21
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
22
|
-
}
|
23
|
-
return to;
|
24
|
-
};
|
25
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
26
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
27
|
-
// file that has been converted to a CommonJS file using a Babel-
|
28
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
29
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
30
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
31
|
-
mod
|
32
|
-
));
|
33
|
-
|
34
|
-
// node_modules/color-support/index.js
|
35
|
-
var require_color_support = __commonJS({
|
36
|
-
"node_modules/color-support/index.js"(exports, module) {
|
37
|
-
module.exports = colorSupport({ alwaysReturn: true }, colorSupport);
|
38
|
-
function hasNone(obj, options) {
|
39
|
-
obj.level = 0;
|
40
|
-
obj.hasBasic = false;
|
41
|
-
obj.has256 = false;
|
42
|
-
obj.has16m = false;
|
43
|
-
if (!options.alwaysReturn) {
|
44
|
-
return false;
|
45
|
-
}
|
46
|
-
return obj;
|
47
|
-
}
|
48
|
-
function hasBasic(obj) {
|
49
|
-
obj.hasBasic = true;
|
50
|
-
obj.has256 = false;
|
51
|
-
obj.has16m = false;
|
52
|
-
obj.level = 1;
|
53
|
-
return obj;
|
54
|
-
}
|
55
|
-
function has256(obj) {
|
56
|
-
obj.hasBasic = true;
|
57
|
-
obj.has256 = true;
|
58
|
-
obj.has16m = false;
|
59
|
-
obj.level = 2;
|
60
|
-
return obj;
|
61
|
-
}
|
62
|
-
function has16m(obj) {
|
63
|
-
obj.hasBasic = true;
|
64
|
-
obj.has256 = true;
|
65
|
-
obj.has16m = true;
|
66
|
-
obj.level = 3;
|
67
|
-
return obj;
|
68
|
-
}
|
69
|
-
function colorSupport(options, obj) {
|
70
|
-
options = options || {};
|
71
|
-
obj = obj || {};
|
72
|
-
if (typeof options.level === "number") {
|
73
|
-
switch (options.level) {
|
74
|
-
case 0:
|
75
|
-
return hasNone(obj, options);
|
76
|
-
case 1:
|
77
|
-
return hasBasic(obj);
|
78
|
-
case 2:
|
79
|
-
return has256(obj);
|
80
|
-
case 3:
|
81
|
-
return has16m(obj);
|
82
|
-
}
|
83
|
-
}
|
84
|
-
obj.level = 0;
|
85
|
-
obj.hasBasic = false;
|
86
|
-
obj.has256 = false;
|
87
|
-
obj.has16m = false;
|
88
|
-
if (typeof process === "undefined" || !process || !process.stdout || !process.env || !process.platform) {
|
89
|
-
return hasNone(obj, options);
|
90
|
-
}
|
91
|
-
var env2 = options.env || process.env;
|
92
|
-
var stream = options.stream || process.stdout;
|
93
|
-
var term = options.term || env2.TERM || "";
|
94
|
-
var platform = options.platform || process.platform;
|
95
|
-
if (!options.ignoreTTY && !stream.isTTY) {
|
96
|
-
return hasNone(obj, options);
|
97
|
-
}
|
98
|
-
if (!options.ignoreDumb && term === "dumb" && !env2.COLORTERM) {
|
99
|
-
return hasNone(obj, options);
|
100
|
-
}
|
101
|
-
if (platform === "win32") {
|
102
|
-
return hasBasic(obj);
|
103
|
-
}
|
104
|
-
if (env2.TMUX) {
|
105
|
-
return has256(obj);
|
106
|
-
}
|
107
|
-
if (!options.ignoreCI && (env2.CI || env2.TEAMCITY_VERSION)) {
|
108
|
-
if (env2.TRAVIS) {
|
109
|
-
return has256(obj);
|
110
|
-
} else {
|
111
|
-
return hasNone(obj, options);
|
112
|
-
}
|
113
|
-
}
|
114
|
-
switch (env2.TERM_PROGRAM) {
|
115
|
-
case "iTerm.app":
|
116
|
-
var ver = env2.TERM_PROGRAM_VERSION || "0.";
|
117
|
-
if (/^[0-2]\./.test(ver)) {
|
118
|
-
return has256(obj);
|
119
|
-
} else {
|
120
|
-
return has16m(obj);
|
121
|
-
}
|
122
|
-
case "HyperTerm":
|
123
|
-
case "Hyper":
|
124
|
-
return has16m(obj);
|
125
|
-
case "MacTerm":
|
126
|
-
return has16m(obj);
|
127
|
-
case "Apple_Terminal":
|
128
|
-
return has256(obj);
|
129
|
-
}
|
130
|
-
if (/^xterm-256/.test(term)) {
|
131
|
-
return has256(obj);
|
132
|
-
}
|
133
|
-
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(term)) {
|
134
|
-
return hasBasic(obj);
|
135
|
-
}
|
136
|
-
if (env2.COLORTERM) {
|
137
|
-
return hasBasic(obj);
|
138
|
-
}
|
139
|
-
return hasNone(obj, options);
|
140
|
-
}
|
141
|
-
}
|
142
|
-
});
|
143
|
-
|
144
|
-
// node_modules/fancy-log/index.js
|
145
|
-
var require_fancy_log = __commonJS({
|
146
|
-
"node_modules/fancy-log/index.js"(exports, module) {
|
147
|
-
"use strict";
|
148
|
-
var util = __require("util");
|
149
|
-
var Console = __require("console").Console;
|
150
|
-
var supportsColor = require_color_support();
|
151
|
-
var console2 = new Console({
|
152
|
-
stdout: process.stdout,
|
153
|
-
stderr: process.stderr,
|
154
|
-
colorMode: false
|
155
|
-
});
|
156
|
-
function hasFlag(flag) {
|
157
|
-
return process.argv.indexOf("--" + flag) !== -1;
|
158
|
-
}
|
159
|
-
function hasColors() {
|
160
|
-
if (hasFlag("no-color")) {
|
161
|
-
return false;
|
162
|
-
}
|
163
|
-
if (hasFlag("color")) {
|
164
|
-
return true;
|
165
|
-
}
|
166
|
-
if (supportsColor()) {
|
167
|
-
return true;
|
168
|
-
}
|
169
|
-
return false;
|
170
|
-
}
|
171
|
-
function Timestamp() {
|
172
|
-
this.now = /* @__PURE__ */ new Date();
|
173
|
-
}
|
174
|
-
Timestamp.prototype[util.inspect.custom] = function(depth, opts) {
|
175
|
-
var timestamp = this.now.toLocaleTimeString("en", { hour12: false });
|
176
|
-
return "[" + opts.stylize(timestamp, "date") + "]";
|
177
|
-
};
|
178
|
-
function getTimestamp() {
|
179
|
-
return util.inspect(new Timestamp(), { colors: hasColors() });
|
180
|
-
}
|
181
|
-
function log3() {
|
182
|
-
var time = getTimestamp();
|
183
|
-
process.stdout.write(time + " ");
|
184
|
-
console2.log.apply(console2, arguments);
|
185
|
-
return this;
|
186
|
-
}
|
187
|
-
function info() {
|
188
|
-
var time = getTimestamp();
|
189
|
-
process.stdout.write(time + " ");
|
190
|
-
console2.info.apply(console2, arguments);
|
191
|
-
return this;
|
192
|
-
}
|
193
|
-
function dir() {
|
194
|
-
var time = getTimestamp();
|
195
|
-
process.stdout.write(time + " ");
|
196
|
-
console2.dir.apply(console2, arguments);
|
197
|
-
return this;
|
198
|
-
}
|
199
|
-
function warn() {
|
200
|
-
var time = getTimestamp();
|
201
|
-
process.stderr.write(time + " ");
|
202
|
-
console2.warn.apply(console2, arguments);
|
203
|
-
return this;
|
204
|
-
}
|
205
|
-
function error() {
|
206
|
-
var time = getTimestamp();
|
207
|
-
process.stderr.write(time + " ");
|
208
|
-
console2.error.apply(console2, arguments);
|
209
|
-
return this;
|
210
|
-
}
|
211
|
-
module.exports = log3;
|
212
|
-
module.exports.info = info;
|
213
|
-
module.exports.dir = dir;
|
214
|
-
module.exports.warn = warn;
|
215
|
-
module.exports.error = error;
|
216
|
-
}
|
217
|
-
});
|
218
8
|
|
219
9
|
// cli.ts
|
220
|
-
|
10
|
+
import log2 from "fancy-log";
|
221
11
|
|
222
12
|
// core.ts
|
223
|
-
|
13
|
+
import log from "fancy-log";
|
224
14
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
225
15
|
import { join, dirname, resolve as resolvePath } from "node:path";
|
226
16
|
import { fileURLToPath } from "node:url";
|
@@ -666,17 +456,17 @@ function generateBindingsAndDefinitions(config) {
|
|
666
456
|
// Add any include paths if necessary, e.g. -I../../include
|
667
457
|
absoluteCppFilePath
|
668
458
|
];
|
669
|
-
(
|
459
|
+
log(`Executing: ${clangPath} ${clangArgs.join(" ")}`);
|
670
460
|
const clangProcess = spawnSync(clangPath, clangArgs, { encoding: "utf-8", shell: true });
|
671
461
|
if (clangProcess.error) {
|
672
|
-
|
462
|
+
log.error(`Failed to start clang++: ${clangProcess.error.message}`);
|
673
463
|
if (clangProcess.error.code === "ENOENT") {
|
674
464
|
throw new Error(`clang++ not found at path "${clangPath}". Please ensure it's installed and in your PATH, or provide a correct path.`);
|
675
465
|
}
|
676
466
|
throw clangProcess.error;
|
677
467
|
}
|
678
468
|
if (clangProcess.stderr && clangProcess.stderr.length > 0) {
|
679
|
-
|
469
|
+
log.warn(`clang++ stderr:
|
680
470
|
${clangProcess.stderr}`);
|
681
471
|
}
|
682
472
|
if (!clangProcess.stdout || clangProcess.stdout.trim().length === 0) {
|
@@ -690,12 +480,12 @@ ${clangProcess.stderr}`);
|
|
690
480
|
try {
|
691
481
|
astArr = JSON.parse(astText);
|
692
482
|
} catch (e) {
|
693
|
-
|
694
|
-
|
483
|
+
log.error("Failed to parse AST JSON:", e);
|
484
|
+
log.error("Problematic AST JSON content (first 1000 chars):", astText.substring(0, 1e3));
|
695
485
|
throw new Error(`Failed to parse AST JSON from clang++. Check for errors in C++ code or clang++ execution.`);
|
696
486
|
}
|
697
487
|
if (!astArr || astArr.length === 0) {
|
698
|
-
|
488
|
+
log.warn(`No AST data was parsed. This might mean the ast-dump-filter ("${nameFilter.slice(0, -2)}") didn't match anything, or the input file is empty or has no relevant declarations.`);
|
699
489
|
}
|
700
490
|
const { cppBinding, tsDefinitions } = processAstAndGenerateCode(astArr, absoluteCppFilePath, bindgenDir, nameFilter, quickjsTypesPath);
|
701
491
|
if (!existsSync(absoluteOutputDir)) {
|
@@ -707,7 +497,7 @@ ${clangProcess.stderr}`);
|
|
707
497
|
}
|
708
498
|
writeFileSync(join(absoluteOutputDir, cppBindingOutputFile), cppBinding);
|
709
499
|
writeFileSync(join(absoluteOutputDir, tsDefinitionOutputFile), tsDefinitions);
|
710
|
-
(
|
500
|
+
log(`Bindings generated successfully in ${absoluteOutputDir}`);
|
711
501
|
}
|
712
502
|
|
713
503
|
// cli.ts
|
@@ -5425,14 +5215,14 @@ async function main() {
|
|
5425
5215
|
const inputFilePath = resolvePath2(inputFile);
|
5426
5216
|
const inputFileDir = dirname4(inputFilePath);
|
5427
5217
|
outputDir = joinPath(inputFileDir, "generated_bindings");
|
5428
|
-
(
|
5218
|
+
log2(`Output directory not specified, defaulting to: ${outputDir}`);
|
5429
5219
|
}
|
5430
5220
|
const absoluteOutputDir = resolvePath2(outputDir);
|
5431
|
-
(
|
5432
|
-
(
|
5433
|
-
(
|
5221
|
+
log2(`Starting binding generation...`);
|
5222
|
+
log2(`Input C++ file: ${inputFile}`);
|
5223
|
+
log2(`Output directory: ${absoluteOutputDir}`);
|
5434
5224
|
if (argv.clang) {
|
5435
|
-
(
|
5225
|
+
log2(`Using clang++ at: ${argv.clang}`);
|
5436
5226
|
}
|
5437
5227
|
generateBindingsAndDefinitions({
|
5438
5228
|
cppFilePath: inputFile,
|
@@ -5444,11 +5234,11 @@ async function main() {
|
|
5444
5234
|
nameFilter: argv.nameFilter + "::"
|
5445
5235
|
// Add "::" back for internal use
|
5446
5236
|
});
|
5447
|
-
(
|
5237
|
+
log2("Binding generation finished successfully.");
|
5448
5238
|
} catch (error) {
|
5449
|
-
|
5239
|
+
log2.error("Error during binding generation:", error.message);
|
5450
5240
|
if (error.stack && process.env.DEBUG) {
|
5451
|
-
|
5241
|
+
log2.error(error.stack);
|
5452
5242
|
}
|
5453
5243
|
process.exit(1);
|
5454
5244
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
|
3
3
|
"name": "breeze-bindgen",
|
4
|
-
"version": "1.0.
|
4
|
+
"version": "1.0.1",
|
5
5
|
"main": "dist/index.cjs",
|
6
6
|
"module": "dist/index.mjs",
|
7
7
|
"types": "dist/index.d.ts",
|
@@ -24,7 +24,7 @@
|
|
24
24
|
"yargs": "17.1.1"
|
25
25
|
},
|
26
26
|
"scripts": {
|
27
|
-
"build": "esbuild index.ts --bundle --outfile=dist/index.cjs --platform=node --format=cjs && esbuild index.ts --bundle --outfile=dist/index.mjs --platform=node --format=esm && esbuild cli.ts --bundle --outfile=dist/cli.mjs --platform=node --format=esm --banner:js=\"#!/usr/bin/env node\"",
|
27
|
+
"build": "esbuild index.ts --bundle --outfile=dist/index.cjs --platform=node --format=cjs && esbuild index.ts --bundle --outfile=dist/index.mjs --platform=node --format=esm && esbuild cli.ts --bundle --outfile=dist/cli.mjs --platform=node --format=esm --banner:js=\"#!/usr/bin/env node\" --external:fancy-log --external:util",
|
28
28
|
"prepublishOnly": "yarn build",
|
29
29
|
"build:cli": "esbuild cli.ts --bundle --outfile=cli.js --platform=node --format=esm --banner:js='#!/usr/bin/env node'",
|
30
30
|
"cli": "node -r esbuild-register cli.ts",
|