Restructure

This commit is contained in:
Able 2025-03-19 18:18:19 -05:00
parent ad31929f7b
commit 0fa5210102
11 changed files with 494 additions and 103 deletions

6
.gitignore vendored
View file

@ -1,3 +1,3 @@
target/*
out/*
cache/*
target/
out/
cache/

235
Cargo.lock generated
View file

@ -2,6 +2,102 @@
# It is not intended for manual editing.
version = 4
[[package]]
name = "anstream"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
[[package]]
name = "anstyle-parse"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
dependencies = [
"anstyle",
"once_cell",
"windows-sys",
]
[[package]]
name = "clap"
version = "4.5.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
name = "colorchoice"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "foldhash"
version = "0.1.5"
@ -17,10 +113,47 @@ dependencies = [
"foldhash",
]
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "once_cell"
version = "1.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
[[package]]
name = "proc-macro2"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rlbuild"
version = "0.1.0"
dependencies = [
"clap",
"rlisp_library",
]
@ -31,3 +164,105 @@ source = "git+https://git.ablecorp.us/able/rlisp.git#a1cef24e513a89f8d4de8a1cb3e
dependencies = [
"hashbrown",
]
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

View file

@ -4,4 +4,5 @@ version = "0.1.0"
edition = "2024"
[dependencies]
rlisp_library = { git="https://git.ablecorp.us/able/rlisp.git"}
rlisp_library = { git="https://git.ablecorp.us/able/rlisp.git"}
clap = { version = "4.5", features = ["derive"] }

View file

@ -0,0 +1,76 @@
;; 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)
(pkg-install :src :rlbuild-test)
;;;;;;;;;;;;;;
;; 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.

75
src/build.rs Normal file
View file

@ -0,0 +1,75 @@
#![feature(slice_take)]
#![allow(special_module_name)]
use std::{
fs::{self, File},
io::Write,
path::Path,
};
use rlisp_library::{
Environ,
Expr::{self, Bool},
RispError, default_env, parse_eval,
};
use crate::environ::extend_environ;
pub fn build_system(system_rl_path: &Path) -> Result<(), Box<dyn std::error::Error>> {
// Create output directory if it doesn't exist
fs::create_dir_all("out")?;
let env = &mut default_env();
let env = &mut extend_environ(env.clone());
let cfg = fs::read_to_string(system_rl_path)?;
println!("{}", cfg);
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 {
return Err("Unmatched parentheses in system.rl file".into());
}
// TODO: Mount the disk image here.
for expr in complete_exprs {
match parse_eval(expr, env) {
Ok(_res) => {}
Err(e) => {
return Err(format!("Error evaluating expression: {:?}", e).into());
}
}
}
let output_path = Path::new("out/system.rl");
let mut file = File::create(output_path)?;
file.write_all(cfg.as_bytes())?;
// TODO: unmount the disk image here.
Ok(())
}

View file

@ -1,25 +1,23 @@
use rlisp_library::*;
pub fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
env.data.insert(
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))
Ok(Expr::Bool(true))
}),
);
env
}
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

@ -4,11 +4,8 @@ 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
}
let mut env = ext::extend_environ(env);
let mut env = old::extend_environ(env);
env
}

View file

@ -9,10 +9,7 @@ use rlisp_library::{
RispError, default_env, parse_eval,
};
pub
fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
pub fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
env.data.insert(
"quit".to_string(),
Expr::Func(|_args: &[Expr]| -> Result<Expr, RispError> {
@ -135,11 +132,11 @@ fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
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
std::fs::copy("cache/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
std::fs::copy("cache/limine/BOOTAA64.EFI", &path).unwrap(); // Copy foo.txt to bar.txt
Ok(Expr::Bool(true))
}),
@ -166,13 +163,13 @@ fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
// If package is from :src repo, copy source files
if repo_name.to_string() == ":src" {
// Try original name first
let src_path = format!("sysdata/programs/{}", pkg_name_str);
let src_path = format!("cache/ableos/sysdata/programs/{}", pkg_name_str);
println!("Checking source path: {}", src_path);
// If not found, try with dashes converted to underscores
let underscored_name = pkg_name_str.replace('-', "_");
let src_path_alt = format!("sysdata/programs/{}", underscored_name);
let src_path_alt = format!("cache/ableos/sysdata/programs/{}", underscored_name);
let (found_path, found_name) = if fs::metadata(&src_path).is_ok() {
(src_path, pkg_name_str.clone())
} else if fs::metadata(&src_path_alt).is_ok() {
@ -217,7 +214,7 @@ fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
// Check if meta.rl exists in source, if not generate one
let meta_src_path = format!("sysdata/programs/{}/meta.rl", found_name);
let meta_dest_path = format!("out/programs/{}/meta.rl", pkg_name_str);
if !fs::metadata(&meta_src_path).is_ok() {
println!("Generating meta.rl for {}", pkg_name_str);
let mut file = File::create(&meta_dest_path).unwrap();
@ -250,8 +247,7 @@ fn extend_environ<'a>(mut env: Environ<'a>) -> Environ<'a> {
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 mut file = File::create(path).unwrap();
let _ = file.write_all(b"()");

31
src/git.rs Normal file
View file

@ -0,0 +1,31 @@
use std::fs;
use std::path::Path;
use std::process::Command;
pub fn fetch_git_repo(url: &str, cache_dir: &Path) -> Result<(), String> {
// Create cache directory if it doesn't exist
if !cache_dir.exists() {
fs::create_dir_all(cache_dir)
.map_err(|e| format!("Failed to create cache directory: {}", e))?;
}
println!("Fetching git repository: {}", url);
// Run git clone with proper error handling
let output = Command::new("git")
.arg("clone")
.arg(url)
.current_dir(cache_dir)
.output()
.map_err(|e| format!("Failed to execute git clone: {}", e))?;
if output.status.success() {
println!("Successfully cloned repository");
Ok(())
} else {
Err(format!(
"Error cloning repository: {}",
String::from_utf8_lossy(&output.stderr)
))
}
}

View file

@ -1,71 +1,47 @@
#![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,
};
mod packages;
use std::env;
use std::path::Path;
mod build;
mod environ;
use environ::extend_environ;
mod git;
mod packages;
fn main() {
let env = &mut default_env();
let env = &mut extend_environ(env.clone());
// let env = &mut
pub fn main() {
let args: Vec<String> = env::args().collect();
let cfg = include_str!("../assets/system.rl");
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 args.len() < 2 {
let a = build::build_system(Path::new("assets/system.rl"));
println!("{:?}", a);
return;
}
if left_parens != 0 {
panic!("unmatched parens. Good luck finding them!");
}
match args[1].as_str() {
"build" => {
let a = build::build_system(Path::new("assets/system.rl"));
println!("{:?}", a); }
"fetch" => {
if args.len() < 3 {
println!("Error: Repository name required for fetch command");
println!("Usage: {} fetch <repository>", args[0]);
return;
}
let repo = &args[2];
let url = match repo.as_str() {
"ableos" => "https://git.ablecorp.us/AbleOS/ableos.git".to_string(),
"limine" => "https://github.com/limine-bootloader/limine.git".to_string(),
_ => {
println!("Unknown repository: {}", repo);
panic!("Unknown repository: {}", repo);
}
};
// TODO: Mount the disk image here.
for expr in complete_exprs {
match parse_eval(expr, env) {
Ok(_res) => {}
Err(e) => {
panic!("{:?}", e)
let cache_dir = Path::new("cache");
if let Err(e) = git::fetch_git_repo(&url, cache_dir) {
println!("{}", e);
}
}
_ => {
println!("Unknown command: {}", args[1]);
println!("Usage: {} [build|fetch <repository>]", args[0]);
}
}
let path = format!("out/system/config.rl");
let mut file = File::create(path).unwrap();
let _ = file.write_all(cfg.as_bytes());
// TODO: unmount the disk image here.
}

View file

@ -15,7 +15,13 @@ pub enum Dependency {
}
impl Package {
pub fn new(name: String, authors: Vec<String>, version: String, dependencies: Vec<Dependency>, build_command: String) -> Self {
pub fn new(
name: String,
authors: Vec<String>,
version: String,
dependencies: Vec<Dependency>,
build_command: String,
) -> Self {
Self {
name,
authors,