@neon-rs/cli 0.0.26 → 0.0.28
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/index.js +266 -248
- package/package.json +10 -2
package/index.js
CHANGED
|
@@ -10099,6 +10099,126 @@ function wrappy (fn, cb) {
|
|
|
10099
10099
|
}
|
|
10100
10100
|
|
|
10101
10101
|
|
|
10102
|
+
/***/ }),
|
|
10103
|
+
|
|
10104
|
+
/***/ 1401:
|
|
10105
|
+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
10106
|
+
|
|
10107
|
+
|
|
10108
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10109
|
+
if (k2 === undefined) k2 = k;
|
|
10110
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10111
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10112
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10113
|
+
}
|
|
10114
|
+
Object.defineProperty(o, k2, desc);
|
|
10115
|
+
}) : (function(o, m, k, k2) {
|
|
10116
|
+
if (k2 === undefined) k2 = k;
|
|
10117
|
+
o[k2] = m[k];
|
|
10118
|
+
}));
|
|
10119
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10120
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
10121
|
+
}) : function(o, v) {
|
|
10122
|
+
o["default"] = v;
|
|
10123
|
+
});
|
|
10124
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
10125
|
+
if (mod && mod.__esModule) return mod;
|
|
10126
|
+
var result = {};
|
|
10127
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
10128
|
+
__setModuleDefault(result, mod);
|
|
10129
|
+
return result;
|
|
10130
|
+
};
|
|
10131
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
10132
|
+
exports.custom = exports.scope = exports.debug = exports.currentTarget = void 0;
|
|
10133
|
+
const path = __importStar(__nccwpck_require__(1017));
|
|
10134
|
+
const fs = __importStar(__nccwpck_require__(7147));
|
|
10135
|
+
function currentTarget() {
|
|
10136
|
+
let os = null;
|
|
10137
|
+
switch (process.platform) {
|
|
10138
|
+
case 'android':
|
|
10139
|
+
switch (process.arch) {
|
|
10140
|
+
case 'arm':
|
|
10141
|
+
return 'android-arm-eabi';
|
|
10142
|
+
case 'arm64':
|
|
10143
|
+
return 'android-arm64';
|
|
10144
|
+
}
|
|
10145
|
+
os = 'Android';
|
|
10146
|
+
break;
|
|
10147
|
+
case 'win32':
|
|
10148
|
+
switch (process.arch) {
|
|
10149
|
+
case 'x64':
|
|
10150
|
+
return 'win32-x64-msvc';
|
|
10151
|
+
case 'arm64':
|
|
10152
|
+
return 'win32-arm64-msvc';
|
|
10153
|
+
case 'ia32':
|
|
10154
|
+
return 'win32-ia32-msvc';
|
|
10155
|
+
}
|
|
10156
|
+
os = 'Windows';
|
|
10157
|
+
break;
|
|
10158
|
+
case 'darwin':
|
|
10159
|
+
switch (process.arch) {
|
|
10160
|
+
case 'x64':
|
|
10161
|
+
return 'darwin-x64';
|
|
10162
|
+
case 'arm64':
|
|
10163
|
+
return 'darwin-arm64';
|
|
10164
|
+
}
|
|
10165
|
+
os = 'macOS';
|
|
10166
|
+
break;
|
|
10167
|
+
case 'linux':
|
|
10168
|
+
switch (process.arch) {
|
|
10169
|
+
case 'x64':
|
|
10170
|
+
case 'arm64':
|
|
10171
|
+
return isGlibc()
|
|
10172
|
+
? `linux-${process.arch}-gnu`
|
|
10173
|
+
: `linux-${process.arch}-musl`;
|
|
10174
|
+
case 'arm':
|
|
10175
|
+
return 'linux-arm-gnueabihf';
|
|
10176
|
+
}
|
|
10177
|
+
os = 'Linux';
|
|
10178
|
+
break;
|
|
10179
|
+
case 'freebsd':
|
|
10180
|
+
if (process.arch === 'x64') {
|
|
10181
|
+
return 'freebsd-x64';
|
|
10182
|
+
}
|
|
10183
|
+
os = 'FreeBSD';
|
|
10184
|
+
break;
|
|
10185
|
+
}
|
|
10186
|
+
if (os) {
|
|
10187
|
+
throw new Error(`Neon: unsupported ${os} architecture: ${process.arch}`);
|
|
10188
|
+
}
|
|
10189
|
+
throw new Error(`Neon: unsupported system: ${process.platform}`);
|
|
10190
|
+
}
|
|
10191
|
+
exports.currentTarget = currentTarget;
|
|
10192
|
+
function isGlibc() {
|
|
10193
|
+
// Cast to unknown to work around a bug in the type definition:
|
|
10194
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/40140
|
|
10195
|
+
const report = process.report?.getReport();
|
|
10196
|
+
if ((typeof report !== 'object') || !report || (!('header' in report))) {
|
|
10197
|
+
return false;
|
|
10198
|
+
}
|
|
10199
|
+
const header = report.header;
|
|
10200
|
+
return (typeof header === 'object') &&
|
|
10201
|
+
!!header &&
|
|
10202
|
+
('glibcVersionRuntime' in header);
|
|
10203
|
+
}
|
|
10204
|
+
function debug(...components) {
|
|
10205
|
+
if (components.length === 0 || !components[components.length - 1].endsWith(".node")) {
|
|
10206
|
+
components.push("index.node");
|
|
10207
|
+
}
|
|
10208
|
+
const pathSpec = path.join(...components);
|
|
10209
|
+
return fs.existsSync(pathSpec) ? require(pathSpec) : null;
|
|
10210
|
+
}
|
|
10211
|
+
exports.debug = debug;
|
|
10212
|
+
function scope(scope) {
|
|
10213
|
+
return require(scope + "/" + currentTarget());
|
|
10214
|
+
}
|
|
10215
|
+
exports.scope = scope;
|
|
10216
|
+
function custom(toRequireSpec) {
|
|
10217
|
+
return require(toRequireSpec(currentTarget()));
|
|
10218
|
+
}
|
|
10219
|
+
exports.custom = custom;
|
|
10220
|
+
|
|
10221
|
+
|
|
10102
10222
|
/***/ }),
|
|
10103
10223
|
|
|
10104
10224
|
/***/ 9491:
|
|
@@ -10176,6 +10296,62 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("tty");
|
|
|
10176
10296
|
|
|
10177
10297
|
module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("util");
|
|
10178
10298
|
|
|
10299
|
+
/***/ }),
|
|
10300
|
+
|
|
10301
|
+
/***/ 430:
|
|
10302
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
10303
|
+
|
|
10304
|
+
const load = __nccwpck_require__(1401);
|
|
10305
|
+
|
|
10306
|
+
const {
|
|
10307
|
+
fromStdin,
|
|
10308
|
+
fromFile,
|
|
10309
|
+
findArtifact,
|
|
10310
|
+
findFileByCrateType
|
|
10311
|
+
} = load.debug(__dirname, '..') || load.scope("@cargo-messages");
|
|
10312
|
+
|
|
10313
|
+
const PRIVATE = {};
|
|
10314
|
+
|
|
10315
|
+
function enforcePrivate(nonce, className) {
|
|
10316
|
+
if (nonce !== PRIVATE) {
|
|
10317
|
+
throw new Error(`${className} constructor is private`);
|
|
10318
|
+
}
|
|
10319
|
+
}
|
|
10320
|
+
|
|
10321
|
+
class CargoArtifact {
|
|
10322
|
+
constructor(nonce, kernel) {
|
|
10323
|
+
enforcePrivate(nonce, 'CargoArtifact');
|
|
10324
|
+
this._kernel = kernel;
|
|
10325
|
+
}
|
|
10326
|
+
|
|
10327
|
+
findFileByCrateType(crateType) {
|
|
10328
|
+
return findFileByCrateType(this._kernel, crateType);
|
|
10329
|
+
}
|
|
10330
|
+
}
|
|
10331
|
+
|
|
10332
|
+
class CargoMessages {
|
|
10333
|
+
constructor(options) {
|
|
10334
|
+
options = options || {};
|
|
10335
|
+
this._mount = options.mount || null;
|
|
10336
|
+
this._manifestPath = options.manifestPath || null;
|
|
10337
|
+
this._kernel = options.file
|
|
10338
|
+
? fromFile(options.file, this._mount, this._manifestPath)
|
|
10339
|
+
: fromStdin(this._mount, this._manifestPath);
|
|
10340
|
+
}
|
|
10341
|
+
|
|
10342
|
+
findArtifact(crateName) {
|
|
10343
|
+
const found = findArtifact(this._kernel, crateName);
|
|
10344
|
+
return found
|
|
10345
|
+
? new CargoArtifact(PRIVATE, found)
|
|
10346
|
+
: null;
|
|
10347
|
+
}
|
|
10348
|
+
}
|
|
10349
|
+
|
|
10350
|
+
module.exports = {
|
|
10351
|
+
CargoMessages
|
|
10352
|
+
};
|
|
10353
|
+
|
|
10354
|
+
|
|
10179
10355
|
/***/ })
|
|
10180
10356
|
|
|
10181
10357
|
/******/ });
|
|
@@ -13232,12 +13408,96 @@ const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.ur
|
|
|
13232
13408
|
// EXTERNAL MODULE: ../../node_modules/command-line-args/dist/index.js
|
|
13233
13409
|
var dist = __nccwpck_require__(4516);
|
|
13234
13410
|
var dist_default = /*#__PURE__*/__nccwpck_require__.n(dist);
|
|
13235
|
-
|
|
13236
|
-
|
|
13411
|
+
// EXTERNAL MODULE: ./node_modules/cargo-messages/cjs/index.cjs
|
|
13412
|
+
var cjs = __nccwpck_require__(430);
|
|
13413
|
+
;// CONCATENATED MODULE: ./node_modules/cargo-messages/esm/index.js
|
|
13414
|
+
|
|
13415
|
+
|
|
13416
|
+
|
|
13417
|
+
|
|
13418
|
+
;// CONCATENATED MODULE: ./src/commands/dist.ts
|
|
13419
|
+
|
|
13420
|
+
|
|
13421
|
+
|
|
13422
|
+
// FIXME: add options to infer crate name from manifests
|
|
13423
|
+
// --package <path/to/package.json>
|
|
13424
|
+
// --crate <path/to/Cargo.toml>
|
|
13425
|
+
const OPTIONS = [
|
|
13426
|
+
{ name: 'name', alias: 'n', type: String, defaultValue: null },
|
|
13427
|
+
{ name: 'file', alias: 'f', type: String, defaultValue: null },
|
|
13428
|
+
{ name: 'log', alias: 'l', type: String, defaultValue: null },
|
|
13429
|
+
{ name: 'mount', alias: 'm', type: String, defaultValue: null },
|
|
13430
|
+
{ name: 'manifest-path', type: String, defaultValue: null },
|
|
13431
|
+
{ name: 'out', alias: 'o', type: String, defaultValue: 'index.node' }
|
|
13432
|
+
];
|
|
13433
|
+
class Dist {
|
|
13434
|
+
static summary() { return 'Generate a .node file from a build.'; }
|
|
13435
|
+
static syntax() { return 'neon dist [-n <name>] [-f <dylib>|[-l <log>] [-m <path>]] [-o <dist>]'; }
|
|
13436
|
+
static options() {
|
|
13437
|
+
return [
|
|
13438
|
+
{ name: '-n, --name', summary: 'Crate name. (Default: $npm_package_name)' },
|
|
13439
|
+
{ name: '-f, --file <dylib>', summary: 'Build .node from dylib file <dylib>.' },
|
|
13440
|
+
{ name: '-l, --log <log>', summary: 'Find dylib path from cargo messages <log>. (Default: stdin)' },
|
|
13441
|
+
{
|
|
13442
|
+
name: '-m, --mount <path>',
|
|
13443
|
+
summary: 'Mounted path of target directory in virtual filesystem. This is used to map paths from the log data back to their real paths, needed when tools such as cross-rs report messages from within a mounted Docker filesystem.'
|
|
13444
|
+
},
|
|
13445
|
+
{ name: '--manifest-path <path>', summary: 'Real path to Cargo.toml. (Default: cargo behavior)' },
|
|
13446
|
+
{ name: '-o, --out <dist>', summary: 'Copy output to file <dist>. (Default: index.node)' }
|
|
13447
|
+
];
|
|
13448
|
+
}
|
|
13449
|
+
static seeAlso() {
|
|
13450
|
+
return [
|
|
13451
|
+
{ name: 'cargo messages', summary: '<https://doc.rust-lang.org/cargo/reference/external-tools.html>' },
|
|
13452
|
+
{ name: 'cross-rs', summary: '<https://github.com/cross-rs/cross>' }
|
|
13453
|
+
];
|
|
13454
|
+
}
|
|
13455
|
+
_log;
|
|
13456
|
+
_file;
|
|
13457
|
+
_mount;
|
|
13458
|
+
_manifestPath;
|
|
13459
|
+
_crateName;
|
|
13460
|
+
_out;
|
|
13461
|
+
constructor(argv) {
|
|
13462
|
+
const options = dist_default()(OPTIONS, { argv });
|
|
13463
|
+
if (options.log && options.file) {
|
|
13464
|
+
throw new Error("Options --log and --file cannot both be enabled.");
|
|
13465
|
+
}
|
|
13466
|
+
if (options.file && options.mount) {
|
|
13467
|
+
throw new Error("Options --mount and --file cannot both be enabled.");
|
|
13468
|
+
}
|
|
13469
|
+
if (options['manifest-path'] && !options.mount) {
|
|
13470
|
+
throw new Error("Option --manifest-path requires option --mount to be provided.");
|
|
13471
|
+
}
|
|
13472
|
+
this._log = options.log ?? null;
|
|
13473
|
+
this._file = options.file ?? null;
|
|
13474
|
+
this._mount = options.mount;
|
|
13475
|
+
this._manifestPath = options['manifest-path'];
|
|
13476
|
+
this._crateName = options.name || process.env['npm_package_name'];
|
|
13477
|
+
this._out = options.out;
|
|
13478
|
+
}
|
|
13479
|
+
findArtifact() {
|
|
13480
|
+
const messages = new cjs.CargoMessages({
|
|
13481
|
+
mount: this._mount || undefined,
|
|
13482
|
+
manifestPath: this._manifestPath || undefined,
|
|
13483
|
+
file: this._log || undefined
|
|
13484
|
+
});
|
|
13485
|
+
return messages.findArtifact(this._crateName)?.findFileByCrateType('cdylib') || null;
|
|
13486
|
+
}
|
|
13487
|
+
async run() {
|
|
13488
|
+
const file = this._file || this.findArtifact();
|
|
13489
|
+
if (!file) {
|
|
13490
|
+
throw new Error(`No library found for crate ${this._crateName}`);
|
|
13491
|
+
}
|
|
13492
|
+
// FIXME: needs all the logic of cargo-cp-artifact (timestamp check, M1 workaround, async, errors)
|
|
13493
|
+
await (0,promises_namespaceObject.copyFile)(file, this._out);
|
|
13494
|
+
}
|
|
13495
|
+
}
|
|
13496
|
+
|
|
13237
13497
|
;// CONCATENATED MODULE: external "node:path"
|
|
13238
13498
|
const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path");
|
|
13239
|
-
|
|
13240
|
-
|
|
13499
|
+
// EXTERNAL MODULE: ../../node_modules/temp/lib/temp.js
|
|
13500
|
+
var temp = __nccwpck_require__(5758);
|
|
13241
13501
|
;// CONCATENATED MODULE: external "node:buffer"
|
|
13242
13502
|
const external_node_buffer_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:buffer");
|
|
13243
13503
|
;// CONCATENATED MODULE: external "node:child_process"
|
|
@@ -14073,6 +14333,8 @@ const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => {
|
|
|
14073
14333
|
});
|
|
14074
14334
|
};
|
|
14075
14335
|
|
|
14336
|
+
;// CONCATENATED MODULE: external "node:fs"
|
|
14337
|
+
const external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs");
|
|
14076
14338
|
;// CONCATENATED MODULE: ../../node_modules/is-stream/index.js
|
|
14077
14339
|
function isStream(stream) {
|
|
14078
14340
|
return stream !== null
|
|
@@ -14767,250 +15029,6 @@ function execaNode(scriptPath, args, options = {}) {
|
|
|
14767
15029
|
);
|
|
14768
15030
|
}
|
|
14769
15031
|
|
|
14770
|
-
;// CONCATENATED MODULE: ./src/cargo.ts
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
function messageReason(message) {
|
|
14776
|
-
return message.reason;
|
|
14777
|
-
}
|
|
14778
|
-
function isCompilerMessage(json) {
|
|
14779
|
-
if (!(json instanceof Object)) {
|
|
14780
|
-
return false;
|
|
14781
|
-
}
|
|
14782
|
-
if (!('reason' in json) || (json.reason !== 'compiler-message')) {
|
|
14783
|
-
return false;
|
|
14784
|
-
}
|
|
14785
|
-
return true;
|
|
14786
|
-
}
|
|
14787
|
-
function isBuildScriptExecuted(json) {
|
|
14788
|
-
if (!(json instanceof Object)) {
|
|
14789
|
-
return false;
|
|
14790
|
-
}
|
|
14791
|
-
if (!('reason' in json) || (json.reason !== 'build-script-executed')) {
|
|
14792
|
-
return false;
|
|
14793
|
-
}
|
|
14794
|
-
return true;
|
|
14795
|
-
}
|
|
14796
|
-
function isCompilerTarget(json) {
|
|
14797
|
-
if (!(json instanceof Object)) {
|
|
14798
|
-
return false;
|
|
14799
|
-
}
|
|
14800
|
-
if (!('kind' in json) || !isStringArray(json.kind)) {
|
|
14801
|
-
return false;
|
|
14802
|
-
}
|
|
14803
|
-
if (!('crate_types' in json) || !isStringArray(json.crate_types)) {
|
|
14804
|
-
return false;
|
|
14805
|
-
}
|
|
14806
|
-
if (!('name' in json) || (typeof json.name !== 'string')) {
|
|
14807
|
-
return false;
|
|
14808
|
-
}
|
|
14809
|
-
return true;
|
|
14810
|
-
}
|
|
14811
|
-
function isCompilerArtifact(json) {
|
|
14812
|
-
if (!(json instanceof Object)) {
|
|
14813
|
-
return false;
|
|
14814
|
-
}
|
|
14815
|
-
if (!('reason' in json) || (json.reason !== 'compiler-artifact')) {
|
|
14816
|
-
return false;
|
|
14817
|
-
}
|
|
14818
|
-
if (!('package_id' in json) || (typeof json.package_id !== 'string')) {
|
|
14819
|
-
return false;
|
|
14820
|
-
}
|
|
14821
|
-
if (!('manifest_path' in json) || (typeof json.manifest_path !== 'string')) {
|
|
14822
|
-
return false;
|
|
14823
|
-
}
|
|
14824
|
-
if (!('target' in json) || !isCompilerTarget(json.target)) {
|
|
14825
|
-
return false;
|
|
14826
|
-
}
|
|
14827
|
-
if (!('filenames' in json) || !isStringArray(json.filenames)) {
|
|
14828
|
-
return false;
|
|
14829
|
-
}
|
|
14830
|
-
return true;
|
|
14831
|
-
}
|
|
14832
|
-
function isStringArray(json) {
|
|
14833
|
-
if (!Array.isArray(json)) {
|
|
14834
|
-
return false;
|
|
14835
|
-
}
|
|
14836
|
-
for (const val of json) {
|
|
14837
|
-
if (typeof val !== 'string') {
|
|
14838
|
-
return false;
|
|
14839
|
-
}
|
|
14840
|
-
}
|
|
14841
|
-
return true;
|
|
14842
|
-
}
|
|
14843
|
-
function isBuildFinished(json) {
|
|
14844
|
-
if (!(json instanceof Object)) {
|
|
14845
|
-
return false;
|
|
14846
|
-
}
|
|
14847
|
-
if (!('reason' in json) || (json.reason !== 'build-finished')) {
|
|
14848
|
-
return false;
|
|
14849
|
-
}
|
|
14850
|
-
return ('success' in json) && (typeof json.success === 'boolean');
|
|
14851
|
-
}
|
|
14852
|
-
function parseMessage(line) {
|
|
14853
|
-
try {
|
|
14854
|
-
const json = JSON.parse(line);
|
|
14855
|
-
if (isCompilerMessage(json) ||
|
|
14856
|
-
isBuildScriptExecuted(json) ||
|
|
14857
|
-
isCompilerArtifact(json) ||
|
|
14858
|
-
isBuildFinished(json)) {
|
|
14859
|
-
return json;
|
|
14860
|
-
}
|
|
14861
|
-
}
|
|
14862
|
-
catch (nope) { }
|
|
14863
|
-
return null;
|
|
14864
|
-
}
|
|
14865
|
-
class MessageStream {
|
|
14866
|
-
_stream;
|
|
14867
|
-
constructor(file) {
|
|
14868
|
-
const input = file ? (0,external_node_fs_namespaceObject.createReadStream)(file) : process.stdin;
|
|
14869
|
-
this._stream = external_node_readline_namespaceObject.createInterface({
|
|
14870
|
-
input,
|
|
14871
|
-
terminal: false
|
|
14872
|
-
});
|
|
14873
|
-
}
|
|
14874
|
-
async findPath(pred) {
|
|
14875
|
-
try {
|
|
14876
|
-
for await (const line of this._stream) {
|
|
14877
|
-
const msg = parseMessage(line);
|
|
14878
|
-
if (!msg) {
|
|
14879
|
-
continue;
|
|
14880
|
-
}
|
|
14881
|
-
const result = pred(msg);
|
|
14882
|
-
if (result !== null) {
|
|
14883
|
-
return result;
|
|
14884
|
-
}
|
|
14885
|
-
}
|
|
14886
|
-
return null;
|
|
14887
|
-
}
|
|
14888
|
-
finally {
|
|
14889
|
-
this._stream.close();
|
|
14890
|
-
}
|
|
14891
|
-
}
|
|
14892
|
-
}
|
|
14893
|
-
class UnmountMessageStream extends MessageStream {
|
|
14894
|
-
_mount;
|
|
14895
|
-
_manifestPath;
|
|
14896
|
-
constructor(mount, manifestPath, file) {
|
|
14897
|
-
super(file);
|
|
14898
|
-
this._mount = mount;
|
|
14899
|
-
this._manifestPath = manifestPath;
|
|
14900
|
-
}
|
|
14901
|
-
async findPath(pred) {
|
|
14902
|
-
// The base class's version reports paths as absolute paths from within
|
|
14903
|
-
// a mount in a virtual filesystem.
|
|
14904
|
-
const mountedPath = await super.findPath(pred);
|
|
14905
|
-
if (!mountedPath) {
|
|
14906
|
-
return null;
|
|
14907
|
-
}
|
|
14908
|
-
// The path relative to the workspace's target directory.
|
|
14909
|
-
const relPath = external_node_path_namespaceObject.relative(this._mount, mountedPath);
|
|
14910
|
-
// Now find the true absolute path of the target directory on the host system.
|
|
14911
|
-
const cargo = await execa('cargo', [
|
|
14912
|
-
'metadata',
|
|
14913
|
-
'--format-version=1',
|
|
14914
|
-
'--no-deps',
|
|
14915
|
-
...(this._manifestPath ? ['--manifest-path', this._manifestPath] : [])
|
|
14916
|
-
], {
|
|
14917
|
-
shell: true
|
|
14918
|
-
});
|
|
14919
|
-
if (cargo.exitCode !== 0) {
|
|
14920
|
-
throw new Error(`Invoking \`cargo metadata\` failed: ${cargo.stderr}`);
|
|
14921
|
-
}
|
|
14922
|
-
const cargoMetadata = JSON.parse(cargo.stdout);
|
|
14923
|
-
// Finally, re-parent the relative path into an absolute path on the host system.
|
|
14924
|
-
const absPath = external_node_path_namespaceObject.join(cargoMetadata.target_directory, relPath);
|
|
14925
|
-
return absPath;
|
|
14926
|
-
}
|
|
14927
|
-
}
|
|
14928
|
-
|
|
14929
|
-
;// CONCATENATED MODULE: ./src/commands/dist.ts
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
14933
|
-
// FIXME: add options to infer crate name from manifests
|
|
14934
|
-
// --package <path/to/package.json>
|
|
14935
|
-
// --crate <path/to/Cargo.toml>
|
|
14936
|
-
const OPTIONS = [
|
|
14937
|
-
{ name: 'name', alias: 'n', type: String, defaultValue: null },
|
|
14938
|
-
{ name: 'file', alias: 'f', type: String, defaultValue: null },
|
|
14939
|
-
{ name: 'log', alias: 'l', type: String, defaultValue: null },
|
|
14940
|
-
{ name: 'mount', alias: 'm', type: String, defaultValue: null },
|
|
14941
|
-
{ name: 'manifest-path', type: String, defaultValue: null },
|
|
14942
|
-
{ name: 'out', alias: 'o', type: String, defaultValue: 'index.node' }
|
|
14943
|
-
];
|
|
14944
|
-
class Dist {
|
|
14945
|
-
static summary() { return 'Generate a .node file from a build.'; }
|
|
14946
|
-
static syntax() { return 'neon dist [-n <name>] [-f <dylib>|[-l <log>] [-m <path>]] [-o <dist>]'; }
|
|
14947
|
-
static options() {
|
|
14948
|
-
return [
|
|
14949
|
-
{ name: '-n, --name', summary: 'Crate name. (Default: $npm_package_name)' },
|
|
14950
|
-
{ name: '-f, --file <dylib>', summary: 'Build .node from dylib file <dylib>.' },
|
|
14951
|
-
{ name: '-l, --log <log>', summary: 'Find dylib path from cargo messages <log>. (Default: stdin)' },
|
|
14952
|
-
{
|
|
14953
|
-
name: '-m, --mount <path>',
|
|
14954
|
-
summary: 'Mounted path of target directory in virtual filesystem. This is used to map paths from the log data back to their real paths, needed when tools such as cross-rs report messages from within a mounted Docker filesystem.'
|
|
14955
|
-
},
|
|
14956
|
-
{ name: '--manifest-path <path>', summary: 'Real path to Cargo.toml. (Default: cargo behavior)' },
|
|
14957
|
-
{ name: '-o, --out <dist>', summary: 'Copy output to file <dist>. (Default: index.node)' }
|
|
14958
|
-
];
|
|
14959
|
-
}
|
|
14960
|
-
static seeAlso() {
|
|
14961
|
-
return [
|
|
14962
|
-
{ name: 'cargo messages', summary: '<https://doc.rust-lang.org/cargo/reference/external-tools.html>' },
|
|
14963
|
-
{ name: 'cross-rs', summary: '<https://github.com/cross-rs/cross>' }
|
|
14964
|
-
];
|
|
14965
|
-
}
|
|
14966
|
-
_log;
|
|
14967
|
-
_file;
|
|
14968
|
-
_mount;
|
|
14969
|
-
_manifestPath;
|
|
14970
|
-
_crateName;
|
|
14971
|
-
_out;
|
|
14972
|
-
constructor(argv) {
|
|
14973
|
-
const options = dist_default()(OPTIONS, { argv });
|
|
14974
|
-
if (options.log && options.file) {
|
|
14975
|
-
throw new Error("Options --log and --file cannot both be enabled.");
|
|
14976
|
-
}
|
|
14977
|
-
if (options.file && options.mount) {
|
|
14978
|
-
throw new Error("Options --mount and --file cannot both be enabled.");
|
|
14979
|
-
}
|
|
14980
|
-
if (options['manifest-path'] && !options.mount) {
|
|
14981
|
-
throw new Error("Option --manifest-path requires option --mount to be provided.");
|
|
14982
|
-
}
|
|
14983
|
-
this._log = options.log ?? null;
|
|
14984
|
-
this._file = options.file ?? null;
|
|
14985
|
-
this._mount = options.mount;
|
|
14986
|
-
this._manifestPath = options['manifest-path'];
|
|
14987
|
-
this._crateName = options.name || process.env['npm_package_name'];
|
|
14988
|
-
this._out = options.out;
|
|
14989
|
-
}
|
|
14990
|
-
async findArtifact() {
|
|
14991
|
-
const stream = this._mount
|
|
14992
|
-
? new UnmountMessageStream(this._mount, this._manifestPath, this._log)
|
|
14993
|
-
: new MessageStream(this._log);
|
|
14994
|
-
return await stream.findPath((msg) => {
|
|
14995
|
-
if (!isCompilerArtifact(msg) || (msg.target.name !== this._crateName)) {
|
|
14996
|
-
return null;
|
|
14997
|
-
}
|
|
14998
|
-
const index = msg.target.crate_types.indexOf('cdylib');
|
|
14999
|
-
return (index < 0) ? null : msg.filenames[index];
|
|
15000
|
-
});
|
|
15001
|
-
}
|
|
15002
|
-
async run() {
|
|
15003
|
-
const file = this._file || await this.findArtifact();
|
|
15004
|
-
if (!file) {
|
|
15005
|
-
throw new Error(`No library found for crate ${this._crateName}`);
|
|
15006
|
-
}
|
|
15007
|
-
// FIXME: needs all the logic of cargo-cp-artifact (timestamp check, M1 workaround, async, errors)
|
|
15008
|
-
await (0,promises_namespaceObject.copyFile)(file, this._out);
|
|
15009
|
-
}
|
|
15010
|
-
}
|
|
15011
|
-
|
|
15012
|
-
// EXTERNAL MODULE: ../../node_modules/temp/lib/temp.js
|
|
15013
|
-
var temp = __nccwpck_require__(5758);
|
|
15014
15032
|
;// CONCATENATED MODULE: ./data/rust.json
|
|
15015
15033
|
const rust_namespaceObject = JSON.parse('{"aarch64-apple-darwin":"darwin-arm64","x86_64-apple-darwin":"darwin-x64","aarch64-apple-ios":"ios-arm64","x86_64-apple-ios":"ios-x64","aarch64-linux-android":"android-arm64","armv7-linux-androideabi":"android-arm-eabi","i686-linux-android":"android-ia32","x86_64-linux-android":"android-x64","aarch64-pc-windows-msvc":"win32-arm64-msvc","i686-pc-windows-gnu":"win32-ia32-gnu","i686-pc-windows-msvc":"win32-ia32-msvc","x86_64-pc-windows-gnu":"win32-x64-gnu","x86_64-pc-windows-msvc":"win32-x64-msvc","aarch64-unknown-linux-gnu":"linux-arm64-gnu","aarch64-unknown-linux-musl":"linux-arm64-musl","arm-unknown-linux-gnueabihf":"linux-arm-gnueabihf","arm-unknown-linux-musleabihf":"linux-arm-musleabihf","armv7-unknown-linux-gnueabihf":"linux-arm-gnueabihf","armv7-unknown-linux-musleabihf":"linux-arm-musleabihf","i686-unknown-linux-gnu":"linux-ia32-gnu","i686-unknown-linux-musl":"linux-ia32-musl","mips-unknown-linux-gnu":"linux-mips-gnu","mips-unknown-linux-musl":"linux-mips-musl","mips64-unknown-linux-gnuabi64":"linux-mips64-gnuabi64","mips64-unknown-linux-muslabi64":"linux-mips64-muslabi64","mips64el-unknown-linux-gnuabi64":"linux-mips64el-gnuabi64","mips64el-unknown-linux-muslabi64":"linux-mips64el-muslabi64","mipsel-unknown-linux-gnu":"linux-mipsel-gnu","mipsel-unknown-linux-musl":"linux-mipsel-musl","powerpc-unknown-linux-gnu":"linux-powerpc-gnu","powerpc64-unknown-linux-gnu":"linux-powerpc64-gnu","powerpc64le-unknown-linux-gnu":"linux-powerpc64le-gnu","riscv64gc-unknown-linux-gnu":"linux-riscv64gc-gnu","s390x-unknown-linux-gnu":"linux-s390x-gnu","sparc64-unknown-linux-gnu":"linux-sparc64-gnu","x86_64-unknown-linux-gnu":"linux-x64-gnu","x86_64-unknown-linux-gnux32":"linux-x64-gnux32","x86_64-unknown-linux-musl":"linux-x64-musl","i686-unknown-freebsd":"freebsd-ia32","x86_64-unknown-freebsd":"freebsd-x64"}');
|
|
15016
15034
|
;// CONCATENATED MODULE: ./data/node.json
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neon-rs/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "Command-line build tool for Neon modules.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./index.js",
|
|
@@ -26,5 +26,13 @@
|
|
|
26
26
|
"url": "https://github.com/dherman/neon-rs/issues"
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/dherman/neon-rs#readme",
|
|
29
|
-
"
|
|
29
|
+
"optionalDependences": {
|
|
30
|
+
"@cargo-messages/win32-x64-msvc": "0.0.26",
|
|
31
|
+
"@cargo-messages/win32-arm64-msvc": "0.0.26",
|
|
32
|
+
"@cargo-messages/darwin-x64": "0.0.26",
|
|
33
|
+
"@cargo-messages/darwin-arm64": "0.0.26",
|
|
34
|
+
"@cargo-messages/linux-x64-gnu": "0.0.26",
|
|
35
|
+
"@cargo-messages/linux-arm-gnueabihf": "0.0.26",
|
|
36
|
+
"@cargo-messages/android-arm-eabi": "0.0.26"
|
|
37
|
+
}
|
|
30
38
|
}
|