@smoothbricks/nx-plugin 0.4.31 → 0.5.0
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/README.md +15 -11
- package/dist/cargo-toolchain-policy.d.ts +6 -6
- package/dist/cargo-toolchain-policy.js +6 -6
- package/dist/cross-check-policy.d.ts +31 -14
- package/dist/cross-check-policy.d.ts.map +1 -1
- package/dist/cross-check-policy.js +43 -15
- package/dist/executors/cargo-zigbuild/executor.d.ts +60 -0
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -0
- package/dist/executors/cargo-zigbuild/executor.js +266 -0
- package/dist/executors/cargo-zigbuild/schema.d.ts +15 -0
- package/dist/executors/cargo-zigbuild/schema.d.ts.map +1 -0
- package/dist/index.d.ts +0 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -89
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -2
- package/executors.json +4 -4
- package/managed/raw/patches/nx@23.2.1.patch +177 -9
- package/managed/raw/tooling/direnv/devenv.smoo.nix +46 -46
- package/managed/raw/tooling/git-hooks/pre-push.sh +41 -23
- package/package.json +1 -1
- package/src/cargo-toolchain-policy.ts +6 -6
- package/src/cross-check-policy.test.ts +90 -11
- package/src/cross-check-policy.ts +47 -17
- package/src/executors/cargo-zigbuild/executor.test.ts +129 -0
- package/src/executors/cargo-zigbuild/executor.ts +176 -0
- package/src/executors/cargo-zigbuild/schema.json +35 -0
- package/src/executors/cargo-zigbuild/schema.ts +14 -0
- package/src/index.test.ts +29 -61
- package/src/index.ts +60 -98
- package/src/nx-daemon-validity.test.ts +65 -0
- package/src/testing.ts +3 -2
- package/test-timings.json +1 -1
- package/dist/executors/napi-cross-toolchain/executor.d.ts +0 -42
- package/dist/executors/napi-cross-toolchain/executor.d.ts.map +0 -1
- package/dist/executors/napi-cross-toolchain/executor.js +0 -126
- package/dist/executors/napi-cross-toolchain/schema.d.ts +0 -4
- package/dist/executors/napi-cross-toolchain/schema.d.ts.map +0 -1
- package/src/executors/napi-cross-toolchain/executor.test.ts +0 -112
- package/src/executors/napi-cross-toolchain/executor.ts +0 -165
- package/src/executors/napi-cross-toolchain/schema.json +0 -15
- package/src/executors/napi-cross-toolchain/schema.ts +0 -3
- /package/dist/executors/{napi-cross-toolchain → cargo-zigbuild}/schema.js +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -6,21 +6,6 @@ export { CARGO_TEST_COMPILE_TARGET };
|
|
|
6
6
|
export declare const DEPLOY_TARGET = "deploy";
|
|
7
7
|
/** The purely file-derived half a deploy needs built first; cached. */
|
|
8
8
|
export declare const DEPLOY_BUILD_TARGET = "deploy-build";
|
|
9
|
-
type NapiArchitecture = 'arm64' | 'x64';
|
|
10
|
-
type NapiTargetFamily = 'linux' | 'macos';
|
|
11
|
-
interface NapiPlatform {
|
|
12
|
-
architecture: NapiArchitecture;
|
|
13
|
-
targetFamily: NapiTargetFamily;
|
|
14
|
-
}
|
|
15
|
-
interface NapiTargetConvention extends NapiPlatform {
|
|
16
|
-
outputName: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Prerequisite target that extracts the cross toolchain one triple needs. The
|
|
20
|
-
* platform suffix keeps it inside its own platform family, so it can be a
|
|
21
|
-
* dependency of `napi-<arch>-linux` and package-local `cli-<arch>-linux`.
|
|
22
|
-
*/
|
|
23
|
-
export declare function napiToolchainTargetName(convention: NapiTargetConvention): string;
|
|
24
9
|
/**
|
|
25
10
|
* The npm packages a cached cargo target runs, for its `externalDependencies`.
|
|
26
11
|
* Cargo runs none. A target this plugin's executor runs, or whose command reads
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAEtB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B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_TIMEOUT_MS, BOUNDED_TEST_KILL_AFTER_MS } from './boun
|
|
|
11
11
|
import { CARGO_CLOSURE_INPUT, cargoClosureInputs, indexedCargoManifests, resolveCargoClosureSource, } from './cargo-closure-input.js';
|
|
12
12
|
import { CARGO_TOOLCHAIN_NAMED_INPUT, CARGO_TOOLCHAIN_PIN_INPUTS, cargoRuntimeInput, } from './cargo-toolchain-policy.js';
|
|
13
13
|
import { attributeCargoWorkspacePackages, CARGO_TEST_ARCHIVE_FILE, CARGO_TEST_ARCHIVE_TARGET, CARGO_TEST_COMPILE_TARGET, CARGO_TEST_EXCEPTIONS_SUFFIX, CARGO_TEST_TARGET, cargoPackageTestInputs, cargoTestGroupTargetName, cargoTestPackageTargetName, createCargoInputsCache, exceptionalTestFilter, listCargoCrossTestTargets, listCargoWorkspacePackages, NEXTEST_REPO_CONFIG_PATH, nextestToolConfigArg, PLUGIN_NEXTEST_CONFIG_PATH, serialTestGroups, } from './cargo-workspace.js';
|
|
14
|
-
import { CARGO_CROSS_LINT_COMMAND, CARGO_CROSS_LINT_TARGET, CARGO_FETCH_COMMAND, CARGO_FETCH_TARGET,
|
|
14
|
+
import { CARGO_CROSS_LINT_COMMAND, CARGO_CROSS_LINT_TARGET, CARGO_FETCH_COMMAND, CARGO_FETCH_TARGET, CARGO_LINT_CLIPPY_COMMAND, cargoCrossTestArchiveFile, cargoCrossTestArchiveTargetName, cargoCrossTestTargetName, cargoFrozen, runsFrozenCargo, } from './cross-check-policy.js';
|
|
15
15
|
import { closeRunCpuPool, serveRunCpuPool } from './executors/bounded-exec/run-cpu-pool.js';
|
|
16
16
|
import { hashVersionlessCrateManifests } from './manifest-hash.js';
|
|
17
17
|
import { EXTRACTED_BINARIES_METADATA, EXTRACTED_CARGO_METADATA, EXTRACTED_TARGET_DIR, NEXTEST_EXTRACT_BIN, } from './nextest-extraction.js';
|
|
@@ -347,13 +347,7 @@ function hostPlatformTargetNames(targetNames, hostPlatform) {
|
|
|
347
347
|
if (hostPlatform === null)
|
|
348
348
|
return [];
|
|
349
349
|
const suffix = `-${hostPlatform.architecture}-${hostPlatform.targetFamily}`;
|
|
350
|
-
return [...new Set(targetNames)]
|
|
351
|
-
.filter(
|
|
352
|
-
// Binary targets only. A toolchain prerequisite carries the same platform
|
|
353
|
-
// suffix but produces no artifact: the cross builds that need it depend
|
|
354
|
-
// on it directly, so the aggregate stays a list of outputs.
|
|
355
|
-
(name) => name.endsWith(suffix) && !name.startsWith(NAPI_TOOLCHAIN_TARGET_PREFIX))
|
|
356
|
-
.sort();
|
|
350
|
+
return [...new Set(targetNames)].filter((name) => name.endsWith(suffix)).sort();
|
|
357
351
|
}
|
|
358
352
|
/**
|
|
359
353
|
* The reserved suffixes name targets that EMIT an artifact, and the `build`
|
|
@@ -439,18 +433,19 @@ function targetCommandText(target) {
|
|
|
439
433
|
}
|
|
440
434
|
/**
|
|
441
435
|
* The N-API build's inputs beyond the Cargo sources: the toolchain pin, the
|
|
442
|
-
* package's `napi` block, which names the binary and the targets, and the
|
|
443
|
-
*
|
|
444
|
-
*
|
|
436
|
+
* package's `napi` block, which names the binary and the targets, and the
|
|
437
|
+
* resolved version of the npm package that drives the build (the napi CLI on
|
|
438
|
+
* macOS; none on Linux, where devenv's zig and cargo-zigbuild are covered by
|
|
439
|
+
* the pin). Neither the package version nor any other lockfile entry is part
|
|
440
|
+
* of the artifact.
|
|
445
441
|
*
|
|
446
|
-
* The pin is stated here rather than inherited: `napi build`
|
|
447
|
-
*
|
|
448
|
-
*
|
|
449
|
-
*
|
|
450
|
-
*
|
|
451
|
-
* next one.
|
|
442
|
+
* The pin is stated here rather than inherited: neither `napi build` nor the
|
|
443
|
+
* `cargo-zigbuild` executor spells `cargo --frozen`, which is how every other
|
|
444
|
+
* cached cargo target acquires its toolchain identity. Without it a `.node`
|
|
445
|
+
* linked against one toolchain hashed equal to the same sources linked against
|
|
446
|
+
* the next one.
|
|
452
447
|
*/
|
|
453
|
-
function napiInputs(projectRoot, repoRooted) {
|
|
448
|
+
function napiInputs(projectRoot, repoRooted, externalDependencies) {
|
|
454
449
|
// Runtime inputs execute from the workspace root, so the manifest is named
|
|
455
450
|
// by its path from there whichever way the Cargo invocation is rooted.
|
|
456
451
|
const packageJson = `./${posix.join(projectRoot, 'package.json')}`;
|
|
@@ -460,7 +455,7 @@ function napiInputs(projectRoot, repoRooted) {
|
|
|
460
455
|
...(repoRooted ? ['{workspaceRoot}/scripts/*.sh'] : []),
|
|
461
456
|
...CARGO_TOOLCHAIN_PIN_INPUTS,
|
|
462
457
|
runtimeInput(`bun -e 'console.log(JSON.stringify(require(${JSON.stringify(packageJson)}).napi ?? null))'`),
|
|
463
|
-
{ externalDependencies: [
|
|
458
|
+
{ externalDependencies: [...externalDependencies] },
|
|
464
459
|
];
|
|
465
460
|
}
|
|
466
461
|
const NAPI_TARGET_CONVENTIONS = {
|
|
@@ -485,25 +480,14 @@ const NAPI_TARGET_CONVENTIONS = {
|
|
|
485
480
|
targetFamily: 'linux',
|
|
486
481
|
},
|
|
487
482
|
};
|
|
488
|
-
const NATIVE_LINUX_COMPILER_ENV = Object.freeze({ CC: 'cc', CXX: 'c++' });
|
|
489
|
-
const CROSS_LINUX_COMPILER_ENV = Object.freeze({ TARGET_CC: 'clang', TARGET_CXX: 'clang++' });
|
|
490
|
-
function usesNapiCross(target, hostPlatform) {
|
|
491
|
-
return target.targetFamily === 'linux' && !sameNapiPlatform(target, hostPlatform);
|
|
492
|
-
}
|
|
493
|
-
function napiCompilerEnv(target, hostPlatform) {
|
|
494
|
-
if (target?.targetFamily !== 'linux')
|
|
495
|
-
return undefined;
|
|
496
|
-
return sameNapiPlatform(target, hostPlatform) ? NATIVE_LINUX_COMPILER_ENV : CROSS_LINUX_COMPILER_ENV;
|
|
497
|
-
}
|
|
498
|
-
const NAPI_TOOLCHAIN_TARGET_PREFIX = 'napi-toolchain-';
|
|
499
483
|
/**
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
484
|
+
* The glibc symbol-version floor every Linux N-API addon links against.
|
|
485
|
+
* cargo-zigbuild reads it from the target triple's suffix
|
|
486
|
+
* (`x86_64-unknown-linux-gnu.2.17`) and links zig's stubs for exactly that
|
|
487
|
+
* glibc, so the floor is this literal on every host rather than whatever glibc
|
|
488
|
+
* the build machine carries. 2.17 is below Node ≥ 18's own 2.28 floor.
|
|
503
489
|
*/
|
|
504
|
-
|
|
505
|
-
return `${NAPI_TOOLCHAIN_TARGET_PREFIX}${convention.architecture}-${convention.targetFamily}`;
|
|
506
|
-
}
|
|
490
|
+
const LINUX_GLIBC_FLOOR = '2.17';
|
|
507
491
|
const CARGO_PROFILE_FLAG = { dev: '', release: ' --release' };
|
|
508
492
|
/** The directory under `target/<triple>/` each profile writes. */
|
|
509
493
|
const CARGO_PROFILE_OUTPUT_DIR = { dev: 'debug', release: 'release' };
|
|
@@ -1216,8 +1200,8 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1216
1200
|
// than a silent absence.
|
|
1217
1201
|
//
|
|
1218
1202
|
// Deliberately NOT pushed to validationTargets: joining the lint aggregate
|
|
1219
|
-
// would make `bun run lint` — and CI's own Linux lint, already native —
|
|
1220
|
-
//
|
|
1203
|
+
// would make `bun run lint` — and CI's own Linux lint, already native — on a
|
|
1204
|
+
// macOS host demand the zig toolchain that the devenv profile keeps opt-in.
|
|
1221
1205
|
targets[CARGO_CROSS_LINT_TARGET] = {
|
|
1222
1206
|
executor: 'nx:run-commands',
|
|
1223
1207
|
cache: true,
|
|
@@ -1338,9 +1322,8 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1338
1322
|
targets[CARGO_FETCH_TARGET] = {
|
|
1339
1323
|
executor: 'nx:run-commands',
|
|
1340
1324
|
// The download lands in CARGO_HOME, outside the workspace: a cache hit
|
|
1341
|
-
// would skip work a cold registry still needs
|
|
1342
|
-
//
|
|
1343
|
-
// there is nothing for Nx to restore in its place.
|
|
1325
|
+
// would skip work a cold registry still needs. Nothing here is a
|
|
1326
|
+
// workspace output, so there is nothing for Nx to restore in its place.
|
|
1344
1327
|
cache: false,
|
|
1345
1328
|
options: {
|
|
1346
1329
|
// One fetch per manifest, independent of the others: Cargo's own
|
|
@@ -1358,7 +1341,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1358
1341
|
continue;
|
|
1359
1342
|
}
|
|
1360
1343
|
const text = targetCommandText(target);
|
|
1361
|
-
if (text
|
|
1344
|
+
if (runsFrozenCargo(text)) {
|
|
1362
1345
|
target.dependsOn = [CARGO_FETCH_TARGET, ...(target.dependsOn ?? [])];
|
|
1363
1346
|
}
|
|
1364
1347
|
}
|
|
@@ -1370,7 +1353,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1370
1353
|
});
|
|
1371
1354
|
for (const target of Object.values(targets)) {
|
|
1372
1355
|
const text = targetCommandText(target);
|
|
1373
|
-
if (text
|
|
1356
|
+
if (runsFrozenCargo(text)) {
|
|
1374
1357
|
target.dependsOn = [rootFetch, ...(target.dependsOn ?? [])];
|
|
1375
1358
|
}
|
|
1376
1359
|
}
|
|
@@ -1381,7 +1364,7 @@ async function createProjectTargets(packageJsonPath, workspaceRoot, hostPlatform
|
|
|
1381
1364
|
// the target already does.
|
|
1382
1365
|
for (const [name, target] of Object.entries(targets)) {
|
|
1383
1366
|
const text = targetCommandText(target);
|
|
1384
|
-
if (!text
|
|
1367
|
+
if (!runsFrozenCargo(text))
|
|
1385
1368
|
continue;
|
|
1386
1369
|
target.outputs ??= [];
|
|
1387
1370
|
if (!target.cache)
|
|
@@ -1830,26 +1813,17 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1830
1813
|
// that stale local artifacts can mask for months.
|
|
1831
1814
|
const packageJsonPath = repoRooted ? posix.join(projectRoot, 'package.json') : 'package.json';
|
|
1832
1815
|
const commonCommand = `--manifest-path ${config.manifestPath} --package ${config.cargoPackage} --package-json-path ${packageJsonPath}`;
|
|
1833
|
-
const cargoInputs = napiInputs(projectRoot, repoRooted);
|
|
1816
|
+
const cargoInputs = napiInputs(projectRoot, repoRooted, ['@napi-rs/cli']);
|
|
1834
1817
|
const cargoCwd = repoRooted ? '.' : projectRoot;
|
|
1835
1818
|
// A repository-root Cargo invocation runs outside the owning npm package, so
|
|
1836
1819
|
// Nx's root-only PATH cannot resolve that package's napi CLI.
|
|
1837
1820
|
const napiCommand = repoRooted ? posix.join(projectRoot, 'node_modules/.bin/napi') : 'napi';
|
|
1838
1821
|
const outputPath = (projectOutput) => (repoRooted ? posix.join(projectRoot, projectOutput) : projectOutput);
|
|
1839
|
-
const
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
const convention = NAPI_TARGET_CONVENTIONS[triple];
|
|
1844
|
-
const targetName = convention ? `napi-${convention.architecture}-${convention.targetFamily}` : null;
|
|
1845
|
-
if (targetName === hostPlatformTargetName && convention && !usesNapiCross(convention, hostPlatform)) {
|
|
1846
|
-
nativeHostTargetName = targetName;
|
|
1847
|
-
break;
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1822
|
+
const hasHostPlatformTarget = config.targets.some((triple) => {
|
|
1823
|
+
const convention = NAPI_TARGET_CONVENTIONS[triple];
|
|
1824
|
+
return convention !== undefined && sameNapiPlatform(convention, hostPlatform);
|
|
1825
|
+
});
|
|
1851
1826
|
const targets = {};
|
|
1852
|
-
const hostCompilerEnv = napiCompilerEnv(hostPlatform, hostPlatform);
|
|
1853
1827
|
// The addon the test suite loads. A plain dev build shares target/debug with
|
|
1854
1828
|
// cargo-test's dependency graph, so after the tests compile this is nearly
|
|
1855
1829
|
// free, where a `--target <triple>` platform build compiles the graph again
|
|
@@ -1867,10 +1841,9 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1867
1841
|
options: {
|
|
1868
1842
|
cwd: cargoCwd,
|
|
1869
1843
|
command: `${napiCommand} build --platform --no-js --dts ${config.binaryName}.napi.d.ts ${commonCommand} --output-dir ${outputPath('.cache/native-debug')}`,
|
|
1870
|
-
...(hostCompilerEnv ? { env: hostCompilerEnv } : {}),
|
|
1871
1844
|
},
|
|
1872
1845
|
};
|
|
1873
|
-
if (
|
|
1846
|
+
if (!hasHostPlatformTarget) {
|
|
1874
1847
|
// The platform target for this host triple is the same compilation, so a
|
|
1875
1848
|
// second cargo-napi invocation only buys a duplicate dependency graph
|
|
1876
1849
|
// (a plain build and a `--target` build write different target/
|
|
@@ -1887,30 +1860,10 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1887
1860
|
options: {
|
|
1888
1861
|
cwd: cargoCwd,
|
|
1889
1862
|
command: hostBuild('dev'),
|
|
1890
|
-
...(hostCompilerEnv ? { env: hostCompilerEnv } : {}),
|
|
1891
1863
|
},
|
|
1892
1864
|
configurations: { [RELEASE_CONFIGURATION]: { command: hostBuild('release') } },
|
|
1893
1865
|
};
|
|
1894
1866
|
}
|
|
1895
|
-
for (const triple of config.targets) {
|
|
1896
|
-
const convention = NAPI_TARGET_CONVENTIONS[triple];
|
|
1897
|
-
if (!convention || !usesNapiCross(convention, hostPlatform)) {
|
|
1898
|
-
continue;
|
|
1899
|
-
}
|
|
1900
|
-
// One toolchain target per triple, shared by every cross build that needs
|
|
1901
|
-
// it: the inferred napi-<arch>-linux plus any package-local cli-<arch>-linux.
|
|
1902
|
-
// Nx runs a shared dependency once, which is what stops those builds from
|
|
1903
|
-
// racing inside the Bun store. See the executor for the failure it removes.
|
|
1904
|
-
// The name carries the platform suffix so a Linux platform target's
|
|
1905
|
-
// dependency closure stays Linux-only (package-target-policy).
|
|
1906
|
-
targets[napiToolchainTargetName(convention)] = {
|
|
1907
|
-
executor: '@smoothbricks/nx-plugin:napi-cross-toolchain',
|
|
1908
|
-
// Extraction lands in ~/.napi-rs, outside the workspace: a cache hit
|
|
1909
|
-
// would skip work a cold home directory still needs.
|
|
1910
|
-
cache: false,
|
|
1911
|
-
options: { triple },
|
|
1912
|
-
};
|
|
1913
|
-
}
|
|
1914
1867
|
for (const triple of config.targets) {
|
|
1915
1868
|
const convention = NAPI_TARGET_CONVENTIONS[triple];
|
|
1916
1869
|
if (!convention) {
|
|
@@ -1918,23 +1871,37 @@ function createNapiTargets(projectRoot, config, hostPlatform, repoRooted) {
|
|
|
1918
1871
|
}
|
|
1919
1872
|
const targetName = `napi-${convention.architecture}-${convention.targetFamily}`;
|
|
1920
1873
|
const outputDirectory = `dist/native/${convention.outputName}`;
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1874
|
+
if (convention.targetFamily === 'linux') {
|
|
1875
|
+
// Every host builds a Linux addon the same way: devenv's zig through
|
|
1876
|
+
// cargo-zigbuild, glibc pinned by the triple suffix. The napi CLI cannot
|
|
1877
|
+
// carry that suffix (it looks for the artifact under
|
|
1878
|
+
// target/<triple>.2.17/), so the executor names the `.node` itself.
|
|
1879
|
+
targets[targetName] = {
|
|
1880
|
+
executor: '@smoothbricks/nx-plugin:cargo-zigbuild',
|
|
1881
|
+
cache: true,
|
|
1882
|
+
inputs: napiInputs(projectRoot, repoRooted, []),
|
|
1883
|
+
outputs: [`{projectRoot}/${outputDirectory}`],
|
|
1884
|
+
options: {
|
|
1885
|
+
target: `${triple}.${LINUX_GLIBC_FLOOR}`,
|
|
1886
|
+
manifestPath: posix.join(cargoCwd, config.manifestPath),
|
|
1887
|
+
package: config.cargoPackage,
|
|
1888
|
+
output: `{projectRoot}/${outputDirectory}/${config.binaryName}.${convention.outputName}.node`,
|
|
1889
|
+
},
|
|
1890
|
+
configurations: { [RELEASE_CONFIGURATION]: { release: true } },
|
|
1891
|
+
};
|
|
1892
|
+
continue;
|
|
1893
|
+
}
|
|
1894
|
+
// macOS addons need Apple's SDK, which zig does not carry: the napi CLI
|
|
1895
|
+
// drives the host's own toolchain and writes the platform `.d.ts`.
|
|
1896
|
+
const platformBuild = (profile) => `${napiCommand} build${CARGO_PROFILE_FLAG[profile]} --platform --no-js --dts ${config.binaryName}.${convention.outputName}.d.ts --target ${triple} ${commonCommand} --output-dir ${outputPath(outputDirectory)}`;
|
|
1925
1897
|
targets[targetName] = {
|
|
1926
1898
|
executor: 'nx:run-commands',
|
|
1927
1899
|
cache: true,
|
|
1928
|
-
...(useNapiCross ? { dependsOn: [napiToolchainTargetName(convention)] } : {}),
|
|
1929
1900
|
inputs: cargoInputs,
|
|
1930
1901
|
outputs: [`{projectRoot}/${outputDirectory}`],
|
|
1931
1902
|
options: {
|
|
1932
1903
|
cwd: cargoCwd,
|
|
1933
1904
|
command: platformBuild('dev'),
|
|
1934
|
-
// Genuine Linux cross-compiles use Clang plus napi-rs's downloaded
|
|
1935
|
-
// GNU sysroot. A native Linux target uses Nix's cc wrapper so C build
|
|
1936
|
-
// scripts resolve the host libc headers instead.
|
|
1937
|
-
...(compilerEnv ? { env: compilerEnv } : {}),
|
|
1938
1905
|
},
|
|
1939
1906
|
configurations: { [RELEASE_CONFIGURATION]: { command: platformBuild('release') } },
|
|
1940
1907
|
};
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAsDA,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,4EAA4E;AAC5E,wBAAsB,YAAY,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAe5D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,EAAE,CAYvG;A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M,CAAC,CAIrG;AAoBD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKhE;AAED;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BtF;AAED;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAMvG;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASnF;AA0DD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAqBxF"}
|
package/dist/testing.js
CHANGED
|
@@ -120,9 +120,10 @@ export function terminate(pid, signal = 'SIGTERM') {
|
|
|
120
120
|
* `timeoutMs` later is an error naming it and `owner`.
|
|
121
121
|
*/
|
|
122
122
|
export async function awaitExit(processes, owner, timeoutMs = EXIT_TIMEOUT_MS) {
|
|
123
|
-
|
|
123
|
+
// The monotonic clock: a wall-clock step (NTP, sleep and wake) must not move the deadline.
|
|
124
|
+
const deadline = performance.now() + timeoutMs;
|
|
124
125
|
for (let waiting = processes.filter((entry) => isRunning(entry.pid)); waiting.length > 0;) {
|
|
125
|
-
if (
|
|
126
|
+
if (performance.now() > deadline) {
|
|
126
127
|
// A signal probe also answers for a zombie, which has already exited.
|
|
127
128
|
const live = new Set((await processTable()).filter((entry) => !entry.stat.startsWith('Z')).map((entry) => entry.pid));
|
|
128
129
|
const survivors = waiting.filter((entry) => live.has(entry.pid));
|
package/executors.json
CHANGED
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"schema": "./src/executors/clean-outputs/schema.json",
|
|
16
16
|
"description": "Remove declared build output directories unless they contain tracked files"
|
|
17
17
|
},
|
|
18
|
-
"
|
|
19
|
-
"implementation": "./dist/executors/
|
|
20
|
-
"schema": "./src/executors/
|
|
21
|
-
"description": "
|
|
18
|
+
"cargo-zigbuild": {
|
|
19
|
+
"implementation": "./dist/executors/cargo-zigbuild/executor.js",
|
|
20
|
+
"schema": "./src/executors/cargo-zigbuild/schema.json",
|
|
21
|
+
"description": "Build one Linux binary or cdylib with devenv's zig through cargo-zigbuild and copy it to its output file"
|
|
22
22
|
},
|
|
23
23
|
"shard-timings": {
|
|
24
24
|
"implementation": "./dist/executors/shard-timings/executor.js",
|
|
@@ -678,7 +678,7 @@ index c2a2f8f70fe71940e47c97931c5925bac1fbd480..39582a8fc342ae59decd3d4ca25179f2
|
|
|
678
678
|
// Bump generation synchronously so any in-flight compute fails its
|
|
679
679
|
diff --git a/dist/src/daemon/server/restart-checks.d.ts b/dist/src/daemon/server/restart-checks.d.ts
|
|
680
680
|
new file mode 100644
|
|
681
|
-
index 0000000000000000000000000000000000000000..
|
|
681
|
+
index 0000000000000000000000000000000000000000..28f263f82b7b698ec1bf88943924696b3d9a91e7
|
|
682
682
|
--- /dev/null
|
|
683
683
|
+++ b/dist/src/daemon/server/restart-checks.d.ts
|
|
684
684
|
@@ -0,0 +1,10 @@
|
|
@@ -687,22 +687,22 @@ index 0000000000000000000000000000000000000000..2a76dce933112854e34d61a44aa90b7c
|
|
|
687
687
|
+export declare const DAEMON_VALIDITY_SAFETY_INTERVAL_MS = 5000;
|
|
688
688
|
+export declare const relativeServerProcess: string;
|
|
689
689
|
+export declare function registerDaemonForRestartChecks(server: Server, sockets: Iterable<Socket>, socketPath: string): void;
|
|
690
|
-
+export declare function
|
|
690
|
+
+export declare function recordInstallationBaseline(): void;
|
|
691
691
|
+export declare function restartDaemonIfLockFilesChanged(paths: string[]): boolean;
|
|
692
692
|
+export declare function stopDaemonIfReplaced(events: WatchEvent[]): boolean;
|
|
693
693
|
+export declare function stopDaemonIfOutdated(): boolean;
|
|
694
694
|
+export declare function stopDaemonIfWorkspaceGone(): boolean;
|
|
695
695
|
diff --git a/dist/src/daemon/server/restart-checks.js b/dist/src/daemon/server/restart-checks.js
|
|
696
696
|
new file mode 100644
|
|
697
|
-
index 0000000000000000000000000000000000000000..
|
|
697
|
+
index 0000000000000000000000000000000000000000..5f7aa0aa874dfe389388169c8acb0c0ab45f5180
|
|
698
698
|
--- /dev/null
|
|
699
699
|
+++ b/dist/src/daemon/server/restart-checks.js
|
|
700
|
-
@@ -0,0 +1,
|
|
700
|
+
@@ -0,0 +1,295 @@
|
|
701
701
|
+"use strict";
|
|
702
702
|
+Object.defineProperty(exports, "__esModule", { value: true });
|
|
703
703
|
+exports.relativeServerProcess = exports.DAEMON_VALIDITY_SAFETY_INTERVAL_MS = void 0;
|
|
704
704
|
+exports.registerDaemonForRestartChecks = registerDaemonForRestartChecks;
|
|
705
|
-
+exports.
|
|
705
|
+
+exports.recordInstallationBaseline = recordInstallationBaseline;
|
|
706
706
|
+exports.restartDaemonIfLockFilesChanged = restartDaemonIfLockFilesChanged;
|
|
707
707
|
+exports.stopDaemonIfReplaced = stopDaemonIfReplaced;
|
|
708
708
|
+exports.stopDaemonIfOutdated = stopDaemonIfOutdated;
|
|
@@ -740,8 +740,14 @@ index 0000000000000000000000000000000000000000..6adb712340b154dcabb7570bc1b4c586
|
|
|
740
740
|
+ }
|
|
741
741
|
+ return (0, file_hasher_1.hashArray)(hashes);
|
|
742
742
|
+}
|
|
743
|
-
|
|
743
|
+
+// The startup baseline of everything a restart judges by bytes: the root
|
|
744
|
+
+// lockfiles and the linked plugins below.
|
|
745
|
+
+function recordInstallationBaseline() {
|
|
744
746
|
+ lockFileHash = hashLockFiles();
|
|
747
|
+
+ const roots = linkedPluginRoots() ?? [];
|
|
748
|
+
+ linkedPluginRootKey = JSON.stringify(roots);
|
|
749
|
+
+ linkedPluginFiles = hashCensus(linkedPluginCensus(roots), new Map());
|
|
750
|
+
+ linkedPluginCensusAt = Date.now();
|
|
745
751
|
+}
|
|
746
752
|
+function lockFileHashChanged() {
|
|
747
753
|
+ const newHash = hashLockFiles();
|
|
@@ -753,6 +759,164 @@ index 0000000000000000000000000000000000000000..6adb712340b154dcabb7570bc1b4c586
|
|
|
753
759
|
+ lockFileHash = newHash;
|
|
754
760
|
+ return false;
|
|
755
761
|
+}
|
|
762
|
+
+// A plugin nx.json names whose package resolves outside the workspace (a
|
|
763
|
+
+// developer link into another checkout) changes behind that link with no
|
|
764
|
+
+// lockfile change here. The daemon kept serving the graph the old plugin code
|
|
765
|
+
+// inferred, so every task hashed after the change was keyed on a configuration
|
|
766
|
+
+// no fresh process computes. Its published files and the lockfiles of the
|
|
767
|
+
+// checkout it lives in are judged like the root lockfiles: a file whose stat
|
|
768
|
+
+// moved is hashed again, and only changed bytes restart the daemon. Files are
|
|
769
|
+
+// keyed by plugin and package-relative path, so a link moved to a copy with the
|
|
770
|
+
+// same bytes keeps the daemon. A request resolves each link and stats the files
|
|
771
|
+
+// already known; a moved link, and at most once per safety interval anyway, takes
|
|
772
|
+
+// the full census, which finds a file added beside them. A package inside the
|
|
773
|
+
+// workspace changes only with its lockfile.
|
|
774
|
+
+let linkedPluginRootKey;
|
|
775
|
+
+let linkedPluginFiles;
|
|
776
|
+
+let linkedPluginCensusAt = 0;
|
|
777
|
+
+const PACKAGE_GLOB = /[*?[{]/;
|
|
778
|
+
+function pluginSpecifiers() {
|
|
779
|
+
+ let plugins;
|
|
780
|
+
+ try {
|
|
781
|
+
+ plugins = JSON.parse((0, fs_1.readFileSync)(nxJson, 'utf8')).plugins;
|
|
782
|
+
+ }
|
|
783
|
+
+ catch (error) {
|
|
784
|
+
+ logger_1.serverLogger.log(`[Server] linked plugins not judged: nx.json unreadable: ${error.message}`);
|
|
785
|
+
+ return null;
|
|
786
|
+
+ }
|
|
787
|
+
+ return (Array.isArray(plugins) ? plugins : [])
|
|
788
|
+
+ .map((entry) => (typeof entry === 'string' ? entry : entry?.plugin))
|
|
789
|
+
+ .filter((name) => typeof name === 'string' && !name.startsWith('.') && !(0, path_1.isAbsolute)(name));
|
|
790
|
+
+}
|
|
791
|
+
+// Each nx.json plugin whose package resolves outside the workspace, as
|
|
792
|
+
+// [specifier, real package root]; null when nx.json cannot say which plugins there are.
|
|
793
|
+
+function linkedPluginRoots() {
|
|
794
|
+
+ const specifiers = pluginSpecifiers();
|
|
795
|
+
+ if (specifiers === null) return null;
|
|
796
|
+
+ const workspace = (0, fs_1.realpathSync)(workspace_root_1.workspaceRoot);
|
|
797
|
+
+ const roots = [];
|
|
798
|
+
+ for (const name of specifiers) {
|
|
799
|
+
+ let root;
|
|
800
|
+
+ try {
|
|
801
|
+
+ root = (0, fs_1.realpathSync)((0, path_1.join)(workspace_root_1.workspaceRoot, 'node_modules', name));
|
|
802
|
+
+ }
|
|
803
|
+
+ catch (error) {
|
|
804
|
+
+ if (error.code === 'ENOENT') continue;
|
|
805
|
+
+ throw error;
|
|
806
|
+
+ }
|
|
807
|
+
+ if (root !== workspace && !root.startsWith(workspace + path_1.sep)) roots.push([name, root]);
|
|
808
|
+
+ }
|
|
809
|
+
+ return roots;
|
|
810
|
+
+}
|
|
811
|
+
+function statKey(stat) {
|
|
812
|
+
+ return `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
|
|
813
|
+
+}
|
|
814
|
+
+// Adds every file under `path` (following links, each directory once) to
|
|
815
|
+
+// `census`, keyed by `prefix` and its path relative to `base`, with its stat.
|
|
816
|
+
+function addFiles(census, prefix, base, path, seen = new Set()) {
|
|
817
|
+
+ let stat;
|
|
818
|
+
+ try {
|
|
819
|
+
+ stat = (0, fs_1.statSync)(path, { bigint: true });
|
|
820
|
+
+ }
|
|
821
|
+
+ catch (error) {
|
|
822
|
+
+ if (error.code === 'ENOENT') return;
|
|
823
|
+
+ throw error;
|
|
824
|
+
+ }
|
|
825
|
+
+ if (stat.isDirectory()) {
|
|
826
|
+
+ const directory = `${stat.dev}:${stat.ino}`;
|
|
827
|
+
+ if (seen.has(directory)) return;
|
|
828
|
+
+ seen.add(directory);
|
|
829
|
+
+ for (const entry of (0, fs_1.readdirSync)(path)) {
|
|
830
|
+
+ if (entry !== 'node_modules') addFiles(census, prefix, base, (0, path_1.join)(path, entry), seen);
|
|
831
|
+
+ }
|
|
832
|
+
+ }
|
|
833
|
+
+ else if (stat.isFile()) {
|
|
834
|
+
+ census.set(`${prefix}${(0, path_1.relative)(base, path)}`, { path, stat: statKey(stat) });
|
|
835
|
+
+ }
|
|
836
|
+
+}
|
|
837
|
+
+// Every file each linked plugin publishes and its checkout's lockfiles.
|
|
838
|
+
+function linkedPluginCensus(roots) {
|
|
839
|
+
+ const census = new Map();
|
|
840
|
+
+ for (const [name, root] of roots) {
|
|
841
|
+
+ const manifest = (0, path_1.join)(root, 'package.json');
|
|
842
|
+
+ addFiles(census, `${name}\0`, root, manifest);
|
|
843
|
+
+ // A manifest with no plain `files` list (absent, a glob, or bytes that do
|
|
844
|
+
+ // not parse, which the census holds too) publishes the whole package.
|
|
845
|
+
+ let files;
|
|
846
|
+
+ try {
|
|
847
|
+
+ files = JSON.parse((0, fs_1.readFileSync)(manifest, 'utf8')).files;
|
|
848
|
+
+ }
|
|
849
|
+
+ catch {
|
|
850
|
+
+ files = undefined;
|
|
851
|
+
+ }
|
|
852
|
+
+ const listed = Array.isArray(files) ? files.filter((file) => typeof file !== 'string' || !file.startsWith('!')) : [];
|
|
853
|
+
+ const published = listed.length > 0 && listed.every((file) => typeof file === 'string' && !PACKAGE_GLOB.test(file));
|
|
854
|
+
+ for (const file of published ? listed : ['.']) addFiles(census, `${name}\0`, root, (0, path_1.join)(root, file));
|
|
855
|
+
+ for (let directory = root; ; directory = (0, path_1.dirname)(directory)) {
|
|
856
|
+
+ const locks = LOCK_FILE_NAMES.map((lock) => (0, path_1.join)(directory, lock)).filter((lock) => (0, fs_1.existsSync)(lock));
|
|
857
|
+
+ if (locks.length > 0 || (0, path_1.dirname)(directory) === directory) {
|
|
858
|
+
+ for (const lock of locks) addFiles(census, `${name}\0lock\0`, directory, lock);
|
|
859
|
+
+ break;
|
|
860
|
+
+ }
|
|
861
|
+
+ }
|
|
862
|
+
+ }
|
|
863
|
+
+ return census;
|
|
864
|
+
+}
|
|
865
|
+
+// The census with each file's hash, reusing `recorded`'s for a file whose path
|
|
866
|
+
+// and stat have not moved.
|
|
867
|
+
+function hashCensus(census, recorded) {
|
|
868
|
+
+ const files = new Map();
|
|
869
|
+
+ for (const [key, { path, stat }] of census) {
|
|
870
|
+
+ const previous = recorded.get(key);
|
|
871
|
+
+ files.set(key, previous !== undefined && previous.path === path && previous.stat === stat
|
|
872
|
+
+ ? previous
|
|
873
|
+
+ : { path, stat, hash: (0, native_1.hashFile)(path) });
|
|
874
|
+
+ }
|
|
875
|
+
+ return files;
|
|
876
|
+
+}
|
|
877
|
+
+// The known files' stats, a vanished one left out.
|
|
878
|
+
+function knownFileStats() {
|
|
879
|
+
+ const census = new Map();
|
|
880
|
+
+ for (const [key, { path }] of linkedPluginFiles) {
|
|
881
|
+
+ let stat;
|
|
882
|
+
+ try {
|
|
883
|
+
+ stat = (0, fs_1.statSync)(path, { bigint: true });
|
|
884
|
+
+ }
|
|
885
|
+
+ catch (error) {
|
|
886
|
+
+ if (error.code === 'ENOENT') continue;
|
|
887
|
+
+ throw error;
|
|
888
|
+
+ }
|
|
889
|
+
+ census.set(key, { path, stat: statKey(stat) });
|
|
890
|
+
+ }
|
|
891
|
+
+ return census;
|
|
892
|
+
+}
|
|
893
|
+
+function linkedPluginsChanged() {
|
|
894
|
+
+ if (linkedPluginFiles === undefined) return false;
|
|
895
|
+
+ const roots = linkedPluginRoots();
|
|
896
|
+
+ if (roots === null) return false;
|
|
897
|
+
+ const rootKey = JSON.stringify(roots);
|
|
898
|
+
+ const now = Date.now();
|
|
899
|
+
+ const full = rootKey !== linkedPluginRootKey || now - linkedPluginCensusAt >= exports.DAEMON_VALIDITY_SAFETY_INTERVAL_MS;
|
|
900
|
+
+ const census = full ? linkedPluginCensus(roots) : knownFileStats();
|
|
901
|
+
+ if (full) {
|
|
902
|
+
+ linkedPluginRootKey = rootKey;
|
|
903
|
+
+ linkedPluginCensusAt = now;
|
|
904
|
+
+ }
|
|
905
|
+
+ const files = hashCensus(census, linkedPluginFiles);
|
|
906
|
+
+ let change = null;
|
|
907
|
+
+ for (const [key, { path, hash }] of files) {
|
|
908
|
+
+ const previous = linkedPluginFiles.get(key);
|
|
909
|
+
+ if (previous === undefined) change ??= `${path} appeared`;
|
|
910
|
+
+ else if (previous.hash !== hash) change ??= `${path} changed`;
|
|
911
|
+
+ }
|
|
912
|
+
+ for (const [key, { path }] of linkedPluginFiles) {
|
|
913
|
+
+ if (!files.has(key)) change ??= `${path} disappeared`;
|
|
914
|
+
+ }
|
|
915
|
+
+ linkedPluginFiles = files;
|
|
916
|
+
+ if (change === null) return false;
|
|
917
|
+
+ logger_1.serverLogger.log(`[Server] linked plugin file ${change}`);
|
|
918
|
+
+ return true;
|
|
919
|
+
+}
|
|
756
920
|
+// Applied paths have been hashed by the native workspace context; same-byte
|
|
757
921
|
+// rewrites were dropped already. No lockfile is read on this watcher path.
|
|
758
922
|
+function restartDaemonIfLockFilesChanged(paths) {
|
|
@@ -806,6 +970,10 @@ index 0000000000000000000000000000000000000000..6adb712340b154dcabb7570bc1b4c586
|
|
|
806
970
|
+ restartDaemon('LOCK_FILES_CHANGED');
|
|
807
971
|
+ return true;
|
|
808
972
|
+ }
|
|
973
|
+
+ if (linkedPluginsChanged()) {
|
|
974
|
+
+ restartDaemon('LINKED_PLUGIN_CHANGED');
|
|
975
|
+
+ return true;
|
|
976
|
+
+ }
|
|
809
977
|
+ return false;
|
|
810
978
|
+}
|
|
811
979
|
+function isReplaced() {
|
|
@@ -826,7 +994,7 @@ index 0000000000000000000000000000000000000000..6adb712340b154dcabb7570bc1b4c586
|
|
|
826
994
|
+ (0, shutdown_utils_1.handleServerProcessTerminationWithRestart)({ server: daemon.server, reason, sockets: daemon.sockets });
|
|
827
995
|
+}
|
|
828
996
|
diff --git a/dist/src/daemon/server/server.js b/dist/src/daemon/server/server.js
|
|
829
|
-
index b1c143e244efd435b28642ed86e999d6c86f7d94..
|
|
997
|
+
index b1c143e244efd435b28642ed86e999d6c86f7d94..c68bcacb9bc46babaa86ea0ac212e79de1b47244 100644
|
|
830
998
|
--- a/dist/src/daemon/server/server.js
|
|
831
999
|
+++ b/dist/src/daemon/server/server.js
|
|
832
1000
|
@@ -7,17 +7,13 @@ const fs_1 = require("fs");
|
|
@@ -1011,8 +1179,8 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..5f1157fd3e37afc8ef739a8adce78a2b
|
|
|
1011
1179
|
+ process.exit(0);
|
|
1012
1180
|
+ }
|
|
1013
1181
|
+ (0, restart_checks_1.registerDaemonForRestartChecks)(server, exports.openSockets, socketPath);
|
|
1014
|
-
+ // Record before watch/scan so a lockfile changed during boot is not lost.
|
|
1015
|
-
+ (0, restart_checks_1.
|
|
1182
|
+
+ // Record before watch/scan so a lockfile or linked plugin changed during boot is not lost.
|
|
1183
|
+
+ (0, restart_checks_1.recordInstallationBaseline)();
|
|
1016
1184
|
// Watch before scan: a file written during boot must be visible to the
|
|
1017
1185
|
// watcher or the scan below. Scan-first left a blind window where such
|
|
1018
1186
|
// files stayed invisible to both until an unrelated change arrived.
|