fix
This commit is contained in:
parent
2624d8107b
commit
c2f6f97590
|
@ -4,7 +4,7 @@ mod utils;
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
|
|
||||||
use crate::{cli::{CliArgs, CompilationTarget}, types::ast::Program};
|
use crate::{cli::{CliArgs, CompilationTarget}, types::ast::Program};
|
||||||
use std::{collections::HashMap, fs::File, io::{BufWriter, Write}, path::{Path, PathBuf}};
|
use std::{collections::HashMap, fs::File, io::{BufWriter, Write}, path::{Path, PathBuf}, process::Command};
|
||||||
|
|
||||||
use self::utils::run_cmd;
|
use self::utils::run_cmd;
|
||||||
|
|
||||||
|
@ -49,7 +49,28 @@ pub fn compile_program(cli_args: &CliArgs, prog_map: HashMap<&Path, Program>) ->
|
||||||
info!("Finished building program");
|
info!("Finished building program");
|
||||||
|
|
||||||
if cli_args.run {
|
if cli_args.run {
|
||||||
run_cmd(format!("./{}", bin_p.to_string_lossy()), cli_args.passthrough.clone())?;
|
// run_cmd(format!("./{}", bin_p.to_string_lossy()), cli_args.passthrough.clone())?;
|
||||||
|
let bin = bin_p.to_string_lossy().to_string();
|
||||||
|
let mut cmd = Command::new(format!("./{}", bin.clone()));
|
||||||
|
let cmd = cmd.args(cli_args.passthrough.clone());
|
||||||
|
|
||||||
|
let child = match cmd.spawn() {
|
||||||
|
Ok(c) => c,
|
||||||
|
Err(e) => {
|
||||||
|
error!("Unable to run {cmd:?}: {e}");
|
||||||
|
bail!("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let ret = child.wait_with_output().expect("fuck i know");
|
||||||
|
|
||||||
|
|
||||||
|
if !ret.status.success() {
|
||||||
|
error!("Process running {bin:?} exited abnormaly, run with -v 2 for more output");
|
||||||
|
bail!("")
|
||||||
|
} else {
|
||||||
|
info!("Process exited successfully")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
32
test.mcl
32
test.mcl
|
@ -16,24 +16,24 @@ include "std.mcl"
|
||||||
// fn putd with int returns void then drop done
|
// fn putd with int returns void then drop done
|
||||||
|
|
||||||
fn main with int ptr returns int then
|
fn main with int ptr returns int then
|
||||||
// 1 2 add
|
1 2 add
|
||||||
// 69 _dbg_print
|
69 _dbg_print
|
||||||
"Hewo\n" puts
|
"Hewo\n" puts
|
||||||
|
|
||||||
// if 3 4 eq do
|
if 3 4 eq do
|
||||||
// "omg what impossible!\n"
|
"omg what impossible!\n"
|
||||||
// else if 1 1 eq do
|
else if 1 1 eq do
|
||||||
// "whaaaaaaaaa\n"
|
"whaaaaaaaaa\n"
|
||||||
// else
|
else
|
||||||
// "finally, some good soup\n"
|
"finally, some good soup\n"
|
||||||
// done
|
done
|
||||||
// puts
|
puts
|
||||||
|
|
||||||
// 10
|
10
|
||||||
// while dup 0 gt do
|
while dup 0 gt do
|
||||||
// "uwu" puts
|
"uwu " puts
|
||||||
// dup _dbg_print
|
dup _dbg_print
|
||||||
// 1 sub
|
1 sub
|
||||||
// done
|
done
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue
Block a user