From a2d9aadf03f59378db08c0af82449c23ebf38643 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Tue, 29 Oct 2024 09:14:54 +1300 Subject: Canonicalize the source path for the assembler When a relative path with only one path component is passed to the assembler, the parent of that path cannot be determined and so the project libraries descending from that parent cannot be included in the program. To fix this, we canonicalize the path before it is used. This also makes the path comments generated for the project source files more stable and readable. --- src/bin/br.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/bin/br.rs') diff --git a/src/bin/br.rs b/src/bin/br.rs index 77bf3ee..632291c 100644 --- a/src/bin/br.rs +++ b/src/bin/br.rs @@ -170,7 +170,11 @@ fn main_asm(args: Asm) { // ----------------------------------------------------------------------- // RESOLVE syntactic symbols let ext = args.ext.unwrap_or(String::from("brc")); - let mut resolver = if let Some(path) = &args.source { + let source_path = args.source.clone().map(|p| { + p.canonicalize().unwrap_or(p) + }); + + let mut resolver = if let Some(path) = &source_path { match SourceUnit::from_path(&path, &ext) { Ok(source_unit) => SymbolResolver::from_source_unit(source_unit), Err(err) => match err { @@ -201,7 +205,7 @@ fn main_asm(args: Asm) { SymbolResolver::from_source_unit(source_unit) }; // Load project libraries. - if let Some(path) = &args.source { + if let Some(path) = &source_path { if !args.no_libs && !args.no_project_libs { let project_library = gather_project_libraries(path, &ext); resolver.add_library_units(project_library); -- cgit v1.2.3-70-g09d2