elf: will start using clap to parse assembler arguments for CLI

I am tired af for some reason
This commit is contained in:
2025-06-23 21:30:48 +01:00
parent ed479ac146
commit 00a28e7711
9 changed files with 181 additions and 0 deletions
Generated
+143
View File
@@ -165,6 +165,56 @@ dependencies = [
"libc",
]
[[package]]
name = "anstream"
version = "0.6.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
[[package]]
name = "anstyle-parse"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9"
dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys 0.59.0",
]
[[package]]
name = "arboard"
version = "3.5.0"
@@ -216,6 +266,7 @@ dependencies = [
name = "assembler"
version = "0.2.0"
dependencies = [
"clap",
"common",
"num_cpus",
"threadpool",
@@ -603,6 +654,46 @@ dependencies = [
"libc",
]
[[package]]
name = "clap"
version = "4.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
[[package]]
name = "clipboard-win"
version = "5.4.0"
@@ -622,6 +713,12 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "colorchoice"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
[[package]]
name = "colorful"
version = "0.3.2"
@@ -641,6 +738,9 @@ dependencies = [
[[package]]
name = "common"
version = "0.2.0"
dependencies = [
"object",
]
[[package]]
name = "concurrent-queue"
@@ -1601,6 +1701,12 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "itoa"
version = "1.0.15"
@@ -2208,12 +2314,31 @@ dependencies = [
"objc2-foundation 0.2.2",
]
[[package]]
name = "object"
version = "0.37.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03fd943161069e1768b4b3d050890ba48730e590f57e56d4aa04e7e090e61b4a"
dependencies = [
"crc32fast",
"hashbrown",
"indexmap",
"memchr",
"rustc-std-workspace-alloc",
]
[[package]]
name = "once_cell"
version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "once_cell_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
[[package]]
name = "option-ext"
version = "0.2.0"
@@ -2582,6 +2707,12 @@ version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
[[package]]
name = "rustc-std-workspace-alloc"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d441c3b2ebf55cebf796bfdc265d67fa09db17b7bb6bd4be75c509e1e8fec3"
[[package]]
name = "rustix"
version = "0.38.44"
@@ -2831,6 +2962,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "strum"
version = "0.26.3"
@@ -3137,6 +3274,12 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "uuid"
version = "1.17.0"
+1
View File
@@ -13,6 +13,7 @@ name = "assembler"
path = "src/lib.rs"
[dependencies]
clap = { version = "4.5.40", features = ["derive"] }
common = { path = "../common" }
num_cpus = "1.17.0"
threadpool = "1.8.1"
+20
View File
@@ -0,0 +1,20 @@
use clap::{Parser, ValueEnum};
#[derive(Debug, Parser, Default)]
pub struct Args {
/// The output format to assemble to. Currently just ELF or a flat binary.
#[arg(value_enum)]
output_format: Option<OutputFormat>,
/// Whether the relocatable object files should be statically linked into a single executable or library.
link: bool,
}
#[derive(Debug, Clone, Copy, ValueEnum, Default)]
/// The executable format the output should take.
pub enum OutputFormat {
/// An ELF file.
#[default]
Elf,
/// A flat binary file.
Flat,
}
+1
View File
@@ -12,6 +12,7 @@
clippy::match_wildcard_for_single_variants
)]
pub mod args;
pub mod assembler;
pub mod brainf;
pub mod tooling;
+3
View File
@@ -1,10 +1,13 @@
use assembler::{brainf, prelude::*};
use clap::Parser;
use std::{fs, io::Write, path::PathBuf};
fn main() {
// Parse command line arguments
let args: Vec<String> = std::env::args().collect();
let _clap_args = assembler::args::Args::parse();
if args.len() == 2 && args[1] == "init" {
project::tool_libcreate();
std::process::exit(0);
+1
View File
@@ -5,3 +5,4 @@ edition.workspace = true
authors.workspace = true
[dependencies]
object = { version = "0.37.1", default-features = false, features = ["elf", "std", "read", "read_core", "write_std", "write", "alloc", "build"] }
+3
View File
@@ -0,0 +1,3 @@
# Common types and methods for the DSA
This library contains the instruction set, encoding and decoding routines, and ELF encoding and loading routines (WIP).
+8
View File
@@ -0,0 +1,8 @@
//! ELF file creation and parsing routines.
use object::{Endianness, build::elf::Builder};
#[allow(clippy::missing_const_for_fn)]
pub fn write() {
let builder = Builder::new(Endianness::Little, false);
}
+1
View File
@@ -12,6 +12,7 @@
clippy::match_wildcard_for_single_variants
)]
pub mod elf;
pub mod instructions;
pub mod prelude {