alef_core/config/languages.rs
1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3use std::path::PathBuf;
4
5use super::extras::Language;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct PythonConfig {
9 pub module_name: Option<String>,
10 pub async_runtime: Option<String>,
11 pub stubs: Option<StubsConfig>,
12 /// PyPI package name (e.g. `"html-to-markdown"`). Used as the `[project] name` in
13 /// `pyproject.toml` and to derive the `python-packages` list for maturin.
14 /// Defaults to the crate name.
15 #[serde(default)]
16 pub pip_name: Option<String>,
17 /// Per-language feature override. When set, these features are used instead of
18 /// `[crate] features` for this language's binding crate.
19 #[serde(default)]
20 pub features: Option<Vec<String>>,
21 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
22 /// When set, this takes priority over the IR type-level serde_rename_all.
23 #[serde(default)]
24 pub serde_rename_all: Option<String>,
25 /// Map of type name -> PyCapsule name for raw pointer wrapping.
26 /// When a function returns one of these types, alef generates PyCapsule_New instead of Arc wrapping.
27 // TODO: Wire into gen_bindings.rs to emit PyCapsule_New / PyCapsule_GetPointer at call sites.
28 #[serde(default)]
29 pub capsule_types: HashMap<String, String>,
30 /// When true, wrap blocking function bodies in py.allow_threads() to release the GIL.
31 // TODO: Wire into gen_bindings.rs to emit py.allow_threads(|| { ... }) for non-async functions.
32 #[serde(default)]
33 pub release_gil: bool,
34 /// Functions to exclude from Python binding generation.
35 #[serde(default)]
36 pub exclude_functions: Vec<String>,
37 /// Types to exclude from Python binding generation.
38 #[serde(default)]
39 pub exclude_types: Vec<String>,
40 /// Additional Cargo dependencies for this language's binding crate only.
41 #[serde(default)]
42 pub extra_dependencies: HashMap<String, toml::Value>,
43 /// Override the scaffold output directory for this language's Cargo.toml and package files.
44 #[serde(default)]
45 pub scaffold_output: Option<PathBuf>,
46 /// Per-field name remapping for this language. Key is `TypeName.field_name` (e.g.
47 /// `"LayoutDetection.class"`), value is the desired binding field name. Applied after
48 /// automatic keyword escaping, so an explicit entry takes priority.
49 #[serde(default)]
50 pub rename_fields: HashMap<String, String>,
51 /// Prefix wrapper for default tool invocations. When set, prepends this string to default
52 /// commands across all pipelines (lint, test, build, etc.).
53 /// E.g., `run_wrapper = "uv run --no-sync"` turns `ruff format packages/python` into
54 /// `uv run --no-sync ruff format packages/python`.
55 #[serde(default)]
56 pub run_wrapper: Option<String>,
57 /// Extra paths to append to default lint commands (format, check, typecheck).
58 /// Space-separated paths are appended to the command.
59 #[serde(default)]
60 pub extra_lint_paths: Vec<String>,
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct StubsConfig {
65 pub output: PathBuf,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct NodeConfig {
70 pub package_name: Option<String>,
71 /// Per-language feature override. When set, these features are used instead of
72 /// `[crate] features` for this language's binding crate.
73 #[serde(default)]
74 pub features: Option<Vec<String>>,
75 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
76 /// When set, this takes priority over the IR type-level serde_rename_all.
77 #[serde(default)]
78 pub serde_rename_all: Option<String>,
79 /// Prefix for generated type names (e.g. "Js" produces `JsConversionOptions`).
80 /// Defaults to `"Js"`.
81 #[serde(default)]
82 pub type_prefix: Option<String>,
83 /// Functions to exclude from Node binding generation.
84 #[serde(default)]
85 pub exclude_functions: Vec<String>,
86 /// Types to exclude from Node binding generation.
87 #[serde(default)]
88 pub exclude_types: Vec<String>,
89 /// Additional Cargo dependencies for this language's binding crate only.
90 #[serde(default)]
91 pub extra_dependencies: HashMap<String, toml::Value>,
92 /// Override the scaffold output directory for this language's Cargo.toml and package files.
93 #[serde(default)]
94 pub scaffold_output: Option<PathBuf>,
95 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
96 /// desired binding field name. Applied after automatic keyword escaping.
97 #[serde(default)]
98 pub rename_fields: HashMap<String, String>,
99 /// Prefix wrapper for default tool invocations. When set, prepends this string to default
100 /// commands across all pipelines (lint, test, build, etc.).
101 #[serde(default)]
102 pub run_wrapper: Option<String>,
103 /// Extra paths to append to default lint commands (format, check, typecheck).
104 #[serde(default)]
105 pub extra_lint_paths: Vec<String>,
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
109pub struct RubyConfig {
110 pub gem_name: Option<String>,
111 pub stubs: Option<StubsConfig>,
112 /// Per-language feature override. When set, these features are used instead of
113 /// `[crate] features` for this language's binding crate.
114 #[serde(default)]
115 pub features: Option<Vec<String>>,
116 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
117 /// When set, this takes priority over the IR type-level serde_rename_all.
118 #[serde(default)]
119 pub serde_rename_all: Option<String>,
120 /// Functions to exclude from Ruby binding generation.
121 #[serde(default)]
122 pub exclude_functions: Vec<String>,
123 /// Types to exclude from Ruby binding generation.
124 #[serde(default)]
125 pub exclude_types: Vec<String>,
126 /// Additional Cargo dependencies for this language's binding crate only.
127 #[serde(default)]
128 pub extra_dependencies: HashMap<String, toml::Value>,
129 /// Override the scaffold output directory for this language's Cargo.toml and package files.
130 #[serde(default)]
131 pub scaffold_output: Option<PathBuf>,
132 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
133 /// desired binding field name. Applied after automatic keyword escaping.
134 #[serde(default)]
135 pub rename_fields: HashMap<String, String>,
136 /// Prefix wrapper for default tool invocations. When set, prepends this string to default
137 /// commands across all pipelines (lint, test, build, etc.).
138 #[serde(default)]
139 pub run_wrapper: Option<String>,
140 /// Extra paths to append to default lint commands (format, check, typecheck).
141 #[serde(default)]
142 pub extra_lint_paths: Vec<String>,
143}
144
145#[derive(Debug, Clone, Serialize, Deserialize)]
146pub struct PhpConfig {
147 pub extension_name: Option<String>,
148 /// Cargo crate name for the PHP binding (e.g. `"ts-pack-core-php"`).
149 /// Used to derive the shared library filename in the e2e test runner.
150 /// When absent, the lib name is derived from `extension_name` by appending `_php`.
151 #[serde(default)]
152 pub cargo_crate_name: Option<String>,
153 /// Override the PHP namespace used for class registration and PSR-4 autoloading.
154 ///
155 /// When set, this value is used verbatim as the PHP namespace (e.g. `"HtmlToMarkdown"`).
156 /// When absent, the namespace is derived from `extension_name` by splitting on `_` and
157 /// converting each segment to PascalCase (e.g. `html_to_markdown` → `Html\To\Markdown`).
158 #[serde(default)]
159 pub namespace: Option<String>,
160 /// Feature gate for ext-php-rs (default: "extension-module").
161 /// All generated code is wrapped in `#[cfg(feature = "...")]`.
162 #[serde(default)]
163 pub feature_gate: Option<String>,
164 /// Output directory for generated PHP facade / stubs (e.g., `packages/php/src/`).
165 #[serde(default)]
166 pub stubs: Option<StubsConfig>,
167 #[serde(default)]
168 pub features: Option<Vec<String>>,
169 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
170 /// When set, this takes priority over the IR type-level serde_rename_all.
171 #[serde(default)]
172 pub serde_rename_all: Option<String>,
173 /// Functions to exclude from PHP binding generation.
174 #[serde(default)]
175 pub exclude_functions: Vec<String>,
176 /// Types to exclude from PHP binding generation.
177 #[serde(default)]
178 pub exclude_types: Vec<String>,
179 /// Additional Cargo dependencies for this language's binding crate only.
180 #[serde(default)]
181 pub extra_dependencies: HashMap<String, toml::Value>,
182 /// Override the scaffold output directory for this language's Cargo.toml and package files.
183 #[serde(default)]
184 pub scaffold_output: Option<PathBuf>,
185 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
186 /// desired binding field name. Applied after automatic keyword escaping.
187 #[serde(default)]
188 pub rename_fields: HashMap<String, String>,
189 /// Prefix wrapper for default tool invocations. When set, prepends this string to default
190 /// commands across all pipelines (lint, test, build, etc.).
191 #[serde(default)]
192 pub run_wrapper: Option<String>,
193 /// Extra paths to append to default lint commands (format, check, typecheck).
194 #[serde(default)]
195 pub extra_lint_paths: Vec<String>,
196}
197
198#[derive(Debug, Clone, Serialize, Deserialize)]
199pub struct ElixirConfig {
200 pub app_name: Option<String>,
201 #[serde(default)]
202 pub features: Option<Vec<String>>,
203 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
204 /// When set, this takes priority over the IR type-level serde_rename_all.
205 #[serde(default)]
206 pub serde_rename_all: Option<String>,
207 /// Functions to exclude from Elixir NIF generation.
208 #[serde(default)]
209 pub exclude_functions: Vec<String>,
210 /// Types to exclude from Elixir NIF generation.
211 #[serde(default)]
212 pub exclude_types: Vec<String>,
213 /// Additional Cargo dependencies for this language's binding crate only.
214 #[serde(default)]
215 pub extra_dependencies: HashMap<String, toml::Value>,
216 /// Override the scaffold output directory for this language's Cargo.toml and package files.
217 #[serde(default)]
218 pub scaffold_output: Option<PathBuf>,
219 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
220 /// desired binding field name. Applied after automatic keyword escaping.
221 #[serde(default)]
222 pub rename_fields: HashMap<String, String>,
223 /// Prefix wrapper for default tool invocations. When set, prepends this string to default
224 /// commands across all pipelines (lint, test, build, etc.).
225 #[serde(default)]
226 pub run_wrapper: Option<String>,
227 /// Extra paths to append to default lint commands (format, check, typecheck).
228 #[serde(default)]
229 pub extra_lint_paths: Vec<String>,
230 /// Functions that should be scheduled on the dirty CPU scheduler.
231 /// HTML parsing and other CPU-intensive NIFs should be listed here to avoid
232 /// blocking BEAM scheduler threads.
233 #[serde(default)]
234 pub cpu_bound_functions: Vec<String>,
235}
236
237#[derive(Debug, Clone, Serialize, Deserialize)]
238pub struct WasmConfig {
239 #[serde(default)]
240 pub exclude_functions: Vec<String>,
241 #[serde(default)]
242 pub exclude_types: Vec<String>,
243 #[serde(default)]
244 pub type_overrides: HashMap<String, String>,
245 #[serde(default)]
246 pub features: Option<Vec<String>>,
247 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
248 /// When set, this takes priority over the IR type-level serde_rename_all.
249 #[serde(default)]
250 pub serde_rename_all: Option<String>,
251 /// Prefix for generated type names (e.g. "Wasm" produces `WasmConversionOptions`).
252 /// Defaults to `"Wasm"`.
253 #[serde(default)]
254 pub type_prefix: Option<String>,
255 /// Functions to exclude from the public TypeScript re-export (index.ts) while still
256 /// generating the Rust binding. Use this when a custom module provides a wrapper.
257 #[serde(default)]
258 pub exclude_reexports: Vec<String>,
259 /// Wide-character C functions to shim for WASM external scanner interop.
260 #[serde(default)]
261 pub env_shims: Vec<String>,
262 /// Additional Cargo dependencies for the WASM binding crate only.
263 #[serde(default)]
264 pub extra_dependencies: HashMap<String, toml::Value>,
265 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
266 /// desired binding field name. Applied after automatic keyword escaping.
267 #[serde(default)]
268 pub rename_fields: HashMap<String, String>,
269 /// Prefix wrapper for default tool invocations. When set, prepends this string to default
270 /// commands across all pipelines (lint, test, build, etc.).
271 #[serde(default)]
272 pub run_wrapper: Option<String>,
273 /// Extra paths to append to default lint commands (format, check, typecheck).
274 #[serde(default)]
275 pub extra_lint_paths: Vec<String>,
276 /// Override the core Cargo dependency name and path for the WASM binding crate.
277 /// When set, the binding `Cargo.toml` depends on this crate (resolved as
278 /// `../<override>`) instead of the umbrella `[crate.name]`. Use this to point
279 /// the WASM binding at a wasm-safe sub-crate while other languages keep the
280 /// facade. Defaults to unset.
281 #[serde(default)]
282 pub core_crate_override: Option<String>,
283 /// Keys to subtract from the merged `extra_dependencies` set for this
284 /// language only. Useful when `[crate.extra_dependencies]` lists sibling
285 /// crates that the WASM target cannot link.
286 #[serde(default)]
287 pub exclude_extra_dependencies: Vec<String>,
288 /// Hand-written Rust modules to declare in the generated lib.rs with `pub mod <name>;`
289 /// and re-export with `pub use <name>::*;`. Separate from `[custom_modules].wasm` which
290 /// only adds TypeScript `export *` re-exports. Use this for Rust-side dispatch/glue modules.
291 #[serde(default)]
292 pub custom_rust_modules: Vec<String>,
293 /// Per-type field exclusions for the generated From impls and binding struct.
294 /// Key is the type name (e.g. "ServerConfig"), value is a list of field names to skip.
295 /// Use when source fields are gated behind `#[cfg(not(target_arch = "wasm32"))]` and
296 /// therefore don't exist in the wasm32 compilation environment.
297 #[serde(default)]
298 pub exclude_fields: HashMap<String, Vec<String>>,
299 /// Source crate names whose types are re-exported by the `core_crate_override`
300 /// crate. References to `<original_crate>::TypeName` in generated code are
301 /// rewritten to `<override_crate>::TypeName`. Only meaningful when
302 /// `core_crate_override` is set.
303 /// Example: with `core_crate_override = "mylib-http"`, setting
304 /// `source_crate_remaps = ["mylib-core", "mylib"]` rewrites
305 /// `mylib_core::Method` and `mylib::Method` references to
306 /// `mylib_http::Method` (assumes `mylib-http` re-exports them via
307 /// `pub use mylib_core::*`).
308 #[serde(default)]
309 pub source_crate_remaps: Vec<String>,
310}
311
312#[derive(Debug, Clone, Serialize, Deserialize)]
313pub struct FfiConfig {
314 pub prefix: Option<String>,
315 #[serde(default = "default_error_style")]
316 pub error_style: String,
317 pub header_name: Option<String>,
318 /// Native library name for Go cgo/Java Panama/C# P/Invoke (e.g., "ts_pack_ffi").
319 /// Defaults to `{prefix}_ffi`.
320 #[serde(default)]
321 pub lib_name: Option<String>,
322 /// If true, generate visitor/callback FFI support.
323 #[serde(default)]
324 pub visitor_callbacks: bool,
325 #[serde(default)]
326 pub features: Option<Vec<String>>,
327 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
328 /// When set, this takes priority over the IR type-level serde_rename_all.
329 #[serde(default)]
330 pub serde_rename_all: Option<String>,
331 /// Functions to exclude from FFI binding generation.
332 #[serde(default)]
333 pub exclude_functions: Vec<String>,
334 /// Types to exclude from FFI binding generation.
335 #[serde(default)]
336 pub exclude_types: Vec<String>,
337 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
338 /// desired binding field name. Applied after automatic keyword escaping.
339 #[serde(default)]
340 pub rename_fields: HashMap<String, String>,
341}
342
343fn default_error_style() -> String {
344 "last_error".to_string()
345}
346
347#[derive(Debug, Clone, Serialize, Deserialize)]
348pub struct GoConfig {
349 pub module: Option<String>,
350 /// Override the Go package name (default: derived from module path)
351 pub package_name: Option<String>,
352 #[serde(default)]
353 pub features: Option<Vec<String>>,
354 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
355 /// When set, this takes priority over the IR type-level serde_rename_all.
356 #[serde(default)]
357 pub serde_rename_all: Option<String>,
358 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
359 /// desired binding field name. Applied after automatic keyword escaping.
360 #[serde(default)]
361 pub rename_fields: HashMap<String, String>,
362 /// Prefix wrapper for default tool invocations. When set, prepends this string to default
363 /// commands across all pipelines (lint, test, build, etc.).
364 #[serde(default)]
365 pub run_wrapper: Option<String>,
366 /// Extra paths to append to default lint commands (format, check, typecheck).
367 #[serde(default)]
368 pub extra_lint_paths: Vec<String>,
369}
370
371#[derive(Debug, Clone, Serialize, Deserialize)]
372pub struct JavaConfig {
373 pub package: Option<String>,
374 #[serde(default = "default_java_ffi_style")]
375 pub ffi_style: String,
376 #[serde(default)]
377 pub features: Option<Vec<String>>,
378 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
379 /// When set, this takes priority over the IR type-level serde_rename_all.
380 #[serde(default)]
381 pub serde_rename_all: Option<String>,
382 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
383 /// desired binding field name. Applied after automatic keyword escaping.
384 #[serde(default)]
385 pub rename_fields: HashMap<String, String>,
386 /// Prefix wrapper for default tool invocations. When set, prepends this string to default
387 /// commands across all pipelines (lint, test, build, etc.).
388 #[serde(default)]
389 pub run_wrapper: Option<String>,
390 /// Extra paths to append to default lint commands (format, check, typecheck).
391 /// Ignored when project_file is set.
392 #[serde(default)]
393 pub extra_lint_paths: Vec<String>,
394 /// Project file for Maven/Gradle (e.g., "pom.xml", "build.gradle"). When set, default
395 /// lint/build/test commands target this file instead of the output directory.
396 #[serde(default)]
397 pub project_file: Option<String>,
398}
399
400fn default_java_ffi_style() -> String {
401 "panama".to_string()
402}
403
404/// Target platform for Kotlin code generation.
405///
406/// - `"jvm"` (default): emits source consuming the Java/Panama FFM facade.
407/// - `"native"`: emits Kotlin/Native source consuming the cbindgen C FFI library.
408/// - `"multiplatform"`: reserved for the KMP stage (Phase 3 follow-up).
409#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)]
410#[serde(rename_all = "lowercase")]
411pub enum KotlinTarget {
412 #[default]
413 Jvm,
414 Native,
415 // Multiplatform — Phase 3 KMP stage; placeholder so the enum is forward-compatible.
416 Multiplatform,
417}
418
419#[derive(Debug, Clone, Serialize, Deserialize)]
420pub struct KotlinConfig {
421 pub package: Option<String>,
422 #[serde(default)]
423 pub features: Option<Vec<String>>,
424 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
425 /// When set, this takes priority over the IR type-level serde_rename_all.
426 #[serde(default)]
427 pub serde_rename_all: Option<String>,
428 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
429 /// desired binding field name. Applied after automatic keyword escaping.
430 #[serde(default)]
431 pub rename_fields: HashMap<String, String>,
432 /// Functions to exclude from Kotlin binding generation.
433 #[serde(default)]
434 pub exclude_functions: Vec<String>,
435 /// Types to exclude from Kotlin binding generation.
436 #[serde(default)]
437 pub exclude_types: Vec<String>,
438 /// Prefix wrapper for default tool invocations. When set, prepends this string to default
439 /// commands across all pipelines (lint, test, build, etc.).
440 #[serde(default)]
441 pub run_wrapper: Option<String>,
442 /// Extra paths to append to default lint commands (format, check, typecheck).
443 #[serde(default)]
444 pub extra_lint_paths: Vec<String>,
445 /// Target platform for Kotlin output. `"jvm"` (default) emits source consuming
446 /// the Java/Panama FFM facade; `"native"` emits Kotlin/Native source consuming
447 /// the cbindgen C FFI library. `"multiplatform"` is reserved for the KMP stage.
448 #[serde(default)]
449 pub target: KotlinTarget,
450}
451
452/// Dart bridging style: FRB (default) or raw `dart:ffi`.
453#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)]
454#[serde(rename_all = "lowercase")]
455pub enum DartStyle {
456 /// flutter_rust_bridge — emits a Rust crate plus Dart wrappers using
457 /// FRB-generated bridge symbols. Default.
458 #[default]
459 Frb,
460 /// Raw `dart:ffi` over the cbindgen C ABI — emits Dart-only source that
461 /// loads the shared library at runtime. Cheaper to ship; loses FRB's
462 /// async ergonomics and freezed-style data classes.
463 Ffi,
464}
465
466#[derive(Debug, Clone, Default, Serialize, Deserialize)]
467pub struct DartConfig {
468 /// Dart pub.dev package name (e.g. `"my_package"`). Used as the `name` in
469 /// `pubspec.yaml`. Defaults to a snake_case derivation of the crate name.
470 #[serde(default)]
471 pub pubspec_name: Option<String>,
472 /// Dart library name (the `library` declaration). Defaults to the pubspec name.
473 #[serde(default)]
474 pub lib_name: Option<String>,
475 /// Dart package name override (e.g. for pub.dev scoped packages).
476 #[serde(default)]
477 pub package_name: Option<String>,
478 /// Bridging style. `"frb"` (default) uses flutter_rust_bridge; `"ffi"` emits
479 /// raw `dart:ffi` source over the cbindgen C library.
480 #[serde(default)]
481 pub style: DartStyle,
482 /// flutter_rust_bridge version to pin in generated pubspec.yaml.
483 /// Defaults to `template_versions::cargo::FLUTTER_RUST_BRIDGE` when unset.
484 #[serde(default)]
485 pub frb_version: Option<String>,
486 /// Cargo features to enable on the binding crate.
487 #[serde(default)]
488 pub features: Option<Vec<String>>,
489 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
490 #[serde(default)]
491 pub serde_rename_all: Option<String>,
492 /// Per-field name remapping. Key is `TypeName.field_name`, value is the
493 /// desired binding field name. Applied after automatic keyword escaping.
494 #[serde(default)]
495 pub rename_fields: HashMap<String, String>,
496 /// Functions to exclude from Dart binding generation.
497 #[serde(default)]
498 pub exclude_functions: Vec<String>,
499 /// Types to exclude from Dart binding generation.
500 #[serde(default)]
501 pub exclude_types: Vec<String>,
502 /// Prefix wrapper for default tool invocations.
503 #[serde(default)]
504 pub run_wrapper: Option<String>,
505 /// Extra paths to append to default lint commands.
506 #[serde(default)]
507 pub extra_lint_paths: Vec<String>,
508 /// Override the core Cargo dependency name and path for the Dart binding crate.
509 /// When set, the binding `Cargo.toml` depends on this crate (resolved as
510 /// `../../../crates/<override>`) instead of the umbrella `[crate.name]`.
511 /// Defaults to unset.
512 #[serde(default)]
513 pub core_crate_override: Option<String>,
514 /// Keys to subtract from the merged `extra_dependencies` set for this
515 /// language only.
516 #[serde(default)]
517 pub exclude_extra_dependencies: Vec<String>,
518}
519
520#[derive(Debug, Clone, Default, Serialize, Deserialize)]
521pub struct SwiftConfig {
522 /// Swift module name (e.g. `"MyLibrary"`). Defaults to PascalCase of the crate name.
523 #[serde(default)]
524 pub module_name: Option<String>,
525 /// Swift package name. Defaults to the module name.
526 #[serde(default)]
527 pub package_name: Option<String>,
528 /// swift-bridge version. Defaults to `template_versions::cargo::SWIFT_BRIDGE` when unset.
529 #[serde(default)]
530 pub swift_bridge_version: Option<String>,
531 /// Minimum macOS deployment target. Defaults to `template_versions::toolchain::SWIFT_MIN_MACOS` when unset.
532 #[serde(default)]
533 pub min_macos_version: Option<String>,
534 /// Minimum iOS deployment target. Defaults to `template_versions::toolchain::SWIFT_MIN_IOS` when unset.
535 #[serde(default)]
536 pub min_ios_version: Option<String>,
537 /// Cargo features to enable on the binding crate.
538 #[serde(default)]
539 pub features: Option<Vec<String>>,
540 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
541 #[serde(default)]
542 pub serde_rename_all: Option<String>,
543 /// Per-field name remapping. Key is `TypeName.field_name`, value is the
544 /// desired binding field name. Applied after automatic keyword escaping.
545 #[serde(default)]
546 pub rename_fields: HashMap<String, String>,
547 /// Functions to exclude from Swift binding generation.
548 #[serde(default)]
549 pub exclude_functions: Vec<String>,
550 /// Types to exclude from Swift binding generation.
551 #[serde(default)]
552 pub exclude_types: Vec<String>,
553 /// Fields to exclude from Swift binding generation.
554 /// Format: `"TypeName.field_name"`.
555 #[serde(default)]
556 pub exclude_fields: Vec<String>,
557 /// Prefix wrapper for default tool invocations.
558 #[serde(default)]
559 pub run_wrapper: Option<String>,
560 /// Extra paths to append to default lint commands.
561 #[serde(default)]
562 pub extra_lint_paths: Vec<String>,
563 /// Override the core Cargo dependency name and path for the Swift binding crate.
564 /// When set, the binding `Cargo.toml` depends on this crate (resolved as
565 /// `../../../crates/<override>`) instead of the umbrella `[crate.name]`.
566 /// Defaults to unset.
567 #[serde(default)]
568 pub core_crate_override: Option<String>,
569 /// Keys to subtract from the merged `extra_dependencies` set for this
570 /// language only.
571 #[serde(default)]
572 pub exclude_extra_dependencies: Vec<String>,
573}
574
575#[derive(Debug, Clone, Serialize, Deserialize)]
576pub struct GleamConfig {
577 pub app_name: Option<String>,
578 /// Erlang atom name for @external(erlang, "<nif>", ...) lookups (e.g., "my_app_nif").
579 /// Defaults to the app_name.
580 #[serde(default)]
581 pub nif_module: Option<String>,
582 #[serde(default)]
583 pub features: Option<Vec<String>>,
584 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
585 /// When set, this takes priority over the IR type-level serde_rename_all.
586 #[serde(default)]
587 pub serde_rename_all: Option<String>,
588 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
589 /// desired binding field name. Applied after automatic keyword escaping.
590 #[serde(default)]
591 pub rename_fields: HashMap<String, String>,
592 /// Functions to exclude from Gleam binding generation.
593 #[serde(default)]
594 pub exclude_functions: Vec<String>,
595 /// Types to exclude from Gleam binding generation.
596 #[serde(default)]
597 pub exclude_types: Vec<String>,
598 /// Prefix wrapper for default tool invocations.
599 #[serde(default)]
600 pub run_wrapper: Option<String>,
601 /// Extra paths to append to default lint commands.
602 #[serde(default)]
603 pub extra_lint_paths: Vec<String>,
604}
605
606#[derive(Debug, Clone, Serialize, Deserialize)]
607pub struct ZigConfig {
608 pub module_name: Option<String>,
609 #[serde(default)]
610 pub features: Option<Vec<String>>,
611 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
612 /// When set, this takes priority over the IR type-level serde_rename_all.
613 #[serde(default)]
614 pub serde_rename_all: Option<String>,
615 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
616 /// desired binding field name. Applied after automatic keyword escaping.
617 #[serde(default)]
618 pub rename_fields: HashMap<String, String>,
619 /// Functions to exclude from Zig binding generation.
620 #[serde(default)]
621 pub exclude_functions: Vec<String>,
622 /// Types to exclude from Zig binding generation.
623 #[serde(default)]
624 pub exclude_types: Vec<String>,
625 /// Prefix wrapper for default tool invocations.
626 #[serde(default)]
627 pub run_wrapper: Option<String>,
628 /// Extra paths to append to default lint commands.
629 #[serde(default)]
630 pub extra_lint_paths: Vec<String>,
631}
632
633#[derive(Debug, Clone, Serialize, Deserialize)]
634pub struct CSharpConfig {
635 pub namespace: Option<String>,
636 /// NuGet `<PackageId>` to publish under. When unset, falls back to `namespace`.
637 /// Use this when the published artifact id must differ from the C# `RootNamespace` —
638 /// e.g. when the unprefixed name is owned by a third party on nuget.org and
639 /// you publish under a vendor-prefixed id like `KreuzbergDev.<Lib>`.
640 #[serde(default)]
641 pub package_id: Option<String>,
642 pub target_framework: Option<String>,
643 #[serde(default)]
644 pub features: Option<Vec<String>>,
645 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
646 /// When set, this takes priority over the IR type-level serde_rename_all.
647 #[serde(default)]
648 pub serde_rename_all: Option<String>,
649 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
650 /// desired binding field name. Applied after automatic keyword escaping.
651 #[serde(default)]
652 pub rename_fields: HashMap<String, String>,
653 /// Prefix wrapper for default tool invocations. When set, prepends this string to default
654 /// commands across all pipelines (lint, test, build, etc.).
655 #[serde(default)]
656 pub run_wrapper: Option<String>,
657 /// Extra paths to append to default lint commands (format, check, typecheck).
658 /// Ignored when project_file is set.
659 #[serde(default)]
660 pub extra_lint_paths: Vec<String>,
661 /// Project file for C# (e.g., "MyProject.csproj", "MySolution.sln"). When set, default
662 /// lint/build/test commands target this file instead of the output directory.
663 #[serde(default)]
664 pub project_file: Option<String>,
665 /// Functions to exclude from C# binding generation (e.g., functions not present in the
666 /// C FFI layer). Excluded functions are omitted from both NativeMethods.cs and the
667 /// wrapper class.
668 #[serde(default)]
669 pub exclude_functions: Vec<String>,
670}
671
672#[derive(Debug, Clone, Serialize, Deserialize)]
673pub struct RConfig {
674 pub package_name: Option<String>,
675 #[serde(default)]
676 pub features: Option<Vec<String>>,
677 /// Override the serde rename_all strategy for JSON field names (e.g. "camelCase", "snake_case").
678 /// When set, this takes priority over the IR type-level serde_rename_all.
679 #[serde(default)]
680 pub serde_rename_all: Option<String>,
681 /// Per-field name remapping for this language. Key is `TypeName.field_name`, value is the
682 /// desired binding field name. Applied after automatic keyword escaping.
683 #[serde(default)]
684 pub rename_fields: HashMap<String, String>,
685 /// Prefix wrapper for default tool invocations. When set, prepends this string to default
686 /// commands across all pipelines (lint, test, build, etc.).
687 #[serde(default)]
688 pub run_wrapper: Option<String>,
689 /// Extra paths to append to default lint commands (format, check, typecheck).
690 #[serde(default)]
691 pub extra_lint_paths: Vec<String>,
692}
693
694/// Custom modules that alef should declare (mod X;) but not generate.
695/// These are hand-written modules imported by the generated lib.rs.
696#[derive(Debug, Clone, Default, Serialize, Deserialize)]
697pub struct CustomModulesConfig {
698 #[serde(default)]
699 pub python: Vec<String>,
700 #[serde(default)]
701 pub node: Vec<String>,
702 #[serde(default)]
703 pub ruby: Vec<String>,
704 #[serde(default)]
705 pub php: Vec<String>,
706 #[serde(default)]
707 pub elixir: Vec<String>,
708 #[serde(default)]
709 pub wasm: Vec<String>,
710 #[serde(default)]
711 pub ffi: Vec<String>,
712 #[serde(default)]
713 pub go: Vec<String>,
714 #[serde(default)]
715 pub java: Vec<String>,
716 #[serde(default)]
717 pub csharp: Vec<String>,
718 #[serde(default)]
719 pub r: Vec<String>,
720}
721
722impl CustomModulesConfig {
723 pub fn for_language(&self, lang: Language) -> &[String] {
724 match lang {
725 Language::Python => &self.python,
726 Language::Node => &self.node,
727 Language::Ruby => &self.ruby,
728 Language::Php => &self.php,
729 Language::Elixir => &self.elixir,
730 Language::Wasm => &self.wasm,
731 Language::Ffi => &self.ffi,
732 Language::Go => &self.go,
733 Language::Java => &self.java,
734 Language::Csharp => &self.csharp,
735 Language::R => &self.r,
736 Language::Rust => &[], // Rust doesn't need custom modules (no binding crate)
737 Language::Kotlin | Language::Swift | Language::Dart | Language::Gleam | Language::Zig | Language::C => &[],
738 }
739 }
740}
741
742/// Custom classes/functions from hand-written modules to register in module init.
743#[derive(Debug, Clone, Default, Serialize, Deserialize)]
744pub struct CustomRegistration {
745 #[serde(default)]
746 pub classes: Vec<String>,
747 #[serde(default)]
748 pub functions: Vec<String>,
749 #[serde(default)]
750 pub init_calls: Vec<String>,
751}
752
753/// Per-language custom registrations.
754#[derive(Debug, Clone, Default, Serialize, Deserialize)]
755pub struct CustomRegistrationsConfig {
756 #[serde(default)]
757 pub python: Option<CustomRegistration>,
758 #[serde(default)]
759 pub node: Option<CustomRegistration>,
760 #[serde(default)]
761 pub ruby: Option<CustomRegistration>,
762 #[serde(default)]
763 pub php: Option<CustomRegistration>,
764 #[serde(default)]
765 pub elixir: Option<CustomRegistration>,
766 #[serde(default)]
767 pub wasm: Option<CustomRegistration>,
768}
769
770impl CustomRegistrationsConfig {
771 pub fn for_language(&self, lang: Language) -> Option<&CustomRegistration> {
772 match lang {
773 Language::Python => self.python.as_ref(),
774 Language::Node => self.node.as_ref(),
775 Language::Ruby => self.ruby.as_ref(),
776 Language::Php => self.php.as_ref(),
777 Language::Elixir => self.elixir.as_ref(),
778 Language::Wasm => self.wasm.as_ref(),
779 _ => None,
780 }
781 }
782}