@@ -22,6 +22,7 @@ use std::io::{self, BufRead};
22
22
use std:: path:: { Path , PathBuf } ;
23
23
use std:: process:: Command ;
24
24
use std:: time:: Instant ;
25
+ use std:: time:: SystemTime ;
25
26
26
27
static TREE : Emoji < ' _ , ' _ > = Emoji ( "🌴 " , "" ) ;
27
28
static SWEEP : Emoji < ' _ , ' _ > = Emoji ( "🧹 " , "" ) ;
@@ -49,6 +50,8 @@ pub struct Module {
49
50
pub asti_path : Option < String > ,
50
51
pub deps : AHashSet < String > ,
51
52
pub package : package_tree:: Package ,
53
+ pub last_modified : Option < SystemTime > ,
54
+ pub interface_last_modified : Option < SystemTime > ,
52
55
}
53
56
54
57
fn get_res_path_from_ast ( ast_file : & str ) -> Option < String > {
@@ -150,7 +153,8 @@ pub fn cleanup_previous_build(
150
153
all_modules : & AHashMap < String , Module > ,
151
154
root_path : & str ,
152
155
) -> ( usize , usize ) {
153
- let mut ast_modules: AHashMap < String , ( String , String , Option < String > ) > = AHashMap :: new ( ) ;
156
+ let mut ast_modules: AHashMap < String , ( String , String , Option < String > , SystemTime ) > =
157
+ AHashMap :: new ( ) ;
154
158
let mut ast_rescript_file_locations = AHashSet :: new ( ) ;
155
159
156
160
let mut rescript_file_locations = all_modules
@@ -198,6 +202,7 @@ pub fn cleanup_previous_build(
198
202
module_name,
199
203
package. name . to_owned ( ) ,
200
204
package. namespace . to_owned ( ) ,
205
+ entry. metadata ( ) . unwrap ( ) . modified ( ) . unwrap ( ) ,
201
206
) ,
202
207
) ;
203
208
let _ = ast_rescript_file_locations. insert ( res_file_path) ;
@@ -229,7 +234,7 @@ pub fn cleanup_previous_build(
229
234
230
235
diff. par_iter ( ) . for_each ( |res_file_location| {
231
236
let _ = std:: fs:: remove_file ( helpers:: change_extension ( res_file_location, "mjs" ) ) ;
232
- let ( _module_name, package_name, package_namespace) = ast_modules
237
+ let ( _module_name, package_name, package_namespace, _last_modified ) = ast_modules
233
238
. get ( & res_file_location. to_string ( ) )
234
239
. expect ( "Could not find module name for ast file" ) ;
235
240
remove_compile_assets (
@@ -559,14 +564,16 @@ pub fn parse(
559
564
asti_path : None ,
560
565
deps,
561
566
package : package. to_owned ( ) ,
567
+ last_modified : Some ( SystemTime :: now ( ) ) ,
568
+ interface_last_modified : Some ( SystemTime :: now ( ) ) ,
562
569
} ,
563
570
) ;
564
571
} ) ;
565
572
566
573
debug ! ( "Building source file-tree for package: {}" , package. name) ;
567
574
match & package. source_files {
568
575
None => ( ) ,
569
- Some ( source_files) => source_files. iter ( ) . for_each ( |( file, _ ) | {
576
+ Some ( source_files) => source_files. iter ( ) . for_each ( |( file, metadata ) | {
570
577
let namespace = package. namespace . to_owned ( ) ;
571
578
572
579
let file_buf = PathBuf :: from ( file) ;
@@ -583,6 +590,8 @@ pub fn parse(
583
590
. and_modify ( |module| {
584
591
if module. file_path . len ( ) > 0 {
585
592
error ! ( "Duplicate files found for module: {}" , & module_name) ;
593
+ error ! ( "file 1: {}" , & module. file_path) ;
594
+ error ! ( "file 2: {}" , & file) ;
586
595
587
596
panic ! ( "Unable to continue... See log output above..." ) ;
588
597
}
@@ -598,6 +607,8 @@ pub fn parse(
598
607
asti_path : None ,
599
608
deps : AHashSet :: new ( ) ,
600
609
package : package. to_owned ( ) ,
610
+ last_modified : Some ( metadata. modified ( ) . unwrap ( ) ) ,
611
+ interface_last_modified : None ,
601
612
} ) ;
602
613
} else {
603
614
modules
@@ -613,6 +624,8 @@ pub fn parse(
613
624
asti_path : None ,
614
625
deps : AHashSet :: new ( ) ,
615
626
package : package. to_owned ( ) ,
627
+ last_modified : None ,
628
+ interface_last_modified : Some ( metadata. modified ( ) . unwrap ( ) ) ,
616
629
} ) ;
617
630
}
618
631
} ) ,
0 commit comments