hopefully clean up soem while going crazy

This commit is contained in:
Able 2025-03-08 08:29:19 -06:00
parent ed6e573a0c
commit c4b8c7cb61
9 changed files with 430 additions and 345 deletions

2
Cargo.lock generated
View file

@ -591,7 +591,7 @@ dependencies = [
[[package]]
name = "rlisp_library"
version = "0.1.0"
source = "git+https://git.ablecorp.us/able/rlisp.git#e349916bb67ad74ca5f868da57c733d00d97397f"
source = "git+https://git.ablecorp.us/able/rlisp.git#a1cef24e513a89f8d4de8a1cb3ede546bc72aeca"
dependencies = [
"hashbrown",
]

38
rlbuild/assets/pkg.rl Normal file
View file

@ -0,0 +1,38 @@
;; ! hbpkg.rli ! ;;
;; package name & version, non-optional.
(package
"example"
;; Major Minor Patch
(version 1 0 1)
:authors ("AbleTheAbove")
:tags ("a" "b" "c")
(deps
;; first item after name is always source.
(lily "https://git.ablecorp.us/lily-org/lily.git"
;; semantic version. min & max both optional.
;; if version is string, exact match will be used.
;; if version is "0.x", then the latest of "0.x.y" will be used
:version (:min "0.0.2" :max "0.0.5")
)
(libexample "./src/lib.hb")
(third-dep
;; Repo lookup refers to the rlrepo project
(repo :core "third-dep")
)
(some_clib "https://example.org/clib.git"
:commit "ABCDEFGH" ;; optional
:branch "trunk" ;; optional
;; optional, probably not required if specifying commit.
:hash "abcdefghijklmnopqrstuvwxyz123456"
)
)
)

View file

@ -0,0 +1,25 @@
use rlisp_library::*;
pub fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
env.data.insert(
"system-install".to_string(),
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
println!("probably the kernel is installed by now");
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"use-repo-path".to_string(),
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
let repo_name = _args.first().unwrap();
println!("{:?}", _args);
Ok(Expr::Bool(true))
}),
);
env
}

View file

@ -0,0 +1,14 @@
use rlisp_library::*;
mod ext;
mod old;
pub fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
let mut env = ext::extend_environ(env);
let mut env = old::extend_environ(env);
env
}

262
rlbuild/src/environ/old.rs Normal file
View file

