@smoothbricks/nx-plugin 0.4.30 → 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 +36 -21
- 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/bounded-exec/cpu-tokens.d.ts +22 -5
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-tokens.js +189 -18
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +3 -2
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts +10 -0
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -0
- package/dist/executors/bounded-exec/run-cpu-pool.js +63 -0
- 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 +3 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -92
- 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/direnv/setup-environment.ts +13 -0
- package/managed/raw/tooling/git-hooks/pre-push.sh +41 -23
- package/package.json +1 -1
- package/src/cargo-closure-key.test.ts +3 -2
- 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/bounded-exec/cpu-tokens.test.ts +205 -0
- package/src/executors/bounded-exec/cpu-tokens.ts +229 -22
- package/src/executors/bounded-exec/executor.ts +3 -2
- package/src/executors/bounded-exec/run-cpu-pool.test.ts +76 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +75 -0
- 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 +41 -63
- package/src/index.ts +73 -101
- package/src/nx-daemon-validity.test.ts +65 -0
- package/src/testing.ts +3 -2
- package/test-timings.json +2 -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
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
3
|
+
import { chmod, copyFile, mkdir, rename } from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { createInterface } from 'node:readline';
|
|
6
|
+
import typia from 'typia';
|
|
7
|
+
|
|
8
|
+
import type { CargoZigbuildOptions } from './schema.js';
|
|
9
|
+
|
|
10
|
+
interface CargoZigbuildContext {
|
|
11
|
+
root: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The fields of cargo's `compiler-artifact` JSON message this executor reads.
|
|
16
|
+
* https://doc.rust-lang.org/cargo/reference/external-tools.html#artifact-messages
|
|
17
|
+
*/
|
|
18
|
+
export interface CargoArtifactMessage {
|
|
19
|
+
reason: 'compiler-artifact';
|
|
20
|
+
manifest_path: string;
|
|
21
|
+
target: { kind: string[]; name: string };
|
|
22
|
+
filenames: string[];
|
|
23
|
+
executable: string | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const validateReason = typia.createValidate<{ reason: string }>();
|
|
27
|
+
const validateArtifact = typia.createValidate<CargoArtifactMessage>();
|
|
28
|
+
|
|
29
|
+
/** What one build produces: a named binary, or the package's cdylib. */
|
|
30
|
+
export type ZigbuildArtifact = { kind: 'bin'; name: string } | { kind: 'cdylib' };
|
|
31
|
+
|
|
32
|
+
export function zigbuildArtifact(options: Pick<CargoZigbuildOptions, 'bin'>): ZigbuildArtifact {
|
|
33
|
+
return options.bin === undefined ? { kind: 'cdylib' } : { kind: 'bin', name: options.bin };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* `cargo-zigbuild zigbuild`, not `cargo zigbuild`. Run through cargo, the
|
|
38
|
+
* subcommand inherits `CARGO` naming the real cargo binary and calls it
|
|
39
|
+
* directly, bypassing the `cargo` on PATH; run directly, its inner `cargo` is
|
|
40
|
+
* the PATH one every other cargo target runs. `--locked` keeps Cargo.lock
|
|
41
|
+
* exactly as committed. The glibc suffix stays on `--target`: it is how
|
|
42
|
+
* cargo-zigbuild pins the symbol versions, and cargo itself sees the bare
|
|
43
|
+
* triple.
|
|
44
|
+
*/
|
|
45
|
+
export function zigbuildArgs(options: CargoZigbuildOptions, manifestPath: string): string[] {
|
|
46
|
+
const artifact = zigbuildArtifact(options);
|
|
47
|
+
return [
|
|
48
|
+
'zigbuild',
|
|
49
|
+
'--locked',
|
|
50
|
+
'--message-format=json-render-diagnostics',
|
|
51
|
+
'--target',
|
|
52
|
+
options.target,
|
|
53
|
+
'--manifest-path',
|
|
54
|
+
manifestPath,
|
|
55
|
+
'--package',
|
|
56
|
+
options.package,
|
|
57
|
+
...(options.release === true ? ['--release'] : []),
|
|
58
|
+
...(artifact.kind === 'bin' ? ['--bin', artifact.name] : ['--lib']),
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** `x86_64-unknown-linux-gnu.2.17` → `x86_64-unknown-linux-gnu`. */
|
|
63
|
+
export function cargoTriple(target: string): string {
|
|
64
|
+
const glibcSuffix = /\.\d+\.\d+$/.exec(target);
|
|
65
|
+
return glibcSuffix === null ? target : target.slice(0, glibcSuffix.index);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The environment without any compiler or linker named for this triple.
|
|
70
|
+
*
|
|
71
|
+
* cargo-zigbuild supplies the triple's `CC_`/`CXX_`/`AR_`/`RANLIB_` and
|
|
72
|
+
* linker only where none is set, and cc-rs reads the hyphenated spelling
|
|
73
|
+
* before cargo-zigbuild's underscored one. A shell that pins its host
|
|
74
|
+
* compiler for the same triple — a Linux devenv shell pins
|
|
75
|
+
* `CC_x86_64_unknown_linux_gnu` to Nix's cc wrapper for host builds — would
|
|
76
|
+
* otherwise compile the artifact's C against the build host's glibc headers,
|
|
77
|
+
* which is exactly the build-host leak the zig toolchain exists to remove.
|
|
78
|
+
*/
|
|
79
|
+
export function zigbuildEnv(env: NodeJS.ProcessEnv, target: string): NodeJS.ProcessEnv {
|
|
80
|
+
const triple = cargoTriple(target);
|
|
81
|
+
const underscored = triple.replaceAll('-', '_');
|
|
82
|
+
const owned = new Set([
|
|
83
|
+
...['CC', 'CXX', 'AR', 'RANLIB'].flatMap((tool) => [`${tool}_${triple}`, `${tool}_${underscored}`]),
|
|
84
|
+
`CARGO_TARGET_${underscored.toUpperCase()}_LINKER`,
|
|
85
|
+
]);
|
|
86
|
+
return Object.fromEntries(Object.entries(env).filter(([name]) => !owned.has(name)));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The artifact file one cargo JSON message names, or null when the message is
|
|
91
|
+
* about anything else. `manifestPath` must be canonical, as cargo reports it.
|
|
92
|
+
*/
|
|
93
|
+
export function artifactFile(line: string, manifestPath: string, artifact: ZigbuildArtifact): string | null {
|
|
94
|
+
if (!line.startsWith('{')) return null;
|
|
95
|
+
const parsed: unknown = JSON.parse(line);
|
|
96
|
+
const header = validateReason(parsed);
|
|
97
|
+
if (!header.success) {
|
|
98
|
+
throw new Error(`cargo emitted a JSON message without a reason: ${line}`);
|
|
99
|
+
}
|
|
100
|
+
if (header.data.reason !== 'compiler-artifact') return null;
|
|
101
|
+
const message = validateArtifact(parsed);
|
|
102
|
+
if (!message.success) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
`cargo compiler-artifact message does not match the artifact contract: ${JSON.stringify(message.errors)}`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
const { data } = message;
|
|
108
|
+
if (data.manifest_path !== manifestPath) return null;
|
|
109
|
+
if (artifact.kind === 'bin') {
|
|
110
|
+
return data.target.kind.includes('bin') && data.target.name === artifact.name ? data.executable : null;
|
|
111
|
+
}
|
|
112
|
+
if (!data.target.kind.includes('cdylib')) return null;
|
|
113
|
+
return data.filenames.find((file) => file.endsWith('.so')) ?? null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default async function cargoZigbuildExecutor(
|
|
117
|
+
options: CargoZigbuildOptions,
|
|
118
|
+
context: CargoZigbuildContext,
|
|
119
|
+
): Promise<{ success: boolean }> {
|
|
120
|
+
const manifestPath = realpathSync(path.resolve(context.root, options.manifestPath));
|
|
121
|
+
const output = path.resolve(context.root, options.output);
|
|
122
|
+
const artifact = zigbuildArtifact(options);
|
|
123
|
+
const args = zigbuildArgs(options, manifestPath);
|
|
124
|
+
const command = `cargo-zigbuild ${args.join(' ')}`;
|
|
125
|
+
|
|
126
|
+
// Cargo discovers `.cargo/config.toml` from its working directory upward,
|
|
127
|
+
// so the crate's own directory sees every config a build of it would.
|
|
128
|
+
const child = spawn('cargo-zigbuild', args, {
|
|
129
|
+
cwd: path.dirname(manifestPath),
|
|
130
|
+
env: zigbuildEnv(process.env, options.target),
|
|
131
|
+
stdio: ['ignore', 'pipe', 'inherit'],
|
|
132
|
+
});
|
|
133
|
+
const exited = new Promise<{ code: number | null; signal: NodeJS.Signals | null }>((resolve, reject) => {
|
|
134
|
+
child.once('error', reject);
|
|
135
|
+
child.once('close', (code, signal) => resolve({ code, signal }));
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
let built: string | null = null;
|
|
139
|
+
for await (const line of createInterface({ input: child.stdout })) {
|
|
140
|
+
built = artifactFile(line, manifestPath, artifact) ?? built;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let status: { code: number | null; signal: NodeJS.Signals | null };
|
|
144
|
+
try {
|
|
145
|
+
status = await exited;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
148
|
+
console.error(
|
|
149
|
+
`${command}: cargo-zigbuild is not on PATH. Linux artifacts build with the linux-cross toolchain; ` +
|
|
150
|
+
'on macOS run the target inside it: tooling/devenv -P linux-cross shell -- nx run <project>:<target>',
|
|
151
|
+
);
|
|
152
|
+
return { success: false };
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
if (status.code !== 0) {
|
|
157
|
+
console.error(`${command}: exited with ${status.signal ?? `status ${status.code}`}`);
|
|
158
|
+
return { success: false };
|
|
159
|
+
}
|
|
160
|
+
if (built === null) {
|
|
161
|
+
const wanted = artifact.kind === 'bin' ? `binary ${artifact.name}` : 'cdylib';
|
|
162
|
+
console.error(`${command}: cargo reported no ${wanted} artifact for ${options.package} at ${manifestPath}`);
|
|
163
|
+
return { success: false };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Copy then rename, so the output path never holds a partial file.
|
|
167
|
+
await mkdir(path.dirname(output), { recursive: true });
|
|
168
|
+
const staging = `${output}.partial`;
|
|
169
|
+
await copyFile(built, staging);
|
|
170
|
+
if (artifact.kind === 'bin') {
|
|
171
|
+
await chmod(staging, 0o755);
|
|
172
|
+
}
|
|
173
|
+
await rename(staging, output);
|
|
174
|
+
console.log(`${path.relative(context.root, built)} -> ${path.relative(context.root, output)}`);
|
|
175
|
+
return { success: true };
|
|
176
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"title": "Cargo Zigbuild Executor",
|
|
5
|
+
"description": "Build one Linux binary or cdylib with devenv's zig through `cargo-zigbuild` and copy it to its output file.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"target": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Rust target triple, with cargo-zigbuild's glibc suffix where it pins one, e.g. x86_64-unknown-linux-gnu.2.17 or x86_64-unknown-linux-musl."
|
|
11
|
+
},
|
|
12
|
+
"manifestPath": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The crate's Cargo.toml, relative to the workspace root."
|
|
15
|
+
},
|
|
16
|
+
"package": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Cargo package to build."
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Build this binary and copy its executable. Absent, build the package's cdylib."
|
|
23
|
+
},
|
|
24
|
+
"output": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Destination file for the artifact, relative to the workspace root."
|
|
27
|
+
},
|
|
28
|
+
"release": {
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"description": "Compile cargo's release profile instead of dev."
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"required": ["target", "manifestPath", "package", "output"],
|
|
34
|
+
"additionalProperties": false
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface CargoZigbuildOptions {
|
|
2
|
+
/** Rust target triple, with cargo-zigbuild's glibc suffix where it pins one: `x86_64-unknown-linux-gnu.2.17`. */
|
|
3
|
+
target: string;
|
|
4
|
+
/** The crate's Cargo.toml, relative to the workspace root. */
|
|
5
|
+
manifestPath: string;
|
|
6
|
+
/** Cargo package to build. */
|
|
7
|
+
package: string;
|
|
8
|
+
/** Build this binary and copy its executable; absent, build the package's cdylib. */
|
|
9
|
+
bin?: string;
|
|
10
|
+
/** Destination file for the artifact, relative to the workspace root. */
|
|
11
|
+
output: string;
|
|
12
|
+
/** Compile cargo's `release` profile instead of `dev`. */
|
|
13
|
+
release?: boolean;
|
|
14
|
+
}
|
package/src/index.test.ts
CHANGED
|
@@ -980,7 +980,12 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
980
980
|
expect(targets.test?.executor).toBe('nx:noop');
|
|
981
981
|
expect(targets.test?.dependsOn).toEqual(['cargo-test']);
|
|
982
982
|
expect(targets.mutation?.cache).toBe(false);
|
|
983
|
-
|
|
983
|
+
// On bounded-exec, so cargo-mutants' own per-core jobserver is sized to a CPU grant.
|
|
984
|
+
expect(targets.mutation?.executor).toBe('@smoothbricks/nx-plugin:bounded-exec');
|
|
985
|
+
expect(targets.mutation?.options).toMatchObject({
|
|
986
|
+
command: 'cargo --frozen mutants --workspace',
|
|
987
|
+
timeoutMs: 6 * 60 * 60 * 1000,
|
|
988
|
+
});
|
|
984
989
|
expect(targets.bench?.options).toMatchObject({ command: 'cargo --frozen bench --workspace' });
|
|
985
990
|
expectNoSchedulerThrottle(targets);
|
|
986
991
|
} finally {
|
|
@@ -1913,79 +1918,47 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
1913
1918
|
// nothing from it, and a platform target's dependency closure may only reach
|
|
1914
1919
|
// its own family (`validatePlatformTargetDependencies`).
|
|
1915
1920
|
expect(targets['napi-arm64-macos']?.dependsOn).toBeUndefined();
|
|
1916
|
-
//
|
|
1917
|
-
//
|
|
1918
|
-
//
|
|
1919
|
-
|
|
1920
|
-
//
|
|
1921
|
-
// inferring — on an x64 Linux runner `napi-x64-linux` is the native build,
|
|
1922
|
-
// with no `--use-napi-cross` and no toolchain prerequisite at all. Those
|
|
1923
|
-
// facts are asserted against forced platforms below instead of against
|
|
1924
|
-
// whichever machine happens to run the suite.
|
|
1925
|
-
|
|
1926
|
-
// Exercise both host branches explicitly: this suite usually runs on
|
|
1927
|
-
// Darwin, but Linux's native compiler selection is the contract at risk.
|
|
1921
|
+
// Every host infers the SAME Linux addon target: devenv's zig through the
|
|
1922
|
+
// cargo-zigbuild executor, glibc pinned by the triple suffix. There is no
|
|
1923
|
+
// native-versus-cross branch to diverge on, so forcing a Linux host and a
|
|
1924
|
+
// macOS host must yield byte-identical Linux targets, and neither may
|
|
1925
|
+
// carry a compiler environment or a toolchain prerequisite.
|
|
1928
1926
|
const linuxX64Targets = await inferProjectTargets(
|
|
1929
1927
|
workspace,
|
|
1930
1928
|
'packages/cowshed/package.json',
|
|
1931
1929
|
createNodesV2ForPlatform('linux', 'x64'),
|
|
1932
1930
|
);
|
|
1933
|
-
expect(linuxX64Targets['napi-x64-linux']?.options?.command).not.toContain('--use-napi-cross');
|
|
1934
|
-
expect(linuxX64Targets['napi-x64-linux']?.options?.env).toEqual({ CC: 'cc', CXX: 'c++' });
|
|
1935
|
-
expect(linuxX64Targets['napi-x64-linux']?.dependsOn).toBeUndefined();
|
|
1936
|
-
expect(linuxX64Targets['napi-toolchain-x64-linux']).toBeUndefined();
|
|
1937
|
-
expect(linuxX64Targets['napi-arm64-linux']?.options?.command).toContain('--use-napi-cross');
|
|
1938
|
-
expect(linuxX64Targets['napi-arm64-linux']?.options?.env).toEqual({
|
|
1939
|
-
TARGET_CC: 'clang',
|
|
1940
|
-
TARGET_CXX: 'clang++',
|
|
1941
|
-
});
|
|
1942
|
-
expect(linuxX64Targets['napi-debug']?.options?.env).toEqual({ CC: 'cc', CXX: 'c++' });
|
|
1943
|
-
|
|
1944
1931
|
const darwinArm64Targets = await inferProjectTargets(
|
|
1945
1932
|
workspace,
|
|
1946
1933
|
'packages/cowshed/package.json',
|
|
1947
1934
|
createNodesV2ForPlatform('darwin', 'arm64'),
|
|
1948
1935
|
);
|
|
1949
|
-
expect(darwinArm64Targets['napi-x64-linux']
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1936
|
+
expect(darwinArm64Targets['napi-x64-linux']).toMatchObject({
|
|
1937
|
+
executor: '@smoothbricks/nx-plugin:cargo-zigbuild',
|
|
1938
|
+
cache: true,
|
|
1939
|
+
outputs: ['{projectRoot}/dist/native/linux-x64-gnu'],
|
|
1940
|
+
options: {
|
|
1941
|
+
target: 'x86_64-unknown-linux-gnu.2.17',
|
|
1942
|
+
manifestPath: 'packages/cowshed/crates/cowshed-napi/Cargo.toml',
|
|
1943
|
+
package: 'cowshed-napi',
|
|
1944
|
+
output: '{projectRoot}/dist/native/linux-x64-gnu/cowshed.linux-x64-gnu.node',
|
|
1945
|
+
},
|
|
1946
|
+
configurations: { [RELEASE_CONFIGURATION]: { release: true } },
|
|
1960
1947
|
});
|
|
1961
|
-
expect(darwinArm64Targets['napi-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
options: { triple: 'x86_64-unknown-linux-gnu' },
|
|
1948
|
+
expect(darwinArm64Targets['napi-arm64-linux']?.options).toMatchObject({
|
|
1949
|
+
target: 'aarch64-unknown-linux-gnu.2.17',
|
|
1950
|
+
output: '{projectRoot}/dist/native/linux-arm64-gnu/cowshed.linux-arm64-gnu.node',
|
|
1965
1951
|
});
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
)
|
|
1971
|
-
|
|
1972
|
-
'napi
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
// toolchain exactly when it is a linux triple that is not this host's own.
|
|
1977
|
-
// Asserting the pair by name is what broke on Linux, where
|
|
1978
|
-
// napi-toolchain-x64-linux legitimately does not exist.
|
|
1979
|
-
for (const [inferred, hostTriple] of [
|
|
1980
|
-
[linuxX64Targets, 'x64-linux'],
|
|
1981
|
-
[darwinArm64Targets, 'arm64-macos'],
|
|
1982
|
-
] as const) {
|
|
1983
|
-
for (const suffix of ['arm64-linux', 'x64-linux', 'arm64-macos', 'x64-macos']) {
|
|
1984
|
-
const expectsToolchain = suffix.endsWith('-linux') && suffix !== hostTriple;
|
|
1985
|
-
expect(inferred[`napi-toolchain-${suffix}`] === undefined).toBe(!expectsToolchain);
|
|
1986
|
-
expect(inferred[`napi-${suffix}`]?.options?.command).toContain(
|
|
1987
|
-
expectsToolchain ? '--use-napi-cross' : '--target',
|
|
1988
|
-
);
|
|
1952
|
+
for (const suffix of ['arm64-linux', 'x64-linux']) {
|
|
1953
|
+
expect(linuxX64Targets[`napi-${suffix}`]).toEqual(darwinArm64Targets[`napi-${suffix}`]);
|
|
1954
|
+
expect(darwinArm64Targets[`napi-${suffix}`]?.dependsOn).toBeUndefined();
|
|
1955
|
+
}
|
|
1956
|
+
for (const inferred of [linuxX64Targets, darwinArm64Targets]) {
|
|
1957
|
+
expect(Object.keys(inferred).filter((name) => name.startsWith('napi-toolchain-'))).toEqual([]);
|
|
1958
|
+
expect(inferred['napi-debug']?.options?.env).toBeUndefined();
|
|
1959
|
+
for (const suffix of ['arm64-macos', 'x64-macos']) {
|
|
1960
|
+
expect(inferred[`napi-${suffix}`]?.options?.command).toContain('napi build');
|
|
1961
|
+
expect(inferred[`napi-${suffix}`]?.options?.env).toBeUndefined();
|
|
1989
1962
|
}
|
|
1990
1963
|
}
|
|
1991
1964
|
// The aggregate build pulls in exactly the inferring host's
|
|
@@ -2698,7 +2671,12 @@ describe('@smoothbricks/nx-plugin inferred targets', () => {
|
|
|
2698
2671
|
|
|
2699
2672
|
// `options` merges key by key, so a declared command overrides only itself.
|
|
2700
2673
|
const mutation = resolveDeclaredOverInferred(targets, declared, 'mutation');
|
|
2701
|
-
expect(mutation?.options).toEqual({
|
|
2674
|
+
expect(mutation?.options).toEqual({
|
|
2675
|
+
command: 'cargo mutants --in-diff',
|
|
2676
|
+
cwd: 'packages/ferris',
|
|
2677
|
+
timeoutMs: 6 * 60 * 60 * 1000,
|
|
2678
|
+
});
|
|
2679
|
+
expect(mutation?.executor).toBe('@smoothbricks/nx-plugin:bounded-exec');
|
|
2702
2680
|
expect(mutation?.cache).toBe(false);
|
|
2703
2681
|
|
|
2704
2682
|
const bench = resolveDeclaredOverInferred(targets, declared, 'bench');
|