Skip to content

Commit

Permalink
feat(cli): add --release for android dev (#6638)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
closes #6594
  • Loading branch information
amrbashir committed Apr 5, 2023
1 parent d03e47d commit 63f088e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changes/cli-android-dev-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'cli.rs': 'patch'
'cli.js': 'patch'
---

Add `--release` flag for `tauri android dev` however you will need to sign your Android app, see https://next--tauri.netlify.app/next/guides/distribution/sign-android
20 changes: 17 additions & 3 deletions tooling/cli/src/mobile/android/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ pub struct Options {
/// Force prompting for an IP to use to connect to the dev server on mobile.
#[clap(long)]
pub force_ip_prompt: bool,
/// Run the code in release mode
#[clap(long = "release")]
pub release_mode: bool,
}

impl From<Options> for DevOptions {
Expand All @@ -78,12 +81,12 @@ impl From<Options> for DevOptions {
features: options.features,
exit_on_panic: options.exit_on_panic,
config: options.config,
release_mode: false,
args: Vec::new(),
no_watch: options.no_watch,
no_dev_server: options.no_dev_server,
port: options.port,
force_ip_prompt: options.force_ip_prompt,
release_mode: options.release_mode,
}
}
}
Expand Down Expand Up @@ -152,14 +155,25 @@ fn run_dev(
.values()
.find(|t| t.triple == target_triple)
.unwrap_or_else(|| Target::all().values().next().unwrap());
target.build(config, metadata, &env, noise_level, true, Profile::Debug)?;
target.build(
config,
metadata,
&env,
noise_level,
true,
if options.release_mode {
Profile::Release
} else {
Profile::Debug
},
)?;

let open = options.open;
let exit_on_panic = options.exit_on_panic;
let no_watch = options.no_watch;
interface.mobile_dev(
MobileOptions {
debug: true,
debug: !options.release_mode,
features: options.features,
args: Vec::new(),
config: options.config,
Expand Down
3 changes: 1 addition & 2 deletions tooling/cli/src/mobile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ fn ensure_init(project_dir: PathBuf, target: Target) -> Result<()> {
target.command_name(),
)
} else {
#[allow(irrefutable_let_patterns)]
if let Target::Android = target {
if target == Target::Android {
create_dir_all(project_dir.join(".tauri").join("plugins"))?;
}
Ok(())
Expand Down

0 comments on commit 63f088e

Please sign in to comment.