forked from AbleOS/ableos
rlbuild: Init commit
This commit is contained in:
parent
4a0fbafd2d
commit
1837fe5826
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
target/
|
target/
|
||||||
|
out/
|
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -582,6 +582,21 @@ dependencies = [
|
||||||
"windows-sys",
|
"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]]
|
[[package]]
|
||||||
name = "rustc_version"
|
name = "rustc_version"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = ["dev", "kernel", "repbuild"]
|
members = ["dev", "kernel", "repbuild", "rlbuild"]
|
||||||
|
|
||||||
# [profile.release]
|
# [profile.release]
|
||||||
# strip = "symbols"
|
# strip = "symbols"
|
||||||
|
|
7
rlbuild/Cargo.toml
Normal file
7
rlbuild/Cargo.toml
Normal 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
255
rlbuild/src/main.rs
Normal 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.
|
||||||
|
}
|
|
@ -1,114 +1,67 @@
|
||||||
;;;;;;;;;;;
|
;; If passed into a use-repo function this will
|
||||||
;; Repos ;;
|
;; 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 ;;
|
(def system-path "sample")
|
||||||
(use-repo core "https://repo.ablecorp.us/core")
|
;;;;;;;;;;;;;;;;;;
|
||||||
;; Add a secondary repo ;;
|
;; REPOSITORIES ;;
|
||||||
;; (use-repo able "https://repo.ablecorp.us/able")
|
;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
;; Set the default pkg-install to be binary ;;
|
(use-repo 'core "https://repo.ablecorp.us/core" use-sources)
|
||||||
(pkg-defaults binary:true)
|
;; another repo example.
|
||||||
|
(use-repo 'games "https://repo.ablecorp.us/games" use-binaries)
|
||||||
;; Install compilers ;;
|
(use-repo 'personal "https://repo.ablecorp.us/able-personal" use-sources)
|
||||||
;; 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)
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;
|
||||||
;; Networking ;;
|
;; BOOTLOADER ;;
|
||||||
;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(networking
|
(def resolution (fn (x y fps) (println x "x" y "@" fps)))
|
||||||
;; 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))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;
|
(pkg-install 'core 'bootloader-limine)
|
||||||
;; Cluster Software ;;
|
(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)
|
||||||
|
|
|
@ -38,14 +38,17 @@ path = "boot:///ps2_mouse_driver.hbf"
|
||||||
# [boot.limine.ableos.modules.ps2_driver]
|
# [boot.limine.ableos.modules.ps2_driver]
|
||||||
# path = "boot:///ps2_driver.hbf"
|
# path = "boot:///ps2_driver.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.sunset_client]
|
[boot.limine.ableos.modules.sunset_client]
|
||||||
# path = "boot:///sunset_client.hbf"
|
path = "boot:///sunset_client.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.adit]
|
[boot.limine.ableos.modules.adit]
|
||||||
path = "boot:///adit.hbf"
|
path = "boot:///adit.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.sketchpad]
|
[boot.limine.ableos.modules.ablefetch]
|
||||||
# path = "boot:///sketchpad.hbf"
|
path = "boot:///ablefetch.hbf"
|
||||||
|
|
||||||
|
[boot.limine.ableos.modules.sketchpad]
|
||||||
|
path = "boot:///sketchpad.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.angels_halo]
|
# [boot.limine.ableos.modules.angels_halo]
|
||||||
# path = "boot:///angels_halo.hbf"
|
# path = "boot:///angels_halo.hbf"
|
||||||
|
|
Loading…
Reference in a new issue