Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-generate AndroidManifest.xml #112

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/ubrn_cli/src/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ impl AndroidConfig {
self.directory(project_root).join(&self.jni_libs)
}

fn main_src(&self) -> String {
"src/main".to_string()
}

fn java_src(&self) -> String {
"src/main/java".to_string()
}
Expand All @@ -96,6 +100,10 @@ impl AndroidConfig {
self.package_name.clone()
}

pub(crate) fn src_main_dir(&self, project_root: &Utf8Path) -> Utf8PathBuf {
self.directory(project_root).join(self.main_src())
}

pub(crate) fn src_main_java_dir(&self, project_root: &Utf8Path) -> Utf8PathBuf {
self.directory(project_root).join(self.java_src())
}
Expand Down
13 changes: 13 additions & 0 deletions crates/ubrn_cli/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ mod files {
BuildGradle::rc_new(config.clone()),
CMakeLists::rc_new(config.clone()),
CppAdapter::rc_new(config.clone()),
AndroidManifest::rc_new(config.clone()),
// iOS
ModuleTemplateH::rc_new(config.clone()),
ModuleTemplateMm::rc_new(config.clone()),
Expand Down Expand Up @@ -295,6 +296,18 @@ mod files {
project_root.join(filename)
}
}

templated_file!(AndroidManifest, "AndroidManifest.xml");
impl RenderedFile for AndroidManifest {
fn path(&self, project_root: &Utf8Path) -> Utf8PathBuf {
let filename = "AndroidManifest.xml";
self.config
.project
.android
.src_main_dir(project_root)
.join(filename)
}
}
}

#[cfg(test)]
Expand Down
5 changes: 5 additions & 0 deletions crates/ubrn_cli/src/codegen/templates/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{%- let android = self.config.project.android.clone() %}
<!-- Generated by uniffi-bindgen-react-native -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="{{ android.package_name() }}">
</manifest>