1
0
Fork 0
forked from koniifer/ableos

patching together some broken stuff

This commit is contained in:
able 2024-05-31 13:31:06 -05:00
parent c57ef99948
commit e08eab8627
8 changed files with 35 additions and 15 deletions

View file

@ -1,4 +1,5 @@
use std::{
fmt::format,
fs::{read_to_string, File},
io::{BufWriter, Write},
process::exit,
@ -67,21 +68,24 @@ impl Package {
let mut files = vec![];
for (count, file) in file_order.enumerate() {
if count != 0 {
println!("{}", file);
files.push(file);
}
}
let mut bundle = vec![];
for file in files {
let contents = read_to_string(file).unwrap();
let file_path = if file.starts_with("libraries") {
format!("sysdata/{}", file)
} else {
format!("sysdata/programs/{}/{}", self.name, file)
};
let contents = read_to_string(file_path).unwrap();
bundle.push((file, contents));
}
use hblang::{codegen, parser};
let mut codegen = codegen::Codegen::default();
for (path, content) in bundle.iter() {
println!("A");
codegen.files = vec![parser::Ast::new(&path, &content, &parser::no_loader)];
codegen.files = vec![parser::Ast::new(path, content, &parser::no_loader)];
codegen.generate();
}
let mut buf = BufWriter::new(Vec::new());
@ -92,7 +96,7 @@ impl Package {
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (),
Err(e) => panic!(),
}
let path = format!("target/test-programs/{}.hbf", self.name);
let path = format!("target/programs/{}.hbf", self.name);
let mut file = File::create(path).unwrap();
file.write_all(&bytes).unwrap();
}

View file

@ -241,7 +241,7 @@ TERM_BACKDROP={}
// let mut real_modules = modules.clone();
modules.into_iter().for_each(|(key, value)| {
if value.is_table() && key == "tests" {
if value.is_table() {
let path = get_path_without_boot_prefix(
value.get("path").expect("You must have `path` as a value"),
)
@ -280,7 +280,7 @@ TERM_BACKDROP={}
.expect("You must have a `path` as a value"),
)
.unwrap();
let fpath = format!("target/test-programs/{}", path);
let fpath = format!("target/programs/{}", path);
copy_file_to_img(&fpath, &fs);
}
});
@ -312,6 +312,7 @@ TERM_BACKDROP={}
fn copy_file_to_img(fpath: &str, fs: &FileSystem<File>) {
let path = Path::new(fpath);
// println!("{path:?}");
io::copy(
&mut File::open(path).expect(&format!("Could not open file {fpath}")),
&mut fs

View file

@ -2,7 +2,7 @@ char := struct {}
log := fn(log_level: int, message: ^char, message_length: int): int {
@eca(i32,1, 1, 1)
return 0;
}
@ -29,3 +29,7 @@ trace := fn(message: ^char, message_length: int): int {
main := fn(): int {
return 0;
}
test := fn(): int {
@eca(i32, 1, 1, 1);
}

View file

@ -0,0 +1,11 @@
[package]
name = "diskio_driver"
authors = ["able"]
[dependants.libraries]
[dependants.binaries]
hblang.version = "1.0.0"
[build]
command = "hblang libraries/stn/src/lib.hb src/main.hb"

View file

@ -1,4 +1,3 @@
main := fn(): int {
return 0;
}

View file

@ -1,5 +1,5 @@
[package]
name = "dev"
name = "fb_driver"
authors = ["able"]
[dependants.libraries]
@ -7,5 +7,5 @@ authors = ["able"]
[dependants.binaries]
hblang.version = "1.0.0"
[build.debug]
command = "hblang libraries/stn/src/lib.hb src/main.hbl"
[build]
command = "hblang libraries/stn/src/lib.hb src/main.hb"

View file

@ -8,4 +8,4 @@ authors = ["able"]
hblang.version = "1.0.0"
[build]
command = "hblang sysdata/libraries/stn/src/lib.hb sysdata/programs/tests/src/main.hb"
command = "hblang libraries/stn/src/lib.hb src/main.hb"

View file

@ -18,5 +18,6 @@ resolution = "1024x768x24"
[boot.limine.ableos.modules]
[boot.limine.ableos.modules.tests]
# TODO: Pull from the programs included here
path = "boot:///tests.hbf"
[boot.limine.ableos.modules.diskio_driver]
path = "boot:///diskio_driver.hbf"