@@ -39,7 +39,7 @@ pub(crate) struct BuildScriptOutput {
39
39
}
40
40
41
41
impl WorkspaceBuildScripts {
42
- fn build_command ( config : & CargoConfig , toolchain : & Option < Version > ) -> Command {
42
+ fn build_command ( config : & CargoConfig ) -> Command {
43
43
if let Some ( [ program, args @ ..] ) = config. run_build_script_command . as_deref ( ) {
44
44
let mut cmd = Command :: new ( program) ;
45
45
cmd. args ( args) ;
@@ -71,26 +71,39 @@ impl WorkspaceBuildScripts {
71
71
}
72
72
}
73
73
74
+ cmd
75
+ }
76
+
77
+ pub ( crate ) fn run (
78
+ config : & CargoConfig ,
79
+ workspace : & CargoWorkspace ,
80
+ progress : & dyn Fn ( String ) ,
81
+ toolchain : & Option < Version > ,
82
+ ) -> io:: Result < WorkspaceBuildScripts > {
74
83
const RUST_1_62 : Version = Version :: new ( 1 , 62 , 0 ) ;
75
84
76
- match toolchain {
77
- Some ( v) if v >= & RUST_1_62 => {
85
+ match Self :: run_ ( Self :: build_command ( config) , config, workspace, progress) {
86
+ Ok ( WorkspaceBuildScripts { error : Some ( error) , .. } )
87
+ if toolchain. as_ref ( ) . map_or ( false , |it| * it >= RUST_1_62 ) =>
88
+ {
89
+ // building build scripts failed, attempt to build with --keep-going so
90
+ // that we potentially get more build data
91
+ let mut cmd = Self :: build_command ( config) ;
78
92
cmd. args ( & [ "-Z" , "unstable-options" , "--keep-going" ] ) . env ( "RUSTC_BOOTSTRAP" , "1" ) ;
93
+ let mut res = Self :: run_ ( cmd, config, workspace, progress) ?;
94
+ res. error = Some ( error) ;
95
+ Ok ( res)
79
96
}
80
- _ => ( ) ,
97
+ res => res ,
81
98
}
82
-
83
- cmd
84
99
}
85
100
86
- pub ( crate ) fn run (
101
+ fn run_ (
102
+ mut cmd : Command ,
87
103
config : & CargoConfig ,
88
104
workspace : & CargoWorkspace ,
89
105
progress : & dyn Fn ( String ) ,
90
- toolchain : & Option < Version > ,
91
106
) -> io:: Result < WorkspaceBuildScripts > {
92
- let mut cmd = Self :: build_command ( config, toolchain) ;
93
-
94
107
if config. wrap_rustc_in_build_scripts {
95
108
// Setup RUSTC_WRAPPER to point to `rust-analyzer` binary itself. We use
96
109
// that to compile only proc macros and build scripts during the initial
0 commit comments