Skip to content

Commit 44696a5

Browse files
committed
fix: incremental build on windows get_res_path_from_ast
1 parent 40f0387 commit 44696a5

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

rewatch/src/build/build_types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ impl BuildState {
136136
}
137137
}
138138

139+
#[derive(Debug)]
139140
pub struct AstModule {
140141
pub module_name: String,
141142
pub package_name: String,
@@ -146,6 +147,7 @@ pub struct AstModule {
146147
pub suffix: String,
147148
}
148149

150+
#[derive(Debug)]
149151
pub struct CompileAssetsState {
150152
pub ast_modules: AHashMap<PathBuf, AstModule>,
151153
pub cmi_modules: AHashMap<String, SystemTime>,

rewatch/src/build/read_compile_state.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,11 @@ pub fn read(build_state: &mut BuildState) -> CompileAssetsState {
7979
"iast" | "ast" => {
8080
let module_name = helpers::file_path_to_module_name(path, package_namespace);
8181

82-
let res_file_path = get_res_path_from_ast(&path);
8382
let root_package = build_state
8483
.packages
8584
.get(&build_state.root_config_name)
8685
.expect("Could not find root package");
87-
if let Some(res_file_path) = res_file_path {
88-
let res_file_path_buf = PathBuf::from(res_file_path);
86+
if let Some(res_file_path_buf) = get_res_path_from_ast(&path) {
8987
let _ = ast_modules.insert(
9088
res_file_path_buf.clone(),
9189
AstModule {
@@ -137,15 +135,15 @@ pub fn read(build_state: &mut BuildState) -> CompileAssetsState {
137135
}
138136
}
139137

140-
fn get_res_path_from_ast(ast_file: &Path) -> Option<String> {
138+
fn get_res_path_from_ast(ast_file: &Path) -> Option<PathBuf> {
141139
if let Ok(lines) = helpers::read_lines(ast_file) {
142140
// we skip the first line with is some null characters
143141
// the following lines in the AST are the dependency modules
144-
// we stop when we hit a line that starts with a "/", this is the path of the file.
142+
// we stop when we hit a line that is an absolute path, this is the path of the file.
145143
// this is the point where the dependencies end and the actual AST starts
146144
for line in lines.skip(1) {
147145
match line {
148-
Ok(line) if line.trim_start().starts_with('/') => return Some(line),
146+
Ok(line) if Path::new(&line).is_absolute() => return Some(PathBuf::from(line)),
149147
_ => (),
150148
}
151149
}

rewatch/src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl StrippedVerbatimPath for PathBuf {
7575
stripped.push(Component::ParentDir);
7676
}
7777
Component::Normal(os_str) => {
78-
stripped.push(os_str);
78+
stripped.push(Component::Normal(os_str));
7979
}
8080
}
8181
}

0 commit comments

Comments
 (0)