@@ -49,72 +49,53 @@ fn compile_linux() {
4949 // First check the features enabled for the crate.
5050 // Only one linux backend should be enabled at a time.
5151
52- let avail_backends: [ ( & ' static str , Box < dyn Fn ( ) > ) ; 6 ] = [
53- (
54- "LINUX_STATIC_HIDRAW" ,
55- Box :: new ( || {
56- let mut config = cc:: Build :: new ( ) ;
57- println ! ( "cargo:rerun-if-changed=etc/hidapi/linux/hid.c" ) ;
58- config
59- . file ( "etc/hidapi/linux/hid.c" )
60- . include ( "etc/hidapi/hidapi" ) ;
61- pkg_config:: probe_library ( "libudev" ) . expect ( "Unable to find libudev" ) ;
62- config. compile ( "libhidapi.a" ) ;
63- println ! ( "cargo:rustc-cfg=hidapi" ) ;
64- } ) ,
65- ) ,
66- (
67- "LINUX_STATIC_LIBUSB" ,
68- Box :: new ( || {
69- let mut config = cc:: Build :: new ( ) ;
70- println ! ( "cargo:rerun-if-changed=etc/hidapi/linux/hid.c" ) ;
71- config
72- . file ( "etc/hidapi/libusb/hid.c" )
73- . include ( "etc/hidapi/hidapi" ) ;
74- let lib =
75- pkg_config:: find_library ( "libusb-1.0" ) . expect ( "Unable to find libusb-1.0" ) ;
76- for path in lib. include_paths {
77- config. include (
78- path. to_str ( )
79- . expect ( "Failed to convert include path to str" ) ,
80- ) ;
81- }
82- config. compile ( "libhidapi.a" ) ;
83- println ! ( "cargo:rustc-cfg=libusb" ) ;
84- println ! ( "cargo:rustc-cfg=hidapi" ) ;
85- } ) ,
86- ) ,
87- (
88- "LINUX_SHARED_HIDRAW" ,
89- Box :: new ( || {
90- pkg_config:: probe_library ( "hidapi-hidraw" ) . expect ( "Unable to find hidapi-hidraw" ) ;
91- println ! ( "cargo:rustc-cfg=hidapi" ) ;
92- } ) ,
93- ) ,
94- (
95- "LINUX_SHARED_LIBUSB" ,
96- Box :: new ( || {
97- pkg_config:: probe_library ( "libusb-1.0" ) . expect ( "Unable to find libusb-1.0" ) ;
98- pkg_config:: probe_library ( "hidapi-libusb" ) . expect ( "Unable to find hidapi-libusb" ) ;
99- println ! ( "cargo:rustc-cfg=libusb" ) ;
100- println ! ( "cargo:rustc-cfg=hidapi" ) ;
101- } ) ,
102- ) ,
103- (
104- "LINUX_NATIVE" ,
105- Box :: new ( || {
106- // The udev crate takes care of finding its library
107- } ) ,
108- ) ,
109- (
110- "LINUX_NATIVE_BASIC_UDEV" ,
111- Box :: new ( || {
112- // Enable `feature="linux-native"` to reuse the existing
113- // linux-native code. It is considered an error in
114- // basic-udev if this fails to compile.
115- println ! ( "cargo:rustc-cfg=feature=\" linux-native\" " ) ;
116- } ) ,
117- ) ,
52+ let avail_backends: [ ( & ' static str , & dyn Fn ( ) ) ; 6 ] = [
53+ ( "LINUX_STATIC_HIDRAW" , & || {
54+ let mut config = cc:: Build :: new ( ) ;
55+ println ! ( "cargo:rerun-if-changed=etc/hidapi/linux/hid.c" ) ;
56+ config
57+ . file ( "etc/hidapi/linux/hid.c" )
58+ . include ( "etc/hidapi/hidapi" ) ;
59+ pkg_config:: probe_library ( "libudev" ) . expect ( "Unable to find libudev" ) ;
60+ config. compile ( "libhidapi.a" ) ;
61+ println ! ( "cargo:rustc-cfg=hidapi" ) ;
62+ } ) ,
63+ ( "LINUX_STATIC_LIBUSB" , & || {
64+ let mut config = cc:: Build :: new ( ) ;
65+ println ! ( "cargo:rerun-if-changed=etc/hidapi/linux/hid.c" ) ;
66+ config
67+ . file ( "etc/hidapi/libusb/hid.c" )
68+ . include ( "etc/hidapi/hidapi" ) ;
69+ let lib = pkg_config:: find_library ( "libusb-1.0" ) . expect ( "Unable to find libusb-1.0" ) ;
70+ for path in lib. include_paths {
71+ config. include (
72+ path. to_str ( )
73+ . expect ( "Failed to convert include path to str" ) ,
74+ ) ;
75+ }
76+ config. compile ( "libhidapi.a" ) ;
77+ println ! ( "cargo:rustc-cfg=libusb" ) ;
78+ println ! ( "cargo:rustc-cfg=hidapi" ) ;
79+ } ) ,
80+ ( "LINUX_SHARED_HIDRAW" , & || {
81+ pkg_config:: probe_library ( "hidapi-hidraw" ) . expect ( "Unable to find hidapi-hidraw" ) ;
82+ println ! ( "cargo:rustc-cfg=hidapi" ) ;
83+ } ) ,
84+ ( "LINUX_SHARED_LIBUSB" , & || {
85+ pkg_config:: probe_library ( "libusb-1.0" ) . expect ( "Unable to find libusb-1.0" ) ;
86+ pkg_config:: probe_library ( "hidapi-libusb" ) . expect ( "Unable to find hidapi-libusb" ) ;
87+ println ! ( "cargo:rustc-cfg=libusb" ) ;
88+ println ! ( "cargo:rustc-cfg=hidapi" ) ;
89+ } ) ,
90+ ( "LINUX_NATIVE" , & || {
91+ // The udev crate takes care of finding its library
92+ } ) ,
93+ ( "LINUX_NATIVE_BASIC_UDEV" , & || {
94+ // Enable `feature="linux-native"` to reuse the existing
95+ // linux-native code. It is considered an error in
96+ // basic-udev if this fails to compile.
97+ println ! ( "cargo:rustc-cfg=feature=\" linux-native\" " ) ;
98+ } ) ,
11899 ] ;
119100
120101 let mut backends = avail_backends
@@ -155,31 +136,24 @@ fn compile_illumos() {
155136 // First check the features enabled for the crate.
156137 // Only one illumos backend should be enabled at a time.
157138
158- let avail_backends: [ ( & ' static str , Box < dyn Fn ( ) > ) ; 2 ] = [
159- (
160- "ILLUMOS_STATIC_LIBUSB" ,
161- Box :: new ( || {
162- let mut config = cc:: Build :: new ( ) ;
163- config
164- . file ( "etc/hidapi/libusb/hid.c" )
165- . include ( "etc/hidapi/hidapi" ) ;
166- let lib =
167- pkg_config:: find_library ( "libusb-1.0" ) . expect ( "Unable to find libusb-1.0" ) ;
168- for path in lib. include_paths {
169- config. include (
170- path. to_str ( )
171- . expect ( "Failed to convert include path to str" ) ,
172- ) ;
173- }
174- config. compile ( "libhidapi.a" ) ;
175- } ) ,
176- ) ,
177- (
178- "ILLUMOS_SHARED_LIBUSB" ,
179- Box :: new ( || {
180- pkg_config:: probe_library ( "hidapi-libusb" ) . expect ( "Unable to find hidapi-libusb" ) ;
181- } ) ,
182- ) ,
139+ let avail_backends: [ ( & ' static str , & dyn Fn ( ) ) ; 2 ] = [
140+ ( "ILLUMOS_STATIC_LIBUSB" , & || {
141+ let mut config = cc:: Build :: new ( ) ;
142+ config
143+ . file ( "etc/hidapi/libusb/hid.c" )
144+ . include ( "etc/hidapi/hidapi" ) ;
145+ let lib = pkg_config:: find_library ( "libusb-1.0" ) . expect ( "Unable to find libusb-1.0" ) ;
146+ for path in lib. include_paths {
147+ config. include (
148+ path. to_str ( )
149+ . expect ( "Failed to convert include path to str" ) ,
150+ ) ;
151+ }
152+ config. compile ( "libhidapi.a" ) ;
153+ } ) ,
154+ ( "ILLUMOS_SHARED_LIBUSB" , & || {
155+ pkg_config:: probe_library ( "hidapi-libusb" ) . expect ( "Unable to find hidapi-libusb" ) ;
156+ } ) ,
183157 ] ;
184158
185159 let mut backends = avail_backends
0 commit comments