Skip to content

Commit

Permalink
修正xml清单uses-feature节点的可选字段的序列化问题;
Browse files Browse the repository at this point in the history
修正一些拼写错误;
更新版本至1.0.3。
  • Loading branch information
SmileSky committed Nov 17, 2024
1 parent 7adc572 commit 13fabba
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "1.0.2"
version = "1.0.3"
authors = [
"SmileSky <[email protected]>",
"The Rust Windowing contributors",
Expand All @@ -12,7 +12,7 @@ rust-version = "1.82.0"

[workspace.dependencies]
dunce = "1.0.5"
serde = "1.0.214"
serde = "1.0.215"
thiserror = "2.0.3"

[workspace]
Expand Down
2 changes: 1 addition & 1 deletion cargo-apk2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ toml = "0.8.19"

[dependencies.ndk-build2]
path = "../ndk-build2"
version = "1.0.2"
version = "1.0.3"

[dependencies.clap]
version = "4.5.20"
Expand Down
40 changes: 25 additions & 15 deletions ndk-build2/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub struct IntentFilter {
#[serde(default)]
pub actions: Vec<String>,
/// 序列化为结构向量以实现正确的 xml 格式
#[serde(serialize_with = "serialize_catergories")]
#[serde(serialize_with = "serialize_categories")]
#[serde(rename(serialize = "category"))]
#[serde(default)]
pub categories: Vec<String>,
Expand Down Expand Up @@ -222,7 +222,7 @@ where
seq.end()
}

fn serialize_catergories<S>(categories: &[String], serializer: S) -> Result<S::Ok, S::Error>
fn serialize_categories<S>(categories: &[String], serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
Expand Down Expand Up @@ -271,30 +271,39 @@ pub struct MetaData {
pub value: String,
}

//noinspection SpellCheckingInspection
/// Android [uses-feature 元素](https://developer.android.com/guide/topics/manifest/uses-feature-element).
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct Feature {
#[serde(rename(serialize = "@android:name"))]
#[serde(
rename(serialize = "@android:name"),
skip_serializing_if = "Option::is_none"
)]
pub name: Option<String>,
#[serde(rename(serialize = "@android:required"))]
#[serde(
rename(serialize = "@android:required"),
skip_serializing_if = "Option::is_none"
)]
pub required: Option<bool>,
/// The `version` field is currently used for the following features:
///
/// - `name="android.hardware.vulkan.compute"`: The minimum level of compute features required. See the [Android documentation](https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_VULKAN_HARDWARE_COMPUTE)
/// for available levels and the respective Vulkan features required/provided.
/// `version` 字段当前用于以下功能:
///
/// - `name="android.hardware.vulkan.level"`: The minimum Vulkan requirements. See the [Android documentation](https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_VULKAN_HARDWARE_LEVEL)
/// for available levels and the respective Vulkan features required/provided.
///
/// - `name="android.hardware.vulkan.version"`: Represents the value of Vulkan's `VkPhysicalDeviceProperties::apiVersion`. See the [Android documentation](https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_VULKAN_HARDWARE_VERSION)
/// for available levels and the respective Vulkan features required/provided.
#[serde(rename(serialize = "@android:version"))]
/// - `name="android.hardware.vulkan.compute"`: 所需的最低计算功能级别。请参阅 [Android 文档](https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_VULKAN_HARDWARE_COMPUTE),了解可用级别以及所需/提供的相应 Vulkan 功能。
/// - `name="android.hardware.vulkan.level"`: Vulkan 的最低要求。请参阅 [Android 文档](https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_VULKAN_HARDWARE_LEVEL)了解可用级别以及所需/提供的相应 Vulkan 功能。
/// - `name="android.hardware.vulkan.version"`: 表示 Vulkan 的 `VkPhysicalDeviceProperties::apiVersion` 的值。请参阅 [Android 文档](https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_VULKAN_HARDWARE_VERSION)以了解可用级别以及所需/提供的相应 Vulkan 功能。
#[serde(
rename(serialize = "@android:version"),
skip_serializing_if = "Option::is_none"
)]
pub version: Option<u32>,
#[serde(rename(serialize = "@android:glEsVersion"))]
#[serde(
rename(serialize = "@android:glEsVersion"),
skip_serializing_if = "Option::is_none"
)]
#[serde(serialize_with = "serialize_opengles_version")]
pub opengles_version: Option<(u8, u8)>,
}

//noinspection SpellCheckingInspection
fn serialize_opengles_version<S>(
version: &Option<(u8, u8)>,
serializer: S,
Expand Down Expand Up @@ -382,6 +391,7 @@ impl Default for Sdk {
}
}

//noinspection HttpUrlsUsage
fn default_namespace() -> String {
"http://schemas.android.com/apk/res/android".to_string()
}
Expand Down

0 comments on commit 13fabba

Please sign in to comment.