Compare commits

..

No commits in common. "c57ef99948d8fa62df6c34cf892c9d34f0ad7d40" and "b427ae1c274489cacade5e4a8878dd5463924e39" have entirely different histories.

View file

@ -12,7 +12,6 @@ use {
path::Path, path::Path,
process::{exit, Command}, process::{exit, Command},
}, },
toml::Value,
}; };
fn main() -> Result<(), Error> { fn main() -> Result<(), Error> {
@ -125,10 +124,6 @@ fn assemble() -> Result<(), Error> {
Ok(()) Ok(())
} }
fn get_path_without_boot_prefix(val: &Value) -> Option<&str> {
val.as_str()?.split("boot:///").last()
}
fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> { fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
let filename = "sysdata/system_config.toml"; let filename = "sysdata/system_config.toml";
@ -144,6 +139,10 @@ fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
let fs = FileSystem::new(img, FsOptions::new())?; let fs = FileSystem::new(img, FsOptions::new())?;
// TODO: Do not hard code these here
let p = Package::load_from_file("sysdata/programs/tests/meta.toml".to_owned());
p.build();
// Read the contents of the file using a `match` block // Read the contents of the file using a `match` block
// to return the `data: Ok(c)` as a `String` // to return the `data: Ok(c)` as a `String`
// or handle any `errors: Err(_)`. // or handle any `errors: Err(_)`.
@ -197,7 +196,12 @@ TERM_BACKDROP={}
); );
// Copy the term_wallpaper to the image // Copy the term_wallpaper to the image
let term_wallpaper_path = get_path_without_boot_prefix(term_wallpaper).unwrap(); let term_wallpaper_path = term_wallpaper
.as_str()
.unwrap()
.split("boot:///")
.last()
.unwrap();
copy_file_to_img(&format!("sysdata/{}", term_wallpaper_path), &fs); copy_file_to_img(&format!("sysdata/{}", term_wallpaper_path), &fs);
limine_str.push_str(&base); limine_str.push_str(&base);
@ -240,22 +244,7 @@ TERM_BACKDROP={}
let modules = value.get_mut("modules").unwrap().as_table_mut().unwrap(); let modules = value.get_mut("modules").unwrap().as_table_mut().unwrap();
// let mut real_modules = modules.clone(); // let mut real_modules = modules.clone();
modules.into_iter().for_each(|(key, value)| { for (key, value) in modules.into_iter() {
if value.is_table() && key == "tests" {
let path = get_path_without_boot_prefix(
value.get("path").expect("You must have `path` as a value"),
)
.unwrap()
.split(".")
.next()
.unwrap();
let p = Package::load_from_file(
format!("sysdata/programs/{}/meta.toml", path).to_owned(),
);
p.build();
}
});
modules.into_iter().for_each(|(_key, value)| {
if value.is_table() { if value.is_table() {
let path = value.get("path").expect("You must have `path` as a value"); let path = value.get("path").expect("You must have `path` as a value");
let default_value = Value::String("".into()); let default_value = Value::String("".into());
@ -269,16 +258,18 @@ TERM_BACKDROP={}
); );
limine_str.push_str(&a); limine_str.push_str(&a);
} }
}); }
// Copy modules into the test_programs directory // Copy modules into the test_programs directory
modules.into_iter().for_each(|(_key, value)| { modules.into_iter().for_each(|(key, value)| {
if value.is_table() { if value.is_table() {
let path = get_path_without_boot_prefix( let path = value
value
.get("path") .get("path")
.expect("You must have a `path` as a value"), .expect("You must have a `path` as a value")
) .as_str()
.unwrap()
.split("boot:///")
.last()
.unwrap(); .unwrap();
let fpath = format!("target/test-programs/{}", path); let fpath = format!("target/test-programs/{}", path);
copy_file_to_img(&fpath, &fs); copy_file_to_img(&fpath, &fs);