1+ use crate :: { SpirvBuilder , SpirvBuilderError , leaf_deps} ;
2+ use notify:: { Event , RecommendedWatcher , RecursiveMode , Watcher } ;
3+ use rustc_codegen_spirv_types:: CompileResult ;
14use std:: {
25 collections:: HashSet ,
3- path:: { Path , PathBuf } ,
6+ path:: PathBuf ,
47 sync:: mpsc:: { Receiver , sync_channel} ,
58} ;
69
7- use notify:: { Event , RecommendedWatcher , RecursiveMode , Watcher } ;
8- use rustc_codegen_spirv_types:: CompileResult ;
9-
10- use crate :: { SpirvBuilder , SpirvBuilderError , leaf_deps} ;
11-
1210impl SpirvBuilder {
1311 /// Watches the module for changes, rebuilding it upon them.
1412 pub fn watch ( self ) -> Result < SpirvWatcher , SpirvBuilderError > {
@@ -24,8 +22,8 @@ pub struct SpirvWatcher {
2422 builder : SpirvBuilder ,
2523 watcher : RecommendedWatcher ,
2624 rx : Receiver < ( ) > ,
27- /// `first_result`: the path to the crate
28- /// `! first_result`: the path to our metadata file with entry point names and file paths
25+ /// `! first_result`: the path to the crate
26+ /// `first_result`: the path to our metadata file with entry point names and file paths
2927 watch_path : PathBuf ,
3028 watched_paths : WatchedPaths ,
3129 first_result : bool ,
@@ -84,7 +82,7 @@ impl SpirvWatcher {
8482 let metadata_file = crate :: invoke_rustc ( & self . builder ) ?;
8583 let result = self . builder . parse_metadata_file ( & metadata_file) ?;
8684
87- Self :: watch_leaf_deps ( & self . watch_path , & mut self . watched_paths , & mut self . watcher ) ?;
85+ self . watch_leaf_deps ( ) ?;
8886 Ok ( result)
8987 }
9088
@@ -113,21 +111,17 @@ impl SpirvWatcher {
113111 } ;
114112 let result = self . builder . parse_metadata_file ( & metadata_file) ?;
115113
116- Self :: watch_leaf_deps ( & metadata_file, & mut self . watched_paths , & mut self . watcher ) ?;
117114 self . watch_path = metadata_file;
118115 self . first_result = true ;
116+ self . watch_leaf_deps ( ) ?;
119117 Ok ( result)
120118 }
121119
122- fn watch_leaf_deps (
123- metadata_file : & Path ,
124- watched_paths : & mut WatchedPaths ,
125- watcher : & mut RecommendedWatcher ,
126- ) -> Result < ( ) , SpirvBuilderError > {
127- leaf_deps ( metadata_file, |artifact| {
120+ fn watch_leaf_deps ( & mut self ) -> Result < ( ) , SpirvBuilderError > {
121+ leaf_deps ( & self . watch_path , |artifact| {
128122 let path = artifact. to_path ( ) . unwrap ( ) ;
129- if watched_paths. insert ( path. to_owned ( ) )
130- && let Err ( err) = watcher. watch ( path, RecursiveMode :: NonRecursive )
123+ if self . watched_paths . insert ( path. to_owned ( ) )
124+ && let Err ( err) = self . watcher . watch ( path, RecursiveMode :: NonRecursive )
131125 {
132126 log:: error!( "files of cargo dependencies are not valid: {err}" ) ;
133127 }
0 commit comments