]> Repositorios git - scryer-prolog.git/commitdiff
represent the current_dir as an absolute path, not a relative one. (#262)
authorMark Thom <[email protected]>
Sat, 7 Mar 2020 23:00:04 +0000 (16:00 -0700)
committerMark Thom <[email protected]>
Sat, 7 Mar 2020 23:00:10 +0000 (16:00 -0700)
build.rs
src/prolog/machine/compile.rs
src/prolog/machine/mod.rs

index 6628f394d5d26349c6d20e92a6f6c9573b8d8f35..715ea3abdbc204474d7100b0f334454d6bc14e70 100644 (file)
--- 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();
 }
index f13cb9bb65e102345cb1b2dc76178bae7033afd6..5241bacf5e87f60e59f923b3048f528d3e6949a9 100644 (file)
@@ -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(())
index 5d20f00b62f1d019fce0e460631c6e913adbb95f..64eef8f3bf119a1043a0b740535e9e2e95907244 100644 (file)
@@ -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
 }