Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust/contracts/rust-core-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5285,7 +5285,7 @@ user to trust the workspace before an action the user started.

| Command | Request | Result |
| --- | --- | --- |
| `build.detect` | `{ workspaceRoot, plugins: [{ manifest }], options?: { <buildSystemID>: { <optionID>: value } }, instanceOptions?: { <buildSystemID>: { <root>: { <optionID>: value } } }, instanceDefaults?: { <buildSystemID>: { <optionID>: value } }, emptySelections?: { <buildSystemID>: { <root>: [optionID] } }, ignoredPaths?: [pattern] }` | `detection`: `{ instances, rejected: [{ index, error }], shadowed: [{ pluginID, buildSystemID, by }] }`; each instance is `{ id, pluginID, buildSystemID, displayName, root, markers, modelSource, optionFingerprint, options, droppedOptions }` plus `model` or `modelError` for `static` and `hostIntegration` sources; a `provider` source has neither. `options` contains accepted stored values after Core scope/root merging, including explicit empty selections; `droppedOptions` names rejected stored values without rewriting the source document. The scan does not enter a directory `ignoredPaths` names; omitted (or `null`), it is Core's default `[".*"]`, every directory whose name starts with a dot, and `[]` ignores nothing beyond the shared scan policy. Hosts pass `storage.ignoredPaths.patterns` from `build.resolveStoredOptions`. An unusable list rejects with `plugin.build.invalidIgnoredPath` (see `build.editIgnoredPaths`). |
| `build.detect` | `{ workspaceRoot, plugins: [{ manifest }], options?: { <buildSystemID>: { <optionID>: value } }, instanceOptions?: { <buildSystemID>: { <root>: { <optionID>: value } } }, instanceDefaults?: { <buildSystemID>: { <optionID>: value } }, emptySelections?: { <buildSystemID>: { <root>: [optionID] } }, ignoredPaths?: [pattern] }` | `detection`: `{ instances, rejected: [{ index, error }], shadowed: [{ pluginID, buildSystemID, by }] }`; each instance is `{ id, pluginID, buildSystemID, displayName, root, markers, modelSource, optionFingerprint, options, droppedOptions }` plus `model` or `modelError` for `static` and `hostIntegration` sources; a `provider` source has neither. `options` contains accepted stored values after Core scope/root merging, including explicit empty selections; `droppedOptions` names rejected stored values without rewriting the source document: a value a declared option does not accept, and a value saved for an option ID the build system no longer declares (in `options`, the root's `instanceOptions` or `instanceDefaults`), which contributes nothing to `options`, the model or the fingerprint. The scan does not enter a directory `ignoredPaths` names; omitted (or `null`), it is Core's default `[".*"]`, every directory whose name starts with a dot, and `[]` ignores nothing beyond the shared scan policy. Hosts pass `storage.ignoredPaths.patterns` from `build.resolveStoredOptions`. An unusable list rejects with `plugin.build.invalidIgnoredPath` (see `build.editIgnoredPaths`). |
| `build.localizeOptions` | `{ language?, plugins: [{ manifest, localizations? }] }`, without the standard manifest/build-system wrapper | `{ manifests, localizations }`: one manifest per plugin in request order, with the `buildOptions` part of the first accepted translation file applied to `buildSystems[].options[]` (`displayName`, `description`, choice `title`), else as sent; one report per plugin that declares a build option when `language` is set, `{ pluginID, language, candidates, maximumBytes, readRequired, applied, rejected }` as in `plugins.settings`. Hosts send it without `localizations`, read the named candidates from the installed package, send it again with them, and detect with the returned manifests. A file that does not fit is refused whole as `plugin.build.invalidLocalization` |
| `build.projectOptions` | `{ document }`, host-read persisted v1 Build options, without a manifest | `document`: validated storage with version 1, systems and optional `ignoredPaths`; options, instance defaults, root values, explicit empty selections and saved custom choices are retained. Missing system fields normalize to empty maps; malformed, unsupported or oversized documents reject with `plugin.build.invalidOptionsDocument`. This pure operation never reads or writes a file and does not replace declared option resolution. |
| `build.resolveStoredOptions` | `{ document, local: { version: 1, document, emptySelections?: { <systemID>: { <root>: [optionID] } } } }`, without a manifest | `storage: { document, local, emptySelections, ignoredPaths: { patterns, source } }`: checked team/local merge; local values override matching keys, unrelated systems/roots/choices stay intact. `ignoredPaths` is the list `build.detect` uses: a local list replaces the team's whole (`source: "local"`), then the team's (`"team"`), then Core's default `[".*"]` (`"default"`). No filesystem I/O. Local documents are machine/workspace preferences, not team files or plugin-native configuration. Their storage syntax is [build-local-options-v1.schema.json](build-local-options-v1.schema.json), with additional cross-field membership and byte limits checked by Core. |
Expand Down
14 changes: 14 additions & 0 deletions rust/crates/build/src/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,20 @@ pub(crate) fn detect<M: BuildManifest>(request: DetectRequest) -> Validation<Val
values.insert(option.id.clone(), json!([]));
}
}
// A value saved for an option the build system no longer
// declares (a plugin update dropped it) is passed on too: it
// contributes nothing, and option resolution names it in the
// instance's droppedOptions so the host can show and clear it.
let defaults = request.instance_defaults.get(&owner.declaration.id);
for (id, value) in stored
.iter()
.chain(local.into_iter().flatten())
.chain(defaults.into_iter().flatten())
{
if owner.declaration.option(id).is_none() {
values.entry(id.clone()).or_insert_with(|| value.clone());
}
}
instances.push(instance(owner, &workspace, &root, markers, &values));
}
}
Expand Down
43 changes: 43 additions & 0 deletions rust/crates/core/src/tests/build_systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,49 @@ fn resolved_tool_environment_reaches_providers_with_option_precedence_and_bounde
}
}

