Investigate incorrect target detection (#1376)

* detect-targets: add debug tracing

See #1375.

* Add new feature `tracing` & `cli-tracing` to `detect-targets

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix clippy lints

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Tamir Duberstein 2023-09-23 06:45:44 -04:00 committed by GitHub
parent 680accd0d3
commit 2db8e254bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 12 deletions

View file

@ -7,6 +7,8 @@ use std::{
use cfg_if::cfg_if;
use tokio::process::Command;
#[cfg(feature = "tracing")]
use tracing::debug;
cfg_if! {
if #[cfg(target_os = "linux")] {
@ -32,10 +34,14 @@ cfg_if! {
/// Check [this issue](https://github.com/ryankurte/cargo-binstall/issues/155)
/// for more information.
pub async fn detect_targets() -> Vec<String> {
let target = get_target_from_rustc().await.unwrap_or_else(|| {
guess_host_triple::guess_host_triple()
.unwrap_or(crate::TARGET)
.to_string()
let target = get_target_from_rustc().await;
#[cfg(feature = "tracing")]
debug!("get_target_from_rustc()={target:?}");
let target = target.unwrap_or_else(|| {
let target = guess_host_triple::guess_host_triple();
#[cfg(feature = "tracing")]
debug!("guess_host_triple::guess_host_triple()={target:?}");
target.unwrap_or(crate::TARGET).to_string()
});
cfg_if! {