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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
use crate::manifest::{ ActivityMetadata, ApplicationMetadata, Feature, IntentFilter, IntentFilterData, Permission, }; use crate::ndk::Ndk; use serde::Deserialize; use std::path::PathBuf; #[derive(Debug)] pub struct Config { pub ndk: Ndk, pub build_dir: PathBuf, pub package_name: String, pub package_label: String, pub version_name: String, pub version_code: u32, pub split: Option<String>, pub target_name: String, pub debuggable: bool, pub assets: Option<PathBuf>, pub res: Option<String>, } #[derive(Clone, Debug, Default, Deserialize)] pub struct Metadata { pub apk_label: Option<String>, pub target_sdk_version: Option<u32>, pub min_sdk_version: Option<u32>, pub icon: Option<String>, pub fullscreen: Option<bool>, pub orientation: Option<String>, pub launch_mode: Option<String>, pub opengles_version: Option<(u8, u8)>, pub feature: Option<Vec<FeatureConfig>>, pub permission: Option<Vec<PermissionConfig>>, pub intent_filter: Option<Vec<IntentFilterConfig>>, pub application_metadatas: Option<Vec<ApplicationMetadataConfig>>, pub activity_metadatas: Option<Vec<ActivityMetadataConfig>>, } #[derive(Clone, Debug, Deserialize)] pub struct FeatureConfig { name: String, required: Option<bool>, } impl From<FeatureConfig> for Feature { fn from(config: FeatureConfig) -> Self { Self { name: config.name, required: config.required.unwrap_or(true), } } } #[derive(Clone, Debug, Deserialize)] pub struct PermissionConfig { name: String, max_sdk_version: Option<u32>, } impl From<PermissionConfig> for Permission { fn from(config: PermissionConfig) -> Self { Self { name: config.name, max_sdk_version: config.max_sdk_version, } } } #[derive(Clone, Debug, Deserialize)] pub struct IntentFilterConfigData { pub scheme: Option<String>, pub host: Option<String>, pub prefix: Option<String>, } impl From<IntentFilterConfigData> for IntentFilterData { fn from(config: IntentFilterConfigData) -> Self { Self { scheme: config.scheme, host: config.host, prefix: config.prefix, } } } #[derive(Clone, Debug, Deserialize)] pub struct IntentFilterConfig { name: String, data: Vec<IntentFilterConfigData>, categories: Vec<String>, } impl From<IntentFilterConfig> for IntentFilter { fn from(config: IntentFilterConfig) -> Self { Self { name: config.name, data: config .data .into_iter() .map(IntentFilterData::from) .rev() .collect(), categories: config.categories, } } } #[derive(Clone, Debug, Deserialize)] pub struct ApplicationMetadataConfig { name: String, value: String, } impl From<ApplicationMetadataConfig> for ApplicationMetadata { fn from(config: ApplicationMetadataConfig) -> Self { Self { name: config.name, value: config.value, } } } #[derive(Clone, Debug, Deserialize)] pub struct ActivityMetadataConfig { name: String, value: String, } impl From<ActivityMetadataConfig> for ActivityMetadata { fn from(config: ActivityMetadataConfig) -> Self { Self { name: config.name, value: config.value, } } }