mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-25 11:43:06 +03:00
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio> closes #7044
This commit is contained in:
parent
e0f0dce220
commit
a28fdf7ec7
6
.changes/cli-skip-targets-install.md
Normal file
6
.changes/cli-skip-targets-install.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
'cli.rs': 'patch'
|
||||
'cli.js': 'patch'
|
||||
---
|
||||
|
||||
Skip Rust target installation if they are already installed.
|
2
.github/workflows/check-license-header.yml
vendored
2
.github/workflows/check-license-header.yml
vendored
@ -2,7 +2,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: Check generated files
|
||||
name: check license header
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
@ -36,6 +36,7 @@ use tauri_utils::display_path;
|
||||
|
||||
mod cargo_config;
|
||||
mod desktop;
|
||||
pub mod installation;
|
||||
pub mod manifest;
|
||||
use cargo_config::Config as CargoConfig;
|
||||
use manifest::{rewrite_manifest, Manifest};
|
||||
|
26
tooling/cli/src/interface/rust/installation.rs
Normal file
26
tooling/cli/src/interface/rust/installation.rs
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use crate::Result;
|
||||
|
||||
use std::{fs::read_dir, path::PathBuf, process::Command};
|
||||
|
||||
pub fn installed_targets() -> Result<Vec<String>> {
|
||||
let output = Command::new("rustc")
|
||||
.args(["--print", "sysroot"])
|
||||
.output()?;
|
||||
let sysroot_path = PathBuf::from(String::from_utf8_lossy(&output.stdout).trim().to_string());
|
||||
|
||||
let mut targets = Vec::new();
|
||||
for entry in read_dir(sysroot_path.join("lib").join("rustlib"))?.flatten() {
|
||||
if entry.file_type().map(|t| t.is_dir()).unwrap_or_default() {
|
||||
let name = entry.file_name();
|
||||
if name != "etc" && name != "src" {
|
||||
targets.push(name.to_string_lossy().into_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(targets)
|
||||
}
|
@ -35,8 +35,22 @@ pub fn gen(
|
||||
(handlebars, mut map): (Handlebars, template::JsonMap),
|
||||
wrapper: &TextWrapper,
|
||||
) -> Result<()> {
|
||||
println!("Installing Android toolchains...");
|
||||
Target::install_all().with_context(|| "failed to run rustup")?;
|
||||
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")?;
|
||||
}
|
||||
}
|
||||
|
||||
println!("Generating Android Studio project...");
|
||||
let dest = config.project_dir();
|
||||
let asset_packs = metadata.asset_packs().unwrap_or_default();
|
||||
|
@ -34,8 +34,22 @@ pub fn gen(
|
||||
non_interactive: bool,
|
||||
reinstall_deps: bool,
|
||||
) -> Result<()> {
|
||||
println!("Installing iOS toolchains...");
|
||||
Target::install_all()?;
|
||||
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")?;
|
||||
}
|
||||
}
|
||||
|
||||
rust_version_check(wrapper)?;
|
||||
|
||||
deps::install_all(wrapper, non_interactive, true, reinstall_deps)
|
||||
|
Loading…
Reference in New Issue
Block a user