-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathcodegen.toml
More file actions
156 lines (149 loc) · 9.16 KB
/
Copy pathcodegen.toml
File metadata and controls
156 lines (149 loc) · 9.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# cddl-codegen multi-crate config: the complete flag set for every crate this repo generates
# from specs/, expressed once. Run it through ./codegen.sh, which pins the cddl-codegen rev,
# supplies the per-machine --static-dir, and wraps the run in the fmt/clippy/review workflow —
# read its header first. Every key here IS a cddl-codegen flag: the tool's
# docs/docs/command_line_flags.mdx says what each one means, and docs/docs/config_file.mdx says
# how values merge across [defaults] -> profiles -> crate tables and everything `deps` derives.
#
# NOT here, deliberately:
# - the byron pass (specs/multiera-byron): it generates a second spec set into the SAME
# multi-era crate, and two crate tables can share neither a lib-name nor an output — both
# are hard errors. It stays an opt-in flag invocation in codegen.sh (./codegen.sh byron).
# - static-dir: a per-machine tool-checkout path a committed file cannot state; codegen.sh
# passes --static-dir on the command line (the one flag --config accepts beside it).
#
# TOML trap to keep in mind when editing: a [crates.<name>.<sub-table>] HEADER ends the crate's
# own table silently — keys written after it belong to the mapping, not the crate. The inline
# `extern-wasm-crate = { ... }` spelling below is used for exactly that reason.
[defaults]
verbosity = "warn"
# Suppress the dead `pub type FooList = Vec<Foo>;` aliases minted for generator-SYNTHESIZED
# collection wrappers; rule-declared aliases are never touched. Emission-only (generated code
# is structural) — intentionally removes dead public re-declarations in every crate.
no-synthesized-rust-collection-aliases = true
json-serde-derives = true
json-schema-export = true
wasm = true
# c-style enums are the one struct kind whose #[wasm_bindgen] lands in the RUST crate; the
# codegen gates that attribute behind a cargo feature and this names it (CML has always used
# `used_from_wasm`; the wasm crates' path deps enable it).
rust-wasm-feature = "used_from_wasm"
# Emit macro CALLS (into cml_core_wasm) for each wasm type's CBOR/JSON API, From/AsRef
# conversions, and Vec<T> list wrappers, instead of inlining the boilerplate per struct.
wasm-cbor-json-api-macro = "cml_core_wasm::impl_wasm_cbor_json_api"
wasm-conversions-macro = "cml_core_wasm::impl_wasm_conversions"
wasm-list-macro = "cml_core_wasm::impl_wasm_list_needs_into"
# The encoding pair is a SUBSET's flags, not everyone's: cip25 has never had them (its CBOR is
# not round-trip-preserving), which is also what makes [runtime].flavor-from necessary below.
[profiles.encoded]
preserve-encodings = true
canonical-form = true
[runtime]
# One static runtime for the whole workspace, written into the hand-owned cml-core crate:
# error.rs, the serialization.rs prelude, ordered_hash_map.rs, non_empty*.rs, json_schema_gen,
# json_value_ser — refreshed on every regen so neither the files nor core/rust/Cargo.toml's
# runtime dep versions can rot against the codegen rev. CML-specific additions inside those
# files ride along in cddl-codegen:insert/replace blocks; hand-added manifest deps/keys pass
# through the merge untouched. Everything else in core/ stays hand-owned.
export-static-crate = "core/rust"
# THE key that makes regen reproduce CML's layout: points the common scaffolding at cml-core
# (expanding to --common-import-override on every crate) and suppresses generating those files
# locally. Each crate's Cargo.toml dependency on cml-core/cml-core-wasm stays a hand edit — an
# override is a Rust path prefix, so no cargo package name can be derived from it.
# The cargo PACKAGE name behind `common-import`'s rust path. `common-import` is a path prefix, so
# the package name cannot be derived from it -- this states it, and is what lets the regen wire the
# runtime-edge dependency (`default-features = false`) and the computed `std` forwarding list that
# names `cml-core/std`. Without it the generated crates' `std` cannot reach cml-core's
# `MapHashBuilder` cfg.
lib-name = "cml-core"
common-import = "cml_core"
# cip25 omits the encoding pair, so no single flavor serves all four crates and the export
# carrier cannot be derived. This declares chain (the maximal flavor) and thereby ACCEPTS
# generating cip25 against a runtime it does not match — safe only while specs/cip25.cddl
# holds no `{+ K => V}` and no `any`; the run states that accepted gap back on every regen.
flavor-from = "chain"
[crates.chain]
input = "specs/conway"
output = "chain"
lib-name = "cml-chain"
profiles = ["encoded"]
# Ship the canonical JSON-schema -> TypeScript scripts into chain/scripts/.
json-schema-scripts = true
# chain's spec references the built-in `int` (DeltaCoin), whose wasm face must resolve through
# cml_core_wasm in wasm-bindgen-exported signatures (otherwise E0277 on every DeltaCoin API).
# cml_core is hand-written and not generated by this config, so the mapping is written by hand
# rather than derived from a `deps` edge — the documented pairing with common-import above.
extern-wasm-crate = { cml_core = "cml_core_wasm" }
# JSON-schema roots: hand-written types whose JSON form is published API but that no CDDL rule
# describes, so the spec-derived row set cannot see them. Verbatim Rust paths, resolved by the
# json-gen crate's own build — cml_crypto resolves because chain/wasm/json-gen/Cargo.toml
# hand-declares it (the manifest merge preserves the entry). Array order is emission order.
# NOTE: cddl-codegen's CML_CONFIG_MIGRATION.md claims most of these rows are dead and its
# example config drops them. That census is WRONG for this tree: the byron classes use
# impl_wasm_cbor_json_api_cbor_event_serialize! (which INCLUDES impl_wasm_json_api!) and Crc32
# has an explicit impl_wasm_json_api!, so dropping a row fails the npm build's json-ts-types.js
# guard naming the class. See draft/REPORT-cml-config-migration-doc-corrections.md.
json-schema-root = [
"cml_chain::byron::AddressContent",
"cml_chain::byron::ByronAddress",
"cml_chain::byron::ByronAddrType",
"cml_chain::byron::ByronTxOut",
"cml_chain::byron::Crc32",
"cml_chain::byron::SpendingData",
"cml_chain::byron::StakeholderId",
"cml_crypto::Bip32PublicKey",
]
[crates.cip25]
input = "specs/cip25.cddl"
output = "cip25"
lib-name = "cml-cip25"
# No `profiles`: the crate that deliberately omits the encoding pair (it never had it).
# cip25 serializes through cbor_event's own trait, so its wasm CBOR/JSON macro differs:
wasm-cbor-json-api-macro = "cml_core_wasm::impl_wasm_cbor_json_api_cbor_event_serialize"
json-schema-root = ["cml_cip25::utils::CIP25MiniMetadataDetails"]
[crates.cip36]
input = "specs/cip36"
output = "cip36"
lib-name = "cml-cip36"
profiles = ["encoded"]
# cip36's crypto/chain types are declared as hand stub trees under
# specs/cip36/_CDDL_CODEGEN_EXTERN_DEPS_DIR_/{cml_crypto,cml_chain}, so the generator emits
# qualified dep paths in rust and — via these mappings — in wasm, and json-gen skips the
# dep-owned schema rows. cml_crypto is hand-written (no export to import), so its stub + this
# mapping is the only spelling there is. cml_chain DOES have an export this config could
# derive (`deps = ["chain"]` + deleting the stub, exactly like multi-era's seam migration) —
# that is a separate migration unit with its own diff review, deliberately not folded in here.
extern-wasm-crate = { cml_crypto = "cml_crypto_wasm", cml_chain = "cml_chain_wasm" }
[crates.multi-era]
input = "specs/multiera"
output = "multi-era"
lib-name = "cml-multi-era"
profiles = ["encoded"]
json-schema-scripts = true
# The whole workspace edge onto chain, both directions, replacing what codegen.sh spelled as
# four flags across two invocations plus hand-kept manifest entries:
# consumer side: --extern-import (chain/extern-interface/cml_chain — the machine-written
# export that replaced the hand stub tree), --extern-wasm-crate, --extern-wrapper-index,
# --workspace-dep, --rust-dep, --wasm-dep, --json-schema-dep/--json-gen-dep threading;
# chain's side: --wrapper-requests (multi-era's borrowed_collections.rs sidecar) and
# --key-requests (borrowed_key_types.rs — chain derives Eq/Ord/Hash where multi-era keys a
# map on one of its types).
# Generation order is a topological sort, dependencies first (chain, cip25, cip36, multi-era),
# then a convergence pass re-runs chain if this run rewrote a sidecar it had already read; the
# committed-state verdict (exit 2, naming the crate to regen) covers subset runs — it is the
# old check_convergence generalized, computed over these `deps` edges.
deps = ["chain"]
# The npm package ships cip25/cip36 wasm classes without multi-era's spec referencing them:
# derives their json-schema threading AND the two wasm/Cargo.toml re-export entries. A
# packaging fact only — no rust edge, no generation-order edge.
wasm-reexports = ["cip25", "cip36"]
# Hand-written roots: the multi-era wrapper enums (utils.rs) plus two byron types (published
# as Blake2B256JSON / AnyJSON after json2ts name normalization). Dep-owned roots arrive
# through the derived json-schema threading instead of being restated here.
json-schema-root = [
"cml_multi_era::byron::Blake2b256",
"cml_multi_era::byron::utils::ByronAny",
"cml_multi_era::utils::MultiEraBlockHeader",
"cml_multi_era::utils::MultiEraCertificate",
"cml_multi_era::utils::MultiEraProtocolParamUpdate",
]