File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change 1
1
use std:: { env, path:: PathBuf } ;
2
2
3
3
fn main ( ) {
4
+ println ! ( "cargo:rerun-if-changed=instrument-hooks/dist/core.c" ) ;
5
+ println ! ( "cargo:rerun-if-changed=instrument-hooks/includes/core.h" ) ;
6
+ println ! ( "cargo:rerun-if-changed=build.rs" ) ;
7
+
4
8
if cfg ! ( not( target_os = "linux" ) ) {
5
9
// The instrument-hooks library is only supported on Linux.
6
10
return ;
7
11
}
8
12
9
- // Compile the C library
10
- cc:: Build :: new ( )
13
+ let mut build = cc:: Build :: new ( ) ;
14
+ build
15
+ . flag ( "-std=gnu17" )
11
16
. file ( "instrument-hooks/dist/core.c" )
12
17
. include ( "instrument-hooks/includes" )
13
- . flag ( "-w" ) // Suppress all warnings
14
- . compile ( "instrument_hooks" ) ;
18
+ . warnings ( false )
19
+ . extra_warnings ( false )
20
+ . cargo_warnings ( false ) ;
21
+
22
+ let result = build. try_compile ( "instrument_hooks" ) ;
23
+ if let Err ( e) = result {
24
+ let compiler = build. try_get_compiler ( ) . expect ( "Failed to get C compiler" ) ;
25
+
26
+ eprintln ! ( "\n \n ERROR: Failed to compile instrument-hooks native library with cc-rs. Ensure you have an up-to-date C compiler installed." ) ;
27
+ eprintln ! ( "Compiler information: {compiler:?}" ) ;
28
+ eprintln ! ( "Compilation error: {e}" ) ;
29
+
30
+ std:: process:: exit ( 1 ) ;
31
+ }
15
32
16
33
let bindings = bindgen:: Builder :: default ( )
17
34
. header ( "instrument-hooks/includes/core.h" )
You can’t perform that action at this time.
0 commit comments