rsconstruct 0.9.85

Rust based fast build system
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
use anyhow::{Context, Result};
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;

use serde::{Deserialize, Serialize};

use crate::config::{StandardConfig, output_config_hash, resolve_extra_inputs};
use crate::file_index::FileIndex;
use crate::graph::{BuildGraph, Product};
use crate::processors::{Processor, anchor_display_dir, check_command_output, run_command};

#[derive(Debug, Deserialize, Serialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct CcLibraryDef {
    pub name: String,
    #[serde(default = "default_cc_lib_type")]
    pub lib_type: String,
    pub sources: Vec<String>,
    #[serde(default)]
    pub include_dirs: Vec<String>,
    #[serde(default)]
    pub cflags: Vec<String>,
    #[serde(default)]
    pub cxxflags: Vec<String>,
    #[serde(default)]
    pub ldflags: Vec<String>,
}

fn default_cc_lib_type() -> String {
    "shared".into()
}

#[derive(Debug, Deserialize, Serialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct CcProgramDef {
    pub name: String,
    pub sources: Vec<String>,
    #[serde(default)]
    pub link: Vec<String>,
    #[serde(default)]
    pub include_dirs: Vec<String>,
    #[serde(default)]
    pub cflags: Vec<String>,
    #[serde(default)]
    pub cxxflags: Vec<String>,
    #[serde(default)]
    pub ldflags: Vec<String>,
}

/// Parsed contents of a cc.yaml file, resolved against the `[processor.cc]`
/// config: the six inheritable fields (`cc`, `cxx`, `cflags`, `cxxflags`,
/// `ldflags`, `include_dirs`) default to the config's values, so
/// `rsconstruct.toml` sets project-wide defaults and each cc.yaml overrides
/// per directory. Construct via [`CcManifest::parse`] — the raw serde shape
/// lives in `CcManifestRaw` so "field absent" (inherit) is distinguishable
/// from "field explicitly set".
#[derive(Debug, Clone)]
pub struct CcManifest {
    pub cc: String,
    pub cxx: String,
    pub cflags: Vec<String>,
    pub cxxflags: Vec<String>,
    pub ldflags: Vec<String>,
    pub include_dirs: Vec<String>,
    pub libraries: Vec<CcLibraryDef>,
    pub programs: Vec<CcProgramDef>,
}

/// The raw serde shape of cc.yaml. Inheritable fields are optional; absent
/// means "inherit the `[processor.cc]` config value".
#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
struct CcManifestRaw {
    cc: Option<String>,
    cxx: Option<String>,
    cflags: Option<Vec<String>>,
    cxxflags: Option<Vec<String>>,
    ldflags: Option<Vec<String>>,
    include_dirs: Option<Vec<String>>,
    #[serde(default)]
    libraries: Vec<CcLibraryDef>,
    #[serde(default)]
    programs: Vec<CcProgramDef>,
}

impl CcManifest {
    /// Parse cc.yaml content, inheriting unset fields from the config.
    pub fn parse(content: &str, defaults: &CcConfig) -> Result<Self, serde_yaml_ng::Error> {
        let raw: CcManifestRaw = serde_yaml_ng::from_str(content)?;
        Ok(Self {
            cc: raw.cc.unwrap_or_else(|| defaults.cc.clone()),
            cxx: raw.cxx.unwrap_or_else(|| defaults.cxx.clone()),
            cflags: raw.cflags.unwrap_or_else(|| defaults.cflags.clone()),
            cxxflags: raw.cxxflags.unwrap_or_else(|| defaults.cxxflags.clone()),
            ldflags: raw.ldflags.unwrap_or_else(|| defaults.ldflags.clone()),
            include_dirs: raw
                .include_dirs
                .unwrap_or_else(|| defaults.include_dirs.clone()),
            libraries: raw.libraries,
            programs: raw.programs,
        })
    }
}

