cli/commands/build/
mod.rs

1pub mod android;
2pub mod apple;
3mod build_context;
4
5pub use build_context::*;
6
7use android::AndroidBuildCommand;
8use apple::AppleBuildCommand;
9
10use crate::error::Result;
11use clap::Clap;
12use creator_tools::{types::Profile, utils::Config};
13use std::path::PathBuf;
14
15#[derive(Clap, Clone, Debug)]
16pub enum BuildCommand {
17    /// Starts the process of building/packaging/signing of the rust crate for Android
18    Android(AndroidBuildCommand),
19    /// Starts the process of building/packaging/signing of the rust crate for iOS
20    Apple(AppleBuildCommand),
21}
22
23impl BuildCommand {
24    pub fn handle_command(&self, config: &Config) -> Result<()> {
25        match &self {
26            Self::Android(cmd) => cmd.run(config),
27            Self::Apple(cmd) => cmd.run(config),
28        }
29    }
30}
31
32#[derive(Clap, Clone, Debug)]
33pub struct SharedBuildCommand {
34    /// Build the specified example
35    #[clap(long)]
36    pub example: Option<String>,
37    /// Space or comma separated list of features to activate. These features only apply to the current
38    /// directory's package. Features of direct dependencies may be enabled with `<dep-name>/<feature-name>` syntax.
39    /// This flag may be specified multiple times, which enables all specified features
40    #[clap(long)]
41    pub features: Vec<String>,
42    /// Activate all available features of selected package
43    #[clap(long)]
44    pub all_features: bool,
45    /// Do not activate the `default` feature of the current directory's package
46    #[clap(long)]
47    pub no_default_features: bool,
48    /// Build optimized artifact with the `release` profile
49    #[clap(long)]
50    pub release: bool,
51    /// Directory for generated artifact and intermediate files
52    #[clap(long)]
53    pub target_dir: Option<PathBuf>,
54}
55
56impl SharedBuildCommand {
57    pub fn profile(&self) -> Profile {
58        match self.release {
59            true => Profile::Release,
60            false => Profile::Debug,
61        }
62    }
63}