1- use crate :: TargetSelection ;
21use crate :: { t, VERSION } ;
2+ use crate :: { Config , TargetSelection } ;
33use std:: env:: consts:: EXE_SUFFIX ;
44use std:: fmt:: Write as _;
55use std:: fs:: File ;
@@ -81,24 +81,22 @@ impl fmt::Display for Profile {
8181 }
8282}
8383
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 ;
8686
87- if cfg_file. as_ref ( ) . map_or ( false , |f| f. exists ( ) ) {
88- let file = cfg_file. unwrap ( ) ;
87+ if path. exists ( ) {
8988 println ! (
9089 "error: you asked `x.py` to setup a new config file, but one already exists at `{}`" ,
91- file . display( )
90+ path . display( )
9291 ) ;
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( ) ) ;
9493 println ! (
9594 "note: this will use the configuration in {}" ,
96- profile. include_path( src_path ) . display( )
95+ profile. include_path( & config . src ) . display( )
9796 ) ;
9897 std:: process:: exit ( 1 ) ;
9998 }
10099
101- let path = cfg_file. unwrap_or_else ( || "config.toml" . into ( ) ) ;
102100 let settings = format ! (
103101 "# Includes one of the default files in src/bootstrap/defaults\n \
104102 profile = \" {}\" \n \
@@ -107,7 +105,7 @@ pub fn setup(src_path: &Path, profile: Profile) {
107105 ) ;
108106 t ! ( fs:: write( path, settings) ) ;
109107
110- let include_path = profile. include_path ( src_path ) ;
108+ let include_path = profile. include_path ( & config . src ) ;
111109 println ! ( "`x.py` will now use the configuration at {}" , include_path. display( ) ) ;
112110
113111 let build = TargetSelection :: from_user ( & env ! ( "BUILD_TRIPLE" ) ) ;
@@ -138,7 +136,7 @@ pub fn setup(src_path: &Path, profile: Profile) {
138136
139137 println ! ( ) ;
140138
141- t ! ( install_git_hook_maybe( src_path ) ) ;
139+ t ! ( install_git_hook_maybe( & config . src ) ) ;
142140
143141 println ! ( ) ;
144142
0 commit comments