euv-cli 0.50.0

Cross-platform CLI tool for the euv native UI framework supporting run, build, check, fmt, doctor, new, and Hyperlane SSE dynamic updates across all supported platforms.
Documentation
use super::*;

/// Target metadata helpers for `AppleTargetKind`.
impl AppleTargetKind {
    /// Returns the canonical CLI label for this Apple target.
    ///
    /// # Returns
    ///
    /// - `&'static str` - Target label string.
    #[must_use]
    pub fn as_label(&self) -> &'static str {
        match self {
            Self::IosSim => APPLE_LABEL_IOS_SIM,
            Self::IpadSim => APPLE_LABEL_IPAD_SIM,
            Self::IosDevice => APPLE_LABEL_IOS_DEVICE,
            Self::IpadDevice => APPLE_LABEL_IPAD_DEVICE,
            Self::WatchOsSim => APPLE_LABEL_WATCHOS_SIM,
            Self::WatchOsDevice => APPLE_LABEL_WATCHOS_DEVICE,
        }
    }

    /// Returns the Rust target triple for compiling the static library.
    ///
    /// # Returns
    ///
    /// - `&'static str` - Rust compiler target triple.
    #[must_use]
    pub fn rust_triple(&self) -> &'static str {
        match self {
            Self::IosSim | Self::IpadSim => APPLE_TRIPLE_IOS_SIM,
            Self::IosDevice | Self::IpadDevice => APPLE_TRIPLE_IOS_DEVICE,
            Self::WatchOsSim => APPLE_TRIPLE_WATCHOS_SIM,
            Self::WatchOsDevice => APPLE_TRIPLE_WATCHOS_DEVICE,
        }
    }

    /// Returns the Xcode `--sdk` name required to compile and link this target.
    ///
    /// # Returns
    ///
    /// - `&'static str` - Xcode SDK identifier.
    #[must_use]
    pub fn xcode_sdk(&self) -> &'static str {
        match self {
            Self::IosSim | Self::IpadSim => APPLE_SDK_IPHONE_SIM,
            Self::IosDevice | Self::IpadDevice => APPLE_SDK_IPHONE_OS,
            Self::WatchOsSim => APPLE_SDK_WATCH_SIM,
            Self::WatchOsDevice => APPLE_SDK_WATCH_OS,
        }
    }

    /// Returns whether this target runs inside an Apple Simulator.
    ///
    /// # Returns
    ///
    /// - `bool` - `true` for simulator targets.
    #[must_use]
    pub fn is_simulator(&self) -> bool {
        matches!(self, Self::IosSim | Self::IpadSim | Self::WatchOsSim)
    }

    /// Returns whether this target builds an Apple watchOS SwiftUI bundle.
    ///
    /// # Returns
    ///
    /// - `bool` - `true` for watchOS targets.
    #[must_use]
    pub fn is_watchos(&self) -> bool {
        matches!(self, Self::WatchOsSim | Self::WatchOsDevice)
    }

    /// Returns whether this target prefers an iPad simulator device.
    ///
    /// # Returns
    ///
    /// - `bool` - `true` for iPadOS targets.
    #[must_use]
    pub fn is_ipad(&self) -> bool {
        matches!(self, Self::IpadSim | Self::IpadDevice)
    }

    /// Returns the `.app` bundle directory name.
    ///
    /// # Returns
    ///
    /// - `&'static str` - `EuvShowcase.app` or `EuvWatch.app`.
    #[must_use]
    pub fn default_bundle_name(&self) -> &'static str {
        if self.is_watchos() {
            APPLE_WATCHOS_BUNDLE_NAME
        } else {
            APPLE_IOS_BUNDLE_NAME
        }
    }

    /// Returns the executable binary filename inside the `.app` bundle.
    ///
    /// # Returns
    ///
    /// - `&'static str` - `EuvShowcase` or `EuvWatch`.
    #[must_use]
    pub fn default_executable_name(&self) -> &'static str {
        if self.is_watchos() {
            APPLE_WATCHOS_EXEC_NAME
        } else {
            APPLE_IOS_EXEC_NAME
        }
    }

    /// Returns the default `CFBundleIdentifier`.
    ///
    /// # Returns
    ///
    /// - `&'static str` - Default bundle identifier string.
    #[must_use]
    pub fn default_bundle_id(&self) -> &'static str {
        if self.is_watchos() {
            APPLE_WATCHOS_BUNDLE_ID
        } else {
            APPLE_IOS_BUNDLE_ID
        }
    }

    /// Returns the default relative output directory under `dist/`.
    ///
    /// # Returns
    ///
    /// - `&'static str` - `"ios"` or `"wearable/watchos"`.
    #[must_use]
    pub fn default_out_subdir(&self) -> &'static str {
        if self.is_watchos() {
            APPLE_OUT_SUBDIR_WATCHOS
        } else {
            APPLE_OUT_SUBDIR_IOS
        }
    }

    /// Returns the staging directory name under `target/mobile-hosts/`.
    ///
    /// # Returns
    ///
    /// - `&'static str` - `"ios-host"` or `"watchos-host"`.
    #[must_use]
    pub fn host_dir_name(&self) -> &'static str {
        if self.is_watchos() {
            APPLE_HOST_DIR_WATCHOS
        } else {
            APPLE_HOST_DIR_IOS
        }
    }
}

/// Default configuration builder for `AppleBuildConfig`.
impl Default for AppleBuildConfig {
    /// Creates a release hardware-rendered iOS Simulator build configuration rooted at `.`.
    ///
    /// # Returns
    ///
    /// - `Self` - Default `AppleBuildConfig`.
    fn default() -> Self {
        Self {
            workspace_root: PathBuf::from("."),
            target_kind: AppleTargetKind::IosSim,
            render_mode: RenderArg::Hardware,
            app_version: None,
            build_number: None,
            bundle_id: None,
            out_dir: None,
            build_dir: None,
            archive_path: None,
            codesign_identity: None,
            sim_udid: None,
            release: true,
            no_launch: false,
            shell_only: false,
        }
    }
}