1
0
Fork 0
forked from AbleOS/ableos

rlbuild: Init commit

This commit is contained in:
Able 2025-02-18 00:58:35 -06:00
parent 4a0fbafd2d
commit 1837fe5826
7 changed files with 344 additions and 110 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
target/
out/

15
Cargo.lock generated
View file

@ -582,6 +582,21 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "rlbuild"
version = "0.1.0"
dependencies = [
"rlisp_library",
]
[[package]]
name = "rlisp_library"
version = "0.1.0"
source = "git+https://git.ablecorp.us/able/rlisp.git#e349916bb67ad74ca5f868da57c733d00d97397f"
dependencies = [
"hashbrown",
]
[[package]]
name = "rustc_version"
version = "0.4.1"

View file

@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["dev", "kernel", "repbuild"]
members = ["dev", "kernel", "repbuild", "rlbuild"]
# [profile.release]
# strip = "symbols"

7
rlbuild/Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "rlbuild"
version = "0.1.0"
edition = "2024"
[dependencies]
rlisp_library = { git="https://git.ablecorp.us/able/rlisp.git"}

255
rlbuild/src/main.rs Normal file
View file

@ -0,0 +1,255 @@
#![feature(slice_take)]
#![allow(special_module_name)]
use std::{fs::{self, File}, io::Write};
use rlisp_library::{
Environ,
Expr::{self, Bool},
RispError, default_env, parse_eval,
};
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 repo_url = &args[1].clone();
let use_sources = &args[2].clone();
let msg = match use_sources {
Bool(b) => match b {
true => "building from sources.",
false => "downloading binaries.",
},
_ => {
panic!("AHHH");
}
};
println!("repo name {} repo url {} {}", repo_name, repo_url, msg);
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 root_package_path = env.data.get("system-path").unwrap();
println!("installing package {} from repo {}", pkg_name, repo_name);
let path = format!("out/programs/{}", pkg_name);
fs::create_dir_all(path).unwrap();
// 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 repo_name = &args[1].clone();
println!("{}", repo_name);
println!("configuring package {}", pkg_name);
// TODO: build the code with the hblang compiler.
// TODO: use the meta.rli to map dependencies.
let path = format!("out/programs/{}/config.rl", pkg_name);
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
}
fn main() {
let env = &mut default_env();
let env = &mut extend_environ(env.clone());
let cfg = include_str!("../../sysdata/system.lisp");
let mut complete_exprs: Vec<String> = vec![];
let mut left_parens = 0;
let mut idx_of_first_left_paran = 0;
for (i, character) in cfg.chars().enumerate() {
if character == '(' {
if left_parens == 0 {
idx_of_first_left_paran = i;
}
left_parens += 1
}
if character == ')' {
left_parens -= 1;
if left_parens == 0 {
let idx_of_last_right_paran = i + 1;
complete_exprs
.push(cfg[idx_of_first_left_paran..idx_of_last_right_paran].to_string());
}
}
}
if left_parens != 0 {
panic!("unmatched parens. Good luck finding them!");
}
// TODO: Mount the disk image here.
for expr in complete_exprs {
match parse_eval(expr, env) {
Ok(_res) => {}
Err(e) => {
panic!("{:?}", e)
}
}
}
// TODO: unmount the disk image here.
}

View file

