@@ -18,6 +18,7 @@ use console::style;
1818use indicatif:: { ProgressBar , ProgressStyle } ;
1919use serde:: Serialize ;
2020use std:: fmt;
21+ use std:: fs:: File ;
2122use std:: io:: { stdout, Write } ;
2223use std:: path:: PathBuf ;
2324use std:: time:: { Duration , Instant } ;
@@ -414,6 +415,20 @@ impl fmt::Display for BuildError {
414415 }
415416}
416417
418+ pub fn write_build_ninja ( build_state : & BuildState ) {
419+ // write build.ninja files in the packages after a non-incremental build
420+ // this is necessary to bust the editor tooling cache. The editor tooling
421+ // is watching this file.
422+ // we don't need to do this in an incremental build because there are no file
423+ // changes (deletes / additions)
424+ for package in build_state. packages . values ( ) {
425+ // write empty file:
426+ let mut f = File :: create ( std:: path:: Path :: new ( & package. get_bs_build_path ( ) ) . join ( "build.ninja" ) )
427+ . expect ( "Unable to write file" ) ;
428+ f. write_all ( b"" ) . expect ( "unable to write to ninja file" ) ;
429+ }
430+ }
431+
417432pub fn build (
418433 filter : & Option < regex:: Regex > ,
419434 path : & str ,
@@ -440,10 +455,12 @@ pub fn build(
440455 default_timing. unwrap_or( timing_total_elapsed) . as_secs_f64( )
441456 ) ;
442457 clean:: cleanup_after_build ( & build_state) ;
458+ write_build_ninja ( & build_state) ;
443459 Ok ( build_state)
444460 }
445461 Err ( e) => {
446462 clean:: cleanup_after_build ( & build_state) ;
463+ write_build_ninja ( & build_state) ;
447464 Err ( BuildError :: IncrementalBuild ( e) )
448465 }
449466 }
0 commit comments