updated DSX tasks/build

This commit is contained in:
2026-08-09 09:17:01 +01:00
parent e3a87ca908
commit e20bf7d08f
4 changed files with 91 additions and 23 deletions
+7
View File
@@ -5,3 +5,10 @@ version.workspace = true
authors.workspace = true
[dependencies]
clap = { version = "4.6.0", features = ["derive"] }
common = { path = "../../libraries/common" }
dsa_formats = { path = "../../libraries/dsa_formats" }
dsa_tasks = { path = "../../libraries/dsa_tasks" }
assembler = { path = "../assembler" }
dsfl_compiler = { path = "../dsfl_compiler" }
bf_compiler = { path = "../bf_compiler" }
+57 -10
View File
@@ -1,14 +1,61 @@
pub fn add(left: u64, right: u64) -> u64 {
left + right
use dsa_formats::binary_dse::DseExecutable;
use dsa_tasks::{ProcessAgent, TraceableProcess};
use dsabf_compiler::BfCompiler;
use std::fmt::{Display, Formatter};
use std::path::PathBuf;
#[derive(Debug)]
pub struct DsxBuilder;
impl DsxBuilder {}
#[derive(Debug)]
pub enum DsxBuildError {
Generic(String),
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
impl DsxBuildError {
fn new(msg: impl Into<String>) -> DsxBuildError {
DsxBuildError::Generic(msg.into())
}
}
impl std::error::Error for DsxBuildError {}
impl Display for DsxBuildError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
}
impl TraceableProcess for DsxBuilder {
type Input = PathBuf;
type Output = DseExecutable;
type Error = DsxBuildError;
fn run(
self: Box<Self>,
input: impl Into<Self::Input>,
ctx: ProcessAgent,
) -> Result<Self::Output, Self::Error> {
if input.into() == FileType::Bf {
let bf_src = std::fs::read_to_string(&args.input_path).unwrap();
let result = BfCompiler::new(
args.input_path
.file_stem()
.unwrap()
.to_string_lossy()
.to_string(),
)
.run_sync(bf_src)
.unwrap();
println!("Successfully compiled {}", args.input_path.display());
println!("Writing result to {}", args.output_path.display());
std::fs::write(&args.output_path, result).unwrap();
BfCompiler::new()
}
}
}