Skip to content

Commit

Permalink
[bndbuild] Add support for martine
Browse files Browse the repository at this point in the history
  • Loading branch information
Krusty/Benediction committed Aug 8, 2024
1 parent 8a2cd1f commit 401d3fe
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 7 deletions.
7 changes: 6 additions & 1 deletion cpclib-bndbuild/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ use crate::runners::disc::DiscManagerRunner;
use crate::runners::echo::EchoRunner;
use crate::runners::imgconverter::ImgConverterRunner;
use crate::runners::r#extern::ExternRunner;
use crate::runners::martine::MartineVersion;
use crate::runners::rm::RmRunner;
use crate::runners::xfer::XferRunner;
use crate::runners::Runner;
use crate::runners::{martine, Runner};
use crate::task::Task;

pub static BASM_RUNNER: LazyLock<BasmRunner> = LazyLock::new(BasmRunner::default);
Expand Down Expand Up @@ -51,6 +52,10 @@ pub fn execute(task: &Task) -> Result<(), String> {
Task::Echo(_) => ECHO_RUNNER.run(task.args()),
Task::Extern(_) => EXTERN_RUNNER.run(task.args()),
Task::ImgConverter(_) => IMGCONV_RUNNER.run(task.args()),
Task::Martine(_) => DelegatedRunner {
app: MartineVersion::default().configuration(),
cmd: MartineVersion::default().get_command().to_owned()
}.run(task.args()),
Task::Rm(_) => RM_RUNNER.run(task.args()),
Task::Xfer(_) => XFER_RUNNER.run(task.args())
}
Expand Down
61 changes: 61 additions & 0 deletions cpclib-bndbuild/src/runners/martine.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
use crate::{delegated::{ArchiveFormat, DelegateApplicationDescription}, task::MARTINE_CMDS};

pub enum MartineVersion {
V0_39
}

impl Default for MartineVersion {
fn default() -> Self {
MartineVersion::V0_39
}
}

impl MartineVersion {
pub fn get_command(&self) -> &str {
MARTINE_CMDS[0]
}
}

cfg_match! {
cfg(target_os = "linux") =>
{
impl MartineVersion {
pub fn configuration(&self) -> DelegateApplicationDescription {
match self {
MartineVersion::V0_39 =>
DelegateApplicationDescription {
download_url: "https://github.com/jeromelesaux/martine/releases/download/v0.39/martine-0.39-linux-amd64.zip", // we assume a modern CPU
folder : "martine_0_39",
archive_format: ArchiveFormat::Zip,
exec_fname: "martine.linux",
compile: None
}
}
}
}
}
cfg(target_os = "windows") =>
{
impl MartineVersion {
pub fn configuration(&self) -> DelegateApplicationDescription {
match self {
MartineVersion::V0_39 =>
DelegateApplicationDescription {
download_url: "https://github.com/jeromelesaux/martine/releases/download/v0.39/martine-0.39-windows-amd64.zip",
folder : "martine_0_39",
archive_format: ArchiveFormat::Zip,
exec_fname: "martine.exe",
compile: None
}
}
}
}

}
cfg(target_os = "macos") =>
{

}
_ => {
}
}
1 change: 1 addition & 0 deletions cpclib-bndbuild/src/runners/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod echo;
pub mod emulator;
pub mod r#extern;
pub mod imgconverter;
pub mod martine;
pub mod rm;
pub mod xfer;

Expand Down
21 changes: 15 additions & 6 deletions cpclib-bndbuild/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum Task {
Emulator(Emulator, StandardTask),
Extern(StandardTask),
ImgConverter(StandardTask),
Martine(StandardTask),
Rm(StandardTask),
Xfer(StandardTask)
}
Expand All @@ -32,6 +33,7 @@ pub const DISC_CMDS: &[&str] = &["dsk", "disc"];
pub const ECHO_CMDS: &[&str] = &["echo", "print"];
pub const EXTERN_CMDS: &[&str] = &["extern"];
pub const IMG2CPC_CMDS: &[&str] = &["img2cpc", "imgconverter"];
pub const MARTINE_CMDS: &[&str] = &["martine"];
pub const RASM_CMDS: &[&str] = &["rasm"];
pub const RM_CMDS: &[&str] = &["rm", "del"];
pub const XFER_CMDS: &[&str] = &["xfer", "cpcwifi", "m4"];
Expand All @@ -48,7 +50,8 @@ impl Display for Task {
Task::ImgConverter(s) => (IMG2CPC_CMDS[0], s),
Task::Rm(s) => (RM_CMDS[0], s),
Task::Xfer(s) => (XFER_CMDS[0], s),
Task::Emulator(e, s) => (e.get_command(), s)
Task::Emulator(e, s) => (e.get_command(), s),
Task::Martine(s) => (MARTINE_CMDS[0], s),
};

