mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
DEV: Canonicalize is never the right thing on windows.
This commit is contained in:
parent
acffc6d5da
commit
6f714e6583
@ -568,31 +568,50 @@ impl ModuleDef {
|
||||
}
|
||||
|
||||
pub fn imports_to_absolute(&mut self, base: PathBuf) {
|
||||
&base;
|
||||
let rewrite_import = |e: &mut Expression| {
|
||||
if let Expression::Include(ref mut def) = e {
|
||||
let path = PathBuf::from(&def.path.fragment);
|
||||
if path.is_relative() {
|
||||
def.path.fragment = base
|
||||
.join(path)
|
||||
.canonicalize()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
if path.is_relative() {
|
||||
def.path.fragment = base
|
||||
.join(path)
|
||||
.canonicalize()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if path.is_relative() {
|
||||
def.path.fragment = dbg!(base.join(path).to_string_lossy().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Expression::Import(ref mut def) = e {
|
||||
let path = PathBuf::from(&def.path.fragment);
|
||||
let path = dbg!(PathBuf::from(&def.path.fragment));
|
||||
// std/ paths are special and do not get made into absolute paths.
|
||||
if path.starts_with("std/") {
|
||||
return;
|
||||
}
|
||||
if path.is_relative() {
|
||||
def.path.fragment = base
|
||||
.join(path)
|
||||
.canonicalize()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
if path.is_relative() {
|
||||
def.path.fragment = base
|
||||
.join(path)
|
||||
.canonicalize()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if path.is_relative() {
|
||||
def.path.fragment = base.join(path).to_string_lossy().to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -381,14 +381,21 @@ where
|
||||
} else {
|
||||
normalized = path;
|
||||
}
|
||||
match normalized.canonicalize() {
|
||||
Ok(p) => Ok(p),
|
||||
Err(e) => Err(error::BuildError::new(
|
||||
format!("Path not found {}", normalized.to_string_lossy()),
|
||||
error::ErrorType::OSError,
|
||||
)
|
||||
.wrap_cause(Box::new(e))
|
||||
.to_boxed()),
|
||||
#[cfg(windows)]
|
||||
{
|
||||
Ok(normalized)
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
match normalized.canonicalize() {
|
||||
Ok(p) => Ok(p),
|
||||
Err(e) => Err(error::BuildError::new(
|
||||
format!("Path not found {}", normalized.to_string_lossy()),
|
||||
error::ErrorType::OSError,
|
||||
)
|
||||
.wrap_cause(Box::new(e))
|
||||
.to_boxed()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user