/// CC (full C/C++ project) config. Custom: cc, cxx, cflags, cxxflags, ldflags, `include_dirs`, `single_invocation`, `cache_output_dir`.
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct CcConfig {
    #[serde(default = "crate::config::default_cc_compiler")]
    pub cc: String,
    #[serde(default = "crate::config::default_cxx_compiler")]
    pub cxx: String,
    #[serde(default)]
    pub cflags: Vec<String>,
    #[serde(default)]
    pub cxxflags: Vec<String>,
    #[serde(default)]
    pub ldflags: Vec<String>,
    #[serde(default)]
    pub include_dirs: Vec<String>,
    #[serde(default)]
    pub single_invocation: bool,
    #[serde(default = "crate::config::default_true")]
    pub cache_output_dir: bool,
    #[serde(flatten)]
    pub standard: StandardConfig,
}

impl Default for CcConfig {
    fn default() -> Self {
        Self {
            cc: "gcc".into(),
            cxx: "g++".into(),
            cflags: Vec::new(),
            cxxflags: Vec::new(),
            ldflags: Vec::new(),
            include_dirs: Vec::new(),
            single_invocation: false,
            cache_output_dir: true,
            standard: StandardConfig::default(),
        }
    }
}

pub struct CcProcessor {
    config: CcConfig,
    /// Compilers the discovered cc.yaml manifests actually resolve to.
    /// Filled during `discover` so `required_tools()` names the real
    /// compilers by execution time (the debug declared-tools assertion
    /// checks against it), not just the config defaults.
    manifest_compilers: std::sync::Mutex<std::collections::BTreeSet<String>>,
}

impl CcProcessor {
    pub const fn new(config: CcConfig) -> Self {
        Self {
            config,
            manifest_compilers: std::sync::Mutex::new(std::collections::BTreeSet::new()),
        }
    }

    /// Determine whether a source file is C++ based on extension.
    fn is_cxx(path: &Path) -> bool {
        matches!(
            path.extension().and_then(|e| e.to_str()),
            Some("cc" | "cpp" | "cxx" | "C")
        )
    }

    /// Choose the compiler for a source file.
    fn compiler_for(manifest: &CcManifest, source: &Path) -> String {
        if Self::is_cxx(source) {
            manifest.cxx.clone()
        } else {
            manifest.cc.clone()
        }
    }

