@@ -24,7 +24,9 @@ pub fn generate_android(crate_name: String, description: String) -> Result<()> {
2424 println ! ( ) ;
2525 write_file (
2626 BuildGradle {
27- crate_name : crate_name. clone ( ) ,
27+ // configureUniFFIBindgen replaces underscores rather than hyphens
28+ crate_name : crate_name. replace ( "-" , "_" ) ,
29+ kotlin_module_name : crate_name. replace ( "-" , "" ) ,
2830 }
2931 . render ( ) ?,
3032 & android_root. join ( "build.gradle" ) ,
@@ -42,7 +44,7 @@ pub fn generate_android(crate_name: String, description: String) -> Result<()> {
4244 "kotlin" ,
4345 [ (
4446 "package_name" ,
45- format ! ( "mozilla.appservices.{crate_name}" ) . into ( ) ,
47+ format ! ( "mozilla.appservices.{}" , crate_name . replace ( "-" , "_" ) ) . into ( ) ,
4648 ) ] ,
4749 ) ?;
4850 add_cargo_toml_dependency (
@@ -115,12 +117,13 @@ fn write_file(contents: impl AsRef<str>, path: &Utf8Path) -> Result<()> {
115117
116118fn update_megazord_lib_rs ( lib_path : & Utf8Path , crate_name : & str ) -> Result < ( ) > {
117119 let content = read_to_string ( lib_path) ?;
120+ let crate_name_rust = crate_name. replace ( "-" , "_" ) ;
118121 let mut lines: Vec < String > = content. split ( "\n " ) . map ( str:: to_string) . collect ( ) ;
119122 let first_use_line = lines
120123 . iter ( )
121124 . position ( |line| line. starts_with ( "pub use" ) )
122125 . ok_or_else ( || anyhow ! ( "Couldn't find a `pub use` line in {lib_path}" ) ) ?;
123- lines. insert ( first_use_line, format ! ( "pub use {crate_name };" ) ) ;
126+ lines. insert ( first_use_line, format ! ( "pub use {crate_name_rust };" ) ) ;
124127 write_file ( lines. join ( "\n " ) , lib_path) ?;
125128 Command :: new ( "cargo" )
126129 . args ( [ "fmt" , "-pmegazord" ] )
@@ -179,6 +182,7 @@ fn buildconfig_needs_update(path: &Utf8Path, crate_name: &str) -> Result<bool> {
179182#[ template( path = "build.gradle" , escape = "none" ) ]
180183struct BuildGradle {
181184 crate_name : String ,
185+ kotlin_module_name : String ,
182186}
183187
184188const ANDROID_MANIFEST : & str =
0 commit comments