mirror of https://github.com/tauri-apps/tauri
* fix(core): allow hyphens and underscores on identifiers, closes #9707 * fix build * fix build * lint * move replace * update tao * update tao-macros
This commit is contained in:
parent
da8c9a7d30
commit
793ee05317
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
"tauri-cli": patch:bug
|
||||
"tauri-build": patch:bug
|
||||
"@tauri-apps/cli": patch:bug
|
||||
"tauri-runtime-wry": patch:bug
|
||||
---
|
||||
|
||||
Allow hyphens and underscores on app identifiers.
|
|
@ -3735,9 +3735,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tao"
|
||||
version = "0.29.0"
|
||||
version = "0.29.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6775bcf3c1da33f848ede9cff5883ed1e45a29f66533ce42ad06c93ae514ed59"
|
||||
checksum = "d3a97abbc7d6cfd0720da3e06fcb1cf2ac87cbfdb5bbbce103a1279a211c4d81"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"cocoa 0.26.0",
|
||||
|
@ -3774,13 +3774,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tao-macros"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec114582505d158b669b136e6851f85840c109819d77c42bb7c0709f727d18c2"
|
||||
checksum = "f4e16beb8b2ac17db28eab8bca40e62dbfbb34c0fcdc6d9826b11b7b5d047dfd"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"syn 2.0.74",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -476,9 +476,12 @@ 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);
|
||||
android_package_prefix.push_str(&w.replace(['_', '-'], "_1"));
|
||||
android_package_prefix.push('_');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<R: FnOnce(String) -> String>(
|
||||
name: &str,
|
||||
replacer: R,
|
||||
error: &mut Option<TokenStream2>,
|
||||
function: &ItemFn,
|
||||
) -> TokenStream2 {
|
||||
fn get_env_var(name: &str, error: &mut Option<TokenStream2>, 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()
|
||||
|
|
|
@ -18,7 +18,7 @@ rustdoc-args = [ "--cfg", "docsrs" ]
|
|||
|
||||
[dependencies]
|
||||
wry = { version = "0.42", default-features = false, features = [ "drag-drop", "protocol", "os-webview" ] }
|
||||
tao = { version = "0.29", default-features = false, features = [ "rwh_06" ] }
|
||||
tao = { version = "0.29.1", default-features = false, features = [ "rwh_06" ] }
|
||||
tauri-runtime = { version = "2.0.0-rc.5", path = "../tauri-runtime" }
|
||||
tauri-utils = { version = "2.0.0-rc.5", path = "../tauri-utils" }
|
||||
raw-window-handle = "0.6"
|
||||
|
|
|
@ -3165,9 +3165,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tao"
|
||||
version = "0.29.0"
|
||||
version = "0.29.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6775bcf3c1da33f848ede9cff5883ed1e45a29f66533ce42ad06c93ae514ed59"
|
||||
checksum = "d3a97abbc7d6cfd0720da3e06fcb1cf2ac87cbfdb5bbbce103a1279a211c4d81"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"cocoa 0.26.0",
|
||||
|
@ -3204,13 +3204,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tao-macros"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec114582505d158b669b136e6851f85840c109819d77c42bb7c0709f727d18c2"
|
||||
checksum = "f4e16beb8b2ac17db28eab8bca40e62dbfbb34c0fcdc6d9826b11b7b5d047dfd"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"syn 2.0.63",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3221,7 +3221,7 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f"
|
|||
|
||||
[[package]]
|
||||
name = "tauri"
|
||||
version = "2.0.0-rc.4"
|
||||
version = "2.0.0-rc.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
|
@ -3271,7 +3271,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tauri-build"
|
||||
version = "2.0.0-rc.4"
|
||||
version = "2.0.0-rc.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo_toml",
|
||||
|
@ -3293,7 +3293,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tauri-codegen"
|
||||
version = "2.0.0-rc.4"
|
||||
version = "2.0.0-rc.5"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"brotli",
|
||||
|
@ -3318,7 +3318,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tauri-macros"
|
||||
version = "2.0.0-rc.4"
|
||||
version = "2.0.0-rc.5"
|
||||
dependencies = [
|
||||
"heck 0.5.0",
|
||||
"proc-macro2",
|
||||
|
@ -3330,7 +3330,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tauri-plugin"
|
||||
version = "2.0.0-rc.4"
|
||||
version = "2.0.0-rc.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"glob",
|
||||
|
@ -3356,7 +3356,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tauri-runtime"
|
||||
version = "2.0.0-rc.4"
|
||||
version = "2.0.0-rc.5"
|
||||
dependencies = [
|
||||
"dpi",
|
||||
"gtk",
|
||||
|
@ -3373,7 +3373,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tauri-runtime-wry"
|
||||
version = "2.0.0-rc.4"
|
||||
version = "2.0.0-rc.5"
|
||||
dependencies = [
|
||||
"cocoa 0.26.0",
|
||||
"gtk",
|
||||
|
@ -3395,7 +3395,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tauri-utils"
|
||||
version = "2.0.0-rc.4"
|
||||
version = "2.0.0-rc.5"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"brotli",
|
||||
|
|
|
@ -557,9 +557,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cargo-mobile2"
|
||||
version = "0.13.4"
|
||||
version = "0.13.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8dd9a8451eeeb998885ec3acb08b9bd32353ccd119b18db5ae6ddc41814fc03"
|
||||
checksum = "76bd9e694230d442d680f8e578b4f252c67adbfd74cc1dd1caa9e1f1767114dc"
|
||||
dependencies = [
|
||||
"colored",
|
||||
"core-foundation 0.10.0",
|
||||
|
|
|
@ -39,7 +39,7 @@ name = "cargo-tauri"
|
|||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
cargo-mobile2 = { version = "0.13.4", default-features = false }
|
||||
cargo-mobile2 = { version = "0.13.5", default-features = false }
|
||||
jsonrpsee = { version = "0.24", features = [ "server" ] }
|
||||
jsonrpsee-core = "0.24"
|
||||
jsonrpsee-client-transport = { version = "0.24", features = [ "ws" ] }
|
||||
|
|
|
@ -52,7 +52,11 @@ pub fn command(options: Options) -> Result<()> {
|
|||
let tauri_config_ = tauri_config_guard.as_ref().unwrap();
|
||||
let cli_options = read_options(&tauri_config_.identifier);
|
||||
let (config, metadata) = get_config(
|
||||
&get_app(tauri_config_, &AppInterface::new(tauri_config_, None)?),
|
||||
&get_app(
|
||||
MobileTarget::Android,
|
||||
tauri_config_,
|
||||
&AppInterface::new(tauri_config_, None)?,
|
||||
),
|
||||
tauri_config_,
|
||||
None,
|
||||
&cli_options,
|
||||
|
|
|
@ -114,7 +114,7 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
|
|||
let interface = AppInterface::new(tauri_config_, build_options.target.clone())?;
|
||||
interface.build_options(&mut Vec::new(), &mut build_options.features, true);
|
||||
|
||||
let app = get_app(tauri_config_, &interface);
|
||||
let app = get_app(MobileTarget::Android, tauri_config_, &interface);
|
||||
let (config, metadata) = get_config(
|
||||
&app,
|
||||
tauri_config_,
|
||||
|
|
|
@ -134,7 +134,7 @@ fn run_command(options: Options, noise_level: NoiseLevel) -> Result<()> {
|
|||
|
||||
let interface = AppInterface::new(tauri_config_, dev_options.target.clone())?;
|
||||
|
||||
let app = get_app(tauri_config_, &interface);
|
||||
let app = get_app(MobileTarget::Android, tauri_config_, &interface);
|
||||
let (config, metadata) = get_config(
|
||||
&app,
|
||||
tauri_config_,
|
||||
|
|
|
@ -89,7 +89,11 @@ pub fn exec(
|
|||
let tauri_config_guard = tauri_config.lock().unwrap();
|
||||
let tauri_config_ = tauri_config_guard.as_ref().unwrap();
|
||||
|
||||
let app = get_app(tauri_config_, &AppInterface::new(tauri_config_, None)?);
|
||||
let app = get_app(
|
||||
target,
|
||||
tauri_config_,
|
||||
&AppInterface::new(tauri_config_, None)?,
|
||||
);
|
||||
|
||||
let (handlebars, mut map) = handlebars(&app);
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
|
|||
let interface = AppInterface::new(tauri_config_, build_options.target.clone())?;
|
||||
interface.build_options(&mut Vec::new(), &mut build_options.features, true);
|
||||
|
||||
let app = get_app(tauri_config_, &interface);
|
||||
let app = get_app(MobileTarget::Ios, tauri_config_, &interface);
|
||||
let (config, _metadata) = get_config(
|
||||
&app,
|
||||
tauri_config_,
|
||||
|
|
|
@ -159,7 +159,7 @@ fn run_command(options: Options, noise_level: NoiseLevel) -> Result<()> {
|
|||
|
||||
let interface = AppInterface::new(tauri_config_, Some(target_triple))?;
|
||||
|
||||
let app = get_app(tauri_config_, &interface);
|
||||
let app = get_app(MobileTarget::Ios, tauri_config_, &interface);
|
||||
let (config, _metadata) = get_config(
|
||||
&app,
|
||||
tauri_config_,
|
||||
|
|
|
@ -81,7 +81,11 @@ pub fn command(options: Options) -> Result<()> {
|
|||
let tauri_config_ = tauri_config_guard.as_ref().unwrap();
|
||||
let cli_options = read_options(&tauri_config_.identifier);
|
||||
let (config, metadata) = get_config(
|
||||
&get_app(tauri_config_, &AppInterface::new(tauri_config_, None)?),
|
||||
&get_app(
|
||||
MobileTarget::Ios,
|
||||
tauri_config_,
|
||||
&AppInterface::new(tauri_config_, None)?,
|
||||
),
|
||||
tauri_config_,
|
||||
None,
|
||||
&cli_options,
|
||||
|
|
|
@ -248,13 +248,19 @@ fn read_options(identifier: &str) -> CliOptions {
|
|||
options
|
||||
}
|
||||
|
||||
pub fn get_app(config: &TauriConfig, interface: &AppInterface) -> App {
|
||||
pub fn get_app(target: Target, config: &TauriConfig, interface: &AppInterface) -> App {
|
||||
let identifier = config
|
||||
.identifier
|
||||
.rsplit('.')
|
||||
.collect::<Vec<&str>>()
|
||||
.join(".");
|
||||
|
||||
let identifier = match target {
|
||||
Target::Android => identifier.replace('-', "_"),
|
||||
#[cfg(target_os = "macos")]
|
||||
Target::Ios => identifier.replace('_', "-"),
|
||||
};
|
||||
|
||||
if identifier.is_empty() {
|
||||
log::error!("Bundle identifier set in `tauri.conf.json > identifier` cannot be empty");
|
||||
exit(1);
|
||||
|
@ -318,7 +324,7 @@ fn ensure_init(
|
|||
Target::Android => {
|
||||
let java_folder = project_dir
|
||||
.join("app/src/main/java")
|
||||
.join(tauri_config_.identifier.replace('.', "/"));
|
||||
.join(tauri_config_.identifier.replace('.', "/").replace('-', "_"));
|
||||
if !java_folder.exists() {
|
||||
project_outdated_reasons
|
||||
.push("you have modified your \"identifier\" in the Tauri configuration");
|
||||
|
@ -330,7 +336,7 @@ fn ensure_init(
|
|||
.context("missing project.yml file in the Xcode project directory")?;
|
||||
if !project_yml.contains(&format!(
|
||||
"PRODUCT_BUNDLE_IDENTIFIER: {}",
|
||||
tauri_config_.identifier
|
||||
tauri_config_.identifier.replace('_', "-")
|
||||
)) {
|
||||
project_outdated_reasons
|
||||
.push("you have modified your \"identifier\" in the Tauri configuration");
|
||||
|
|
Loading…
Reference in New Issue