File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 3
3
// Distributed under the MIT software license
4
4
5
5
use std:: process:: { Command , Stdio } ;
6
+ use std:: fs;
7
+ use std:: path:: PathBuf ;
6
8
7
9
use lib_flutter_rust_bridge_codegen:: codegen;
8
10
use lib_flutter_rust_bridge_codegen:: codegen:: Config ;
@@ -17,12 +19,26 @@ fn main() {
17
19
if !is_flutter_installed ( ) {
18
20
panic ! ( "Warning: flutter not installed." ) ;
19
21
}
22
+
23
+ // Parse config
24
+ let config = Config :: from_config_file ( "../flutter_rust_bridge.yaml" )
25
+ . unwrap ( )
26
+ . unwrap ( ) ;
27
+
28
+ // Delete previously generated dart code
29
+ if let Some ( path) = & config. dart_output {
30
+ let dir: PathBuf = PathBuf :: from ( ".." ) . join ( path) ;
31
+ if dir. exists ( ) {
32
+ println ! ( "Deleting {}" , dir. display( ) ) ;
33
+ fs:: remove_dir_all ( & dir) . unwrap ( ) ;
34
+ }
35
+
36
+ fs:: create_dir_all ( dir) . unwrap ( ) ;
37
+ }
20
38
21
39
// Execute code generator with auto-detected config
22
40
codegen:: generate (
23
- Config :: from_config_file ( "../flutter_rust_bridge.yaml" )
24
- . unwrap ( )
25
- . unwrap ( ) ,
41
+ config,
26
42
Default :: default ( ) ,
27
43
)
28
44
. unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments