/
githubmirror
/
tauri
Обзор
Документация
Войти
/
githubmirror
/
tauri
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
crates/tauri-cli/src/interface/rust/installation.rs
39 строк
1 KB
Lucas Fernandes Nogueira
refactor(cli): improve errors (#14126)
02 окт 2025, 12:58
Не верифицирован
02 окт 2025, 12:58
b06b3bd
Код
Авторство
О чём код?
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT use crate::{ error::{Error, ErrorExt}, 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() .map_err(|error| Error::CommandFailed { command: "rustc --print sysroot".to_string(), error, })?; 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")) .fs_context( "failed to read Rust sysroot", 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) }