Skip to content

Commit 992b498

Browse files
committed
moved install config parsing logic to toml/install.rs
1 parent f0406ab commit 992b498

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/bootstrap/src/core/config/parsing.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -486,16 +486,7 @@ impl Config {
486486
// Verbose flag is a good default for `rust.verbose-tests`.
487487
config.verbose_tests = config.is_verbose();
488488

489-
if let Some(install) = toml.install {
490-
let Install { prefix, sysconfdir, docdir, bindir, libdir, mandir, datadir } = install;
491-
config.prefix = prefix.map(PathBuf::from);
492-
config.sysconfdir = sysconfdir.map(PathBuf::from);
493-
config.datadir = datadir.map(PathBuf::from);
494-
config.docdir = docdir.map(PathBuf::from);
495-
set(&mut config.bindir, bindir.map(PathBuf::from));
496-
config.libdir = libdir.map(PathBuf::from);
497-
config.mandir = mandir.map(PathBuf::from);
498-
}
489+
config.apply_install_config(toml.install);
499490

500491
config.llvm_assertions =
501492
toml.llvm.as_ref().is_some_and(|llvm| llvm.assertions.unwrap_or(false));

src/bootstrap/src/core/config/toml/install.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use serde::{Deserialize, Deserializer};
22

3+
use crate::core::config::set;
34
use crate::core::config::toml::{Merge, ReplaceOpt};
4-
use crate::{HashSet, PathBuf, define_config, exit};
5+
use crate::{Config, HashSet, PathBuf, define_config, exit};
56

67
define_config! {
78
/// TOML representation of various global install decisions.
@@ -15,3 +16,18 @@ define_config! {
1516
datadir: Option<String> = "datadir",
1617
}
1718
}
19+
20+
impl Config {
21+
pub fn apply_install_config(&mut self, toml_install: Option<Install>) {
22+
if let Some(install) = toml_install {
23+
let Install { prefix, sysconfdir, docdir, bindir, libdir, mandir, datadir } = install;
24+
self.prefix = prefix.map(PathBuf::from);
25+
self.sysconfdir = sysconfdir.map(PathBuf::from);
26+
self.datadir = datadir.map(PathBuf::from);
27+
self.docdir = docdir.map(PathBuf::from);
28+
set(&mut self.bindir, bindir.map(PathBuf::from));
29+
self.libdir = libdir.map(PathBuf::from);
30+
self.mandir = mandir.map(PathBuf::from);
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)