@ -1,114 +1,67 @@
;;;;;;;;;;;
;; Repos ;;
;;;;;;;;;;;
;; 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)
;; This is the core repo that is used for core things like networking ;;
(use-repo core "https://repo.ablecorp.us/core")
;; Add a secondary repo ;;
;; (use-repo able "https://repo.ablecorp.us/able")
(def system-path "sample")
;;;;;;;;;;;;;;;;;;
;; REPOSITORIES ;;
;;;;;;;;;;;;;;;;;;
;; Set the default pkg-install to be binary ;;
(pkg-defaults binary:true)
;; Install compilers ;;
;; pkg-install <repo> <pkg-name>
;; pkg-name : A string or atom to search.
(pkg-install core hblang2)
;; Install the rust compiler ;;
(pkg-install core rustc)
(pkg-install core clang)
;;;;;;;;;;;;;;;
;; Compilers ;;
;;;;;;;;;;;;;;;
;; Set default compilers to use ;;
;; the dev tool pulls from this ;;
(compilers
hblang: 'hblang2
rust: 'rustc
;; Clang is not supported :thumbsup:
;; c: 'clang
)
;;;;;;;;;;;;;;;;;
;; Boot Loader ;;
;;;;;;;;;;;;;;;;;
(pkg-install core limine)
(def limine_res (resolution 1024 768 24))
(boot-loader
default-entry:1
timeout:0
interface_resolution: 'limine_res)
(boot-loader-entry "ableos"
comment: "Default AbleOS boot entry."
protocol: "limine"
kernel_path: "boot:///kernel_${ARCH}"
kernel_cmdline: ""
resolution: 'limine_res)
(boot-loader-entry "ableos-no-cluster"
comment: "Default AbleOS boot entry."
protocol: "limine"
kernel_path: "boot:///kernel_${ARCH}"
kernel_cmdline: "cluster=false"
resolution: 'limine_res)
;;;;;;;;;;;;;;;;;;;;
;; Kernel Options ;;
;;;;;;;;;;;;;;;;;;;;
;; A kernel package is required
(pkg-install core kernel-rust)
;; Set the kernel to be used by ableOS ;;
;; Maybe set a default if this isn't set? ;;
;; Must be installed already ;;
(kernel 'kernel-rust)
;;;;;;;;;;;;
;; Config ;;
;;;;;;;;;;;;
;; Install packages ;;
(pkg-install core sunset)
(pkg-install core ps2-driver)
;; A list of programs to run on startup ;;
(start '())
;; A list of programs to add to the driver supervisor ;;
(start-driver '(ps2-driver))
;; Set the window system to be used by ableOS ;;
;; Must be installed already ;;
;; adds the window system to the driver supervisor ;;
;; (def window-system (fn (a) (start-driver a)))
(window-system 'sunset)
(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)
;;;;;;;;;;;;;;;;
;; Networking ;;
;; BOOTLOADER ;;
;;;;;;;;;;;;;;;;
(networking
;; set the network hostname
;; TODO Namespace this somehow ;;
(hostname "ableOS")
;; use dhcp to find an ip ;;
(ipv4 dhcp)
(ipv6 dhcp)
;; Set the time server ;;
(ntp "time.nist.gov")
(dns 'router-dns-steal))
(def resolution (fn (x y fps) (println x "x" y "@" fps)))
;;;;;;;;;;;;;;;;;;;;;;
;; Cluster Software ;;
;;;;;;;;;;;;;;;;;;;;;;
(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)
;; Install the cluster software ;;
(pkg-install core cluster)
;; Defaults to false ;;
(cluster enabled:false)
;;;;;;;;;;;;;
;; DRIVERS ;;
;;;;;;;;;;;;;
(pkg-install 'core 'ps2-driver)
(pkg-install 'core 'ata-pio)
;;;;;;;;;;;;;;
;; SERVICES ;;
;;;;;;;;;;;;;;
(pkg-install 'core 'vfsaur)
(pkg-install 'core '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)

View file

@ -38,14 +38,17 @@ path = "boot:///ps2_mouse_driver.hbf"
# [boot.limine.ableos.modules.ps2_driver]
# path = "boot:///ps2_driver.hbf"
# [boot.limine.ableos.modules.sunset_client]
# path = "boot:///sunset_client.hbf"
[boot.limine.ableos.modules.sunset_client]
path = "boot:///sunset_client.hbf"
[boot.limine.ableos.modules.adit]
path = "boot:///adit.hbf"
# [boot.limine.ableos.modules.sketchpad]
# path = "boot:///sketchpad.hbf"
[boot.limine.ableos.modules.ablefetch]
path = "boot:///ablefetch.hbf"
[boot.limine.ableos.modules.sketchpad]
path = "boot:///sketchpad.hbf"
# [boot.limine.ableos.modules.angels_halo]
# path = "boot:///angels_halo.hbf"