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::{CompilerBuiltins, 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", // unused, present for compatibility
39        yarn: Option<String> = "yarn",
40        python: Option<String> = "python",
41        windows_rc: Option<String> = "windows-rc",
42        reuse: Option<String> = "reuse",
43        locked_deps: Option<bool> = "locked-deps",
44        vendor: Option<bool> = "vendor",
45        full_bootstrap: Option<bool> = "full-bootstrap",
46        bootstrap_cache_path: Option<PathBuf> = "bootstrap-cache-path",
47        extended: Option<bool> = "extended",
48        tools: Option<HashSet<String>> = "tools",
49        tool: Option<HashMap<String, Tool>> = "tool",
50        verbose: Option<usize> = "verbose",
51        sanitizers: Option<bool> = "sanitizers",
52        profiler: Option<bool> = "profiler",
53        cargo_native_static: Option<bool> = "cargo-native-static",
54        low_priority: Option<bool> = "low-priority",
55        configure_args: Option<Vec<String>> = "configure-args",
56        local_rebuild: Option<bool> = "local-rebuild",
57        print_step_timings: Option<bool> = "print-step-timings",
58        print_step_rusage: Option<bool> = "print-step-rusage",
59        check_stage: Option<u32> = "check-stage",
60        doc_stage: Option<u32> = "doc-stage",
61        build_stage: Option<u32> = "build-stage",
62        test_stage: Option<u32> = "test-stage",
63        install_stage: Option<u32> = "install-stage",
64        dist_stage: Option<u32> = "dist-stage",
65        bench_stage: Option<u32> = "bench-stage",
66        patch_binaries_for_nix: Option<bool> = "patch-binaries-for-nix",
67        // NOTE: only parsed by bootstrap.py, `--feature build-metrics` enables metrics unconditionally
68        metrics: Option<bool> = "metrics",
69        android_ndk: Option<PathBuf> = "android-ndk",
70        optimized_compiler_builtins: Option<CompilerBuiltins> = "optimized-compiler-builtins",
71        jobs: Option<u32> = "jobs",
72        compiletest_diff_tool: Option<String> = "compiletest-diff-tool",
73        compiletest_allow_stage0: Option<bool> = "compiletest-allow-stage0",
74        /// No longer has any effect; kept (for now) to avoid breaking people's configs.
75        /// FIXME(#146929): Remove this in 2026.
76        compiletest_use_stage0_libtest: Option<bool> = "compiletest-use-stage0-libtest",
77        tidy_extra_checks: Option<String> = "tidy-extra-checks",
78        ccache: Option<StringOrBool> = "ccache",
79        exclude: Option<Vec<PathBuf>> = "exclude",
80    }
81}
82
83define_config! {
84    /// Configuration specific for some tool, e.g. which features to enable during build.
85    #[derive(Default, Clone)]
86    struct Tool {
87        features: Option<Vec<String>> = "features",
88    }
89}