mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-01 11:13:40 +03:00
This commit is contained in:
parent
7fee3d3a2a
commit
735db1ce83
6
.changes/skip-target-install-arg.md
Normal file
6
.changes/skip-target-install-arg.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
'cli.rs': 'patch:enhance'
|
||||
'cli.js': 'patch:enhance'
|
||||
---
|
||||
|
||||
Add `--skip-targets-install` flag for `tauri android init` and `tauri ios init` to skip installing needed rust targets vie rustup.
|
@ -62,6 +62,9 @@ pub struct InitOptions {
|
||||
/// Skip prompting for values
|
||||
#[clap(long)]
|
||||
ci: bool,
|
||||
/// Skips installing rust toolchains via rustup
|
||||
#[clap(long)]
|
||||
skip_targets_install: bool,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
@ -78,7 +81,12 @@ enum Commands {
|
||||
pub fn command(cli: Cli, verbosity: u8) -> Result<()> {
|
||||
let noise_level = NoiseLevel::from_occurrences(verbosity as u64);
|
||||
match cli.command {
|
||||
Commands::Init(options) => init_command(MobileTarget::Android, options.ci, false)?,
|
||||
Commands::Init(options) => init_command(
|
||||
MobileTarget::Android,
|
||||
options.ci,
|
||||
false,
|
||||
options.skip_targets_install,
|
||||
)?,
|
||||
Commands::Open => open::command()?,
|
||||
Commands::Dev(options) => dev::command(options, noise_level)?,
|
||||
Commands::Build(options) => build::command(options, noise_level)?,
|
||||
|
@ -34,23 +34,25 @@ pub fn gen(
|
||||
metadata: &Metadata,
|
||||
(handlebars, mut map): (Handlebars, template::JsonMap),
|
||||
wrapper: &TextWrapper,
|
||||
skip_targets_install: bool,
|
||||
) -> Result<()> {
|
||||
let installed_targets =
|
||||
crate::interface::rust::installation::installed_targets().unwrap_or_default();
|
||||
let missing_targets = Target::all()
|
||||
.values()
|
||||
.filter(|t| !installed_targets.contains(&t.triple().into()))
|
||||
.collect::<Vec<&Target>>();
|
||||
if !skip_targets_install {
|
||||
let installed_targets =
|
||||
crate::interface::rust::installation::installed_targets().unwrap_or_default();
|
||||
let missing_targets = Target::all()
|
||||
.values()
|
||||
.filter(|t| !installed_targets.contains(&t.triple().into()))
|
||||
.collect::<Vec<&Target>>();
|
||||
|
||||
if !missing_targets.is_empty() {
|
||||
println!("Installing Android Rust toolchains...");
|
||||
for target in missing_targets {
|
||||
target
|
||||
.install()
|
||||
.context("failed to install target with rustup")?;
|
||||
if !missing_targets.is_empty() {
|
||||
println!("Installing Android Rust toolchains...");
|
||||
for target in missing_targets {
|
||||
target
|
||||
.install()
|
||||
.context("failed to install target with rustup")?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println!("Generating Android Studio project...");
|
||||
let dest = config.project_dir();
|
||||
let asset_packs = metadata.asset_packs().unwrap_or_default();
|
||||
|
@ -24,13 +24,19 @@ use std::{
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
pub fn command(target: Target, ci: bool, reinstall_deps: bool) -> Result<()> {
|
||||
pub fn command(
|
||||
target: Target,
|
||||
ci: bool,
|
||||
reinstall_deps: bool,
|
||||
skip_targets_install: bool,
|
||||
) -> Result<()> {
|
||||
let wrapper = TextWrapper::with_splitter(textwrap::termwidth(), textwrap::NoHyphenation);
|
||||
exec(
|
||||
target,
|
||||
&wrapper,
|
||||
ci || var_os("CI").is_some(),
|
||||
reinstall_deps,
|
||||
skip_targets_install,
|
||||
)
|
||||
.map_err(|e| anyhow::anyhow!("{:#}", e))?;
|
||||
Ok(())
|
||||
@ -78,6 +84,7 @@ pub fn exec(
|
||||
wrapper: &TextWrapper,
|
||||
#[allow(unused_variables)] non_interactive: bool,
|
||||
#[allow(unused_variables)] reinstall_deps: bool,
|
||||
skip_targets_install: bool,
|
||||
) -> Result<App> {
|
||||
let tauri_config = get_tauri_config(None)?;
|
||||
let tauri_config_guard = tauri_config.lock().unwrap();
|
||||
@ -154,7 +161,13 @@ pub fn exec(
|
||||
let (app, config, metadata) =
|
||||
super::android::get_config(Some(app), tauri_config_, &Default::default());
|
||||
map.insert("android", &config);
|
||||
super::android::project::gen(&config, &metadata, (handlebars, map), wrapper)?;
|
||||
super::android::project::gen(
|
||||
&config,
|
||||
&metadata,
|
||||
(handlebars, map),
|
||||
wrapper,
|
||||
skip_targets_install,
|
||||
)?;
|
||||
app
|
||||
}
|
||||
Err(err) => {
|
||||
@ -183,6 +196,7 @@ pub fn exec(
|
||||
wrapper,
|
||||
non_interactive,
|
||||
reinstall_deps,
|
||||
skip_targets_install,
|
||||
)?;
|
||||
app
|
||||
}
|
||||
|
@ -66,6 +66,9 @@ pub struct InitOptions {
|
||||
/// Reinstall dependencies
|
||||
#[clap(short, long)]
|
||||
reinstall_deps: bool,
|
||||
/// Skips installing rust toolchains via rustup
|
||||
#[clap(long)]
|
||||
skip_targets_install: bool,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
@ -82,7 +85,12 @@ enum Commands {
|
||||
pub fn command(cli: Cli, verbosity: u8) -> Result<()> {
|
||||
let noise_level = NoiseLevel::from_occurrences(verbosity as u64);
|
||||
match cli.command {
|
||||
Commands::Init(options) => init_command(MobileTarget::Ios, options.ci, options.reinstall_deps)?,
|
||||
Commands::Init(options) => init_command(
|
||||
MobileTarget::Ios,
|
||||
options.ci,
|
||||
options.reinstall_deps,
|
||||
options.skip_targets_install,
|
||||
)?,
|
||||
Commands::Open => open::command()?,
|
||||
Commands::Dev(options) => dev::command(options, noise_level)?,
|
||||
Commands::Build(options) => build::command(options, noise_level)?,
|
||||
|
@ -33,20 +33,23 @@ pub fn gen(
|
||||
wrapper: &TextWrapper,
|
||||
non_interactive: bool,
|
||||
reinstall_deps: bool,
|
||||
skip_targets_install: bool,
|
||||
) -> Result<()> {
|
||||
let installed_targets =
|
||||
crate::interface::rust::installation::installed_targets().unwrap_or_default();
|
||||
let missing_targets = Target::all()
|
||||
.values()
|
||||
.filter(|t| !installed_targets.contains(&t.triple().into()))
|
||||
.collect::<Vec<&Target>>();
|
||||
if !skip_targets_install {
|
||||
let installed_targets =
|
||||
crate::interface::rust::installation::installed_targets().unwrap_or_default();
|
||||
let missing_targets = Target::all()
|
||||
.values()
|
||||
.filter(|t| !installed_targets.contains(&t.triple().into()))
|
||||
.collect::<Vec<&Target>>();
|
||||
|
||||
if !missing_targets.is_empty() {
|
||||
println!("Installing iOS Rust toolchains...");
|
||||
for target in missing_targets {
|
||||
target
|
||||
.install()
|
||||
.context("failed to install target with rustup")?;
|
||||
if !missing_targets.is_empty() {
|
||||
println!("Installing iOS Rust toolchains...");
|
||||
for target in missing_targets {
|
||||
target
|
||||
.install()
|
||||
.context("failed to install target with rustup")?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user