@@ -2,10 +2,10 @@ fn main() {
22 build_info_build:: build_script ( ) ;
33
44 #[ allow( unused_assignments, unused_mut) ] // due to feature flag
5- let mut _is_posix = true ;
5+ let mut is_posix = true ;
66 #[ cfg( target_os = "windows" ) ]
77 {
8- _is_posix = false ;
8+ is_posix = false ;
99 }
1010
1111 #[ allow( unused_assignments, unused_mut) ] // due to feature flag
@@ -16,41 +16,41 @@ fn main() {
1616 }
1717
1818 // Generate C code bindings for xcplib
19- let bindings = bindgen :: Builder :: default ( )
20- . header ( "xcplib/wrapper.h" )
21- //
22- //.clang_args(&["-target", "x86_64-pc-windows-msvc"])
23- . clang_arg ( "-Ixcplib/src" )
24- . clang_arg ( "-Ixcplib" )
25- . parse_callbacks ( Box :: new ( bindgen :: CargoCallbacks :: new ( ) ) )
26- //
27- . blocklist_type ( "T_CLOCK_INFO" )
28- . allowlist_type ( "tXcpDaqLists ")
29- // Protocol layer
30- . allowlist_function ( "XcpInit" )
31- . allowlist_function ( "XcpDisconnect" )
32- // Transport layer
33- . allowlist_function ( "XcpEthTlGetInfo" )
34- // Server
35- . allowlist_function ( "XcpEthServerInit" )
36- . allowlist_function ( "XcpEthServerShutdown" )
37- . allowlist_function ( "XcpEthServerStatus" )
38- // DAQ
39- . allowlist_function ( "XcpEvent" )
40- . allowlist_function ( "XcpEventExt" )
41- // Misc
42- . allowlist_function ( "XcpSetLogLevel" )
43- . allowlist_function ( "XcpPrint" )
44- . allowlist_function ( "XcpSetEpk" )
45- . allowlist_function ( "XcpSendTerminateSessionEvent " )
46- // .allowlist_function("ApplXcpGetAddr ")
47- . allowlist_function ( "ApplXcpSetA2lName " )
48- . allowlist_function ( "ApplXcpRegisterCallbacks " )
49- . allowlist_function ( "ApplXcpGetClock64" )
50- //
51- . generate ( )
52- . expect ( "Unable to generate bindings" ) ;
53- bindings . write_to_file ( "src/xcp/xcplib.rs" ) . expect ( "Couldn't write bindings!" ) ;
19+ if is_posix {
20+ let bindings = bindgen :: Builder :: default ( )
21+ . header ( "xcplib/wrapper.h" )
22+ //
23+ //.clang_args(&["-target", "x86_64-pc-windows-msvc"] )
24+ . clang_arg ( "-Ixcplib/src " )
25+ . clang_arg ( "-Ixcplib" )
26+ . parse_callbacks ( Box :: new ( bindgen :: CargoCallbacks :: new ( ) ) )
27+ //
28+ . blocklist_type ( "T_CLOCK_INFO ")
29+ // Protocol layer
30+ . allowlist_function ( "XcpInit" )
31+ . allowlist_function ( "XcpDisconnect" )
32+ // Transport layer
33+ . allowlist_function ( "XcpEthTlGetInfo" )
34+ // Server
35+ . allowlist_function ( "XcpEthServerInit" )
36+ . allowlist_function ( "XcpEthServerShutdown" )
37+ . allowlist_function ( "XcpEthServerStatus" )
38+ // DAQ
39+ . allowlist_function ( "XcpEvent" )
40+ . allowlist_function ( "XcpEventExt" )
41+ // Misc
42+ . allowlist_function ( "XcpSetLogLevel" )
43+ . allowlist_function ( "XcpPrint" )
44+ . allowlist_function ( "XcpSetEpk" )
45+ . allowlist_function ( "ApplXcpSetA2lName " )
46+ . allowlist_function ( "ApplXcpRegisterCallbacks " )
47+ . allowlist_function ( "XcpSendTerminateSessionEvent " )
48+ . allowlist_function ( "ApplXcpGetClock64 " )
49+ //
50+ . generate ( )
51+ . expect ( "Unable to generate bindings" ) ;
52+ bindings . write_to_file ( "src/xcp/xcplib.rs" ) . expect ( "Couldn't write bindings! " ) ;
53+ }
5454
5555 // Build xcplib
5656 let mut builder = cc:: Build :: new ( ) ;
@@ -60,16 +60,17 @@ fn main() {
6060 . file ( "xcplib/src/platform.c" )
6161 . file ( "xcplib/src/xcpLite.c" )
6262 . file ( "xcplib/src/xcpQueue64.c" )
63+ . file ( "xcplib/src/xcpQueue32.c" )
6364 . file ( "xcplib/src/xcpEthTl.c" )
64- . file ( "xcplib/src/xcpEthServer.c" )
65- . flag ( "-std=c11" ) ;
66-
67- if is_release {
68- builder. flag ( "-O2" ) ;
69- } else {
70- builder. flag ( "-O0" ) . flag ( "-g" ) ;
65+ . file ( "xcplib/src/xcpEthServer.c" ) ;
66+ if is_posix {
67+ builder. flag ( "-std=c11" ) ;
68+ if is_release {
69+ builder. flag ( "-O2" ) ;
70+ } else {
71+ builder. flag ( "-O0" ) . flag ( "-g" ) ;
72+ }
7173 }
72-
7374 builder. compile ( "xcplib" ) ;
7475
7576 // Tell cargo to invalidate the built crate whenever any of these files changed.
@@ -86,6 +87,7 @@ fn main() {
8687 println ! ( "cargo:rerun-if-changed=xcplib/src/platform.c" ) ;
8788 println ! ( "cargo:rerun-if-changed=xcplib/src/xcpQueue.h" ) ;
8889 println ! ( "cargo:rerun-if-changed=xcplib/src/xcpQueue64.c" ) ;
90+ println ! ( "cargo:rerun-if-changed=xcplib/src/xcpQueue32.c" ) ;
8991 println ! ( "cargo:rerun-if-changed=xcplib/src/xcpEthTl.h" ) ;
9092 println ! ( "cargo:rerun-if-changed=xcplib/src/xcpEthTl.c" ) ;
9193 println ! ( "cargo:rerun-if-changed=xcplib/src/xcpEthServer.h" ) ;
0 commit comments