diff --git a/core/tauri-build/src/lib.rs b/core/tauri-build/src/lib.rs index f06bc85d7ef6..8bfef91d9568 100644 --- a/core/tauri-build/src/lib.rs +++ b/core/tauri-build/src/lib.rs @@ -476,7 +476,10 @@ pub fn try_build(attributes: Attributes) -> Result<()> { let mut android_package_prefix = String::new(); for (i, w) in s.enumerate() { if i == last { - println!("cargo:rustc-env=TAURI_ANDROID_PACKAGE_NAME_APP_NAME={w}"); + println!( + "cargo:rustc-env=TAURI_ANDROID_PACKAGE_NAME_APP_NAME={}", + w.replace('-', "_") + ); } else { android_package_prefix.push_str(&w.replace(['_', '-'], "_1")); android_package_prefix.push('_'); diff --git a/core/tauri-macros/src/mobile.rs b/core/tauri-macros/src/mobile.rs index 09e9af1f025a..9ec2b6d94776 100644 --- a/core/tauri-macros/src/mobile.rs +++ b/core/tauri-macros/src/mobile.rs @@ -8,15 +8,10 @@ use quote::{format_ident, quote}; use std::env::var; use syn::{parse_macro_input, spanned::Spanned, ItemFn}; -fn get_env_var String>( - name: &str, - replacer: R, - error: &mut Option, - function: &ItemFn, -) -> TokenStream2 { +fn get_env_var(name: &str, error: &mut Option, function: &ItemFn) -> TokenStream2 { match var(name) { Ok(value) => { - let ident = format_ident!("{}", replacer(value)); + let ident = format_ident!("{value}"); quote!(#ident) } Err(_) => { @@ -37,18 +32,8 @@ pub fn entry_point(_attributes: TokenStream, item: TokenStream) -> TokenStream { let function_name = &function.sig.ident; let mut error = None; - let domain = get_env_var( - "TAURI_ANDROID_PACKAGE_NAME_PREFIX", - |r| r, - &mut error, - &function, - ); - let app_name = get_env_var( - "TAURI_ANDROID_PACKAGE_NAME_APP_NAME", - |r| r.replace('-', "_"), - &mut error, - &function, - ); + let domain = get_env_var("TAURI_ANDROID_PACKAGE_NAME_PREFIX", &mut error, &function); + let app_name = get_env_var("TAURI_ANDROID_PACKAGE_NAME_APP_NAME", &mut error, &function); if let Some(e) = error { quote!(#e).into()