Skip to content

Commit 2644c35

Browse files
committed
bender-slang: Cannonicalize include paths on windows
1 parent 886a326 commit 2644c35

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/bender-slang/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ edition = "2024"
77
cxx = "1.0.194"
88
thiserror = "2.0.12"
99

10+
[target.'cfg(windows)'.dependencies]
11+
dunce = "1.0.4"
12+
1013
[build-dependencies]
1114
cmake = "0.1.57"
1215
cxx-build = "1.0.194"

crates/bender-slang/src/lib.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl SlangSession {
150150
defines: &[String],
151151
) -> Result<Vec<usize>> {
152152
let files_vec = files.to_vec();
153-
let includes_vec = includes.to_vec();
153+
let includes_vec = normalize_include_dirs(includes)?;
154154
let defines_vec = defines.to_vec();
155155

156156
let start = self.tree_count();
@@ -220,3 +220,23 @@ impl Default for SlangSession {
220220
Self::new()
221221
}
222222
}
223+
224+
#[cfg(windows)]
225+
fn normalize_include_dirs(includes: &[String]) -> Result<Vec<String>> {
226+
let mut out = Vec::with_capacity(includes.len());
227+
for include in includes {
228+
let canonical = dunce::canonicalize(include).map_err(|cause| SlangError::ParseGroup {
229+
message: format!(
230+
"Failed to canonicalize include directory '{}': {}",
231+
include, cause
232+
),
233+
})?;
234+
out.push(canonical.to_string_lossy().into_owned());
235+
}
236+
Ok(out)
237+
}
238+
239+
#[cfg(not(windows))]
240+
fn normalize_include_dirs(includes: &[String]) -> Result<Vec<String>> {
241+
Ok(includes.to_vec())
242+
}

0 commit comments

Comments
 (0)