Skip to content

Commit 0941898

Browse files
committed
Provide build_internal error context
1 parent 4503a17 commit 0941898

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

clamav-sys/build_internal.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn bindgen_internal(output_path: &Path) -> anyhow::Result<()> {
100100
std::env::vars()
101101
.filter(|(k, _)| ENV_PATTERNS.iter().any(|prefix| k.starts_with(prefix)))
102102
.for_each(|(k, v)| eprintln!(" {}={:?}", k, v));
103-
detect_clamav_build()?;
103+
detect_clamav_build().map_err(|e| anyhow!("detect_clamav_build: {e}"))?;
104104

105105
// We only want to generate bindings for `cargo build`, not `cargo test`.
106106
// FindRust.cmake defines $CARGO_CMD so we can differentiate.
@@ -114,13 +114,15 @@ pub fn bindgen_internal(output_path: &Path) -> anyhow::Result<()> {
114114
// On the plus-side, this means that our `.rs` file is present before our
115115
// first build, so at least rust-analyzer will be happy.
116116
if super::in_maintainer_mode() {
117-
execute_bindgen(output_path)?;
117+
execute_bindgen(output_path).map_err(|e| anyhow!("execute_bindgen: {e}"))?;
118118
// And place a copy in the source tree (for potential check-in)
119-
std::fs::copy(output_path, BINDGEN_OUTPUT_FILE)?;
119+
std::fs::copy(output_path, BINDGEN_OUTPUT_FILE)
120+
.map_err(|e| anyhow!("copying {output_path:?} to {BINDGEN_OUTPUT_FILE}: {e}"))?;
120121
} else {
121122
// Otherwise, just copy the pre-generated file to the specified
122123
// location.
123-
std::fs::copy(BINDGEN_OUTPUT_FILE, output_path)?;
124+
std::fs::copy(BINDGEN_OUTPUT_FILE, output_path)
125+
.map_err(|e| anyhow!("copying {BINDGEN_OUTPUT_FILE} to {output_path}: {e}"))?;
124126
}
125127
} else {
126128
eprintln!("NOTE: Not generating bindings because CARGO_CMD != build");
@@ -182,7 +184,9 @@ fn execute_bindgen(output_path: &Path) -> anyhow::Result<()> {
182184
fn detect_clamav_build() -> anyhow::Result<()> {
183185
println!("cargo:rerun-if-env-changed=LIBCLAMAV");
184186

185-
if search_and_link_lib("LIBCLAMAV")? {
187+
if search_and_link_lib("LIBCLAMAV")
188+
.map_err(|e| anyhow!("search_and_link_lib(LIBCLAMAV): {e}"))?
189+
{
186190
eprintln!("NOTE: LIBCLAMAV defined. Examining LIB* environment variables");
187191
// Need to link with libclamav dependencies
188192

@@ -267,7 +271,8 @@ fn search_and_link_lib(environment_variable: &str) -> anyhow::Result<bool> {
267271
}
268272
};
269273

270-
let parsed_path = parse_lib_path(&filepath_str)?;
274+
let parsed_path = parse_lib_path(&filepath_str)
275+
.map_err(|e| anyhow!("parse_lib_path({filepath_str}): {e}"))?;
271276
eprintln!(
272277
" - adding {:?} to rustc library search path",
273278
&parsed_path.dir

macos-cmake-github.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
PATH="/usr/local/opt/flex/bin:$PATH"; export PATH
4+
LDFLAGS="-L/usr/local/opt/flex/lib"; export LDFLAGS
5+
CPPFLAGS="-I/usr/local/opt/flex/include"; export CPPFLAGS
6+
PATH="/usr/local/opt/bison/bin:$PATH"; export PATH
7+
#cmake .. -D OPENSSL_ROOT_DIR=/usr/local/opt/openssl -D CMAKE_BUILD_TYPE=Release -D ENABLE_STATIC_LIB=ON -D ENABLE_EXAMPLES=ON
8+
cmake .. -D CMAKE_BUILD_TYPE=Release -D ENABLE_STATIC_LIB=ON -D ENABLE_EXAMPLES=ON

0 commit comments

Comments
 (0)