forked from AbleOS/ableos
dev tool prototype
This commit is contained in:
parent
0444fe4dfa
commit
1c491e70e0
|
@ -1,2 +1,3 @@
|
||||||
[alias]
|
[alias]
|
||||||
repbuild = "run --manifest-path ./repbuild/Cargo.toml -r --"
|
repbuild = "run --manifest-path ./repbuild/Cargo.toml -r --"
|
||||||
|
dev = "run --manifest-path ./dev/Cargo.toml -r --"
|
||||||
|
|
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -245,6 +245,10 @@ dependencies = [
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dev"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "embedded-graphics"
|
name = "embedded-graphics"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = ["kernel", "repbuild"]
|
members = [ "dev","kernel", "repbuild"]
|
||||||
|
|
|
@ -19,3 +19,6 @@ For running AbleOS, `repbuild` uses QEMU.
|
||||||
1. Ensure you have qemu installed
|
1. Ensure you have qemu installed
|
||||||
2. `git submodule update --init`
|
2. `git submodule update --init`
|
||||||
3. `cargo repbuild run`
|
3. `cargo repbuild run`
|
||||||
|
|
||||||
|
# Developing
|
||||||
|
There is a new work in progress developer tool for hblang.
|
6
dev/Cargo.toml
Normal file
6
dev/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[package]
|
||||||
|
name = "dev"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
6
dev/README.md
Normal file
6
dev/README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# dev
|
||||||
|
`dev` is an ableOS specific tool meant to help the development of ableOS.
|
||||||
|
|
||||||
|
At the current stage changes are not welcome. If you have feature suggestions ping me on discord `@abletheabove`.
|
||||||
|
|
||||||
|
Run `cargo dev help` to see usage.
|
98
dev/src/main.rs
Normal file
98
dev/src/main.rs
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
use std::{fmt::format, io::Write};
|
||||||
|
|
||||||
|
pub enum Options {
|
||||||
|
Build,
|
||||||
|
Clean,
|
||||||
|
New,
|
||||||
|
Run,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut args: Vec<String> = std::env::args().collect();
|
||||||
|
args.remove(0);
|
||||||
|
args.reverse();
|
||||||
|
|
||||||
|
let binding = args.pop().unwrap_or("help".to_string());
|
||||||
|
let subcommand = binding.as_str();
|
||||||
|
|
||||||
|
match subcommand {
|
||||||
|
"build" => {
|
||||||
|
let name = &args[1];
|
||||||
|
build(name.to_string())
|
||||||
|
}
|
||||||
|
"new" => {
|
||||||
|
let binding = args.pop().unwrap();
|
||||||
|
let dev_type = binding.as_str();
|
||||||
|
let name = args.pop().unwrap();
|
||||||
|
match dev_type {
|
||||||
|
"lib" | "library" => new(true, name),
|
||||||
|
"prog" | "program" => new(false, name),
|
||||||
|
_ => {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
"run" => run(),
|
||||||
|
|
||||||
|
"help" => {
|
||||||
|
// println!("This is the help message.");
|
||||||
|
// println!("A prototype build tool meant to help with ableOS software development.");
|
||||||
|
help()
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
println!("Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new(library: bool, name: String) {
|
||||||
|
let (folder_hierarchy, entry_name) = match library {
|
||||||
|
true => ("libraries", "lib.hb"),
|
||||||
|
false => ("programs", "main.hb"),
|
||||||
|
};
|
||||||
|
let project_folder_path_string = format!("sysdata/{folder_hierarchy}/{name}");
|
||||||
|
|
||||||
|
if std::path::Path::new(&project_folder_path_string).exists() {
|
||||||
|
panic!("Project already exists.")
|
||||||
|
}
|
||||||
|
|
||||||
|
std::fs::create_dir(project_folder_path_string.clone()).unwrap();
|
||||||
|
let readme_path_string = format!("{}/README.md", project_folder_path_string);
|
||||||
|
let mut readme_file = std::fs::File::create(readme_path_string.clone()).unwrap();
|
||||||
|
|
||||||
|
let readme_contents = format!("# {}", name);
|
||||||
|
readme_file.write_all(readme_contents.as_bytes()).unwrap();
|
||||||
|
|
||||||
|
let src_folder_path_string = format!("{}/src", project_folder_path_string);
|
||||||
|
std::fs::create_dir(src_folder_path_string.clone()).unwrap();
|
||||||
|
|
||||||
|
let full_path_string = format!("{src_folder_path_string}/{entry_name}");
|
||||||
|
let mut file = std::fs::File::create(full_path_string.clone()).unwrap();
|
||||||
|
let file_contents = if library {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
"main := fn(): int {
|
||||||
|
return 0
|
||||||
|
}"
|
||||||
|
}
|
||||||
|
.to_string();
|
||||||
|
file.write_all(file_contents.as_bytes()).unwrap();
|
||||||
|
|
||||||
|
println!("{}", full_path_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run() {
|
||||||
|
println!("Running is not supported on a non-ableOS platform");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build(name: String) {
|
||||||
|
println!("building {}", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn help() {
|
||||||
|
println!(
|
||||||
|
"==========
|
||||||
|
= Help =
|
||||||
|
==========
|
||||||
|
Subcommands
|
||||||
|
- new Usage: `cargo dev new library name` or `cargo dev new program name`"
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in a new issue