Skip to content

Commit 4f938f2

Browse files
committed
some small cleanups
1 parent fd1fdd6 commit 4f938f2

File tree

11 files changed

+42
-53
lines changed

11 files changed

+42
-53
lines changed

packages/cli-opt/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ keywords = ["dom", "ui", "gui", "react"]
1313
anyhow = { workspace = true }
1414
manganis = { workspace = true }
1515
manganis-core = { workspace = true }
16-
permissions-core = { path = "../permissions/permissions-core" }
16+
permissions = { path = "../permissions/permissions" }
1717
object = { workspace = true, features = ["wasm"] }
1818
serde = { workspace = true, features = ["derive"] }
1919
serde_json = { workspace = true }

packages/cli-opt/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ mod json;
1919
pub use file::process_file_to;
2020
pub use hash::add_hash_to_asset;
2121

22-
// Re-export SymbolData from permissions-core for convenience
23-
pub use permissions_core::SymbolData;
22+
// Re-export SymbolData from the public permissions crate for convenience
23+
pub use permissions::SymbolData;
2424

2525
/// A manifest of all assets collected from dependencies
2626
///

packages/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ depinfo = { workspace = true }
2828
subsecond-types = { workspace = true }
2929
dioxus-cli-telemetry = { workspace = true }
3030
dioxus-component-manifest = { workspace = true }
31-
permissions-core = { workspace = true }
31+
permissions = { workspace = true }
3232

3333
clap = { workspace = true, features = ["derive", "cargo"] }
3434
convert_case = { workspace = true }

packages/cli/src/build/assets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use dioxus_cli_opt::AssetManifest;
4040
use manganis::{AssetOptions, AssetVariant, BundledAsset, ImageFormat, ImageSize};
4141
use object::{File, Object, ObjectSection, ObjectSymbol, ReadCache, ReadRef, Section, Symbol};
4242
use pdb::FallibleIterator;
43-
use permissions_core::{Permission, SymbolData};
43+
use permissions::{Permission, SymbolData};
4444
use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator};
4545

4646
/// Extract all manganis symbols and their sections from the given object file.

packages/cli/src/build/permissions.rs

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
use std::path::Path;
1414

1515
use crate::Result;
16-
use permissions_core::{Permission, Platform};
16+
use permissions::Platform;
1717
use serde::Serialize;
1818

19+
/// Alias the shared manifest type from the permissions crate for CLI-specific helpers
20+
pub type PermissionManifest = permissions::PermissionManifest;
21+
1922
/// Android permission for Handlebars template
2023
#[derive(Debug, Clone, Serialize)]
2124
pub struct AndroidPermission {
@@ -55,36 +58,7 @@ pub(crate) async fn extract_permissions_from_file(
5558
// Use the unified symbol extraction which handles both assets and permissions
5659
let result = extract_symbols_from_file(path).await?;
5760

58-
Ok(PermissionManifest::new(result.permissions))
59-
}
60-
61-
/// A manifest of all permissions found in a binary
62-
#[derive(Debug, Clone, Default)]
63-
pub struct PermissionManifest {
64-
permissions: Vec<Permission>,
65-
}
66-
67-
impl PermissionManifest {
68-
pub fn new(permissions: Vec<Permission>) -> Self {
69-
Self { permissions }
70-
}
71-
72-
#[allow(dead_code)]
73-
pub fn permissions(&self) -> &[Permission] {
74-
&self.permissions
75-
}
76-
77-
#[allow(dead_code)]
78-
pub fn is_empty(&self) -> bool {
79-
self.permissions.is_empty()
80-
}
81-
82-
pub fn permissions_for_platform(&self, platform: Platform) -> Vec<&Permission> {
83-
self.permissions
84-
.iter()
85-
.filter(|p| p.supports_platform(platform))
86-
.collect()
87-
}
61+
Ok(PermissionManifest::from_permissions(result.permissions))
8862
}
8963

9064
/// Get Android permissions for Handlebars template

packages/cli/src/build/request.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,13 +1441,13 @@ impl BuildRequest {
14411441
let permission_manifest = if skip_permissions {
14421442
super::permissions::PermissionManifest::default()
14431443
} else {
1444-
let manifest = super::permissions::PermissionManifest::new(result.permissions);
1444+
let manifest = super::permissions::PermissionManifest::from_permissions(result.permissions);
14451445

14461446
// Log permissions found for platforms that need them
14471447
let platform = match self.bundle {
1448-
BundleFormat::Android => Some(permissions_core::Platform::Android),
1449-
BundleFormat::Ios => Some(permissions_core::Platform::Ios),
1450-
BundleFormat::MacOS => Some(permissions_core::Platform::Macos),
1448+
BundleFormat::Android => Some(permissions::Platform::Android),
1449+
BundleFormat::Ios => Some(permissions::Platform::Ios),
1450+
BundleFormat::MacOS => Some(permissions::Platform::Macos),
14511451
_ => None,
14521452
};
14531453

packages/permissions/permissions-core/src/permission.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ impl PermissionManifest {
113113
}
114114
}
115115

116+
/// Create a manifest from an existing list of permissions
117+
pub fn from_permissions(permissions: Vec<Permission>) -> Self {
118+
Self { permissions }
119+
}
120+
116121
/// Add a permission to the manifest
117122
pub fn add_permission(&mut self, permission: Permission) {
118123
self.permissions.push(permission);

packages/permissions/permissions/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
3232
pub use permissions_core::{
3333
CustomPermissionBuilder, LocationPrecision, Permission, PermissionBuilder, PermissionKind,
34-
PermissionManifest, Platform, PlatformFlags, PlatformIdentifiers,
34+
PermissionManifest, Platform, PlatformFlags, PlatformIdentifiers, SymbolData,
3535
};
3636
pub use permissions_macro::{permission, static_permission};
3737

packages/platform-bridge-macro/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,3 @@ proc-macro = true
1818
syn = { version = "2.0", features = ["full"] }
1919
quote = "1.0"
2020
proc-macro2 = "1.0"
21-
const-serialize = { path = "../const-serialize" }
22-
const-serialize-macro = { path = "../const-serialize-macro" }
23-
24-
[dev-dependencies]
25-

packages/platform-bridge-macro/src/android_plugin.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,18 @@ impl ToTokens for AndroidPluginParser {
152152
__FILE_PATHS,
153153
);
154154

155-
// Serialize the metadata
156-
const __BUFFER: const_serialize::ConstVec<u8, 4096> = {
157-
const EMPTY: const_serialize::ConstVec<u8, 4096> = const_serialize::ConstVec::new_with_max_size();
158-
const_serialize::serialize_const(&__JAVA_META, EMPTY)
159-
};
155+
// Serialize the metadata using the shared helper
156+
const __BUFFER: dioxus_platform_bridge::android::metadata::JavaMetadataBuffer =
157+
dioxus_platform_bridge::android::metadata::serialize_java_metadata(&__JAVA_META);
160158
const __BYTES: &[u8] = __BUFFER.as_ref();
161159
const __LEN: usize = __BYTES.len();
162160

163161
// Embed in linker section
164162
#[link_section = "__DATA,__java_source"]
165163
#[used]
166164
#[unsafe(export_name = #export_name_lit)]
167-
static __LINK_SECTION: [u8; __LEN] = dioxus_platform_bridge::android::macro_helpers::copy_bytes(__BYTES);
165+
static __LINK_SECTION: [u8; __LEN] =
166+
dioxus_platform_bridge::android::macro_helpers::copy_bytes(__BYTES);
168167
};
169168

170169
tokens.extend(link_section);

0 commit comments

Comments
 (0)