From d2c3bd6211f743ee8997aa46438b95489631ac12 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Fri, 4 Oct 2024 09:02:24 +0200 Subject: [PATCH] Auto-generate AndroidManifest.xml Relates to: #109 --- crates/ubrn_cli/src/android.rs | 8 ++++++++ crates/ubrn_cli/src/codegen/mod.rs | 13 +++++++++++++ .../src/codegen/templates/AndroidManifest.xml | 5 +++++ 3 files changed, 26 insertions(+) create mode 100644 crates/ubrn_cli/src/codegen/templates/AndroidManifest.xml diff --git a/crates/ubrn_cli/src/android.rs b/crates/ubrn_cli/src/android.rs index 4ec838bc..2d809975 100644 --- a/crates/ubrn_cli/src/android.rs +++ b/crates/ubrn_cli/src/android.rs @@ -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() } @@ -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()) } diff --git a/crates/ubrn_cli/src/codegen/mod.rs b/crates/ubrn_cli/src/codegen/mod.rs index beee0dd4..f6116c01 100644 --- a/crates/ubrn_cli/src/codegen/mod.rs +++ b/crates/ubrn_cli/src/codegen/mod.rs @@ -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()), @@ -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)] diff --git a/crates/ubrn_cli/src/codegen/templates/AndroidManifest.xml b/crates/ubrn_cli/src/codegen/templates/AndroidManifest.xml new file mode 100644 index 00000000..9b8064bc --- /dev/null +++ b/crates/ubrn_cli/src/codegen/templates/AndroidManifest.xml @@ -0,0 +1,5 @@ +{%- let android = self.config.project.android.clone() %} + + +