    /// Choose cflags or cxxflags for a source file.
    fn lang_flags_for<'a>(manifest: &'a CcManifest, source: &Path) -> &'a [String] {
        if Self::is_cxx(source) {
            &manifest.cxxflags
        } else {
            &manifest.cflags
        }
    }

    /// Parse a cc.yaml file, inheriting unset fields from the
    /// `[processor.cc]` config (project-wide defaults, per-directory
    /// overrides).
    fn parse_manifest(&self, yaml_path: &Path) -> Result<CcManifest> {
        let content = fs::read_to_string(yaml_path)
            .with_context(|| format!("Failed to read {}", yaml_path.display()))?;
        let manifest = CcManifest::parse(&content, &self.config)
            .with_context(|| format!("Failed to parse {}", yaml_path.display()))?;
        Ok(manifest)
    }

    /// Compile a single source file to an object file.
    /// All paths are relative to the project root.
    fn compile_object(
        ctx: &crate::build_context::BuildContext,
        manifest: &CcManifest,
        source: &Path,
        obj: &Path,
        extra_cflags: &[String],
    ) -> Result<()> {
        crate::processors::ensure_output_dir(obj)?;
        let compiler = Self::compiler_for(manifest, source);
        let mut cmd = Command::new(&compiler);
        cmd.arg("-c");
        for flag in Self::lang_flags_for(manifest, source) {
            cmd.arg(flag);
        }
        for flag in extra_cflags {
            cmd.arg(flag);
        }
        cmd.arg("-o").arg(obj).arg(source);
        let output = run_command(ctx, &cmd)?;
        check_command_output(
            &output,
            format_args!("{} -c {}", compiler, source.display()),
        )
    }

    /// Build a static library from object files.
    fn build_static_lib(
        ctx: &crate::build_context::BuildContext,
        lib_path: &Path,
        objects: &[PathBuf],
    ) -> Result<()> {
        crate::processors::ensure_output_dir(lib_path)?;
        let mut cmd = Command::new("ar");
        cmd.arg("rcs").arg(lib_path);
        for obj in objects {
            cmd.arg(obj);
        }
        let output = run_command(ctx, &cmd)?;
        check_command_output(&output, format_args!("ar rcs {}", lib_path.display()))
    }

    /// Object file path for a source, mirroring the manifest-relative source
    /// path under the target's obj dir so equal stems in different directories
    /// (`src1/util.c`, `src2/util.c`) cannot collide. `..`/`.` components are
    /// dropped to keep the object inside the obj dir.
    fn object_path_for(target_obj_dir: &Path, source_rel: &str) -> PathBuf {
        let mut rel: PathBuf = Path::new(source_rel)
            .components()
            .filter_map(|c| match c {
                std::path::Component::Normal(p) => Some(p),
                _ => None,
            })
            .collect();
        rel.set_extension("o");
        target_obj_dir.join(rel)
    }

    /// Build a shared library from object files.
    /// `has_cxx` selects the C++ driver, which C++ objects need at link time.
    fn build_shared_lib(
        ctx: &crate::build_context::BuildContext,
        manifest: &CcManifest,
        lib_path: &Path,
        objects: &[PathBuf],
        ldflags: &[String],
        has_cxx: bool,
    ) -> Result<()> {
        crate::processors::ensure_output_dir(lib_path)?;
        let compiler = if has_cxx { &manifest.cxx } else { &manifest.cc };
        let mut cmd = Command::new(compiler);
        cmd.arg("-shared").arg("-o").arg(lib_path);
        for obj in objects {
            cmd.arg(obj);
        }
        for flag in &manifest.ldflags {
            cmd.arg(flag);
        }
        for flag in ldflags {
            cmd.arg(flag);
        }
        let output = run_command(ctx, &cmd)?;
        check_command_output(
            &output,
            format_args!("{} -shared -o {}", compiler, lib_path.display()),
        )
    }

    /// Link object files into an executable.
    /// `has_cxx` selects the C++ driver, which C++ objects need at link time.
    ///
    /// 8 arguments against clippy's limit of 7 — each is a distinct part of
    /// a linker invocation, and the natural grouping (`CcManifest`) is
    /// already one of them.
    #[allow(clippy::too_many_arguments)]
    fn link_program(
        ctx: &crate::build_context::BuildContext,
        manifest: &CcManifest,
        exe_path: &Path,
        objects: &[PathBuf],
        lib_dir: &Path,
        link_libs: &[String],
        ldflags: &[String],
        has_cxx: bool,
    ) -> Result<()> {
        crate::processors::ensure_output_dir(exe_path)?;
        let compiler = if has_cxx { &manifest.cxx } else { &manifest.cc };
        let mut cmd = Command::new(compiler);
        cmd.arg("-o").arg(exe_path);
        for obj in objects {
            cmd.arg(obj);
        }
        if !link_libs.is_empty() {
            cmd.arg(format!("-L{}", lib_dir.display()));
            for lib in link_libs {
                cmd.arg(format!("-l{lib}"));
            }
        }
        for flag in &manifest.ldflags {
            cmd.arg(flag);
        }
        for flag in ldflags {
            cmd.arg(flag);
        }
        let output = run_command(ctx, &cmd)?;
        check_command_output(
            &output,
            format_args!("{} -o {}", compiler, exe_path.display()),
        )
    }

    /// Single-invocation build for a program (all sources in one command).
    fn single_invocation_program(
        ctx: &crate::build_context::BuildContext,
        manifest: &CcManifest,
        exe_path: &Path,
        sources: &[PathBuf],
        lib_dir: &Path,
        link_libs: &[String],
        ldflags: &[String],
    ) -> Result<()> {
        crate::processors::ensure_output_dir(exe_path)?;
        let has_cxx = sources.iter().any(|s| Self::is_cxx(s));
        let compiler = if has_cxx { &manifest.cxx } else { &manifest.cc };
        let mut cmd = Command::new(compiler);
        let global_flags = if has_cxx {
            &manifest.cxxflags
        } else {
            &manifest.cflags
        };
        for flag in global_flags {
            cmd.arg(flag);
        }
        cmd.arg("-o").arg(exe_path);
        for source in sources {
            cmd.arg(source);
        }
        if !link_libs.is_empty() {
            cmd.arg(format!("-L{}", lib_dir.display()));
            for lib in link_libs {
                cmd.arg(format!("-l{lib}"));
            }
        }
        for flag in &manifest.ldflags {
            cmd.arg(flag);
        }
        for flag in ldflags {
            cmd.arg(flag);
        }
        let output = run_command(ctx, &cmd)?;
        check_command_output(
            &output,
            format_args!("{} -o {}", compiler, exe_path.display()),
        )
    }

    /// Compute the output directory for a cc.yaml file.
    /// Output goes under out/cc/<relative-path-to-cc.yaml-dir>/.
    fn output_dir_for(yaml_path: &Path) -> PathBuf {
        let anchor_dir = crate::processors::parent_dir_or_empty(yaml_path);
        if anchor_dir.as_os_str().is_empty() {
            PathBuf::from("out/cc")
        } else {
            Path::new("out/cc").join(anchor_dir)
        }
    }

    /// Execute a full cc.yaml build.
    /// All commands run from the project root. Manifest paths are resolved
    /// to project-root-relative paths using the cc.yaml's parent directory.
    fn execute_build(
        &self,
        ctx: &crate::build_context::BuildContext,
        yaml_path: &Path,
    ) -> Result<()> {
        let manifest = self.parse_manifest(yaml_path)?;
        let anchor_dir = crate::processors::parent_dir_or_empty(yaml_path);
        let output_dir = Self::output_dir_for(yaml_path);
        let obj_dir = output_dir.join("obj");
        let lib_dir = output_dir.join("lib");
        let bin_dir = output_dir.join("bin");

        // include_dirs are relative to the project root (not the cc.yaml directory)
        let resolved_include_flags: Vec<String> = manifest
            .include_dirs
            .iter()
            .map(|dir| format!("-I{dir}"))
            .collect();

        // Build libraries
        for lib in &manifest.libraries {
            let build_shared = matches!(lib.lib_type.as_str(), "shared" | "both");
            let build_static = matches!(lib.lib_type.as_str(), "static" | "both");

            let mut extra_cflags: Vec<String> = lib.cflags.clone();
            if build_shared {
                extra_cflags.push("-fPIC".into());
            }
            for dir in &lib.include_dirs {
                extra_cflags.push(format!("-I{dir}"));
            }
            extra_cflags.extend_from_slice(&resolved_include_flags);

            let target_obj_dir = obj_dir.join(&lib.name);
            let mut objects = Vec::new();
            for source_str in &lib.sources {
                let source = crate::processors::resolve_anchor_path(anchor_dir, source_str);
                let obj = Self::object_path_for(&target_obj_dir, source_str);
                Self::compile_object(ctx, &manifest, &source, &obj, &extra_cflags)?;
                objects.push(obj);
            }
            let has_cxx = lib.sources.iter().any(|s| Self::is_cxx(Path::new(s)));

            if build_static {
                let lib_path = lib_dir.join(format!("lib{}.a", lib.name));
                Self::build_static_lib(ctx, &lib_path, &objects)?;
            }
            if build_shared {
                let lib_path = lib_dir.join(format!("lib{}.so", lib.name));
                Self::build_shared_lib(ctx, &manifest, &lib_path, &objects, &lib.ldflags, has_cxx)?;
            }
        }

        // Build programs
        for prog in &manifest.programs {
            let exe_path = bin_dir.join(&prog.name);

            // Resolve source paths
            let sources: Vec<PathBuf> = prog
                .sources
                .iter()
                .map(|s| crate::processors::resolve_anchor_path(anchor_dir, s))
                .collect();

            if self.config.single_invocation {
                Self::single_invocation_program(
                    ctx,
                    &manifest,
                    &exe_path,
                    &sources,
                    &lib_dir,
                    &prog.link,
                    &prog.ldflags,
                )?;
            } else {
                let target_obj_dir = obj_dir.join(&prog.name);
                let mut objects = Vec::new();

                let mut extra_cflags: Vec<String> = prog.cflags.clone();
                for dir in &prog.include_dirs {
                    extra_cflags.push(format!("-I{dir}"));
                }
                extra_cflags.extend_from_slice(&resolved_include_flags);

                for (source_str, source) in prog.sources.iter().zip(&sources) {
                    let obj = Self::object_path_for(&target_obj_dir, source_str);
                    Self::compile_object(ctx, &manifest, source, &obj, &extra_cflags)?;
                    objects.push(obj);
                }
                let has_cxx = sources.iter().any(|s| Self::is_cxx(s));
                Self::link_program(
                    ctx,
                    &manifest,
                    &exe_path,
                    &objects,
                    &lib_dir,
                    &prog.link,
                    &prog.ldflags,
                    has_cxx,
                )?;
            }
        }

        Ok(())
    }
}

