Skip to content

Commit 7615e9e

Browse files
committed
add last_modified
1 parent f6f9cc2 commit 7615e9e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/build.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use std::io::{self, BufRead};
2222
use std::path::{Path, PathBuf};
2323
use std::process::Command;
2424
use std::time::Instant;
25+
use std::time::SystemTime;
2526

2627
static TREE: Emoji<'_, '_> = Emoji("🌴 ", "");
2728
static SWEEP: Emoji<'_, '_> = Emoji("🧹 ", "");
@@ -49,6 +50,8 @@ pub struct Module {
4950
pub asti_path: Option<String>,
5051
pub deps: AHashSet<String>,
5152
pub package: package_tree::Package,
53+
pub last_modified: Option<SystemTime>,
54+
pub interface_last_modified: Option<SystemTime>,
5255
}
5356

5457
fn get_res_path_from_ast(ast_file: &str) -> Option<String> {
@@ -150,7 +153,8 @@ pub fn cleanup_previous_build(
150153
all_modules: &AHashMap<String, Module>,
151154
root_path: &str,
152155
) -> (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();
154158
let mut ast_rescript_file_locations = AHashSet::new();
155159

156160
let mut rescript_file_locations = all_modules
@@ -198,6 +202,7 @@ pub fn cleanup_previous_build(
198202
module_name,
199203
package.name.to_owned(),
200204
package.namespace.to_owned(),
205+
entry.metadata().unwrap().modified().unwrap(),
201206
),
202207
);
203208
let _ = ast_rescript_file_locations.insert(res_file_path);
@@ -229,7 +234,7 @@ pub fn cleanup_previous_build(
229234

230235
diff.par_iter().for_each(|res_file_location| {
231236
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
233238
.get(&res_file_location.to_string())
234239
.expect("Could not find module name for ast file");
235240
remove_compile_assets(
@@ -559,14 +564,16 @@ pub fn parse(
559564
asti_path: None,
560565
deps,
561566
package: package.to_owned(),
567+
last_modified: Some(SystemTime::now()),
568+
interface_last_modified: Some(SystemTime::now()),
562569
},
563570
);
564571
});
565572

566573
debug!("Building source file-tree for package: {}", package.name);
567574
match &package.source_files {
568575
None => (),
569-
Some(source_files) => source_files.iter().for_each(|(file, _)| {
576+
Some(source_files) => source_files.iter().for_each(|(file, metadata)| {
570577
let namespace = package.namespace.to_owned();
571578

572579
let file_buf = PathBuf::from(file);
@@ -583,6 +590,8 @@ pub fn parse(
583590
.and_modify(|module| {
584591
if module.file_path.len() > 0 {
585592
error!("Duplicate files found for module: {}", &module_name);
593+
error!("file 1: {}", &module.file_path);
594+
error!("file 2: {}", &file);
586595

587596
panic!("Unable to continue... See log output above...");
588597
}
@@ -598,6 +607,8 @@ pub fn parse(
598607
asti_path: None,
599608
deps: AHashSet::new(),
600609
package: package.to_owned(),
610+
last_modified: Some(metadata.modified().unwrap()),
611+
interface_last_modified: None,
601612
});
602613
} else {
603614
modules
@@ -613,6 +624,8 @@ pub fn parse(
613624
asti_path: None,
614625
deps: AHashSet::new(),
615626
package: package.to_owned(),
627+
last_modified: None,
628+
interface_last_modified: Some(metadata.modified().unwrap()),
616629
});
617630
}
618631
}),

0 commit comments

Comments
 (0)