@smoothbricks/nx-plugin 0.4.31 → 0.5.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/README.md +67 -46
- 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/ensure-built.d.ts.map +1 -1
- package/dist/ensure-built.js +14 -9
- package/dist/executors/bounded-exec/cpu-pool.d.ts +14 -7
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +297 -38
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +19 -7
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-tokens.js +21 -7
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +12 -6
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +5 -4
- 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/producer-receipts.d.ts +10 -0
- package/dist/producer-receipts.d.ts.map +1 -1
- package/dist/producer-receipts.js +30 -5
- 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 +47 -49
- package/managed/raw/tooling/direnv/linked-snapshots.ts +18 -8
- package/managed/raw/tooling/direnv/repo-path +1 -1
- package/managed/raw/tooling/git-hooks/pre-push.sh +41 -23
- package/package.json +1 -1
- package/src/__tests__/counted-cargo.ts +1 -1
- package/src/cargo-closure-input.test.ts +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/ensure-built.test.ts +39 -0
- package/src/ensure-built.ts +23 -9
- package/src/executors/bounded-exec/cpu-pool.test.ts +132 -4
- package/src/executors/bounded-exec/cpu-pool.ts +300 -46
- package/src/executors/bounded-exec/cpu-tokens.test.ts +60 -15
- package/src/executors/bounded-exec/cpu-tokens.ts +34 -11
- package/src/executors/bounded-exec/executor.test.ts +72 -4
- package/src/executors/bounded-exec/executor.ts +12 -6
- package/src/executors/bounded-exec/run-cpu-pool.test.ts +3 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +5 -4
- 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/producer-receipts.test.ts +37 -15
- package/src/producer-receipts.ts +29 -5
- 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.js
CHANGED
|
@@ -11,7 +11,7 @@ import { BOUNDED_TEST_IDLE_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
|
};
|
|
@@ -7,6 +7,16 @@ export interface ProducerReceiptsOptions {
|
|
|
7
7
|
readonly targets: readonly string[];
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Where a checkout keeps its producer records, relative to its root: in its own source tree, never in Nx's
|
|
12
|
+
* workspace-data. Under cowshed that directory is build state on the checkout's build volume
|
|
13
|
+
* (specs/cowshed/16_build_volumes.md), and a consumer's read grant of the provider checkout does not reach a volume
|
|
14
|
+
* the checkout only links to (specs/cowshed/04_sandbox.md, "Read grants have one narrow meaning"), so a consumer
|
|
15
|
+
* could never read the receipt it is asked to validate. The directory ignores itself (a `.gitignore` of `*` written
|
|
16
|
+
* with its first record), so in any checkout git never tracks a record and Nx's file walk never hashes one: a record
|
|
17
|
+
* is no source or input of the run that publishes it.
|
|
18
|
+
*/
|
|
19
|
+
export declare const PRODUCER_RECORDS: string;
|
|
10
20
|
export declare function completedProducerTasks(graph: TaskGraph, results: PostTasksExecutionContext['taskResults']): ReceiptEvidence<readonly Task[]>;
|
|
11
21
|
export declare function producerEnvironmentIdentity(inputs: EnsureBuiltProducerReceipt['inputs']): string;
|
|
12
22
|
export declare function preTasksExecution(options: ProducerReceiptsOptions | undefined, context: PreTasksExecutionContext): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"producer-receipts.d.ts","sourceRoot":"","sources":["../src/producer-receipts.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAEnH,OAAO,EAEL,KAAK,0BAA0B,EAE/B,KAAK,kBAAkB,EAIxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,2BAA2B,CAAC;AAUnC,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;CACrE;
|
|
1
|
+
{"version":3,"file":"producer-receipts.d.ts","sourceRoot":"","sources":["../src/producer-receipts.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAEnH,OAAO,EAEL,KAAK,0BAA0B,EAE/B,KAAK,kBAAkB,EAIxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,2BAA2B,CAAC;AAUnC,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;CACrE;AACD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,QAAsC,CAAC;AA2QpE,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,yBAAyB,CAAC,aAAa,CAAC,GAChD,eAAe,CAAC,SAAS,IAAI,EAAE,CAAC,CAqBlC;AACD,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,0BAA0B,CAAC,QAAQ,CAAC,GAAG,MAAM,CAShG;AACD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,uBAAuB,GAAG,SAAS,EAC5C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAyCf;AACD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,uBAAuB,GAAG,SAAS,EAC5C,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,IAAI,CAAC,CAoIf;AACD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAOrG"}
|
|
@@ -7,6 +7,16 @@ import { createWorkspaceNxRequire, parseTargetSelector, providerInputProof, sele
|
|
|
7
7
|
import { captureProducerSource, producerOutputPaths, providerReceipt, receiptNode, } from './ensure-built-receipt.js';
|
|
8
8
|
import { censusStart, graphInstallationIdentity, movedNodes, workspaceSnapshot, } from './ensure-built-witness.js';
|
|
9
9
|
import { graphInputContractIdentity } from './graph-input-contract.js';
|
|
10
|
+
/**
|
|
11
|
+
* Where a checkout keeps its producer records, relative to its root: in its own source tree, never in Nx's
|
|
12
|
+
* workspace-data. Under cowshed that directory is build state on the checkout's build volume
|
|
13
|
+
* (specs/cowshed/16_build_volumes.md), and a consumer's read grant of the provider checkout does not reach a volume
|
|
14
|
+
* the checkout only links to (specs/cowshed/04_sandbox.md, "Read grants have one narrow meaning"), so a consumer
|
|
15
|
+
* could never read the receipt it is asked to validate. The directory ignores itself (a `.gitignore` of `*` written
|
|
16
|
+
* with its first record), so in any checkout git never tracks a record and Nx's file walk never hashes one: a record
|
|
17
|
+
* is no source or input of the run that publishes it.
|
|
18
|
+
*/
|
|
19
|
+
export const PRODUCER_RECORDS = join('.cache', 'producer-receipts');
|
|
10
20
|
const runs = new Map();
|
|
11
21
|
function sha(value) {
|
|
12
22
|
return createHash('sha256').update(JSON.stringify(value)).digest('hex');
|
|
@@ -19,13 +29,15 @@ function configured(options) {
|
|
|
19
29
|
* its products never replaces the receipt an earlier run published: readers validate that receipt on its own evidence.
|
|
20
30
|
*/
|
|
21
31
|
function recordPath(root, target, disposition) {
|
|
22
|
-
|
|
23
|
-
return join(load('nx/src/utils/cache-directory').workspaceDataDirectoryForWorkspace(root), `producer-${disposition === 'published' ? 'receipt' : 'refusal'}-${sha(target)}.json`);
|
|
32
|
+
return join(root, PRODUCER_RECORDS, `producer-${disposition === 'published' ? 'receipt' : 'refusal'}-${sha(target)}.json`);
|
|
24
33
|
}
|
|
25
34
|
function publish(root, target, record) {
|
|
26
35
|
try {
|
|
27
36
|
const path = recordPath(root, target, record.disposition);
|
|
28
|
-
|
|
37
|
+
const records = dirname(path);
|
|
38
|
+
mkdirSync(records, { recursive: true });
|
|
39
|
+
if (!existsSync(join(records, '.gitignore')))
|
|
40
|
+
writeFileSync(join(records, '.gitignore'), '*\n');
|
|
29
41
|
const temporary = `${path}.${randomUUID()}`;
|
|
30
42
|
try {
|
|
31
43
|
writeFileSync(temporary, JSON.stringify(record), { flag: 'wx', mode: 0o600 });
|
|
@@ -443,6 +455,19 @@ function latestRefusal(root, target) {
|
|
|
443
455
|
}
|
|
444
456
|
}
|
|
445
457
|
function validatedReceipt(root, target) {
|
|
458
|
+
const path = recordPath(root, target, 'published');
|
|
459
|
+
let text;
|
|
460
|
+
try {
|
|
461
|
+
text = readFileSync(path, 'utf8');
|
|
462
|
+
}
|
|
463
|
+
catch (error) {
|
|
464
|
+
// No receipt is a producer that never published one; any other failure is a receipt this reader cannot reach.
|
|
465
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
|
|
466
|
+
return { ok: false, detail: `No producer completion receipt at ${path}` };
|
|
467
|
+
if (error instanceof Error)
|
|
468
|
+
return { ok: false, detail: `Cannot read producer completion receipt: ${error.message}` };
|
|
469
|
+
throw error;
|
|
470
|
+
}
|
|
446
471
|
try {
|
|
447
472
|
const record = (() => {
|
|
448
473
|
const _ip0 = (input, _vctx = {}) => 1 === input["version"];
|
|
@@ -863,9 +888,9 @@ function validatedReceipt(root, target) {
|
|
|
863
888
|
})();
|
|
864
889
|
const __is = (input, _vctx = {}) => "object" === typeof input && null !== input && _io0(input, _vctx);
|
|
865
890
|
return input => { input = JSON.parse(input); return __is(input) ? input : null; };
|
|
866
|
-
})()(
|
|
891
|
+
})()(text);
|
|
867
892
|
if (record === null || record.version !== 1)
|
|
868
|
-
return { ok: false, detail:
|
|
893
|
+
return { ok: false, detail: `Corrupt producer completion contract at ${path}` };
|
|
869
894
|
const receipt = record.receipt;
|
|
870
895
|
if (receipt.workspaceRoot !== realpathSync(root) ||
|
|
871
896
|
receipt.producer.version !== 1 ||
|
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,C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,eAAe,GAAG,MAAM,CAWjF;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,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",
|