impl Processor for CcProcessor {
    fn scan_config(&self) -> &crate::config::StandardConfig {
        &self.config.standard
    }

    fn config_json(&self) -> Option<String> {
        crate::processors::ProcessorBase::config_json(&self.config)
    }

    fn clean(&self, product: &crate::graph::Product, verbose: bool) -> anyhow::Result<usize> {
        crate::processors::ProcessorBase::clean_output_dir(product, &product.processor, verbose)
    }

    fn required_tools(&self) -> Vec<String> {
        // The config values are project-wide defaults; each cc.yaml may
        // override the compiler per directory. Discovery records what the
        // manifests actually resolve to, so by execution time this names
        // the real compilers, not just the defaults.
        let mut tools: Vec<String> = vec![
            self.config.cc.clone(),
            self.config.cxx.clone(),
            "ar".to_string(),
        ];
        for compiler in self.manifest_compilers.lock().unwrap().iter() {
            if !tools.contains(compiler) {
                tools.push(compiler.clone());
            }
        }
        tools
    }

    fn discover(
        &self,
        graph: &mut BuildGraph,
        file_index: &FileIndex,
        instance_name: &str,
    ) -> Result<()> {
        let Some(files) = crate::processors::scan_or_skip(&self.config.standard, file_index) else {
            return Ok(());
        };
        let hash = Some(output_config_hash(
            &self.config,
            &crate::config::checksum_fields_of(instance_name),
        ));
        let extra = resolve_extra_inputs(&self.config.standard.dep_inputs)?;

        for yaml_path in files {
            let manifest = match self.parse_manifest(&yaml_path) {
                Ok(m) => m,
                Err(e) => {
                    anyhow::bail!("Failed to parse {}: {}", yaml_path.display(), e);
                }
            };

            // Record the compilers this manifest resolves to, so
            // required_tools() covers per-manifest overrides.
            {
                let mut compilers = self.manifest_compilers.lock().unwrap();
                compilers.insert(manifest.cc.clone());
                compilers.insert(manifest.cxx.clone());
            }

            // Source paths in the manifest are relative to the cc.yaml directory.
            // Resolve to project-root-relative paths for the build graph.
            let anchor_dir = crate::processors::parent_dir_or_empty(&yaml_path);

            let mut inputs: Vec<PathBuf> = Vec::new();
            inputs.push(yaml_path.clone());

            for lib in &manifest.libraries {
                for source in &lib.sources {
                    inputs.push(crate::processors::resolve_anchor_path(anchor_dir, source));
                }
            }
            for prog in &manifest.programs {
                for source in &prog.sources {
                    inputs.push(crate::processors::resolve_anchor_path(anchor_dir, source));
                }
            }

            inputs.extend_from_slice(&extra);

            if self.config.cache_output_dir {
                let output_dir = Self::output_dir_for(&yaml_path);
                graph.add_product_with_output_dir(
                    inputs,
                    vec![],
                    instance_name,
                    hash.clone(),
                    output_dir,
                )?;
            } else {
                graph.add_product(inputs, vec![], instance_name, hash.clone())?;
            }
        }
        Ok(())
    }

