@@ -34,8 +34,6 @@ mod sysroot;
3434mod util;
3535mod xargo;
3636
37- const HELP : & str = include_str ! ( "help.txt" ) ;
38-
3937// We use a different sysroot for Native compilation to avoid file locking
4038//
4139// Cross compilation requires `lib/rustlib/$HOST` to match `rustc`'s sysroot,
@@ -84,12 +82,12 @@ impl CompilationMode {
8482 }
8583}
8684
87- pub fn main ( ) {
85+ pub fn main_common ( command_name : & str ) {
8886 fn show_backtrace ( ) -> bool {
8987 env:: var ( "RUST_BACKTRACE" ) . as_ref ( ) . map ( |s| & s[ ..] ) == Ok ( "1" )
9088 }
9189
92- match run ( ) {
90+ match run ( command_name ) {
9391 Err ( e) => {
9492 let stderr = io:: stderr ( ) ;
9593 let mut stderr = stderr. lock ( ) ;
@@ -117,14 +115,14 @@ pub fn main() {
117115 }
118116}
119117
120- fn run ( ) -> Result < Option < ExitStatus > > {
118+ fn run ( command_name : & str ) -> Result < Option < ExitStatus > > {
121119 use cli:: Command ;
122120
123- let ( command, args) = cli:: args ( ) ?;
121+ let ( command, args) = cli:: args ( command_name ) ?;
124122 match command {
125- Command :: Build => Ok ( Some ( build ( args) ?) ) ,
123+ Command :: Build => Ok ( Some ( build ( args, command_name ) ?) ) ,
126124 Command :: Help => {
127- print ! ( "{}" , HELP ) ;
125+ print ! ( include_str! ( "help.txt" ) , command_name = command_name ) ;
128126 Ok ( None )
129127 }
130128 Command :: Version => {
@@ -138,7 +136,7 @@ fn run() -> Result<Option<ExitStatus>> {
138136 }
139137}
140138
141- fn build ( args : cli:: Args ) -> Result < ( ExitStatus ) > {
139+ fn build ( args : cli:: Args , command_name : & str ) -> Result < ( ExitStatus ) > {
142140 let verbose = args. verbose ( ) ;
143141 let meta = rustc:: version ( ) ;
144142 let cd = CurrentDirectory :: get ( ) ?;
@@ -206,7 +204,7 @@ fn build(args: cli::Args) -> Result<(ExitStatus)> {
206204 & sysroot,
207205 verbose,
208206 ) ?;
209- return xargo:: run ( & args, & cmode, rustflags, & home, & meta, verbose) ;
207+ return xargo:: run ( & args, & cmode, rustflags, & home, & meta, command_name , verbose) ;
210208 }
211209
212210 cargo:: run ( & args, verbose)
0 commit comments