From 7fe3b6688794a608ee1b604105df8801d78d779d Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 03:40:19 +0900 Subject: [PATCH] S1 0.4.0: a generated unit names the authored file it copies (ide.generated[].origin) --- docs/specs/CHANGELOG.md | 9 +++++++++ docs/specs/README.md | 2 +- docs/specs/s1-build-database.md | 4 +++- docs/specs/schema/s1-build-database.schema.json | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/specs/CHANGELOG.md b/docs/specs/CHANGELOG.md index 4aa7279f..f78502e5 100644 --- a/docs/specs/CHANGELOG.md +++ b/docs/specs/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 2026-11-23 — S1 0.4.0: a generated unit names the file it copies + +S1 §7.2: a `source` entry of `ide.generated` may carry `origin`, the absolute path of the authored file the generated +unit is a transformed copy of, one of its generator's `inputs`, as the step that writes the unit states it; a producer +does not infer it from `inputs` (S1-7.2-14). A consumer treats that file as the unit's source for navigation and +diagnostics, and not as a second provider of the unit's module (S1-7.2-15). mcpp writes it from the build rule's +`mcpp::action::origin` (mcpp-community/mcpp#1004). Additive: a MINOR version of the profile; a consumer of 0.3.0 reads +a 0.4.0 document as before. + ## 2026-11-22 — S3: a shadowed source, and a file not formatted Two notice codes are named (mcpp-language-server#95). `shadowed-source`: an open file that is not compiled as it is, diff --git a/docs/specs/README.md b/docs/specs/README.md index 8c909ddf..59a7cf5b 100644 --- a/docs/specs/README.md +++ b/docs/specs/README.md @@ -4,7 +4,7 @@ This directory holds the normative specifications that let C++ named modules be | Spec | Title | Version | Status | Schema | |---|---|---|---|---| -| [S1](s1-build-database.md) | C++ Build Database: IDE Profile | profile-version 0.3.0 | Draft | [s1-build-database.schema.json](schema/s1-build-database.schema.json) | +| [S1](s1-build-database.md) | C++ Build Database: IDE Profile | profile-version 0.4.0 | Draft | [s1-build-database.schema.json](schema/s1-build-database.schema.json) | | [S2](s2-discovery.md) | Build Database Discovery Protocol | 0.3.0 | Draft | [s2-discovery.schema.json](schema/s2-discovery.schema.json) | | [S3](s3-lsp-extensions.md) | Language Server Protocol Extensions for C++ Modules | protocol version 1 | Draft | TypeScript interfaces in the text; [target selection field](schema/s3-target-selection.schema.json) | | [S4](s4-semantic-kit.md) | Semantic Kit | kit-version 1 | Draft | [s4-kit.schema.json](schema/s4-kit.schema.json) | diff --git a/docs/specs/s1-build-database.md b/docs/specs/s1-build-database.md index 740e2407..ba97bfb9 100644 --- a/docs/specs/s1-build-database.md +++ b/docs/specs/s1-build-database.md @@ -3,7 +3,7 @@ | | | |---|---| | Specification | S1 | -| Profile version | 0.3.0 | +| Profile version | 0.4.0 | | Status | Draft | | Schema | [`schema/s1-build-database.schema.json`](schema/s1-build-database.schema.json) | | Examples | [`examples/s1-level3-gcc.json`](examples/s1-level3-gcc.json), [`examples/s1-level2-clang-two-sets.json`](examples/s1-level2-clang-two-sets.json) | @@ -179,6 +179,7 @@ A build can generate files that the units of a set compile or include: sources a | `path` | string | MUST | Absolute path of the file or directory in the configuration this document describes, as the units' `arguments` name it. S1-7.2-1 | | `build-path` | string | SHOULD | Absolute path at which the build of the same configuration writes it. It differs from `path` when the producer plans in a directory of its own, and equals `path` otherwise. It is stated whether or not the file exists. S1-7.2-2 | | `kind` | enum | MUST | `source` (a unit of the set is compiled from it), `header` (units of the set include it) or `directory` (an include directory whose contents are generated). S1-7.2-3 | +| `origin` | string | MAY | For `source` only: the absolute path of the authored file the generated unit is a transformed copy of (the file a person edits to change the unit), one of the generator's `inputs`, as the step that writes the unit states it. A producer **MUST NOT** infer it from `inputs`. S1-7.2-14 (0.4.0) | | `generator` | object | conditional MUST | REQUIRED for `source` and `header`, absent for `directory`. It has `id` (string, MUST), the producer's name for the step that writes the file; `inputs` (string[], SHOULD), the absolute paths of the files the step reads; `arguments` (string[], SHOULD), the step's command, program first; and `work-directory` (string, MAY). S1-7.2-4, S1-7.2-5, S1-7.2-6, S1-7.2-7, S1-7.2-8 | A producer **SHOULD** list every generated file that a unit's `arguments` name, and every generated file in an include directory that the `arguments` name, whenever it knows the step that writes the file. S1-7.2-9 A translation unit whose `source` is the `path` of a `source` entry is a generated unit: before a build its source may be absent or empty. @@ -188,6 +189,7 @@ A consumer: - **MUST NOT** report a unit's reference to a generated file that does not exist as an error in that unit's source, and **SHOULD** tell the user that the file is generated, by which step, and that a build writes it; S1-7.2-10, S1-7.2-11 - **MAY** read the file at `build-path` when it exists, read-only (section 14), and **MUST** then treat it as possibly stale relative to the step's inputs; S1-7.2-12 - **MUST NOT** run a step's `arguments` unless the user has allowed it for the workspace (section 14). S1-7.2-13 +- **SHOULD**, for a `source` entry with `origin`, treat the authored file as the source of the generated unit for navigation and diagnostics, and **MUST NOT** treat it as a second provider of the module the unit provides. S1-7.2-15 (0.4.0) Rationale: a producer that does not build (for example mcpp's `emit build-database`, which writes nothing into the project and runs no build step) plans in a directory of its own, so a generated header named by the units' `-I` arguments is absent there. Without this object a consumer reports a missing header in every source that includes it and loses the semantics of that source. The object states which files are generated and where the build writes them; running the generators remains a decision of the consumer and its user. diff --git a/docs/specs/schema/s1-build-database.schema.json b/docs/specs/schema/s1-build-database.schema.json index f4696165..0666e95e 100644 --- a/docs/specs/schema/s1-build-database.schema.json +++ b/docs/specs/schema/s1-build-database.schema.json @@ -257,6 +257,9 @@ "directory" ] }, + "origin": { + "$ref": "#/$defs/nonEmptyString" + }, "generator": { "type": "object", "required": [