1
- use crate :: TargetSelection ;
2
1
use crate :: { t, VERSION } ;
2
+ use crate :: { Config , TargetSelection } ;
3
3
use std:: env:: consts:: EXE_SUFFIX ;
4
4
use std:: fmt:: Write as _;
5
5
use std:: fs:: File ;
@@ -81,24 +81,22 @@ impl fmt::Display for Profile {
81
81
}
82
82
}
83
83
84
- pub fn setup ( src_path : & Path , profile : Profile ) {
85
- let cfg_file = env :: var_os ( "BOOTSTRAP_CONFIG" ) . map ( PathBuf :: from ) ;
84
+ pub fn setup ( config : & Config , profile : Profile ) {
85
+ let path = & config . config ;
86
86
87
- if cfg_file. as_ref ( ) . map_or ( false , |f| f. exists ( ) ) {
88
- let file = cfg_file. unwrap ( ) ;
87
+ if path. exists ( ) {
89
88
println ! (
90
89
"error: you asked `x.py` to setup a new config file, but one already exists at `{}`" ,
91
- file . display( )
90
+ path . display( )
92
91
) ;
93
- println ! ( "help: try adding `profile = \" {}\" ` at the top of {}" , profile, file . display( ) ) ;
92
+ println ! ( "help: try adding `profile = \" {}\" ` at the top of {}" , profile, path . display( ) ) ;
94
93
println ! (
95
94
"note: this will use the configuration in {}" ,
96
- profile. include_path( src_path ) . display( )
95
+ profile. include_path( & config . src ) . display( )
97
96
) ;
98
97
std:: process:: exit ( 1 ) ;
99
98
}
100
99
101
- let path = cfg_file. unwrap_or_else ( || "config.toml" . into ( ) ) ;
102
100
let settings = format ! (
103
101
"# Includes one of the default files in src/bootstrap/defaults\n \
104
102
profile = \" {}\" \n \
@@ -107,7 +105,7 @@ pub fn setup(src_path: &Path, profile: Profile) {
107
105
) ;
108
106
t ! ( fs:: write( path, settings) ) ;
109
107
110
- let include_path = profile. include_path ( src_path ) ;
108
+ let include_path = profile. include_path ( & config . src ) ;
111
109
println ! ( "`x.py` will now use the configuration at {}" , include_path. display( ) ) ;
112
110
113
111
let build = TargetSelection :: from_user ( & env ! ( "BUILD_TRIPLE" ) ) ;
@@ -138,7 +136,7 @@ pub fn setup(src_path: &Path, profile: Profile) {
138
136
139
137
println ! ( ) ;
140
138
141
- t ! ( install_git_hook_maybe( src_path ) ) ;
139
+ t ! ( install_git_hook_maybe( & config . src ) ) ;
142
140
143
141
println ! ( ) ;
144
142
0 commit comments