@ -0,0 +1,262 @@
use std::{
fs::{self, File},
io::Write,
};
use rlisp_library::{
Environ,
Expr::{self, Bool},
RispError, default_env, parse_eval,
};
pub
fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
env.data.insert(
"quit".to_string(),
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
// TODO: let this function take in arguments
println!("Exiting.");
std::process::exit(0);
#[allow(unreachable_code)]
Err(RispError::Reason("Cannot exit process".to_string()))
}),
);
env.data.insert(
"print".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let mut stri = String::new();
for arg in args {
let fmted = match arg {
Expr::Str(string) => {
let string = string.clone();
// string.pop();
// string.remove(0);
format!("{}", string)
}
_ => {
format!("{}", arg)
}
};
stri.push_str(&fmted);
if args.len() > 1 {
stri.push_str(" ")
}
}
print!("{}", stri);
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"println".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let mut stri = String::new();
for arg in args {
let fmted = match arg {
Expr::Str(string) => {
let string = string.clone();
// string.pop();
// string.remove(0);
format!("{}", string)
}
_ => {
format!("{}", arg)
}
};
stri.push_str(&fmted);
if args.len() > 1 {
stri.push_str(" ")
}
}
println!("{}", stri);
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"use-repo".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let repo_name = &args[0].clone();
let mut repo_name_str = repo_name.to_string();
repo_name_str.remove(0);
let repo_url = &args[1].clone();
let use_sources = &args[2].clone();
let msg = match use_sources {
Bool(b) => match b {
true => "build_from_src = true",
false => "build_from_src = false",
},
_ => {
panic!("AHHH");
}
};
let path = format!("out/system/repos");
fs::create_dir_all(path).unwrap();
let path = format!("out/system/repos/{}.repo", repo_name_str);
println!("repo name {} repo url {} {}", repo_name, repo_url, msg);
let mut file = File::create(path).unwrap();
let msg = format!("url = {}\n{}", repo_url, msg);
let _ = file.write(msg.as_bytes());
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"bootloader-install".to_string(),
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
// let loader_name = &args[1].clone();
// let mut loader_name_str = loader_name.to_string();
// loader_name_str.remove(0);
let path = format!("out/boot/limine");
fs::create_dir_all(path).unwrap();
// let path = format!("out/boot/limine/config.rl");
// let mut file = File::create(path).unwrap();
// let _ = file.write_all(b"()");
let path = format!("out/boot/limine/limine.conf");
let mut file = File::create(path).unwrap();
let _ = file.write_all(b"");
let path = format!("out/boot/limine/BOOTX64.EFI");
let mut x64_file = File::create(&path).unwrap();
std::fs::copy("limine/BOOTX64.EFI", &path).unwrap(); // Copy foo.txt to bar.txt
let path = format!("out/boot/limine/BOOTAA64.EFI");
let mut x64_file = File::create(&path).unwrap();
std::fs::copy("limine/BOOTAA64.EFI", &path).unwrap(); // Copy foo.txt to bar.txt
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"pkg-install".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let repo_name = &args[0].clone();
let pkg_name = &args[1].clone();
let mut pkg_name_str = pkg_name.to_string();
pkg_name_str.remove(0);
println!(
"installing package {} from repo {}",
pkg_name_str, repo_name
);
let path = format!("out/programs/{}", pkg_name_str);
fs::create_dir_all(path).unwrap();
let path = format!("out/programs/{}/src", pkg_name_str);
fs::create_dir_all(path).unwrap();
let path = format!("out/programs/{}/app.axe", pkg_name_str);
let mut file = File::create(path).unwrap();
let _ = file.write_all(b"");
// TODO: build the code with the hblang compiler.
// TODO: use the meta.rli to map dependencies.
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"pkg-configure".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let pkg_name = &args[0].clone();
let mut pkg_name_str = pkg_name.to_string();
pkg_name_str.remove(0);
println!("installing package {}.", pkg_name_str);
let path = format!("out/programs/{}/config.rl", pkg_name_str);
println!("configuring package {}", pkg_name_str);
// TODO: build the code with the hblang compiler.
// TODO: use the meta.rli to map dependencies.
let mut file = File::create(path).unwrap();
let _ = file.write_all(b"()");
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"drivers".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let mut stri = String::new();
for arg in args {
let fmted = match arg {
Expr::Str(string) => {
let string = string.clone();
format!("{}", string)
}
_ => {
format!("{}", arg)
}
};
stri.push_str(&fmted);
if args.len() > 1 {
stri.push_str(" ")
}
}
println!("Drivers {}", stri);
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"services".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let mut stri = String::new();
for arg in args {
let fmted = match arg {
Expr::Str(string) => {
let string = string.clone();
format!("{}", string)
}
_ => {
format!("{}", arg)
}
};
stri.push_str(&fmted);
if args.len() > 1 {
stri.push_str(" ")
}
}
println!("Services {}", stri);
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"reincarnation-server".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let reinc = &args[0].clone();
println!("Reincarnation Server {}", reinc);
Ok(Expr::Bool(true))
}),
);
env
}

View file

