Skip to main content

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, HashSet};
10use std::path::PathBuf;
11
12use serde::{Deserialize, Deserializer};
13
14use crate::core::config::toml::ReplaceOpt;
15use crate::core::config::{Allocator, CompilerBuiltins, DebuggerPath, Merge, StringOrBool};
16use crate::define_config;
17
18define_config! {
19    /// TOML representation of various global build decisions.
20    #[derive(Default)]
21    struct Build {
22        build: Option<String> = "build",
23        description: Option<String> = "description",
24        host: Option<Vec<String>> = "host",
25        target: Option<Vec<String>> = "target",
26        build_dir: Option<String> = "build-dir",
27        cargo: Option<PathBuf> = "cargo",
28        rustc: Option<PathBuf> = "rustc",
29        rustdoc: Option<PathBuf> = "rustdoc",
30        rustfmt: Option<PathBuf> = "rustfmt",
31        cargo_clippy: Option<PathBuf> = "cargo-clippy",
32        docs: Option<bool> = "docs",
33        compiler_docs: Option<bool> = "compiler-docs",
34        library_docs_private_items: Option<bool> = "library-docs-private-items",
35        docs_minification: Option<bool> = "docs-minification",
36        submodules: Option<bool> = "submodules",
37        gdb: Option<DebuggerPath> = "gdb",
38        lldb: Option<DebuggerPath> = "lldb",
39        nodejs: Option<String> = "nodejs",
40        npm: Option<String> = "npm", // unused, present for compatibility
41        yarn: Option<String> = "yarn",
42        python: Option<String> = "python",
43        windows_rc: Option<String> = "windows-rc",
44        reuse: Option<String> = "reuse",
45        locked_deps: Option<bool> = "locked-deps",
46        vendor: Option<bool> = "vendor",
47        full_bootstrap: Option<bool> = "full-bootstrap",
48        bootstrap_cache_path: Option<PathBuf> = "bootstrap-cache-path",
49        extended: Option<bool> = "extended",
50        tools: Option<HashSet<String>> = "tools",
51        tool: Option<HashMap<String, Tool>> = "tool",
52        verbose: Option<usize> = "verbose",
53        sanitizers: Option<bool> = "sanitizers",
54        profiler: Option<bool> = "profiler",
55        cargo_native_static: Option<bool> = "cargo-native-static",
56        low_priority: Option<bool> = "low-priority",
57        configure_args: Option<Vec<String>> = "configure-args",
58        local_rebuild: Option<bool> = "local-rebuild",
59        print_step_timings: Option<bool> = "print-step-timings",
60        print_step_rusage: Option<bool> = "print-step-rusage",
61        check_stage: Option<u32> = "check-stage",
62        doc_stage: Option<u32> = "doc-stage",
63        build_stage: Option<u32> = "build-stage",
64        test_stage: Option<u32> = "test-stage",
65        install_stage: Option<u32> = "install-stage",
66        dist_stage: Option<u32> = "dist-stage",
67        bench_stage: Option<u32> = "bench-stage",
68        patch_binaries_for_nix: Option<bool> = "patch-binaries-for-nix",
69        // NOTE: only parsed by bootstrap.py, `--feature build-metrics` enables metrics unconditionally
70        metrics: Option<bool> = "metrics",
71        android_ndk: Option<PathBuf> = "android-ndk",
72        optimized_compiler_builtins: Option<CompilerBuiltins> = "optimized-compiler-builtins",
73        jobs: Option<u32> = "jobs",
74        compiletest_diff_tool: Option<String> = "compiletest-diff-tool",
75        compiletest_allow_stage0: Option<bool> = "compiletest-allow-stage0",
76        tidy_extra_checks: Option<String> = "tidy-extra-checks",
77        ccache: Option<StringOrBool> = "ccache",
78        exclude: Option<Vec<PathBuf>> = "exclude",
79        record_failed_tests_path: Option<String> = "record_failed_tests_path",
80        sde: Option<String> = "sde",
81        allocator: Option<Allocator> = "allocator",
82    }
83}
84
85define_config! {
86    /// Configuration specific for some tool, e.g. which features to enable during build.
87    #[derive(Default, Clone)]
88    struct Tool {
89        features: Option<Vec<String>> = "features",
90    }
91}