@convesoft/nx-rust 0.0.0 → 1.0.0-rc.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/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +47 -1
- package/executors.json +35 -0
- package/generators.json +19 -0
- package/package.json +17 -4
- package/src/cargo/build-settings.d.ts +54 -0
- package/src/cargo/build-settings.js +93 -0
- package/src/cargo/build-settings.js.map +1 -0
- package/src/cargo/configured-runner.d.ts +36 -0
- package/src/cargo/configured-runner.js +99 -0
- package/src/cargo/configured-runner.js.map +1 -0
- package/src/cargo/configured-tools.d.ts +35 -0
- package/src/cargo/configured-tools.js +46 -0
- package/src/cargo/configured-tools.js.map +1 -0
- package/src/cargo/dep-info-basedir.d.ts +18 -0
- package/src/cargo/dep-info-basedir.js +38 -0
- package/src/cargo/dep-info-basedir.js.map +1 -0
- package/src/cargo/directories.d.ts +40 -0
- package/src/cargo/directories.js +89 -0
- package/src/cargo/directories.js.map +1 -0
- package/src/cargo/host-triple.d.ts +7 -0
- package/src/cargo/host-triple.js +21 -0
- package/src/cargo/host-triple.js.map +1 -0
- package/src/cargo/lockfile.d.ts +63 -0
- package/src/cargo/lockfile.js +157 -0
- package/src/cargo/lockfile.js.map +1 -0
- package/src/cargo/metadata.d.ts +112 -0
- package/src/cargo/metadata.js +37 -0
- package/src/cargo/metadata.js.map +1 -0
- package/src/cargo/package-specs.d.ts +54 -0
- package/src/cargo/package-specs.js +109 -0
- package/src/cargo/package-specs.js.map +1 -0
- package/src/cargo/paths-crates.d.ts +27 -0
- package/src/cargo/paths-crates.js +69 -0
- package/src/cargo/paths-crates.js.map +1 -0
- package/src/cargo/print-artifact-folders.d.ts +1 -0
- package/src/cargo/print-artifact-folders.js +58 -0
- package/src/cargo/print-artifact-folders.js.map +1 -0
- package/src/cargo/redirections.d.ts +87 -0
- package/src/cargo/redirections.js +195 -0
- package/src/cargo/redirections.js.map +1 -0
- package/src/cargo/run-cargo.d.ts +31 -0
- package/src/cargo/run-cargo.js +75 -0
- package/src/cargo/run-cargo.js.map +1 -0
- package/src/cargo/target-triples.d.ts +98 -0
- package/src/cargo/target-triples.js +265 -0
- package/src/cargo/target-triples.js.map +1 -0
- package/src/cargo/version-req.d.ts +12 -0
- package/src/cargo/version-req.js +122 -0
- package/src/cargo/version-req.js.map +1 -0
- package/src/compatibility/cargo-version.d.ts +43 -0
- package/src/compatibility/cargo-version.js +83 -0
- package/src/compatibility/cargo-version.js.map +1 -0
- package/src/compatibility/nx-bridge.d.ts +312 -0
- package/src/compatibility/nx-bridge.js +407 -0
- package/src/compatibility/nx-bridge.js.map +1 -0
- package/src/compatibility/nx-version.d.ts +104 -0
- package/src/compatibility/nx-version.js +272 -0
- package/src/compatibility/nx-version.js.map +1 -0
- package/src/executors/affected-inputs.d.ts +29 -0
- package/src/executors/affected-inputs.js +259 -0
- package/src/executors/affected-inputs.js.map +1 -0
- package/src/executors/affected-run.d.ts +54 -0
- package/src/executors/affected-run.js +394 -0
- package/src/executors/affected-run.js.map +1 -0
- package/src/executors/affected.d.ts +239 -0
- package/src/executors/affected.js +589 -0
- package/src/executors/affected.js.map +1 -0
- package/src/executors/baseline-context.d.ts +85 -0
- package/src/executors/baseline-context.js +227 -0
- package/src/executors/baseline-context.js.map +1 -0
- package/src/executors/baseline.d.ts +123 -0
- package/src/executors/baseline.js +356 -0
- package/src/executors/baseline.js.map +1 -0
- package/src/executors/batch.d.ts +75 -0
- package/src/executors/batch.js +434 -0
- package/src/executors/batch.js.map +1 -0
- package/src/executors/build-records.d.ts +110 -0
- package/src/executors/build-records.js +267 -0
- package/src/executors/build-records.js.map +1 -0
- package/src/executors/cargo/executor.d.ts +28 -0
- package/src/executors/cargo/executor.js +58 -0
- package/src/executors/cargo/executor.js.map +1 -0
- package/src/executors/cargo/schema.json +54 -0
- package/src/executors/cargo-invocation.d.ts +81 -0
- package/src/executors/cargo-invocation.js +109 -0
- package/src/executors/cargo-invocation.js.map +1 -0
- package/src/executors/cargo-output.d.ts +212 -0
- package/src/executors/cargo-output.js +646 -0
- package/src/executors/cargo-output.js.map +1 -0
- package/src/executors/command.d.ts +318 -0
- package/src/executors/command.js +517 -0
- package/src/executors/command.js.map +1 -0
- package/src/executors/coverage-baseline.d.ts +23 -0
- package/src/executors/coverage-baseline.js +284 -0
- package/src/executors/coverage-baseline.js.map +1 -0
- package/src/executors/declared-options.d.ts +21 -0
- package/src/executors/declared-options.js +58 -0
- package/src/executors/declared-options.js.map +1 -0
- package/src/executors/digests.d.ts +94 -0
- package/src/executors/digests.js +190 -0
- package/src/executors/digests.js.map +1 -0
- package/src/executors/dotenv-check.d.ts +79 -0
- package/src/executors/dotenv-check.js +553 -0
- package/src/executors/dotenv-check.js.map +1 -0
- package/src/executors/group-invocations.d.ts +80 -0
- package/src/executors/group-invocations.js +253 -0
- package/src/executors/group-invocations.js.map +1 -0
- package/src/executors/group-run.d.ts +114 -0
- package/src/executors/group-run.js +591 -0
- package/src/executors/group-run.js.map +1 -0
- package/src/executors/groups.d.ts +113 -0
- package/src/executors/groups.js +285 -0
- package/src/executors/groups.js.map +1 -0
- package/src/executors/input-check.d.ts +52 -0
- package/src/executors/input-check.js +271 -0
- package/src/executors/input-check.js.map +1 -0
- package/src/executors/kept-files.d.ts +98 -0
- package/src/executors/kept-files.js +341 -0
- package/src/executors/kept-files.js.map +1 -0
- package/src/executors/lockfile/executor.d.ts +16 -0
- package/src/executors/lockfile/executor.js +37 -0
- package/src/executors/lockfile/executor.js.map +1 -0
- package/src/executors/lockfile/schema.json +50 -0
- package/src/executors/napi-build.d.ts +73 -0
- package/src/executors/napi-build.js +420 -0
- package/src/executors/napi-build.js.map +1 -0
- package/src/executors/nextest.d.ts +185 -0
- package/src/executors/nextest.js +498 -0
- package/src/executors/nextest.js.map +1 -0
- package/src/executors/nx-command.d.ts +95 -0
- package/src/executors/nx-command.js +205 -0
- package/src/executors/nx-command.js.map +1 -0
- package/src/executors/nx-task-files.d.ts +82 -0
- package/src/executors/nx-task-files.js +156 -0
- package/src/executors/nx-task-files.js.map +1 -0
- package/src/executors/print-test-mode.d.ts +1 -0
- package/src/executors/print-test-mode.js +25 -0
- package/src/executors/print-test-mode.js.map +1 -0
- package/src/executors/release-publish/executor.d.ts +24 -0
- package/src/executors/release-publish/executor.js +165 -0
- package/src/executors/release-publish/executor.js.map +1 -0
- package/src/executors/release-publish/schema.json +30 -0
- package/src/executors/run/executor.d.ts +12 -0
- package/src/executors/run/executor.js +27 -0
- package/src/executors/run/executor.js.map +1 -0
- package/src/executors/run/schema.json +45 -0
- package/src/executors/runner-script.d.ts +12 -0
- package/src/executors/runner-script.js +22 -0
- package/src/executors/runner-script.js.map +1 -0
- package/src/executors/runtime-input-check.d.ts +24 -0
- package/src/executors/runtime-input-check.js +87 -0
- package/src/executors/runtime-input-check.js.map +1 -0
- package/src/executors/shared-artifacts.d.ts +44 -0
- package/src/executors/shared-artifacts.js +132 -0
- package/src/executors/shared-artifacts.js.map +1 -0
- package/src/executors/split-words.d.ts +24 -0
- package/src/executors/split-words.js +111 -0
- package/src/executors/split-words.js.map +1 -0
- package/src/executors/stage.d.ts +163 -0
- package/src/executors/stage.js +526 -0
- package/src/executors/stage.js.map +1 -0
- package/src/executors/staged-run.d.ts +24 -0
- package/src/executors/staged-run.js +110 -0
- package/src/executors/staged-run.js.map +1 -0
- package/src/executors/task-env.d.ts +271 -0
- package/src/executors/task-env.js +494 -0
- package/src/executors/task-env.js.map +1 -0
- package/src/executors/task-execution.d.ts +61 -0
- package/src/executors/task-execution.js +122 -0
- package/src/executors/task-execution.js.map +1 -0
- package/src/executors/task-guards.d.ts +112 -0
- package/src/executors/task-guards.js +430 -0
- package/src/executors/task-guards.js.map +1 -0
- package/src/executors/task-options.d.ts +114 -0
- package/src/executors/task-options.js +258 -0
- package/src/executors/task-options.js.map +1 -0
- package/src/executors/task.d.ts +166 -0
- package/src/executors/task.js +520 -0
- package/src/executors/task.js.map +1 -0
- package/src/executors/test-mode.d.ts +182 -0
- package/src/executors/test-mode.js +391 -0
- package/src/executors/test-mode.js.map +1 -0
- package/src/executors/test-runner.d.ts +44 -0
- package/src/executors/test-runner.js +159 -0
- package/src/executors/test-runner.js.map +1 -0
- package/src/executors/test-steps.d.ts +109 -0
- package/src/executors/test-steps.js +535 -0
- package/src/executors/test-steps.js.map +1 -0
- package/src/executors/wasm-build.d.ts +56 -0
- package/src/executors/wasm-build.js +216 -0
- package/src/executors/wasm-build.js.map +1 -0
- package/src/generators/crate/binary.schema.json +28 -0
- package/src/generators/crate/crate.d.ts +24 -0
- package/src/generators/crate/crate.js +108 -0
- package/src/generators/crate/crate.js.map +1 -0
- package/src/generators/crate/enclosing-workspace.d.ts +25 -0
- package/src/generators/crate/enclosing-workspace.js +58 -0
- package/src/generators/crate/enclosing-workspace.js.map +1 -0
- package/src/generators/crate/library.schema.json +28 -0
- package/src/generators/init/graph-check.d.ts +81 -0
- package/src/generators/init/graph-check.js +299 -0
- package/src/generators/init/graph-check.js.map +1 -0
- package/src/generators/init/init.d.ts +23 -0
- package/src/generators/init/init.js +113 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/report.d.ts +19 -0
- package/src/generators/init/report.js +93 -0
- package/src/generators/init/report.js.map +1 -0
- package/src/generators/init/schema.json +9 -0
- package/src/graph/artifact-kinds.d.ts +29 -0
- package/src/graph/artifact-kinds.js +50 -0
- package/src/graph/artifact-kinds.js.map +1 -0
- package/src/graph/artifact-names.d.ts +97 -0
- package/src/graph/artifact-names.js +276 -0
- package/src/graph/artifact-names.js.map +1 -0
- package/src/graph/build-records.d.ts +74 -0
- package/src/graph/build-records.js +104 -0
- package/src/graph/build-records.js.map +1 -0
- package/src/graph/caching.d.ts +148 -0
- package/src/graph/caching.js +676 -0
- package/src/graph/caching.js.map +1 -0
- package/src/graph/collisions.d.ts +106 -0
- package/src/graph/collisions.js +156 -0
- package/src/graph/collisions.js.map +1 -0
- package/src/graph/computation-reports.d.ts +89 -0
- package/src/graph/computation-reports.js +216 -0
- package/src/graph/computation-reports.js.map +1 -0
- package/src/graph/declared-files.d.ts +190 -0
- package/src/graph/declared-files.js +600 -0
- package/src/graph/declared-files.js.map +1 -0
- package/src/graph/discovery.d.ts +175 -0
- package/src/graph/discovery.js +656 -0
- package/src/graph/discovery.js.map +1 -0
- package/src/graph/edges.d.ts +25 -0
- package/src/graph/edges.js +94 -0
- package/src/graph/edges.js.map +1 -0
- package/src/graph/entries.d.ts +83 -0
- package/src/graph/entries.js +259 -0
- package/src/graph/entries.js.map +1 -0
- package/src/graph/inputs.d.ts +420 -0
- package/src/graph/inputs.js +746 -0
- package/src/graph/inputs.js.map +1 -0
- package/src/graph/lockfile-task.d.ts +74 -0
- package/src/graph/lockfile-task.js +105 -0
- package/src/graph/lockfile-task.js.map +1 -0
- package/src/graph/names.d.ts +41 -0
- package/src/graph/names.js +34 -0
- package/src/graph/names.js.map +1 -0
- package/src/graph/napi.d.ts +107 -0
- package/src/graph/napi.js +206 -0
- package/src/graph/napi.js.map +1 -0
- package/src/graph/nx-glob.d.ts +36 -0
- package/src/graph/nx-glob.js +152 -0
- package/src/graph/nx-glob.js.map +1 -0
- package/src/graph/nx-internals.d.ts +57 -0
- package/src/graph/nx-internals.js +128 -0
- package/src/graph/nx-internals.js.map +1 -0
- package/src/graph/options.d.ts +32 -0
- package/src/graph/options.js +80 -0
- package/src/graph/options.js.map +1 -0
- package/src/graph/outputs.d.ts +75 -0
- package/src/graph/outputs.js +140 -0
- package/src/graph/outputs.js.map +1 -0
- package/src/graph/path-dependencies.d.ts +122 -0
- package/src/graph/path-dependencies.js +459 -0
- package/src/graph/path-dependencies.js.map +1 -0
- package/src/graph/plugin-package.d.ts +36 -0
- package/src/graph/plugin-package.js +132 -0
- package/src/graph/plugin-package.js.map +1 -0
- package/src/graph/plugin-version.d.ts +20 -0
- package/src/graph/plugin-version.js +153 -0
- package/src/graph/plugin-version.js.map +1 -0
- package/src/graph/projects.d.ts +141 -0
- package/src/graph/projects.js +182 -0
- package/src/graph/projects.js.map +1 -0
- package/src/graph/reached-projects.d.ts +46 -0
- package/src/graph/reached-projects.js +102 -0
- package/src/graph/reached-projects.js.map +1 -0
- package/src/graph/real-path.d.ts +47 -0
- package/src/graph/real-path.js +113 -0
- package/src/graph/real-path.js.map +1 -0
- package/src/graph/redirected-uses.d.ts +98 -0
- package/src/graph/redirected-uses.js +434 -0
- package/src/graph/redirected-uses.js.map +1 -0
- package/src/graph/registration.d.ts +121 -0
- package/src/graph/registration.js +233 -0
- package/src/graph/registration.js.map +1 -0
- package/src/graph/script-input.d.ts +46 -0
- package/src/graph/script-input.js +65 -0
- package/src/graph/script-input.js.map +1 -0
- package/src/graph/settings.d.ts +178 -0
- package/src/graph/settings.js +479 -0
- package/src/graph/settings.js.map +1 -0
- package/src/graph/target-defaults-causes.d.ts +33 -0
- package/src/graph/target-defaults-causes.js +202 -0
- package/src/graph/target-defaults-causes.js.map +1 -0
- package/src/graph/target-defaults-layers.d.ts +186 -0
- package/src/graph/target-defaults-layers.js +420 -0
- package/src/graph/target-defaults-layers.js.map +1 -0
- package/src/graph/target-defaults-meaning.d.ts +95 -0
- package/src/graph/target-defaults-meaning.js +292 -0
- package/src/graph/target-defaults-meaning.js.map +1 -0
- package/src/graph/target-defaults-report.d.ts +77 -0
- package/src/graph/target-defaults-report.js +242 -0
- package/src/graph/target-defaults-report.js.map +1 -0
- package/src/graph/target-defaults.d.ts +79 -0
- package/src/graph/target-defaults.js +425 -0
- package/src/graph/target-defaults.js.map +1 -0
- package/src/graph/target-fields.d.ts +16 -0
- package/src/graph/target-fields.js +134 -0
- package/src/graph/target-fields.js.map +1 -0
- package/src/graph/target-tables.d.ts +45 -0
- package/src/graph/target-tables.js +299 -0
- package/src/graph/target-tables.js.map +1 -0
- package/src/graph/targets.d.ts +367 -0
- package/src/graph/targets.js +404 -0
- package/src/graph/targets.js.map +1 -0
- package/src/graph/unification.d.ts +141 -0
- package/src/graph/unification.js +459 -0
- package/src/graph/unification.js.map +1 -0
- package/src/graph/unignored-directories.d.ts +25 -0
- package/src/graph/unignored-directories.js +89 -0
- package/src/graph/unignored-directories.js.map +1 -0
- package/src/graph/visibility.d.ts +17 -0
- package/src/graph/visibility.js +67 -0
- package/src/graph/visibility.js.map +1 -0
- package/src/graph/warnings.d.ts +38 -0
- package/src/graph/warnings.js +77 -0
- package/src/graph/warnings.js.map +1 -0
- package/src/graph/wasm.d.ts +56 -0
- package/src/graph/wasm.js +77 -0
- package/src/graph/wasm.js.map +1 -0
- package/src/index.d.ts +68 -0
- package/src/index.js +109 -0
- package/src/index.js.map +1 -0
- package/src/release/manifests.d.ts +95 -0
- package/src/release/manifests.js +164 -0
- package/src/release/manifests.js.map +1 -0
- package/src/release/places.d.ts +127 -0
- package/src/release/places.js +368 -0
- package/src/release/places.js.map +1 -0
- package/src/release/publish-cargo.d.ts +177 -0
- package/src/release/publish-cargo.js +351 -0
- package/src/release/publish-cargo.js.map +1 -0
- package/src/release/publish-crates.d.ts +124 -0
- package/src/release/publish-crates.js +242 -0
- package/src/release/publish-crates.js.map +1 -0
- package/src/release/publish-environments.d.ts +50 -0
- package/src/release/publish-environments.js +284 -0
- package/src/release/publish-environments.js.map +1 -0
- package/src/release/publish-messages.d.ts +66 -0
- package/src/release/publish-messages.js +273 -0
- package/src/release/publish-messages.js.map +1 -0
- package/src/release/publish-registry.d.ts +27 -0
- package/src/release/publish-registry.js +135 -0
- package/src/release/publish-registry.js.map +1 -0
- package/src/release/publish-settings.d.ts +26 -0
- package/src/release/publish-settings.js +56 -0
- package/src/release/publish-settings.js.map +1 -0
- package/src/release/publish.d.ts +59 -0
- package/src/release/publish.js +620 -0
- package/src/release/publish.js.map +1 -0
- package/src/release/repository.d.ts +73 -0
- package/src/release/repository.js +219 -0
- package/src/release/repository.js.map +1 -0
- package/src/release/requirements.d.ts +34 -0
- package/src/release/requirements.js +30 -0
- package/src/release/requirements.js.map +1 -0
- package/src/release/toml-edit.d.ts +67 -0
- package/src/release/toml-edit.js +453 -0
- package/src/release/toml-edit.js.map +1 -0
- package/src/release/version-actions.d.ts +133 -0
- package/src/release/version-actions.js +474 -0
- package/src/release/version-actions.js.map +1 -0
- package/src/release/version-checks.d.ts +21 -0
- package/src/release/version-checks.js +151 -0
- package/src/release/version-checks.js.map +1 -0
- package/src/release/version-lockfiles.d.ts +61 -0
- package/src/release/version-lockfiles.js +222 -0
- package/src/release/version-lockfiles.js.map +1 -0
- package/src/tools/napi-cli.d.ts +70 -0
- package/src/tools/napi-cli.js +63 -0
- package/src/tools/napi-cli.js.map +1 -0
- package/src/tools/optional-tools.d.ts +121 -0
- package/src/tools/optional-tools.js +303 -0
- package/src/tools/optional-tools.js.map +1 -0
- package/src/tools/print-napi-cli.d.ts +1 -0
- package/src/tools/print-napi-cli.js +24 -0
- package/src/tools/print-napi-cli.js.map +1 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.profileFolder = profileFolder;
|
|
4
|
+
exports.enabledFeatures = enabledFeatures;
|
|
5
|
+
exports.callTriples = callTriples;
|
|
6
|
+
exports.nameRecords = nameRecords;
|
|
7
|
+
exports.parseRecord = parseRecord;
|
|
8
|
+
exports.libraryRecordNames = libraryRecordNames;
|
|
9
|
+
const node_fs_1 = require("node:fs");
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const target_triples_1 = require("../cargo/target-triples");
|
|
12
|
+
const build_records_1 = require("../graph/build-records");
|
|
13
|
+
/**
|
|
14
|
+
* The folder that cargo gives a profile's artifacts: `debug` for `dev` and
|
|
15
|
+
* `test`, `release` for `release` and `bench`, and the profile's own name for
|
|
16
|
+
* any other, also one that inherits from those four.
|
|
17
|
+
*/
|
|
18
|
+
function profileFolder(profile) {
|
|
19
|
+
switch (profile) {
|
|
20
|
+
case undefined:
|
|
21
|
+
case "":
|
|
22
|
+
case "dev":
|
|
23
|
+
case "test":
|
|
24
|
+
return "debug";
|
|
25
|
+
case "release":
|
|
26
|
+
case "bench":
|
|
27
|
+
return "release";
|
|
28
|
+
default:
|
|
29
|
+
return profile;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The features of the crate that a selection turns on, as cargo resolves
|
|
34
|
+
* them: all of them with `--all-features`, otherwise `default` unless
|
|
35
|
+
* `--no-default-features`, and those that `--features` names, a
|
|
36
|
+
* `<package>/<feature>` entry for the crate itself included; then, to any
|
|
37
|
+
* depth, what each turned-on feature turns on. A plain entry turns on the
|
|
38
|
+
* feature it names. A `<dependency>/<feature>` entry also turns on the
|
|
39
|
+
* crate's feature of the dependency's name where the dependency is
|
|
40
|
+
* optional, as cargo does for the implicit feature of an optional
|
|
41
|
+
* dependency; `dep:<name>` and the weak `<dependency>?/<feature>` turn on
|
|
42
|
+
* no feature of the crate. An optional dependency that a platform limits
|
|
43
|
+
* counts as required, since cargo matches it only on that platform: a binary
|
|
44
|
+
* that only it would turn on then stays unnamed and unchecked rather than
|
|
45
|
+
* read from a record that cargo may not have written.
|
|
46
|
+
*
|
|
47
|
+
* @param optionalDependencies The names under which the crate lists its
|
|
48
|
+
* optional dependencies that no platform limits.
|
|
49
|
+
*/
|
|
50
|
+
function enabledFeatures(packageName, table, selection, optionalDependencies = []) {
|
|
51
|
+
var _a;
|
|
52
|
+
const features = new Map(Object.entries(table));
|
|
53
|
+
const optional = new Set(optionalDependencies);
|
|
54
|
+
const queue = [];
|
|
55
|
+
if (selection.allFeatures === true) {
|
|
56
|
+
queue.push(...features.keys());
|
|
57
|
+
}
|
|
58
|
+
else if (selection.noDefaultFeatures !== true) {
|
|
59
|
+
queue.push("default");
|
|
60
|
+
}
|
|
61
|
+
const own = `${packageName}/`;
|
|
62
|
+
for (const entry of ((_a = selection.features) !== null && _a !== void 0 ? _a : []).flatMap((value) => value.split(/[\s,]+/))) {
|
|
63
|
+
queue.push(entry.startsWith(own) ? entry.slice(own.length) : entry);
|
|
64
|
+
}
|
|
65
|
+
const enabled = new Set();
|
|
66
|
+
while (queue.length > 0) {
|
|
67
|
+
const feature = turnedOnFeature(queue.pop(), optional);
|
|
68
|
+
const enables = feature === undefined ? undefined : features.get(feature);
|
|
69
|
+
if (feature === undefined || enables === undefined || enabled.has(feature)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
enabled.add(feature);
|
|
73
|
+
queue.push(...enables);
|
|
74
|
+
}
|
|
75
|
+
return enabled;
|
|
76
|
+
}
|
|
77
|
+
// The feature of the crate that a feature entry turns on, if any: the one
|
|
78
|
+
// it names, or for `<dependency>/<feature>` that of an optional dependency's
|
|
79
|
+
// name; none for `dep:<name>` and the weak `<dependency>?/<feature>`.
|
|
80
|
+
function turnedOnFeature(entry, optional) {
|
|
81
|
+
if (entry === "" || entry.startsWith("dep:")) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
const slash = entry.indexOf("/");
|
|
85
|
+
if (slash === -1) {
|
|
86
|
+
return entry;
|
|
87
|
+
}
|
|
88
|
+
const dependency = entry.slice(0, slash);
|
|
89
|
+
return optional.has(dependency) ? dependency : undefined;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The triples that the call builds for (`DES-BUILD-INPUT-CHECK`, point 1):
|
|
93
|
+
* the task's own triple, or else those that `build.target` in the
|
|
94
|
+
* configuration files that cargo reads in `workspaceRoot` and
|
|
95
|
+
* `CARGO_BUILD_TARGET` in the task's environment pick, read as for the
|
|
96
|
+
* outputs of `build` ({@link pickedTriples}, `DES-OUTPUTS`). Where `host`
|
|
97
|
+
* is given, `host-tuple`, in the option or the configuration, stands for
|
|
98
|
+
* it, as cargo replaces it.
|
|
99
|
+
*/
|
|
100
|
+
function callTriples(selection, env, workspaceRoot, host) {
|
|
101
|
+
const triple = selection.targetTriple;
|
|
102
|
+
if (typeof triple === "string" && triple !== "") {
|
|
103
|
+
return {
|
|
104
|
+
kind: "triples",
|
|
105
|
+
triples: [triple === "host-tuple" && host !== undefined ? host : triple],
|
|
106
|
+
files: [],
|
|
107
|
+
fromEnv: false,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return (0, target_triples_1.pickedTriples)(workspaceRoot, env, host);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The records that `cargo build -p <crate>` exports for a call with this
|
|
114
|
+
* selection, named from what graph creation reported, without asking cargo
|
|
115
|
+
* (`DES-BUILD-INPUT-CHECK`, point 1): those of {@link libraryRecordNames}
|
|
116
|
+
* for the library and
|
|
117
|
+
* `<name>.d` for each binary whose required features are all features of the
|
|
118
|
+
* crate that the selection turns on ({@link enabledFeatures}), in `<artifact directory>/<profile folder>`,
|
|
119
|
+
* or in `<artifact directory>/<triple>/<profile folder>` for each triple that
|
|
120
|
+
* the call builds for ({@link callTriples}); a proc macro's library record
|
|
121
|
+
* stays in the profile folder whatever the triple. For an empty list of
|
|
122
|
+
* triples, cargo builds nothing, and no record is named.
|
|
123
|
+
*
|
|
124
|
+
* Left out are the records it cannot name with certainty (point 2): one whose
|
|
125
|
+
* name a target of another crate with the same artifact directory shares,
|
|
126
|
+
* and, where the configuration or the environment picks a triple whose
|
|
127
|
+
* folder the plugin cannot name, one whose folder depends on the triple
|
|
128
|
+
* while a record of the same name lies in any
|
|
129
|
+
* `<artifact directory>/<folder>/<profile folder>`, since the call's records
|
|
130
|
+
* may then lie there.
|
|
131
|
+
*
|
|
132
|
+
* @param artifactDirectory The absolute path of Cargo's artifact directory.
|
|
133
|
+
* @param workspaceRoot The absolute path of the workspace root, where cargo ran.
|
|
134
|
+
*/
|
|
135
|
+
// @mara implements DES-BUILD-INPUT-CHECK
|
|
136
|
+
function nameRecords(source, packageName, selection, env, artifactDirectory, workspaceRoot) {
|
|
137
|
+
var _a;
|
|
138
|
+
const profile = profileFolder(selection.profile);
|
|
139
|
+
const picked = callTriples(selection, env, workspaceRoot);
|
|
140
|
+
if (picked.kind === "triples" && picked.triples.length === 0) {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
const hostFolder = (0, node_path_1.join)(artifactDirectory, profile);
|
|
144
|
+
const tripleFolders = picked.kind === "triples"
|
|
145
|
+
? picked.triples.map((triple) => ({
|
|
146
|
+
folder: (0, node_path_1.join)(artifactDirectory, tripleFolderName(triple), profile),
|
|
147
|
+
triple,
|
|
148
|
+
}))
|
|
149
|
+
: [{ folder: hostFolder }];
|
|
150
|
+
const shared = new Set(source.shared);
|
|
151
|
+
const records = [];
|
|
152
|
+
const add = (kind, target, names, followsTriple) => {
|
|
153
|
+
for (const { folder, triple } of followsTriple ? tripleFolders : [{ folder: hostFolder }]) {
|
|
154
|
+
for (const name of names(followsTriple ? triple : undefined)) {
|
|
155
|
+
if (shared.has(name)) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (followsTriple &&
|
|
159
|
+
picked.kind === "unnamed" &&
|
|
160
|
+
inAnyTripleFolder(artifactDirectory, profile, name)) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
records.push({ path: (0, node_path_1.join)(folder, name), kind, target });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
if (source.library !== undefined) {
|
|
168
|
+
const { name, procMacro, crateTypes } = source.library;
|
|
169
|
+
add("library", name, (triple) => libraryRecordNames(name, crateTypes, triple), !procMacro);
|
|
170
|
+
}
|
|
171
|
+
const enabled = enabledFeatures(packageName, source.features, selection, (_a = source.optionalDependencies) !== null && _a !== void 0 ? _a : []);
|
|
172
|
+
for (const binary of source.binaries) {
|
|
173
|
+
if (binary.requiredFeatures.every((feature) => enabled.has(feature))) {
|
|
174
|
+
add("binary", binary.name, () => [(0, build_records_1.binaryRecordName)(binary.name)], true);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return records;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The rules of a record in Makefile syntax, as cargo writes it
|
|
181
|
+
* (`DES-BUILD-INPUT-CHECK`, point 3): `<artifact>: <path> <path> ...`, with a
|
|
182
|
+
* space inside a path escaped by a backslash. A line without a target is
|
|
183
|
+
* skipped, and so is a comment.
|
|
184
|
+
*/
|
|
185
|
+
// @mara implements DES-BUILD-INPUT-CHECK
|
|
186
|
+
function parseRecord(text) {
|
|
187
|
+
const rules = [];
|
|
188
|
+
for (const line of text.split(/\r?\n/)) {
|
|
189
|
+
if (line.trimStart().startsWith("#")) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const words = splitMakeWords(line);
|
|
193
|
+
const index = words.findIndex((word) => word.endsWith(":"));
|
|
194
|
+
if (index !== 0) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
rules.push({ target: words[0].slice(0, -1), paths: words.slice(1) });
|
|
198
|
+
}
|
|
199
|
+
return rules;
|
|
200
|
+
}
|
|
201
|
+
// The words of a Makefile line, split at unescaped spaces and tabs, with
|
|
202
|
+
// `\ ` read as a space. Cargo escapes nothing else, so any other backslash
|
|
203
|
+
// stays.
|
|
204
|
+
function splitMakeWords(line) {
|
|
205
|
+
const words = [];
|
|
206
|
+
let word = "";
|
|
207
|
+
for (let index = 0; index < line.length; index += 1) {
|
|
208
|
+
const character = line[index];
|
|
209
|
+
if (character === "\\" && line[index + 1] === " ") {
|
|
210
|
+
word += " ";
|
|
211
|
+
index += 1;
|
|
212
|
+
}
|
|
213
|
+
else if (character === " " || character === "\t") {
|
|
214
|
+
if (word !== "") {
|
|
215
|
+
words.push(word);
|
|
216
|
+
}
|
|
217
|
+
word = "";
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
word += character;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (word !== "") {
|
|
224
|
+
words.push(word);
|
|
225
|
+
}
|
|
226
|
+
return words;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The records that cargo exports for a library with these crate types built
|
|
230
|
+
* for `triple`, `undefined` for the host (`DES-BUILD-INPUT-CHECK`, point 1):
|
|
231
|
+
* `lib<name>.d`, and for a `cdylib` built for a wasm triple, whose file is
|
|
232
|
+
* `<name>.wasm` without the `lib` prefix, `<name>.d` in its place, beside
|
|
233
|
+
* `lib<name>.d` where the library has another crate type as well, as cargo
|
|
234
|
+
* 1.100.0 writes them for `wasm32-unknown-unknown` (`EVD-WASM-POSTPROCESS`).
|
|
235
|
+
* A graph that recorded no crate types names `lib<name>.d`.
|
|
236
|
+
*/
|
|
237
|
+
function libraryRecordNames(name, crateTypes, triple) {
|
|
238
|
+
const unprefixed = crateTypes !== undefined &&
|
|
239
|
+
crateTypes.includes("cdylib") &&
|
|
240
|
+
triple !== undefined &&
|
|
241
|
+
/^wasm(32|64)-/.test(triple);
|
|
242
|
+
if (!unprefixed) {
|
|
243
|
+
return [(0, build_records_1.libraryRecordName)(name)];
|
|
244
|
+
}
|
|
245
|
+
return [
|
|
246
|
+
(0, build_records_1.unprefixedLibraryRecordName)(name),
|
|
247
|
+
...(crateTypes.some((type) => type !== "cdylib") ? [(0, build_records_1.libraryRecordName)(name)] : []),
|
|
248
|
+
];
|
|
249
|
+
}
|
|
250
|
+
// The folder cargo names after a triple: the triple, or the file stem of a
|
|
251
|
+
// target specification file.
|
|
252
|
+
function tripleFolderName(triple) {
|
|
253
|
+
return (0, node_path_1.extname)(triple) === ".json" ? (0, node_path_1.basename)(triple, ".json") : triple;
|
|
254
|
+
}
|
|
255
|
+
// Whether a record of this name lies in `<artifact directory>/<folder>/<profile folder>`
|
|
256
|
+
// for any folder.
|
|
257
|
+
function inAnyTripleFolder(artifactDirectory, profile, name) {
|
|
258
|
+
let entries;
|
|
259
|
+
try {
|
|
260
|
+
entries = (0, node_fs_1.readdirSync)(artifactDirectory);
|
|
261
|
+
}
|
|
262
|
+
catch (_a) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
return entries.some((entry) => (0, node_fs_1.existsSync)((0, node_path_1.join)(artifactDirectory, entry, profile, name)));
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=build-records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-records.js","sourceRoot":"","sources":["../../../../nx-rust/src/executors/build-records.ts"],"names":[],"mappings":";;AAuCA,sCAaC;AAoBD,0CA6BC;AA0BD,kCAgBC;AA0BD,kCA6DC;AAoBD,kCAcC;AAqCD,gDAiBC;AA9TD,qCAAkD;AAClD,yCAAoD;AACpD,4DAA4E;AAC5E,0DAKgC;AA0BhC;;;;GAIG;AACH,SAAgB,aAAa,CAAC,OAA2B;IACvD,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,SAAS,CAAC;QACf,KAAK,EAAE,CAAC;QACR,KAAK,KAAK,CAAC;QACX,KAAK,MAAM;YACT,OAAO,OAAO,CAAC;QACjB,KAAK,SAAS,CAAC;QACf,KAAK,OAAO;YACV,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,eAAe,CAC7B,WAAmB,EACnB,KAAkD,EAClD,SAAyB,EACzB,uBAA0C,EAAE;;IAE5C,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,SAAS,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;QACnC,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjC,CAAC;SAAM,IAAI,SAAS,CAAC,iBAAiB,KAAK,IAAI,EAAE,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxB,CAAC;IACD,MAAM,GAAG,GAAG,GAAG,WAAW,GAAG,CAAC;IAC9B,KAAK,MAAM,KAAK,I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IAAA,gBAAI,EAAC,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ExecutorContext, TaskGraph } from "@nx/devkit";
|
|
2
|
+
import { type BatchReport } from "../batch";
|
|
3
|
+
import type { CargoTargetOptions } from "../command";
|
|
4
|
+
/**
|
|
5
|
+
* The executor of every inferred target but `build` and `doc`, `run` and
|
|
6
|
+
* `lockfile`, `@convesoft/nx-rust:cargo`, for a task that Nx runs on its own:
|
|
7
|
+
* the task runs its own cargo command (`DES-TARGET-COMMANDS`,
|
|
8
|
+
* `DES-WORKSPACE-TARGETS`).
|
|
9
|
+
*/
|
|
10
|
+
export default function cargoTask(options: CargoTargetOptions, context: ExecutorContext): Promise<{
|
|
11
|
+
success: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* The batch implementation of `@convesoft/nx-rust:cargo`, for the tasks that
|
|
15
|
+
* Nx runs together (`DES-BATCH`).
|
|
16
|
+
*/
|
|
17
|
+
export declare function batch(taskGraph: TaskGraph, inputs: Record<string, CargoTargetOptions>, _overrides: unknown, context: ExecutorContext): AsyncGenerator<BatchReport>;
|
|
18
|
+
/**
|
|
19
|
+
* The executor of `build` and `doc`, the targets whose files Nx stores,
|
|
20
|
+
* `@convesoft/nx-rust:cargo-outputs`: the same implementation under a name of
|
|
21
|
+
* its own, so that Nx batches and stores these tasks apart from those that
|
|
22
|
+
* wait for them (`DES-BATCH`, "Two batch executors"; `ADR-TEST-AFTER-BUILD`).
|
|
23
|
+
*/
|
|
24
|
+
export declare function outputsTask(options: CargoTargetOptions, context: ExecutorContext): Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
/** The batch implementation of `@convesoft/nx-rust:cargo-outputs` (`DES-BATCH`). */
|
|
28
|
+
export declare function outputsBatch(taskGraph: TaskGraph, inputs: Record<string, CargoTargetOptions>, _overrides: unknown, context: ExecutorContext): AsyncGenerator<BatchReport>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = cargoTask;
|
|
4
|
+
exports.batch = batch;
|
|
5
|
+
exports.outputsTask = outputsTask;
|
|
6
|
+
exports.outputsBatch = outputsBatch;
|
|
7
|
+
const targets_1 = require("../../graph/targets");
|
|
8
|
+
const batch_1 = require("../batch");
|
|
9
|
+
const declared_options_1 = require("../declared-options");
|
|
10
|
+
const task_1 = require("../task");
|
|
11
|
+
// The two executors, with the options of their schema, read where graph
|
|
12
|
+
// creation reads them (`declaredExecutorOptions`).
|
|
13
|
+
const cargo = {
|
|
14
|
+
name: targets_1.cargoExecutor,
|
|
15
|
+
shortName: "cargo",
|
|
16
|
+
declared: (0, declared_options_1.declaredOptionsOf)(targets_1.cargoExecutor),
|
|
17
|
+
serves: (target) => !targets_1.outputsTargets.has(target) && target !== "run" && target !== "lockfile",
|
|
18
|
+
};
|
|
19
|
+
const cargoOutputs = {
|
|
20
|
+
name: targets_1.cargoOutputsExecutor,
|
|
21
|
+
shortName: "cargo-outputs",
|
|
22
|
+
declared: (0, declared_options_1.declaredOptionsOf)(targets_1.cargoOutputsExecutor),
|
|
23
|
+
serves: (target) => targets_1.outputsTargets.has(target),
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The executor of every inferred target but `build` and `doc`, `run` and
|
|
27
|
+
* `lockfile`, `@convesoft/nx-rust:cargo`, for a task that Nx runs on its own:
|
|
28
|
+
* the task runs its own cargo command (`DES-TARGET-COMMANDS`,
|
|
29
|
+
* `DES-WORKSPACE-TARGETS`).
|
|
30
|
+
*/
|
|
31
|
+
// @mara implements DES-TARGETS
|
|
32
|
+
function cargoTask(options, context) {
|
|
33
|
+
return (0, task_1.runTask)(cargo, options, context);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The batch implementation of `@convesoft/nx-rust:cargo`, for the tasks that
|
|
37
|
+
* Nx runs together (`DES-BATCH`).
|
|
38
|
+
*/
|
|
39
|
+
// @mara implements DES-BATCH
|
|
40
|
+
function batch(taskGraph, inputs, _overrides, context) {
|
|
41
|
+
return (0, batch_1.runBatch)(cargo, taskGraph, inputs, context);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The executor of `build` and `doc`, the targets whose files Nx stores,
|
|
45
|
+
* `@convesoft/nx-rust:cargo-outputs`: the same implementation under a name of
|
|
46
|
+
* its own, so that Nx batches and stores these tasks apart from those that
|
|
47
|
+
* wait for them (`DES-BATCH`, "Two batch executors"; `ADR-TEST-AFTER-BUILD`).
|
|
48
|
+
*/
|
|
49
|
+
// @mara implements DES-TARGETS
|
|
50
|
+
function outputsTask(options, context) {
|
|
51
|
+
return (0, task_1.runTask)(cargoOutputs, options, context);
|
|
52
|
+
}
|
|
53
|
+
/** The batch implementation of `@convesoft/nx-rust:cargo-outputs` (`DES-BATCH`). */
|
|
54
|
+
// @mara implements DES-BATCH
|
|
55
|
+
function outputsBatch(taskGraph, inputs, _overrides, context) {
|
|
56
|
+
return (0, batch_1.runBatch)(cargoOutputs, taskGraph, inputs, context);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../nx-rust/src/executors/cargo/executor.ts"],"names":[],"mappings":";;AAoCA,4BAKC;AAOD,sBAOC;AASD,kCAKC;AAID,oCAOC;AA/ED,iDAK6B;AAC7B,oCAAsD;AAEtD,0DAAwD;AACxD,kCAAkC;AAGlC,wEAAwE;AACxE,mDAAmD;AACnD,MAAM,KAAK,GAAmB;IAC5B,IAAI,EAAE,uBAAa;IACnB,SAAS,EAAE,OAAO;IAClB,QAAQ,EAAE,IAAA,oCAAiB,EAAC,uBAAa,CAAC;IAC1C,MAAM,EAAE,CAAC,MAA0B,EAAE,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|
+
"description": "Runs the cargo command of a target that @convesoft/nx-rust infers, in the root folder of the Cargo workspace.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"features": {
|
|
10
|
+
"type": "array",
|
|
11
|
+
"items": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
"description": "Features to activate, passed as --features. Taken by build, check, lint, test, bench, run, napi-build, wasm-build and doc."
|
|
15
|
+
},
|
|
16
|
+
"allFeatures": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"description": "Activate all features, passed as --all-features. Taken by build, check, lint, test, bench, run, napi-build, wasm-build and doc."
|
|
19
|
+
},
|
|
20
|
+
"noDefaultFeatures": {
|
|
21
|
+
"type": "boolean",
|
|
22
|
+
"description": "Do not activate the default features, passed as --no-default-features. Taken by build, check, lint, test, bench, run, napi-build, wasm-build and doc."
|
|
23
|
+
},
|
|
24
|
+
"profile": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "The Cargo profile to build with, passed as --profile. Taken by build, check, lint, test, bench, run, napi-build, wasm-build and doc."
|
|
27
|
+
},
|
|
28
|
+
"targetTriple": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "The platform triple to build for, passed as --target. Taken by build, check, lint, bench, run and doc; test and napi-build run and build for the host triple only, and wasm-build for wasm32-unknown-unknown."
|
|
31
|
+
},
|
|
32
|
+
"allTargets": {
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"description": "Check the tests, benches and examples too, passed as --all-targets. Taken by check and lint, where the inferred target sets it."
|
|
35
|
+
},
|
|
36
|
+
"noDeps": {
|
|
37
|
+
"type": "boolean",
|
|
38
|
+
"description": "Document the workspace's members only, passed as --no-deps. Taken by doc, where the inferred target sets it."
|
|
39
|
+
},
|
|
40
|
+
"wasmTarget": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"enum": ["bundler", "web", "nodejs"],
|
|
43
|
+
"description": "The wasm target of the wasm package, passed to the wasm-bindgen CLI as --target. Taken by wasm-build, where the inferred target sets bundler."
|
|
44
|
+
},
|
|
45
|
+
"affectedTests": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"description": "Whether test selects affected tests in a workspace that uses selection. Taken by test."
|
|
48
|
+
},
|
|
49
|
+
"pluginVersion": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"description": "The plugin's version, which the plugin sets for the cache key. Not meant to be set by hand."
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ExecutorContext } from "@nx/devkit";
|
|
2
|
+
/** One cargo command that a task runs. */
|
|
3
|
+
export interface CargoInvocation {
|
|
4
|
+
/** The arguments after `cargo`. */
|
|
5
|
+
args: string[];
|
|
6
|
+
/** The absolute path of the folder where cargo starts, the workspace root. */
|
|
7
|
+
cwd: string;
|
|
8
|
+
/**
|
|
9
|
+
* The environment variables that the plugin sets for this command over
|
|
10
|
+
* the task's environment, which it otherwise passes on unchanged
|
|
11
|
+
* (`DES-INVOCATION`): only the compile of `napi-build` sets some (`DES-NAPI`).
|
|
12
|
+
*/
|
|
13
|
+
env?: Readonly<Record<string, string>>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The environment that cargo runs with for `invocation`: the task's
|
|
17
|
+
* environment, with the variables of the invocation laid over it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function cargoEnvironment(invocation: CargoInvocation, taskEnv: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
20
|
+
/**
|
|
21
|
+
* Whether Nx runs a single task verbosely, through its `--verbose` flag or
|
|
22
|
+
* `NX_VERBOSE_LOGGING=true` (`DES-INVOCATION`, "Printing the command"): what
|
|
23
|
+
* `isVerbose` in the task's executor context says, and nothing else.
|
|
24
|
+
*
|
|
25
|
+
* Nx 24 turns the flag and the variable into one value of
|
|
26
|
+
* `NX_VERBOSE_LOGGING` in the `nx` process, the flag winning both ways, and
|
|
27
|
+
* hands that to the executor as `isVerbose`. The task's own environment is
|
|
28
|
+
* no substitute: Nx deletes from it each variable whose value a root `.env`
|
|
29
|
+
* file repeats and then loads the task's dotenv files, so a crate's `.env`
|
|
30
|
+
* can give the task another `NX_VERBOSE_LOGGING` than the run's
|
|
31
|
+
* (`EVD-NX-24-VERBOSE`). A batch implementation, whose context never says
|
|
32
|
+
* that the run is verbose, asks {@link batchRunsVerbosely} instead.
|
|
33
|
+
*/
|
|
34
|
+
export declare function taskRunsVerbosely(context: Pick<ExecutorContext, "isVerbose">): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether Nx runs a batch verbosely, for a batch implementation, whose
|
|
37
|
+
* context in Nx 24 always has `isVerbose: false` (`DES-INVOCATION`, "Printing
|
|
38
|
+
* the command"): whether `NX_VERBOSE_LOGGING` is `true` in the batch
|
|
39
|
+
* process's environment. Nx copies that environment from the `nx` process
|
|
40
|
+
* after its `--verbose` flag has set the variable there, and loads no task's
|
|
41
|
+
* dotenv file into it (`EVD-NX-24-VERBOSE`). A single task asks
|
|
42
|
+
* {@link taskRunsVerbosely} instead.
|
|
43
|
+
*
|
|
44
|
+
* @param batchEnv The batch process's own environment, `process.env`, not a
|
|
45
|
+
* task's environment that the batch rebuilds from dotenv files.
|
|
46
|
+
*/
|
|
47
|
+
export declare function batchRunsVerbosely(batchEnv: NodeJS.ProcessEnv): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The lines that a verbose run prints before cargo starts for `invocation`
|
|
50
|
+
* (`DES-INVOCATION`, "Printing the command"): a heading that names `tasks`,
|
|
51
|
+
* then, indented, a `cd` to the folder where cargo starts and the command,
|
|
52
|
+
* with the variables that the plugin sets for it before `cargo`, as POSIX
|
|
53
|
+
* shell code that runs the same command where it is pasted. Every word is
|
|
54
|
+
* quoted where a shell would read it otherwise ({@link shellWord}).
|
|
55
|
+
*
|
|
56
|
+
* The lines come from the invocation that cargo is started with, so that
|
|
57
|
+
* they cannot differ from what runs.
|
|
58
|
+
*
|
|
59
|
+
* @param tasks The task, or the tasks, whose command it is, such as `api:test`.
|
|
60
|
+
* @throws {Error} When a variable's name is no name that a POSIX shell can
|
|
61
|
+
* assign.
|
|
62
|
+
*/
|
|
63
|
+
export declare function commandBlock(tasks: string, invocation: CargoInvocation): string;
|
|
64
|
+
/**
|
|
65
|
+
* Writes the lines of {@link commandBlock} for `invocation` to this
|
|
66
|
+
* process's standard error, and resolves once they are out, so that they
|
|
67
|
+
* come before what cargo prints (`DES-INVOCATION`, "Printing the command").
|
|
68
|
+
* A task run on its own and a batch both print through it: a task's
|
|
69
|
+
* standard error is its own output, and a batch process's is the batch's,
|
|
70
|
+
* which belongs to no task.
|
|
71
|
+
*/
|
|
72
|
+
export declare function printCommand(tasks: string, invocation: CargoInvocation): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* `word` as a POSIX shell reads it back: as it is where it holds only
|
|
75
|
+
* letters, digits and `_ - . / : @ % + , =`, and does not start with `=`,
|
|
76
|
+
* which zsh expands, and else in single quotes, with each single quote
|
|
77
|
+
* written `'\''`. So a package ID specification is quoted for its `#`,
|
|
78
|
+
* which starts a comment in some places and is a glob operator in zsh, and
|
|
79
|
+
* a folder for its spaces, while `%20` in a specification stays as it is.
|
|
80
|
+
*/
|
|
81
|
+
export declare function shellWord(word: string): string;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cargoEnvironment = cargoEnvironment;
|
|
4
|
+
exports.taskRunsVerbosely = taskRunsVerbosely;
|
|
5
|
+
exports.batchRunsVerbosely = batchRunsVerbosely;
|
|
6
|
+
exports.commandBlock = commandBlock;
|
|
7
|
+
exports.printCommand = printCommand;
|
|
8
|
+
exports.shellWord = shellWord;
|
|
9
|
+
/**
|
|
10
|
+
* The environment that cargo runs with for `invocation`: the task's
|
|
11
|
+
* environment, with the variables of the invocation laid over it.
|
|
12
|
+
*/
|
|
13
|
+
function cargoEnvironment(invocation, taskEnv) {
|
|
14
|
+
return invocation.env === undefined ? taskEnv : Object.assign(Object.assign({}, taskEnv), invocation.env);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Whether Nx runs a single task verbosely, through its `--verbose` flag or
|
|
18
|
+
* `NX_VERBOSE_LOGGING=true` (`DES-INVOCATION`, "Printing the command"): what
|
|
19
|
+
* `isVerbose` in the task's executor context says, and nothing else.
|
|
20
|
+
*
|
|
21
|
+
* Nx 24 turns the flag and the variable into one value of
|
|
22
|
+
* `NX_VERBOSE_LOGGING` in the `nx` process, the flag winning both ways, and
|
|
23
|
+
* hands that to the executor as `isVerbose`. The task's own environment is
|
|
24
|
+
* no substitute: Nx deletes from it each variable whose value a root `.env`
|
|
25
|
+
* file repeats and then loads the task's dotenv files, so a crate's `.env`
|
|
26
|
+
* can give the task another `NX_VERBOSE_LOGGING` than the run's
|
|
27
|
+
* (`EVD-NX-24-VERBOSE`). A batch implementation, whose context never says
|
|
28
|
+
* that the run is verbose, asks {@link batchRunsVerbosely} instead.
|
|
29
|
+
*/
|
|
30
|
+
// @mara implements DES-INVOCATION
|
|
31
|
+
function taskRunsVerbosely(context) {
|
|
32
|
+
return context.isVerbose === true;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether Nx runs a batch verbosely, for a batch implementation, whose
|
|
36
|
+
* context in Nx 24 always has `isVerbose: false` (`DES-INVOCATION`, "Printing
|
|
37
|
+
* the command"): whether `NX_VERBOSE_LOGGING` is `true` in the batch
|
|
38
|
+
* process's environment. Nx copies that environment from the `nx` process
|
|
39
|
+
* after its `--verbose` flag has set the variable there, and loads no task's
|
|
40
|
+
* dotenv file into it (`EVD-NX-24-VERBOSE`). A single task asks
|
|
41
|
+
* {@link taskRunsVerbosely} instead.
|
|
42
|
+
*
|
|
43
|
+
* @param batchEnv The batch process's own environment, `process.env`, not a
|
|
44
|
+
* task's environment that the batch rebuilds from dotenv files.
|
|
45
|
+
*/
|
|
46
|
+
// @mara implements DES-INVOCATION
|
|
47
|
+
function batchRunsVerbosely(batchEnv) {
|
|
48
|
+
return batchEnv.NX_VERBOSE_LOGGING === "true";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The lines that a verbose run prints before cargo starts for `invocation`
|
|
52
|
+
* (`DES-INVOCATION`, "Printing the command"): a heading that names `tasks`,
|
|
53
|
+
* then, indented, a `cd` to the folder where cargo starts and the command,
|
|
54
|
+
* with the variables that the plugin sets for it before `cargo`, as POSIX
|
|
55
|
+
* shell code that runs the same command where it is pasted. Every word is
|
|
56
|
+
* quoted where a shell would read it otherwise ({@link shellWord}).
|
|
57
|
+
*
|
|
58
|
+
* The lines come from the invocation that cargo is started with, so that
|
|
59
|
+
* they cannot differ from what runs.
|
|
60
|
+
*
|
|
61
|
+
* @param tasks The task, or the tasks, whose command it is, such as `api:test`.
|
|
62
|
+
* @throws {Error} When a variable's name is no name that a POSIX shell can
|
|
63
|
+
* assign.
|
|
64
|
+
*/
|
|
65
|
+
// @mara implements DES-INVOCATION
|
|
66
|
+
function commandBlock(tasks, invocation) {
|
|
67
|
+
var _a;
|
|
68
|
+
const assignments = Object.entries((_a = invocation.env) !== null && _a !== void 0 ? _a : {}).map(([name, value]) => {
|
|
69
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {
|
|
70
|
+
throw new Error(`The variable name ${JSON.stringify(name)} cannot be set in a POSIX shell.`);
|
|
71
|
+
}
|
|
72
|
+
return `${name}=${shellWord(value)}`;
|
|
73
|
+
});
|
|
74
|
+
const command = [...assignments, "cargo", ...invocation.args.map(shellWord)].join(" ");
|
|
75
|
+
return [
|
|
76
|
+
`${tasks}: @convesoft/nx-rust runs cargo as these lines do in a POSIX shell:`,
|
|
77
|
+
` cd ${shellWord(invocation.cwd)}`,
|
|
78
|
+
` ${command}`,
|
|
79
|
+
"",
|
|
80
|
+
].join("\n");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Writes the lines of {@link commandBlock} for `invocation` to this
|
|
84
|
+
* process's standard error, and resolves once they are out, so that they
|
|
85
|
+
* come before what cargo prints (`DES-INVOCATION`, "Printing the command").
|
|
86
|
+
* A task run on its own and a batch both print through it: a task's
|
|
87
|
+
* standard error is its own output, and a batch process's is the batch's,
|
|
88
|
+
* which belongs to no task.
|
|
89
|
+
*/
|
|
90
|
+
// @mara implements DES-INVOCATION
|
|
91
|
+
function printCommand(tasks, invocation) {
|
|
92
|
+
const block = commandBlock(tasks, invocation);
|
|
93
|
+
return new Promise((resolve) => process.stderr.write(block, () => resolve()));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* `word` as a POSIX shell reads it back: as it is where it holds only
|
|
97
|
+
* letters, digits and `_ - . / : @ % + , =`, and does not start with `=`,
|
|
98
|
+
* which zsh expands, and else in single quotes, with each single quote
|
|
99
|
+
* written `'\''`. So a package ID specification is quoted for its `#`,
|
|
100
|
+
* which starts a comment in some places and is a glob operator in zsh, and
|
|
101
|
+
* a folder for its spaces, while `%20` in a specification stays as it is.
|
|
102
|
+
*/
|
|
103
|
+
function shellWord(word) {
|
|
104
|
+
if (/^[A-Za-z0-9_\-./:@%+,][A-Za-z0-9_\-./:@%+,=]*$/.test(word)) {
|
|
105
|
+
return word;
|
|
106
|
+
}
|
|
107
|
+
return `'${word.replace(/'/g, `'\\''`)}'`;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=cargo-invocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cargo-invocation.js","sourceRoot":"","sources":["../../../../nx-rust/src/executors/cargo-invocation.ts"],"names":[],"mappings":";;AAoBA,4CAKC;AAiBD,8CAEC;AAeD,gDAEC;AAkBD,oCAcC;AAWD,oCAGC;AAUD,8BAKC;AA1GD;;;GAGG;AACH,SAAgB,gBAAgB,CAC9B,UAA2B,EAC3B,OAA0B;IAE1B,OAAO,UAAU,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,iC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