bootstrap/core/config/toml/
build.rs

1//! This module defines the `Build` struct, which represents the `[build]` table
2//! in the `bootstrap.toml` configuration file.
3//!
4//! The `[build]` table contains global options that influence the overall build process,
5//! such as default host and target triples, paths to tools, build directories, and
6//! various feature flags. These options apply across different stages and components
7//! unless specifically overridden by other configuration sections or command-line flags.
8
9use std::collections::HashMap;
10
11use serde::{Deserialize, Deserializer};
12
13use crate::core::config::toml::ReplaceOpt;
14use crate::core::config::{Merge, StringOrBool};
15use crate::{HashSet, PathBuf, define_config, exit};
16
17define_config! {
18    /// TOML representation of various global build decisions.
19    #[derive(Default)]
20    struct Build {
21        build: Option<String> = "build",
22        description: Option<String> = "description",
23        host: Option<Vec<String>> = "host",
24        target: Option<Vec<String>> = "target",
25        build_dir: Option<String> = "build-dir",
26        cargo: Option<PathBuf> = "cargo",
27        rustc: Option<PathBuf> = "rustc",
28        rustfmt: Option<PathBuf> = "rustfmt",
29        cargo_clippy: Option<PathBuf> = "cargo-clippy",
30        docs: Option<bool> = "docs",
31        compiler_docs: Option<bool> = "compiler-docs",
32        library_docs_private_items: Option<bool> = "library-docs-private-items",
33        docs_minification: Option<bool> = "docs-minification",
34        submodules: Option<bool> = "submodules",
35        gdb: Option<String> = "gdb",
36        lldb: Option<String> = "lldb",
37        nodejs: Option<String> = "nodejs",
38        npm: Option<String> = "npm",
39        python: Option<String> = "python",
40        reuse: Option<String> = "reuse",
41        locked_deps: Option<bool> = "locked-deps",
42        vendor: Option<bool> = "vendor",
43        full_bootstrap: Option<bool> = "full-bootstrap",
44        bootstrap_cache_path: Option<PathBuf> = "bootstrap-cache-path",
45        extended: Option<bool> = "extended",
46        tools: Option<HashSet<String>> = "tools",
47        tool: Option<HashMap<String, Tool>> = "tool",
48        verbose: Option<usize> = "verbose",
49        sanitizers: Option<bool> = "sanitizers",
50        profiler: Option<bool> = "profiler",
51        cargo_native_static: Option<bool> = "cargo-native-static",
52        low_priority: Option<bool> = "low-priority",
53        configure_args: Option<Vec<String>> = "configure-args",
54        local_rebuild: Option<bool> = "local-rebuild",
55        print_step_timings: Option<bool> = "print-step-timings",
56        print_step_rusage: Option<bool> = "print-step-rusage",
57        check_stage: Option<u32> = "check-stage",
58        doc_stage: Option<u32> = "doc-stage",
59        build_stage: Option<u32> = "build-stage",
60        test_stage: Option<u32> = "test-stage",
61        install_stage: Option<u32> = "install-stage",
62        dist_stage: Option<u32> = "dist-stage",
63        bench_stage: Option<u32> = "bench-stage",
64        patch_binaries_for_nix: Option<bool> = "patch-binaries-for-nix",
65        // NOTE: only parsed by bootstrap.py, `--feature build-metrics` enables metrics unconditionally
66        metrics: Option<bool> = "metrics",
67        android_ndk: Option<PathBuf> = "android-ndk",
68        optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins",
69        jobs: Option<u32> = "jobs",
70        compiletest_diff_tool: Option<String> = "compiletest-diff-tool",
71        compiletest_use_stage0_libtest: Option<bool> = "compiletest-use-stage0-libtest",
72        ccache: Option<StringOrBool> = "ccache",
73        exclude: Option<Vec<PathBuf>> = "exclude",
74    }
75}
76
77define_config! {
78    /// Configuration specific for some tool, e.g. which features to enable during build.
79    #[derive(Default, Clone)]
80    struct Tool {
81        features: Option<Vec<String>> = "features",
82    }
83}