@@ -100,7 +100,7 @@ pub fn bindgen_internal(output_path: &Path) -> anyhow::Result<()> {
100
100
std:: env:: vars ( )
101
101
. filter ( |( k, _) | ENV_PATTERNS . iter ( ) . any ( |prefix| k. starts_with ( prefix) ) )
102
102
. for_each ( |( k, v) | eprintln ! ( " {}={:?}" , k, v) ) ;
103
- detect_clamav_build ( ) ?;
103
+ detect_clamav_build ( ) . map_err ( |e| anyhow ! ( "detect_clamav_build: {e}" ) ) ?;
104
104
105
105
// We only want to generate bindings for `cargo build`, not `cargo test`.
106
106
// FindRust.cmake defines $CARGO_CMD so we can differentiate.
@@ -114,13 +114,15 @@ pub fn bindgen_internal(output_path: &Path) -> anyhow::Result<()> {
114
114
// On the plus-side, this means that our `.rs` file is present before our
115
115
// first build, so at least rust-analyzer will be happy.
116
116
if super :: in_maintainer_mode ( ) {
117
- execute_bindgen ( output_path) ?;
117
+ execute_bindgen ( output_path) . map_err ( |e| anyhow ! ( "execute_bindgen: {e}" ) ) ?;
118
118
// 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}" ) ) ?;
120
121
} else {
121
122
// Otherwise, just copy the pre-generated file to the specified
122
123
// 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}" ) ) ?;
124
126
}
125
127
} else {
126
128
eprintln ! ( "NOTE: Not generating bindings because CARGO_CMD != build" ) ;
@@ -182,7 +184,9 @@ fn execute_bindgen(output_path: &Path) -> anyhow::Result<()> {
182
184
fn detect_clamav_build ( ) -> anyhow:: Result < ( ) > {
183
185
println ! ( "cargo:rerun-if-env-changed=LIBCLAMAV" ) ;
184
186
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
+ {
186
190
eprintln ! ( "NOTE: LIBCLAMAV defined. Examining LIB* environment variables" ) ;
187
191
// Need to link with libclamav dependencies
188
192
@@ -267,7 +271,8 @@ fn search_and_link_lib(environment_variable: &str) -> anyhow::Result<bool> {
267
271
}
268
272
} ;
269
273
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}" ) ) ?;
271
276
eprintln ! (
272
277
" - adding {:?} to rustc library search path" ,
273
278
& parsed_path. dir
0 commit comments