@ -13,262 +13,15 @@ use rlisp_library::{
};
mod packages;
fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
env.data.insert(
"quit".to_string(),
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
// TODO: let this function take in arguments
println!("Exiting.");
std::process::exit(0);
#[allow(unreachable_code)]
Err(RispError::Reason("Cannot exit process".to_string()))
}),
);
env.data.insert(
"print".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let mut stri = String::new();
for arg in args {
let fmted = match arg {
Expr::Str(string) => {
let string = string.clone();
// string.pop();
// string.remove(0);
format!("{}", string)
}
_ => {
format!("{}", arg)
}
};
stri.push_str(&fmted);
if args.len() > 1 {
stri.push_str(" ")
}
}
print!("{}", stri);
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"println".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let mut stri = String::new();
for arg in args {
let fmted = match arg {
Expr::Str(string) => {
let string = string.clone();
// string.pop();
// string.remove(0);
format!("{}", string)
}
_ => {
format!("{}", arg)
}
};
stri.push_str(&fmted);
if args.len() > 1 {
stri.push_str(" ")
}
}
println!("{}", stri);
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"use-repo".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let repo_name = &args[0].clone();
let mut repo_name_str = repo_name.to_string();
repo_name_str.remove(0);
let repo_url = &args[1].clone();
let use_sources = &args[2].clone();
let msg = match use_sources {
Bool(b) => match b {
true => "build_from_src = true",
false => "build_from_src = false",
},
_ => {
panic!("AHHH");
}
};
let path = format!("out/system/repos");
fs::create_dir_all(path).unwrap();
let path = format!("out/system/repos/{}.repo", repo_name_str);
println!("repo name {} repo url {} {}", repo_name, repo_url, msg);
let mut file = File::create(path).unwrap();
let msg = format!("url = {}\n{}", repo_url, msg);
let _ = file.write(msg.as_bytes());
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"bootloader-install".to_string(),
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
// let loader_name = &args[1].clone();
// let mut loader_name_str = loader_name.to_string();
// loader_name_str.remove(0);
let path = format!("out/boot/limine");
fs::create_dir_all(path).unwrap();
let path = format!("out/boot/limine/config.rl");
let mut file = File::create(path).unwrap();
let _ = file.write_all(b"()");
let path = format!("out/boot/limine/limine.conf");
let mut file = File::create(path).unwrap();
let _ = file.write_all(b"");
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"pkg-install".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let repo_name = &args[0].clone();
let pkg_name = &args[1].clone();
let mut pkg_name_str = pkg_name.to_string();
pkg_name_str.remove(0);
println!(
"installing package {} from repo {}",
pkg_name_str, repo_name
);
let path = format!("out/programs/{}", pkg_name_str);
fs::create_dir_all(path).unwrap();
let path = format!("out/programs/{}/src", pkg_name_str);
fs::create_dir_all(path).unwrap();
let path = format!("out/programs/{}/app.axe", pkg_name_str);
let mut file = File::create(path).unwrap();
let _ = file.write_all(b"");
// TODO: build the code with the hblang compiler.
// TODO: use the meta.rli to map dependencies.
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"pkg-configure".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let pkg_name = &args[0].clone();
let mut pkg_name_str = pkg_name.to_string();
pkg_name_str.remove(0);
println!("installing package {}.", pkg_name_str);
let path = format!("out/programs/{}/config.rl", pkg_name_str);
println!("configuring package {}", pkg_name_str);
// TODO: build the code with the hblang compiler.
// TODO: use the meta.rli to map dependencies.
let mut file = File::create(path).unwrap();
let _ = file.write_all(b"()");
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"drivers".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let mut stri = String::new();
for arg in args {
let fmted = match arg {
Expr::Str(string) => {
let string = string.clone();
format!("{}", string)
}
_ => {
format!("{}", arg)
}
};
stri.push_str(&fmted);
if args.len() > 1 {
stri.push_str(" ")
}
}
println!("Drivers {}", stri);
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"services".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let mut stri = String::new();
for arg in args {
let fmted = match arg {
Expr::Str(string) => {
let string = string.clone();
// string.pop();
// string.remove(0);
format!("{}", string)
}
_ => {
format!("{}", arg)
}
};
stri.push_str(&fmted);
if args.len() > 1 {
stri.push_str(" ")
}
}
println!("Services {}", stri);
Ok(Expr::Bool(true))
}),
);
env.data.insert(
"reincarnation-server".to_string(),
Expr::Func(|args: &[Expr]| -> Result<Expr, RispError> {
let reinc = &args[0].clone();
println!("Reincarnation Server {}", reinc);
Ok(Expr::Bool(true))
}),
);
env
}
mod environ;
use environ::extend_environ;
fn main() {
let env = &mut default_env();
let env = &mut extend_environ(env.clone());
// let env = &mut
let cfg = include_str!("../../sysdata/system.lisp");
let cfg = include_str!("../../sysdata/system.rl");
let mut complete_exprs: Vec<String> = vec![];
let mut left_parens = 0;
@ -308,11 +61,11 @@ fn main() {
}
}
let path = format!("out/system/config.rl");
let mut file = File::create(path).unwrap();
let path = format!("out/system/config.rl");
let _ = file.write_all(cfg.as_bytes());
let mut file = File::create(path).unwrap();
let _ = file.write_all(cfg.as_bytes());
// TODO: unmount the disk image here.
}

View file

