1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#[cfg(feature = "android")]
pub mod android;
#[cfg(feature = "apple")]
pub mod apple;
mod build_context;
pub use build_context::*;
#[cfg(feature = "android")]
use android::AndroidBuildCommand;
#[cfg(feature = "apple")]
use apple::IosBuildCommand;
use crate::error::Result;
use clap::Parser;
use crossbundle_tools::types::{Config, Profile};
use std::path::PathBuf;
#[derive(Parser, Clone, Debug)]
pub enum BuildCommand {
#[cfg(feature = "android")]
Android(AndroidBuildCommand),
#[cfg(feature = "apple")]
Ios(IosBuildCommand),
}
impl BuildCommand {
pub fn handle_command(&self, config: &Config) -> Result<()> {
#[cfg(any(feature = "android", feature = "apple"))]
match &self {
#[cfg(feature = "android")]
Self::Android(cmd) => cmd.run(config)?,
#[cfg(feature = "apple")]
Self::Ios(cmd) => cmd.run(config)?,
}
Ok(())
}
}
#[derive(Parser, Clone, Debug, Default)]
pub struct SharedBuildCommand {
#[clap(long)]
pub example: Option<String>,
#[clap(long)]
pub features: Vec<String>,
#[clap(long)]
pub all_features: bool,
#[clap(long)]
pub no_default_features: bool,
#[clap(long)]
pub release: bool,
#[clap(long)]
pub target_dir: Option<PathBuf>,
}
impl SharedBuildCommand {
pub fn profile(&self) -> Profile {
match self.release {
true => Profile::Release,
false => Profile::Debug,
}
}
}