#[test]
fn detection_names_saved_options_the_build_system_no_longer_declares() {
let workspace = TemporaryWorkspace::new("build-dropped-options");
workspace
.write(
"a/Cargo.toml",
"[package]\nname = \"a\"\nversion = \"1.0.0\"\n",
)
.write("a/src/main.rs", "fn main() {}\n");
let manifest = fixture("build-instance-options.plugin.json");
let detect = |options: Value, instances: Value, defaults: Value| {
let result = build_detect_command::<Manifest>(json!({
"workspaceRoot": workspace.root(), "plugins": [{"manifest": manifest.clone()}],
"options": {"cargo": options},
"instanceOptions": {"cargo": {"a": instances}},
"instanceDefaults": {"cargo": defaults}
}))
.unwrap();
assert_eq!(result["status"], "ok", "{result}");
instance(&result["detection"], "cargo:a").clone()
};
let kept = detect(
json!({"offline": true}),
json!({"settingsFile": "/fixture/a.xml"}),
json!({}),
);
let dropped = detect(
json!({"offline": true, "javaHome": "/jdk/21"}),
json!({"settingsFile": "/fixture/a.xml", "oldInstance": "x"}),
json!({"oldDefault": ["y"]}),
);
assert_eq!(kept["droppedOptions"], json!([]));
assert_eq!(
dropped["droppedOptions"],
json!(["javaHome", "oldDefault", "oldInstance"])
);
// The values are named, never applied: options, model and fingerprint
// are those of the instance without them.
assert_eq!(dropped["options"], kept["options"]);
assert_eq!(dropped["model"], kept["model"]);
assert_eq!(dropped["optionFingerprint"], kept["optionFingerprint"]);
}

#[test]
fn instance_options_drive_static_run_entries_without_crossing_roots_or_scopes() {
let workspace = TemporaryWorkspace::new("build-instance-options");
Expand Down
Loading