cpclib_runner/runner/assembler/
vasm.rs

1use std::sync::OnceLock;
2
3use crate::delegated::{
4    ArchiveFormat, DownloadableInformation, ExecutableInformation,
5    InternetStaticCompiledApplication, MutiplatformUrls, StaticInformation
6};
7
8pub const VASM_CMD: &str = "vasm";
9
10#[derive(Clone, Debug, PartialEq, Eq, Hash, Default)]
11pub enum VasmVersion {
12    #[default]
13    V2021_03_19
14}
15
16impl InternetStaticCompiledApplication for VasmVersion {}
17
18impl DownloadableInformation for VasmVersion {
19    fn target_os_archive_format(&self) -> ArchiveFormat {
20        match self {
21            VasmVersion::V2021_03_19 => {
22                #[cfg(target_os = "windows")]
23                return ArchiveFormat::Zip;
24                #[cfg(target_os = "macos")]
25                unimplemented!();
26                #[cfg(target_os = "linux")]
27                return ArchiveFormat::Tar; // XXX yep extension is wrong
28            }
29        }
30    }
31}
32
33impl StaticInformation for VasmVersion {
34    fn static_download_urls(&self) -> &'static MutiplatformUrls {
35        match self {
36            VasmVersion::V2021_03_19 => {
37                static URL: OnceLock<MutiplatformUrls> = OnceLock::new();
38                URL.get_or_init(|| {
39                    MutiplatformUrls {
40                        linux: Some("http://www.ibaug.de/vbcc/vbcc_linux_x64.tar.gz".to_owned()),
41                        windows: Some("http://www.ibaug.de/vbcc/vbcc_win_x64.zip".to_owned()),
42                        macos: None
43                    }
44                })
45            }
46        }
47    }
48}
49
50impl ExecutableInformation for VasmVersion {
51    fn target_os_folder(&self) -> &'static str {
52        match self {
53            Self::V2021_03_19 => "vasm20210319"
54        }
55    }
56
57    fn target_os_exec_fname(&self) -> &'static str {
58        #[cfg(target_os = "windows")]
59        return "bin/vasmz80_oldstyle.exe";
60        #[cfg(target_os = "macos")]
61        unimplemented!();
62        #[cfg(target_os = "linux")]
63        return "vbcc/bin/vasmz80_oldstyle";
64    }
65}