diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 3485842..889ecd2 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -8,6 +8,6 @@ license = "GPL-3.0-only" # Interim: track `core` by git rev (see design/runtime-repo-structure.md — no # crates.io publishing at this stage). Local iteration: uncomment the # workspace-root [patch] onto a sibling checkout. -comline-core = { git = "https://github.com/ComlineProject/core", rev = "5c1f3474b462ed912f4f2f5a518b87a5f6576aaa" } +comline-core = { git = "https://github.com/ComlineProject/core", rev = "016e38603152444f9b51fddfd46b1e6b1d73f1d8" } eyre = "0.6.8" diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index 71243df..1e6193b 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -49,6 +49,13 @@ pub struct GenRequest<'a> { /// built-in default. The value is a framing name the generator recognises /// (`"jsonrpc"`, `"datagram"`, …); an unknown one falls back to the default. pub default_framing: Option, + /// The target's language/toolchain version - the `#`-suffix of the + /// language the congregation declared (`rust#1.70.0` -> `"1.70.0"`, + /// `typescript#5.0` -> `"5.0"`), which is also what selected this + /// generator. A generator records it in whatever its own ecosystem's + /// manifest calls that (`rust-version` in a `Cargo.toml`), and ignores + /// it otherwise - `Mode::Code` has no manifest to put it in. + pub lang_version: String, /// `comline.toml`'s `[generate] external_std` - `true` means `std` /// should be referenced as its own crate instead of inlined into this /// package's own generated output. Only a generator that knows how to diff --git a/conformance/Cargo.toml b/conformance/Cargo.toml index cfd51e3..d55d9aa 100644 --- a/conformance/Cargo.toml +++ b/conformance/Cargo.toml @@ -11,9 +11,9 @@ publish = false # to their own repos. See design/runtime-repo-structure.md (rollout step 3). [dependencies] -comline-core = { git = "https://github.com/ComlineProject/core", rev = "5c1f3474b462ed912f4f2f5a518b87a5f6576aaa" } +comline-core = { git = "https://github.com/ComlineProject/core", rev = "016e38603152444f9b51fddfd46b1e6b1d73f1d8" } [dev-dependencies] comline-codegen = { path = "../codegen" } -comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "eb8396a337e0efe452cea32cdb0e6a50dd56f2d5" } -comline-codegen-typescript = { git = "https://github.com/ComlineProject/comline-typescript", rev = "d8a1df17b83752314a34d9c0b7817e4feb16820e" } +comline-codegen-rust = { git = "https://github.com/ComlineProject/comline-rust", rev = "5b1ba2b099cc295c6768935623f4c084f134e6b8" } +comline-codegen-typescript = { git = "https://github.com/ComlineProject/comline-typescript", rev = "c484b764b4341d8a8529eb52613e4ce2fb6c35d5" } diff --git a/conformance/tests/conformance.rs b/conformance/tests/conformance.rs index 3eecc8a..425834c 100644 --- a/conformance/tests/conformance.rs +++ b/conformance/tests/conformance.rs @@ -31,7 +31,7 @@ fn golden_path(fixture: &str, lang: &str, ext: &str) -> PathBuf { .join(format!("{lang}.{ext}")) } -fn request(schemas: &[(String, Vec)]) -> GenRequest<'_> { +fn request<'a>(schemas: &'a [(String, Vec)], lang: &str) -> GenRequest<'a> { GenRequest { mode: Mode::Code, schemas, @@ -39,6 +39,16 @@ fn request(schemas: &[(String, Vec)]) -> GenRequest<'_> { name: "conformance".to_string(), version: "0.0.0".to_string(), }, + // Each generator's own registered version. `Mode::Code` has no + // manifest to record it in, so no golden depends on it - but a + // request that named the wrong one would still be a lie about what + // is being asked for. + lang_version: match lang { + "rust" => comline_codegen_rust::LANG_VERSION, + "typescript" => comline_codegen_typescript::LANG_VERSION, + other => panic!("unknown language `{other}`"), + } + .to_string(), default_framing: None, external_std: false, } @@ -52,7 +62,7 @@ fn corpus_matches_golden() { for fx in corpus() { let schemas = vec![(fx.namespace.to_string(), fx.units.clone())]; for &(lang, ext) in LANGS { - let req = request(&schemas); + let req = request(&schemas, lang); let files = generate(lang, &req); assert_eq!( files.len(),