@@ -25,9 +25,12 @@ pub fn load_extension_api_json(watch: &mut StopWatch) -> String {
25
25
rerun_on_changed ( & godot_bin) ;
26
26
watch. record ( "locate_godot" ) ;
27
27
28
- // Regnerate API JSON if first time or Godot version is different
29
- if !json_path. exists ( ) || has_version_changed ( & godot_bin) {
28
+ // Regenerate API JSON if first time or Godot version is different
29
+ let version = read_godot_version ( & godot_bin) ;
30
+ if !json_path. exists ( ) || has_version_changed ( & version) {
30
31
dump_extension_api ( & godot_bin, json_path) ;
32
+ update_version_file ( & version) ;
33
+
31
34
watch. record ( "dump_extension_api" ) ;
32
35
}
33
36
@@ -37,23 +40,23 @@ pub fn load_extension_api_json(watch: &mut StopWatch) -> String {
37
40
result
38
41
}
39
42
40
- fn has_version_changed ( godot_bin : & Path ) -> bool {
43
+ fn has_version_changed ( current_version : & str ) -> bool {
41
44
let version_path = Path :: new ( GODOT_VERSION_PATH ) ;
42
- rerun_on_changed ( version_path) ;
43
45
44
- let current_version = read_godot_version ( & godot_bin) ;
45
- let changed = match std:: fs:: read_to_string ( version_path) {
46
+ match std:: fs:: read_to_string ( version_path) {
46
47
Ok ( last_version) => current_version != last_version,
47
48
Err ( _) => true ,
48
- } ;
49
-
50
- if changed {
51
- std:: fs:: write ( version_path, current_version) . expect ( & format ! (
52
- "write Godot version to file {}" ,
53
- version_path. display( )
54
- ) ) ;
55
49
}
56
- changed
50
+ }
51
+
52
+ fn update_version_file ( version : & str ) {
53
+ let version_path = Path :: new ( GODOT_VERSION_PATH ) ;
54
+ rerun_on_changed ( version_path) ;
55
+
56
+ std:: fs:: write ( version_path, version) . expect ( & format ! (
57
+ "write Godot version to file {}" ,
58
+ version_path. display( )
59
+ ) ) ;
57
60
}
58
61
59
62
fn read_godot_version ( godot_bin : & Path ) -> String {
0 commit comments