1use clap::Parser;
2use platforms::Platform;
3use std::collections::HashMap;
4use std::path::PathBuf;
5
6impl Args {
7    pub(crate) fn get() -> Self {
8        let mut args = Args::parse();
9        if !(args.build_c || args.build_dotnet || args.build_java) {
10            args.build_c = true;
11            args.build_dotnet = true;
12            args.build_java = true;
13        }
14        args
15    }
16}
17
18use crate::backend::dotnet::TargetFramework;
19use serde::Deserialize;
20
21#[derive(Deserialize)]
22pub(crate) struct EnabledLanguages {
23    pub(crate) cpp: bool,
24    pub(crate) dotnet: bool,
25    pub(crate) java: bool,
26}
27
28#[derive(Deserialize)]
29pub(crate) struct PackageOptions {
30    targets: HashMap<String, EnabledLanguages>,
32}
33
34impl PackageOptions {
35    pub(crate) fn package_dotnet(&self, platform: &Platform) -> bool {
36        self.targets
37            .get(platform.target_triple)
38            .map(|x| x.dotnet)
39            .unwrap_or(false)
40    }
41
42    pub(crate) fn package_cpp(&self, platform: &Platform) -> bool {
43        self.targets
44            .get(platform.target_triple)
45            .map(|x| x.cpp)
46            .unwrap_or(false)
47    }
48
49    pub(crate) fn package_java(&self, platform: &Platform) -> bool {
50        self.targets
51            .get(platform.target_triple)
52            .map(|x| x.java)
53            .unwrap_or(false)
54    }
55}
56
57#[derive(Parser)]
58#[command(author, version, about, long_about = None)]
59pub(crate) struct Args {
60    #[arg(long = "c", default_value_t = false)]
62    pub(crate) build_c: bool,
63    #[arg(long = "dotnet", default_value_t = false)]
65    pub(crate) build_dotnet: bool,
66    #[arg(long = "java", default_value_t = false)]
68    pub(crate) build_java: bool,
69    #[arg(long = "artifact-dir", short = 'a')]
72    pub(crate) artifact_dir: Option<PathBuf>,
73    #[arg(long = "target", short = 'r')]
75    pub(crate) target_triple: Option<String>,
76    #[arg(value_enum, short = 't', long = "target-dotnet-framework", default_value_t = TargetFramework::NetStandard2_0)]
78    pub(crate) target_framework: TargetFramework,
79    #[arg(long = "doxygen", default_value_t = false)]
81    pub(crate) generate_doxygen: bool,
82    #[arg(long = "no-tests", default_value_t = false)]
84    pub(crate) no_tests: bool,
85    #[arg(long = "package", short = 'k')]
87    pub(crate) package_dir: Option<PathBuf>,
88    #[arg(long = "options", short = 'o')]
90    pub(crate) package_options: Option<PathBuf>,
91    #[arg(short = 'f', long = "extra-files")]
93    pub(crate) extra_files: Vec<PathBuf>,
94}