write!(
Expand Down Expand Up @@ -124,6 +127,9 @@ impl<'de> Deserialize<'de> for Task {
else if IMG2CPC_CMDS.iter().contains(&code) {
Ok(Task::ImgConverter(std))
}
else if MARTINE_CMDS.iter().contains(&code) {
Ok(Task::Martine(std))
}
else if RM_CMDS.iter().contains(&code) {
Ok(Task::Rm(std))
}
Expand Down Expand Up @@ -172,14 +178,15 @@ impl Task {
fn standard_task(&self) -> &StandardTask {
match self {
Task::Assembler(_, t)
| Task::Rm(t)
| Task::BndBuild(t)
| Task::Cp(t)
| Task::Disc(t)
| Task::Echo(t)
| Task::Extern(t)
| Task::ImgConverter(t)
| Task::Martine(t)
| Task::Rm(t)
| Task::Xfer(t)
| Task::Extern(t)
| Task::Disc(t)
| Task::BndBuild(t)
| Task::Cp(t)
| Task::Emulator(_, t) => t
}
}
Expand All @@ -194,6 +201,7 @@ impl Task {
| Task::Extern(t)
| Task::Disc(t)
| Task::BndBuild(t)
| Task::Martine(t)
| Task::Cp(t)
| Task::Emulator(_, t) => t
}
Expand All @@ -220,6 +228,7 @@ impl Task {
Task::Echo(_) => true,
Task::Emulator(..) => true,
Task::Xfer(_) => true, // wrong when downloading files
Task::Martine(t) => false,
Task::ImgConverter(_) => false,
Task::Extern(_) => false,
Task::BndBuild(_) => false,
Expand Down
2 changes: 2 additions & 0 deletions cpclib-bndbuild/tests/delegated/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
martine.scr
show.sna
23 changes: 23 additions & 0 deletions cpclib-bndbuild/tests/delegated/build.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This project only use delegated commands.
# No one comes from benediction

- tgt: ace
dep: show.sna
cmd: ace show.sna

- tgt: show.sna
dep: martine.scr/MARTIN.SCR martine.scr/MARTIN.PAL show.asm
cmd: rasm show.asm -oi show.sna -map

- tgt: martine.scr/MARTIN.SCR martine.scr/MARTIN.PAL
dep: martine-logo.png
cmd: martine -in martine-logo.png -mode 1 -noheader -out martine.scr

- tgt: clean
pnony: true
cmd: -rm martine.scr # ATM it is buggy as it is a folderand not handled

- tgt: distclean
dep: clean
phony: true
cmd: -rm show.sna
Binary file added cpclib-bndbuild/tests/delegated/martine-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions cpclib-bndbuild/tests/delegated/show.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
BUILDSNA ; Mandatory for rasm
BANKSET 0 ; Mandatory for rasm

org 0xc000
incbin "martine.scr/MARTIN.SCR"

org 0x4000
run $

di
ld bc, 0x7f00
ld hl, PAL

repeat 4
ld a, (hl)
out (c), c : out (c), a
inc a
inc hl
rend

jp $

PAL
incbin "martine.scr/MARTIN.PAL", 3, 1
incbin "martine.scr/MARTIN.PAL", 3+12, 1
incbin "martine.scr/MARTIN.PAL", 3+12+12, 1
incbin "martine.scr/MARTIN.PAL", 3+12+12+12, 1

0 comments on commit 401d3fe

Please sign in to comment.