@ -1,24 +1,15 @@
pub enum GitOrRepo {
Git(String),
Repo(String)
pub enum Origin {
GitRepo(String),
Path(String),
Repo()
}
pub struct Package {
name: String,
authors: Vec<String>,
tags: Vec<String>,
version: u8,
depends: Vec<(String, String)>,
git_or_repo: GitOrRepo,
name: String,
authors: Vec<String>,
tags: Vec<String>,
version: u8,
depends: Vec<(String, String)>,
origin: Origin,
}
impl Package{
}
impl Package {}

View file

@ -1,69 +0,0 @@
;; If passed into a use-repo function this will
;; download source code and build it.
(def use-sources true)
;; Set to false so that binaries are downloaded.
(def use-binaries false)
(def system-path "sample")
;;;;;;;;;;;;;;;;;;
;; REPOSITORIES ;;
;;;;;;;;;;;;;;;;;;
(use-repo 'core "https://repo.ablecorp.us/core" use-sources)
;; another repo example.
(use-repo 'games "https://repo.ablecorp.us/games" use-binaries)
(use-repo 'personal "https://repo.ablecorp.us/able-personal" use-sources)
;;;;;;;;;;;;;;;;
;; BOOTLOADER ;;
;;;;;;;;;;;;;;;;
(def resolution (fn (x y fps) (println x "x" y "@" fps)))
(pkg-install 'core 'bootloader-limine)
(pkg-configure 'bootloader-limine
'comment "Default"
'kernel 'kernel-rust
'boot-protocol "limine"
'verbose true
'resolution 1024 768 24
'timeout 10)
(bootloader-install 'bootloader-limine)
;;;;;;;;;;;;;
;; DRIVERS ;;
;;;;;;;;;;;;;
(pkg-install 'core 'ps2-driver)
(pkg-install 'core 'ata-pio)
;;;;;;;;;;;;;;
;; SERVICES ;;
;;;;;;;;;;;;;;
(pkg-install 'core 'vfsaur)
(pkg-install 'core 'angels-halo)
(pkg-configure 'angels-halo)
(pkg-install 'core 'sunset)
(pkg-install 'core 'cluster)
;; Init System
(pkg-install 'core 'genesis)
;; Typically drivers should not have dependencies. Thus simplifing dependency solving.
;; Services might have dependencies on drivers or other services that can be auto-started even if you don't specify them
(pkg-configure 'genesis
(reincarnation-server 'angels-halo)
(drivers 'ata-pio 'serial)
(services 'sunset 'vfsaur 'fat32))
;;;;;;;;;;;;
;; KERNEL ;;
;;;;;;;;;;;;
(pkg-install 'core 'kernel-rust)
;; Set the program to be launched to init the system.
(pkg-configure 'kernel-rust
'init-system 'genesis)

71
sysdata/system.rl Normal file
View file

@ -0,0 +1,71 @@
;; If passed into a use-repo function this will
;; download source code and build it.
(def use-sources true)
;; Set to false so that binaries are downloaded.
(def use-binaries false)
(def system-path "sample")
;;;;;;;;;;;;;;;;;;
;; REPOSITORIES ;;
;;;;;;;;;;;;;;;;;;
(use-repo :core "https://repo.ablecorp.us/core" use-sources)
;; another repo example.
(use-repo :games "https://repo.ablecorp.us/games" use-binaries)
(use-repo :personal "https://repo.ablecorp.us/able-personal" use-sources)
;; Treat a path like a repo
(use-repo-path :src "sysdata/")
;;;;;;;;;;;;;;;;
;; BOOTLOADER ;;
;;;;;;;;;;;;;;;;
(def resolution (fn (x y fps) (println x "x" y "@" fps)))
(pkg-install :core :bootloader-limine)
(pkg-configure :bootloader-limine
:comment "Default"
:kernel :kernel-rust
:boot-protocol "limine"
:verbose true
:resolution 1024 768 24
:timeout 10)
(bootloader-install :bootloader-limine)
;;;;;;;;;;;;;
;; DRIVERS ;;
;;;;;;;;;;;;;
(pkg-install :core :ps2-driver)
(pkg-install :core :ata-pio)
;;;;;;;;;;;;;;
;; SERVICES ;;
;;;;;;;;;;;;;;
(pkg-install :core :vfsaur)
(pkg-install :core :angels-halo)
(pkg-configure :angels-halo)
(pkg-install :core :sunset)
(pkg-install :core :cluster)
;; Init System
(pkg-install :core :genesis)
;; Typically drivers should not have dependencies. Thus simplifing dependency solving.
;; Services might have dependencies on drivers or other services that can be auto-started even if you don:t specify them
(pkg-configure :genesis
(reincarnation-server :angels-halo)
(drivers :ata-pio :serial)
(services :sunset :vfsaur :fat32))
;;;;;;;;;;;;
;; KERNEL ;;
;;;;;;;;;;;;
(system-install :core :kernel-rust)
;; Set the program to be launched to init the system.