From ffc68e19c4cff9407946f44f5ea448de251f6276 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 23 Jun 2025 10:03:35 -0300 Subject: [PATCH 1/2] feat(cli): allow passing Cargo commands to mobile dev/build commands --- .changes/mobile-args.md | 7 +++++++ crates/tauri-cli/src/mobile/android/build.rs | 8 +++++++- crates/tauri-cli/src/mobile/android/dev.rs | 9 +++++++-- crates/tauri-cli/src/mobile/ios/build.rs | 8 +++++++- crates/tauri-cli/src/mobile/ios/dev.rs | 9 +++++++-- 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 .changes/mobile-args.md diff --git a/.changes/mobile-args.md b/.changes/mobile-args.md new file mode 100644 index 000000000000..a527d94dd74c --- /dev/null +++ b/.changes/mobile-args.md @@ -0,0 +1,7 @@ +--- +--- +"tauri-cli": "minor:feat" +"@tauri-apps/cli": "minor:feat" +--- + +Allow passing Cargo arguments to mobile dev and build commands. diff --git a/crates/tauri-cli/src/mobile/android/build.rs b/crates/tauri-cli/src/mobile/android/build.rs index 358042127bf3..731df7e4d57d 100644 --- a/crates/tauri-cli/src/mobile/android/build.rs +++ b/crates/tauri-cli/src/mobile/android/build.rs @@ -73,6 +73,11 @@ pub struct Options { /// Skip prompting for values #[clap(long, env = "CI")] pub ci: bool, + /// Command line arguments passed to the runner. + /// Use `--` to explicitly mark the start of the arguments. + /// e.g. `tauri android build -- [runnerArgs]`. + #[clap(last(true))] + pub args: Vec, } impl From for BuildOptions { @@ -85,7 +90,7 @@ impl From for BuildOptions { bundles: None, no_bundle: false, config: options.config, - args: Vec::new(), + args: options.args, ci: options.ci, } } @@ -197,6 +202,7 @@ fn run_build( let interface_options = InterfaceOptions { debug: build_options.debug, target: build_options.target.clone(), + args: build_options.args.clone(), ..Default::default() }; diff --git a/crates/tauri-cli/src/mobile/android/dev.rs b/crates/tauri-cli/src/mobile/android/dev.rs index 01570851c728..30cca450d806 100644 --- a/crates/tauri-cli/src/mobile/android/dev.rs +++ b/crates/tauri-cli/src/mobile/android/dev.rs @@ -96,6 +96,11 @@ pub struct Options { /// Specify port for the built-in dev server for static files. Defaults to 1430. #[clap(long, env = "TAURI_CLI_PORT")] pub port: Option, + /// Command line arguments passed to the runner. + /// Use `--` to explicitly mark the start of the arguments. + /// e.g. `tauri android dev -- [runnerArgs]`. + #[clap(last(true))] + pub args: Vec, } impl From for DevOptions { @@ -106,7 +111,7 @@ impl From for DevOptions { features: options.features, exit_on_panic: options.exit_on_panic, config: options.config, - args: Vec::new(), + args: options.args, no_watch: options.no_watch, no_dev_server_wait: options.no_dev_server_wait, no_dev_server: options.no_dev_server, @@ -257,7 +262,7 @@ fn run_dev( MobileOptions { debug: !options.release_mode, features: options.features, - args: Vec::new(), + args: options.args, config: dev_options.config.clone(), no_watch: options.no_watch, }, diff --git a/crates/tauri-cli/src/mobile/ios/build.rs b/crates/tauri-cli/src/mobile/ios/build.rs index 27ff18ba1cab..92f1b88f4045 100644 --- a/crates/tauri-cli/src/mobile/ios/build.rs +++ b/crates/tauri-cli/src/mobile/ios/build.rs @@ -83,6 +83,11 @@ pub struct Options { /// Use this to create a package ready for the App Store (app-store-connect option) or TestFlight (release-testing option). #[clap(long, value_enum)] pub export_method: Option, + /// Command line arguments passed to the runner. + /// Use `--` to explicitly mark the start of the arguments. + /// e.g. `tauri ios build -- [runnerArgs]`. + #[clap(last(true))] + pub args: Vec, } #[derive(Debug, Clone, Copy, ValueEnum)] @@ -125,7 +130,7 @@ impl From for BuildOptions { bundles: None, no_bundle: false, config: options.config, - args: Vec::new(), + args: options.args, ci: options.ci, } } @@ -282,6 +287,7 @@ fn run_build( let out_dir = app_settings.out_dir(&InterfaceOptions { debug: build_options.debug, target: build_options.target.clone(), + args: build_options.args.clone(), ..Default::default() })?; let _lock = flock::open_rw(out_dir.join("lock").with_extension("ios"), "iOS")?; diff --git a/crates/tauri-cli/src/mobile/ios/dev.rs b/crates/tauri-cli/src/mobile/ios/dev.rs index ae3f1e4301ef..dc7f9fc87431 100644 --- a/crates/tauri-cli/src/mobile/ios/dev.rs +++ b/crates/tauri-cli/src/mobile/ios/dev.rs @@ -101,6 +101,11 @@ pub struct Options { /// Specify port for the built-in dev server for static files. Defaults to 1430. #[clap(long, env = "TAURI_CLI_PORT")] pub port: Option, + /// Command line arguments passed to the runner. + /// Use `--` to explicitly mark the start of the arguments. + /// e.g. `tauri ios dev -- [runnerArgs]`. + #[clap(last(true))] + pub args: Vec, } impl From for DevOptions { @@ -112,7 +117,7 @@ impl From for DevOptions { exit_on_panic: options.exit_on_panic, config: options.config, release_mode: options.release_mode, - args: Vec::new(), + args: options.args, no_watch: options.no_watch, no_dev_server: options.no_dev_server, no_dev_server_wait: options.no_dev_server_wait, @@ -265,7 +270,7 @@ fn run_dev( MobileOptions { debug: true, features: options.features, - args: Vec::new(), + args: options.args, config: dev_options.config.clone(), no_watch: options.no_watch, }, From 6cbfb44286bc587a22c7d66410ed86299a6ae583 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 23 Jun 2025 10:04:37 -0300 Subject: [PATCH 2/2] fmt --- .changes/mobile-args.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.changes/mobile-args.md b/.changes/mobile-args.md index a527d94dd74c..1b44058b3ff8 100644 --- a/.changes/mobile-args.md +++ b/.changes/mobile-args.md @@ -1,5 +1,4 @@ --- ---- "tauri-cli": "minor:feat" "@tauri-apps/cli": "minor:feat" ---