cpclib_runner/runner/
convgeneric.rs

1use std::fmt::Display;
2
3use crate::delegated::{
4    ArchiveFormat, CompilableInformation, DownloadableInformation, ExecutableInformation,
5    GithubCompilableApplication, GithubInformation
6};
7
8pub const CONVGENERIC_CMD: &str = "convgeneric";
9
10#[derive(Clone, Debug, PartialEq, Eq, Hash, Default)]
11pub enum ConvGenericVersion {
12    #[default]
13    GroSSeWindowBug // V2_2
14}
15
16impl ConvGenericVersion {
17    pub fn get_command(&self) -> &str {
18        CONVGENERIC_CMD
19    }
20}
21
22impl GithubCompilableApplication for ConvGenericVersion {}
23
24impl Display for ConvGenericVersion {
25    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26        write!(f, "rasm {}", self.version_name())
27    }
28}
29
30impl GithubInformation for ConvGenericVersion {
31    fn version_name(&self) -> &'static str {
32        match self {
33            Self::GroSSeWindowBug => "GroSSe Windows Bug!"
34        }
35    }
36
37    fn project(&self) -> &'static str {
38        "convgeneric"
39    }
40
41    fn owner(&self) -> &'static str {
42        "EdouardBERGE"
43    }
44
45    fn linux_key(&self) -> Option<&'static str> {
46        Some("Source code (zip)")
47    }
48
49    fn windows_key(&self) -> Option<&'static str> {
50        Some("convgeneric.exe")
51    }
52}
53
54impl ExecutableInformation for ConvGenericVersion {
55    fn target_os_folder(&self) -> &'static str {
56        match self {
57            Self::GroSSeWindowBug => "convgeneric_grosswindowbug"
58        }
59    }
60
61    fn target_os_exec_fname(&self) -> &'static str {
62        #[cfg(target_os = "windows")]
63        return "convgeneric.exe";
64        #[cfg(not(target_os = "windows"))]
65        return "convgeneric";
66    }
67}
68
69impl CompilableInformation for ConvGenericVersion {
70    fn target_os_commands(&self) -> Option<&'static [&'static [&'static str]]> {
71        if cfg!(target_os = "linux") {
72            Some(&[&[
73                "gcc",
74                "convgeneric.c",
75                "-o",
76                "convgeneric",
77                "-lm",
78                "-lpng16"
79            ]])
80        }
81        else {
82            None
83        }
84    }
85}
86
87impl DownloadableInformation for ConvGenericVersion {
88    fn target_os_archive_format(&self) -> ArchiveFormat {
89        #[cfg(target_os = "windows")]
90        return ArchiveFormat::Raw;
91
92        #[cfg(not(target_os = "windows"))]
93        return ArchiveFormat::Zip;
94    }
95}