Link modules for vstc compile (almost works)

This commit is contained in:
Andrew Morris
2023-03-09 12:19:53 +11:00
parent 5e95be162e
commit 5244987f89
7 changed files with 529 additions and 71 deletions

View File

@@ -0,0 +1,27 @@
use std::path::{Path, PathBuf};
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct ResolvedPath {
pub path: String,
}
impl std::fmt::Display for ResolvedPath {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.path)
}
}
pub fn resolve_path(importer_path: &ResolvedPath, path: &String) -> ResolvedPath {
let importer_path_buf = PathBuf::from(&importer_path.path);
let parent = importer_path_buf.parent().unwrap_or_else(|| Path::new("/"));
ResolvedPath {
path: parent
.join(path)
.canonicalize()
.expect("Failed to canonicalize path")
.to_str()
.expect("Failed to convert path to string")
.to_string(),
}
}