polyhorn_cli/android/
spec.rs

1use serde::{Deserialize, Serialize};
2
3/// This spec contains Android-specific settings.
4#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
5pub struct Spec {
6    /// This is the package identifier for Android that uniquely identifies your
7    /// app on a user's device and within the Google Play Store. The package
8    /// identifier usually looks like a reverse DNS name. The package identifier
9    /// must contain of at least two segments, each segment must start with a
10    /// letter and can only contain alphanumeric characters.
11    pub package: String,
12
13    /// This is the version code for Android. The version code is used to
14    /// determine the order of multiple releases of the same app. Each
15    /// subsequent release must have a version code that is strictly greater
16    /// than the previous release's version code (but it is allowed to skip
17    /// version codes in between). Additionally, this is also used by the OS to
18    /// deny downgrades to earlier versions of your app (e.g. to protect against
19    /// cases where you introduce backwards incompatible changes to a persistent
20    /// storage format).
21    #[serde(rename = "version-code")]
22    pub version_code: usize,
23
24    /// This is the minimum API version that your app supports. If you're not
25    /// bringing in your own native Java code, this should generally not be
26    /// changed. In any case, don't change this to an API version lower than the
27    /// Polyhorn default (16), because our own Java code might not be compatible
28    /// with earlier API versions.
29    #[serde(rename = "min-sdk-version", default = "Spec::default_min_sdk_version")]
30    pub min_sdk_version: usize,
31
32    /// This is the target API version that your app uses to build. We're
33    /// currently compiling native Java code against the most recent Android API
34    /// level. If you don't bring in your own Java code, you shouldn't need to
35    /// change this. Even if you do bring in your own Java code, it's unlikely
36    /// that you need to change this.
37    #[serde(
38        rename = "target-sdk-version",
39        default = "Spec::default_target_sdk_version"
40    )]
41    pub target_sdk_version: usize,
42
43    /// This is the name of the shared library that will contain your Rust code.
44    /// End users will not be aware of this. It simply refers to the name of the
45    /// shared library that will reside in `jniLibs/*`. Usually, this will be
46    /// the lowercased last segment of the package identifier.
47    pub library: String,
48}
49
50impl Spec {
51    fn default_min_sdk_version() -> usize {
52        16
53    }
54
55    fn default_target_sdk_version() -> usize {
56        30
57    }
58}