diff --git a/Cargo.lock b/Cargo.lock index 7e130f9ba..9a515ee18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "color-eyre" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ebf286c900a6d5867aeff75cfee3192857bb7f24b547d4f0df2ed6baa812c90" +checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" dependencies = [ "backtrace", "color-spantrace", diff --git a/Cargo.toml b/Cargo.toml index 695d6dce3..19072ac0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ members = ["xtask"] [dependencies] atty = "0.2" clap = { version = "3.2.2", features = ["derive", "unstable-v4"] } -color-eyre = { version = "0.6", default-features = false } +color-eyre = { version = "0.6.2", default-features = false, features = ["track-caller"] } eyre = "0.6" thiserror = "1" home = "0.5" diff --git a/src/docker/shared.rs b/src/docker/shared.rs index be4ba533e..9fb7675b5 100644 --- a/src/docker/shared.rs +++ b/src/docker/shared.rs @@ -718,7 +718,7 @@ pub fn get_image_name(config: &Config, target: &Target, uses_zig: bool) -> Resul ); } - let version = if include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")).is_empty() { + let version = if crate::commit_info().is_empty() { env!("CARGO_PKG_VERSION") } else { "main" @@ -754,7 +754,7 @@ pub(crate) fn get_image(config: &Config, target: &Target, uses_zig: bool) -> Res ); } - let version = if include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")).is_empty() { + let version = if crate::commit_info().is_empty() { env!("CARGO_PKG_VERSION") } else { "main" diff --git a/src/errors.rs b/src/errors.rs index c0c5aaf88..364317f87 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -10,8 +10,10 @@ pub use eyre::Result; pub static mut TERMINATED: AtomicBool = AtomicBool::new(false); pub fn install_panic_hook() -> Result<()> { + let is_dev = !crate::commit_info().is_empty() || std::env::var("CROSS_DEBUG").is_ok(); color_eyre::config::HookBuilder::new() - .display_env_section(false) + .display_env_section(is_dev) + .display_location_section(is_dev) .install() } diff --git a/src/lib.rs b/src/lib.rs index 03d9ec2ec..44c8dbe79 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -501,10 +501,9 @@ pub fn run( msg_info: &mut MessageInfo, ) -> Result> { if args.version && args.subcommand.is_none() { - let commit_info = include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")); msg_info.print(format_args!( concat!("cross ", env!("CARGO_PKG_VERSION"), "{}"), - commit_info + crate::commit_info() ))?; } @@ -771,6 +770,10 @@ pub(crate) fn warn_host_version_mismatch( Ok(VersionMatch::Same) } +fn commit_info() -> &'static str { + include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt")) +} + /// Obtains the [`CrossToml`] from one of the possible locations /// /// These locations are checked in the following order: