mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-20 15:27:45 +03:00
Have CLI use the given file's directory as src_dir
This commit is contained in:
parent
57c4261b08
commit
b19386c1f6
@ -22,7 +22,6 @@ use std::time::SystemTime;
|
||||
use inkwell::targets::{
|
||||
CodeModel, FileType, InitializationConfig, RelocMode, Target, TargetTriple,
|
||||
};
|
||||
use std::env::current_dir;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
use target_lexicon::{Architecture, OperatingSystem, Triple, Vendor};
|
||||
@ -34,12 +33,8 @@ fn main() -> io::Result<()> {
|
||||
|
||||
match argv.get(1) {
|
||||
Some(filename) => {
|
||||
let mut path = Path::new(filename).canonicalize().unwrap();
|
||||
let src_dir = current_dir()?;
|
||||
|
||||
if !path.is_absolute() {
|
||||
path = src_dir.join(path).canonicalize().unwrap();
|
||||
}
|
||||
let path = Path::new(filename);
|
||||
let src_dir = path.parent().unwrap().canonicalize().unwrap();
|
||||
|
||||
// Create the runtime
|
||||
let mut rt = Builder::new()
|
||||
@ -50,7 +45,7 @@ fn main() -> io::Result<()> {
|
||||
.expect("Error spawning initial compiler thread."); // TODO make this error nicer.
|
||||
|
||||
// Spawn the root task
|
||||
let loaded = rt.block_on(load_file(src_dir, path));
|
||||
let loaded = rt.block_on(load_file(src_dir, path.canonicalize().unwrap()));
|
||||
|
||||
loaded.expect("TODO gracefully handle LoadingProblem");
|
||||
|
||||
|
3
examples/hello-world/HelloStr.roc
Normal file
3
examples/hello-world/HelloStr.roc
Normal file
@ -0,0 +1,3 @@
|
||||
interface HelloStr exposes [ str ] imports []
|
||||
|
||||
str = "Hi, World!"
|
Loading…
Reference in New Issue
Block a user