@@ -64,26 +64,31 @@ impl Build {
64
64
std:: env:: current_dir( ) ?. display( )
65
65
) ;
66
66
67
- if !self . build_args . watch {
67
+ if self . build_args . watch {
68
+ let this = self . clone ( ) ;
69
+ self . build_args
70
+ . spirv_builder
71
+ . watch ( move |result, accept| {
72
+ let result1 = this. parse_compilation_result ( & result) ;
73
+ if let Some ( accept) = accept {
74
+ accept. submit ( result1) ;
75
+ }
76
+ } ) ?
77
+ . context ( "unreachable" ) ??;
78
+ std:: thread:: park ( ) ;
79
+ } else {
68
80
crate :: user_output!(
69
81
"Compiling shaders at {}...\n " ,
70
82
self . install. spirv_install. shader_crate. display( )
71
83
) ;
72
84
let result = self . build_args . spirv_builder . build ( ) ?;
73
- self . parse_compilation_result ( result) ?;
74
- Ok ( ( ) )
75
- } else {
76
- let this = self . clone ( ) ;
77
- self . build_args . spirv_builder . watch ( move |result| {
78
- this. parse_compilation_result ( result)
79
- . expect ( "watch operation failed" )
80
- } ) ?;
81
- std:: thread:: park ( ) ;
82
- Ok ( ( ) )
85
+ self . parse_compilation_result ( & result) ?;
83
86
}
87
+ Ok ( ( ) )
84
88
}
85
89
86
- fn parse_compilation_result ( & self , result : CompileResult ) -> anyhow:: Result < ( ) > {
90
+ /// Parses compilation result from `SpirvBuilder` and writes it out to a file
91
+ fn parse_compilation_result ( & self , result : & CompileResult ) -> anyhow:: Result < ( ) > {
87
92
let shaders = match & result. module {
88
93
ModuleResult :: MultiModule ( modules) => {
89
94
anyhow:: ensure!( !modules. is_empty( ) , "No shader modules were compiled" ) ;
0 commit comments