mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-01 11:13:40 +03:00
fix(tauri-macros): escape _
in mobile entry point's app name (#5029)
This commit is contained in:
parent
641d56dcb3
commit
ff4cb56b2e
@ -4,10 +4,15 @@ use quote::{format_ident, quote};
|
||||
use std::env::var;
|
||||
use syn::{parse_macro_input, spanned::Spanned, ItemFn};
|
||||
|
||||
fn get_env_var(name: &str, error: &mut Option<TokenStream2>, function: &ItemFn) -> TokenStream2 {
|
||||
fn get_env_var<R: FnOnce(String) -> String>(
|
||||
name: &str,
|
||||
replacer: R,
|
||||
error: &mut Option<TokenStream2>,
|
||||
function: &ItemFn,
|
||||
) -> TokenStream2 {
|
||||
match var(name) {
|
||||
Ok(value) => {
|
||||
let ident = format_ident!("{}", value);
|
||||
let ident = format_ident!("{}", replacer(value));
|
||||
quote!(#ident)
|
||||
}
|
||||
Err(_) => {
|
||||
@ -31,8 +36,13 @@ pub fn entry_point(_attributes: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let function_name = function.sig.ident.clone();
|
||||
|
||||
let mut error = None;
|
||||
let domain = get_env_var("TAURI_ANDROID_DOMAIN", &mut error, &function);
|
||||
let app_name = get_env_var("CARGO_PKG_NAME", &mut error, &function);
|
||||
let domain = get_env_var("TAURI_ANDROID_DOMAIN", |r| r, &mut error, &function);
|
||||
let app_name = get_env_var(
|
||||
"CARGO_PKG_NAME",
|
||||
|r| r.replace('_', "_1"),
|
||||
&mut error,
|
||||
&function,
|
||||
);
|
||||
|
||||
if let Some(e) = error {
|
||||
quote!(#e).into()
|
||||
|
3
examples/api/src-tauri/Cargo.lock
generated
3
examples/api/src-tauri/Cargo.lock
generated
@ -3107,8 +3107,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "tao"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2093fa6bba3cc0c185b21c900de1b757e66637e78848cbcdda967b836d8c0ec"
|
||||
source = "git+https://github.com/tauri-apps/tao?branch=dev#816ca49dc648a5286eab943c6fc936629fd3a596"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cairo-rs",
|
||||
|
@ -8,6 +8,7 @@ license = "Apache-2.0 OR MIT"
|
||||
|
||||
[patch.crates-io]
|
||||
wry = { git = "https://github.com/tauri-apps/wry", branch = "dev" }
|
||||
tao = { git = "https://github.com/tauri-apps/tao", branch = "dev" }
|
||||
|
||||
[lib]
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
Loading…
Reference in New Issue
Block a user