From 350f1c26e0c0d0b148378ef7d408685fba5c185d Mon Sep 17 00:00:00 2001 From: Kornel Date: Wed, 28 Aug 2024 14:19:45 +0100 Subject: [PATCH 1/3] Print fatal error without backtrace noise --- openssl-sys/build/find_normal.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openssl-sys/build/find_normal.rs b/openssl-sys/build/find_normal.rs index 1e910a0ee..facb80ce9 100644 --- a/openssl-sys/build/find_normal.rs +++ b/openssl-sys/build/find_normal.rs @@ -187,7 +187,8 @@ https://github.com/sfackler/rust-openssl#windows ); } - panic!("{}", msg); + eprintln!("{}", msg); + std::process::exit(101); // same as panic previously } /// Attempt to find OpenSSL through pkg-config. From 3815c15092004b8124846b49a24689c6342cf80c Mon Sep 17 00:00:00 2001 From: Kornel Date: Wed, 28 Aug 2024 14:41:14 +0100 Subject: [PATCH 2/3] Format pkg_config error --- openssl-sys/build/find_normal.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openssl-sys/build/find_normal.rs b/openssl-sys/build/find_normal.rs index facb80ce9..73613760b 100644 --- a/openssl-sys/build/find_normal.rs +++ b/openssl-sys/build/find_normal.rs @@ -213,7 +213,7 @@ fn try_pkg_config() { { Ok(lib) => lib, Err(e) => { - println!("run pkg_config fail: {:?}", e); + println!("\n\nCould not find openssl via pkg-config:\n{}\n", e); return; } }; From eeb920f85179af6dbe373caf048f0deffa378c1a Mon Sep 17 00:00:00 2001 From: Kornel Date: Wed, 28 Aug 2024 14:41:29 +0100 Subject: [PATCH 3/3] Emit cargo:warning as well --- openssl-sys/build/find_normal.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/openssl-sys/build/find_normal.rs b/openssl-sys/build/find_normal.rs index 73613760b..1439e9ab3 100644 --- a/openssl-sys/build/find_normal.rs +++ b/openssl-sys/build/find_normal.rs @@ -102,13 +102,21 @@ fn find_openssl_dir(target: &str) -> OsString { return OsString::from("/usr/local"); } + let msg_header = + "Could not find directory of OpenSSL installation, and this `-sys` crate cannot +proceed without this knowledge. If OpenSSL is installed and this crate had +trouble finding it, you can set the `OPENSSL_DIR` environment variable for the +compilation process."; + + println!( + "cargo:warning={} See stderr section below for further information.", + msg_header.replace('\n', " ") + ); + let mut msg = format!( " -Could not find directory of OpenSSL installation, and this `-sys` crate cannot -proceed without this knowledge. If OpenSSL is installed and this crate had -trouble finding it, you can set the `OPENSSL_DIR` environment variable for the -compilation process. +{} Make sure you also have the development packages of openssl installed. For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora. @@ -122,6 +130,7 @@ $TARGET = {} openssl-sys = {} ", + msg_header, host, target, env!("CARGO_PKG_VERSION")