File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ const NEXT_MINOR_VERSION: u8 = 3;
128
128
129
129
pub fn clear_dir ( dir : & Path , watch : & mut StopWatch ) {
130
130
if dir. exists ( ) {
131
- std :: fs :: remove_dir_all ( dir) . unwrap_or_else ( |e| panic ! ( "failed to delete dir: {e}" ) ) ;
131
+ remove_dir_all_reliable ( dir) ;
132
132
watch. record ( "delete_gen_dir" ) ;
133
133
}
134
134
std:: fs:: create_dir_all ( dir) . unwrap_or_else ( |e| panic ! ( "failed to create dir: {e}" ) ) ;
@@ -161,3 +161,25 @@ pub fn emit_godot_version_cfg() {
161
161
println ! ( r#"cargo:rustc-cfg=gdextension_exact_api="{major}.{minor}""# ) ;
162
162
}
163
163
}
164
+
165
+ // Function for safely removal of build directory. Workaround for errors happening during CI builds:
166
+ // https://github.com/godot-rust/gdext/issues/616
167
+ pub fn remove_dir_all_reliable ( path : & std:: path:: Path ) {
168
+ let mut retry_count = 0 ;
169
+
170
+ while path. exists ( ) {
171
+ match std:: fs:: remove_dir_all ( path) {
172
+ Ok ( _) => break ,
173
+ Err ( err) => {
174
+ if retry_count >= 5 {
175
+ panic ! (
176
+ "cannot remove directory: {path_display} after 5 tries with error: {err}" ,
177
+ path_display = path. display( )
178
+ )
179
+ }
180
+ retry_count += 1 ;
181
+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 10 ) ) ;
182
+ }
183
+ }
184
+ }
185
+ }
Original file line number Diff line number Diff line change @@ -12,9 +12,7 @@ fn main() {
12
12
// struggle with static analysis when symbols are outside the crate directory (April 2023).
13
13
let gen_path = Path :: new ( concat ! ( env!( "CARGO_MANIFEST_DIR" ) , "/src/gen" ) ) ;
14
14
15
- if gen_path. exists ( ) {
16
- std:: fs:: remove_dir_all ( gen_path) . unwrap_or_else ( |e| panic ! ( "failed to delete dir: {e}" ) ) ;
17
- }
15
+ godot_bindings:: remove_dir_all_reliable ( gen_path) ;
18
16
19
17
godot_codegen:: generate_core_files ( gen_path) ;
20
18
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
You can’t perform that action at this time.
0 commit comments