    fn execute(&self, ctx: &crate::build_context::BuildContext, product: &Product) -> Result<()> {
        let yaml_path = product.primary_input();
        let display_dir = anchor_display_dir(yaml_path);
        self.execute_build(ctx, yaml_path)
            .with_context(|| format!("cc build failed in {display_dir}"))
    }
}

fn plugin_create(toml: &toml::Value) -> anyhow::Result<Box<dyn crate::processors::Processor>> {
    crate::registries::deserialize_and_create(toml, |cfg| Box::new(CcProcessor::new(cfg)))
}
inventory::submit! {
    crate::registries::ProcessorPlugin {
        version: 1,
        name: "cc",
        processor_type: crate::processors::ProcessorType::Creator,
        create: plugin_create,
        fields: &[
            crate::config::FieldSpec { name: "cc", ty: crate::config::FieldType::String,
                affects_output: true, required: false,
                doc: "Default C compiler executable (overridable per cc.yaml)" },
            crate::config::FieldSpec { name: "cxx", ty: crate::config::FieldType::String,
                affects_output: true, required: false,
                doc: "Default C++ compiler executable (overridable per cc.yaml)" },
            crate::config::FieldSpec { name: "cflags", ty: crate::config::FieldType::StringArray,
                affects_output: true, required: false,
                doc: "Default C compiler flags (overridable per cc.yaml)" },
            crate::config::FieldSpec { name: "cxxflags", ty: crate::config::FieldType::StringArray,
                affects_output: true, required: false,
                doc: "Default C++ compiler flags (overridable per cc.yaml)" },
            crate::config::FieldSpec { name: "ldflags", ty: crate::config::FieldType::StringArray,
                affects_output: true, required: false,
                doc: "Default linker flags (overridable per cc.yaml)" },
            crate::config::FieldSpec { name: "include_dirs", ty: crate::config::FieldType::StringArray,
                affects_output: true, required: false,
                doc: "Default header search directories (overridable per cc.yaml)" },
            crate::config::FieldSpec { name: "single_invocation", ty: crate::config::FieldType::Bool,
                affects_output: true, required: false,
                doc: "Compile all sources in one compiler call" },
            crate::config::FieldSpec { name: "cache_output_dir", ty: crate::config::FieldType::Bool,
                affects_output: false, required: false,
                doc: "Cache the entire output directory as a unit" },
        ],
        omit_standard_fields: &["command", "formats", "args", "dep_auto", "output_dir"],
        scan_defaults: Some(crate::config::ScanDefaultsData { src_dirs: &[], src_extensions: &["cc.yaml"], src_exclude_dirs: &[] }),
        defaults: None,
        defconfig_json: crate::registries::default_config_json::<CcConfig>,
        keywords: &["c", "cpp", "builder", "compiler", "gcc", "clang", "cc", "h", "hpp"],
        description: "Build C/C++ projects from cc.yaml manifests",
        is_native: false,
        can_fix: false,
        supports_batch: false,
        max_jobs_cap: Some(1),
    }
}