From: Mark Thom Date: Sat, 7 Mar 2020 23:00:04 +0000 (-0700) Subject: represent the current_dir as an absolute path, not a relative one. (#262) X-Git-Tag: v0.8.119~60 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=c7591045afd1c70d818dffba0b20909eeb9e975f;p=scryer-prolog.git represent the current_dir as an absolute path, not a relative one. (#262) --- diff --git a/build.rs b/build.rs index 6628f394..715ea3ab 100644 --- a/build.rs +++ b/build.rs @@ -52,5 +52,9 @@ fn main() } libraries.write_all(b"\n\n m\n }; -}").unwrap(); +}\n").unwrap(); + + libraries.write_all(b"\npub static PROJECT_DIR: &'static str = \"").unwrap(); + libraries.write_all(env::var("CARGO_MANIFEST_DIR").unwrap().as_bytes()).unwrap(); + libraries.write_all(b"\";\n").unwrap(); } diff --git a/src/prolog/machine/compile.rs b/src/prolog/machine/compile.rs index f13cb9bb..5241bacf 100644 --- a/src/prolog/machine/compile.rs +++ b/src/prolog/machine/compile.rs @@ -548,8 +548,8 @@ fn add_module( term_dir: TermDir, ) { module.code_dir.extend(indices.code_dir); - module.op_dir.extend(indices.op_dir.into_iter()); - module.term_dir.extend(term_dir.into_iter()); + module.op_dir.extend(indices.op_dir); + module.term_dir.extend(term_dir); wam.add_in_situ_module_dir(indices.module_dir); wam.add_module(module); @@ -568,7 +568,7 @@ fn add_non_module_code( clause_code_generator.generate_clause_code(&dynamic_clause_map, wam)?; add_toplevel(wam, indices, term_dir); - wam.code_repo.code.extend(code.into_iter()); + wam.code_repo.code.extend(code); clause_code_generator.add_clause_code(wam, dynamic_clause_map); Ok(()) diff --git a/src/prolog/machine/mod.rs b/src/prolog/machine/mod.rs index 5d20f00b..64eef8f3 100644 --- a/src/prolog/machine/mod.rs +++ b/src/prolog/machine/mod.rs @@ -193,8 +193,11 @@ impl SubModuleUser for IndexStore { #[inline] fn current_dir() -> std::path::PathBuf { - let mut path_buf = std::path::PathBuf::from(file!()); - path_buf.pop(); + let mut path_buf = std::path::PathBuf::from(PROJECT_DIR); + // file!() always produces a path relative to PROJECT_DIR. + path_buf = path_buf.join(std::path::PathBuf::from(file!())); + + path_buf.pop(); path_buf }