Skip to content

Commit

Permalink
Auto-generate AndroidManifest.xml
Browse files Browse the repository at this point in the history
Relates to: jhugman#109
  • Loading branch information
Johennes committed Oct 4, 2024
1 parent 0ded7d3 commit d2c3bd6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
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>

0 comments on commit d2c3bd6

Please sign in to comment.