Skip to content

Commit a8998dd

Browse files
committed
Removed unnecessary boxes from build.rs.
Or, in other words: Make clippy happy.
1 parent 2790909 commit a8998dd

File tree

1 file changed

+59
-82
lines changed

1 file changed

+59
-82
lines changed

build.rs

Lines changed: 59 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -46,63 +46,47 @@ fn compile_linux() {
4646
// First check the features enabled for the crate.
4747
// Only one linux backend should be enabled at a time.
4848

49-
let avail_backends: [(&'static str, Box<dyn Fn()>); 5] = [
50-
(
51-
"LINUX_STATIC_HIDRAW",
52-
Box::new(|| {
53-
let mut config = cc::Build::new();
54-
println!("cargo:rerun-if-changed=etc/hidapi/linux/hid.c");
55-
config
56-
.file("etc/hidapi/linux/hid.c")
57-
.include("etc/hidapi/hidapi");
58-
pkg_config::probe_library("libudev").expect("Unable to find libudev");
59-
config.compile("libhidapi.a");
60-
println!("cargo:rustc-cfg=hidapi");
61-
}),
62-
),
63-
(
64-
"LINUX_STATIC_LIBUSB",
65-
Box::new(|| {
66-
let mut config = cc::Build::new();
67-
println!("cargo:rerun-if-changed=etc/hidapi/linux/hid.c");
68-
config
69-
.file("etc/hidapi/libusb/hid.c")
70-
.include("etc/hidapi/hidapi");
71-
let lib =
72-
pkg_config::find_library("libusb-1.0").expect("Unable to find libusb-1.0");
73-
for path in lib.include_paths {
74-
config.include(
75-
path.to_str()
76-
.expect("Failed to convert include path to str"),
77-
);
78-
}
79-
config.compile("libhidapi.a");
80-
println!("cargo:rustc-cfg=libusb");
81-
println!("cargo:rustc-cfg=hidapi");
82-
}),
83-
),
84-
(
85-
"LINUX_SHARED_HIDRAW",
86-
Box::new(|| {
87-
pkg_config::probe_library("hidapi-hidraw").expect("Unable to find hidapi-hidraw");
88-
println!("cargo:rustc-cfg=hidapi");
89-
}),
90-
),
91-
(
92-
"LINUX_SHARED_LIBUSB",
93-
Box::new(|| {
94-
pkg_config::probe_library("libusb-1.0").expect("Unable to find libusb-1.0");
95-
pkg_config::probe_library("hidapi-libusb").expect("Unable to find hidapi-libusb");
96-
println!("cargo:rustc-cfg=libusb");
97-
println!("cargo:rustc-cfg=hidapi");
98-
}),
99-
),
100-
(
101-
"LINUX_NATIVE",
102-
Box::new(|| {
103-
// The udev crate takes care of finding its library
104-
}),
105-
),
49+
let avail_backends: [(&str, &dyn Fn()); 5] = [
50+
("LINUX_STATIC_HIDRAW", &|| {
51+
let mut config = cc::Build::new();
52+
println!("cargo:rerun-if-changed=etc/hidapi/linux/hid.c");
53+
config
54+
.file("etc/hidapi/linux/hid.c")
55+
.include("etc/hidapi/hidapi");
56+
pkg_config::probe_library("libudev").expect("Unable to find libudev");
57+
config.compile("libhidapi.a");
58+
println!("cargo:rustc-cfg=hidapi");
59+
}),
60+
("LINUX_STATIC_LIBUSB", &|| {
61+
let mut config = cc::Build::new();
62+
println!("cargo:rerun-if-changed=etc/hidapi/linux/hid.c");
63+
config
64+
.file("etc/hidapi/libusb/hid.c")
65+
.include("etc/hidapi/hidapi");
66+
let lib = pkg_config::find_library("libusb-1.0").expect("Unable to find libusb-1.0");
67+
for path in lib.include_paths {
68+
config.include(
69+
path.to_str()
70+
.expect("Failed to convert include path to str"),
71+
);
72+
}
73+
config.compile("libhidapi.a");
74+
println!("cargo:rustc-cfg=libusb");
75+
println!("cargo:rustc-cfg=hidapi");
76+
}),
77+
("LINUX_SHARED_HIDRAW", &|| {
78+
pkg_config::probe_library("hidapi-hidraw").expect("Unable to find hidapi-hidraw");
79+
println!("cargo:rustc-cfg=hidapi");
80+
}),
81+
("LINUX_SHARED_LIBUSB", &|| {
82+
pkg_config::probe_library("libusb-1.0").expect("Unable to find libusb-1.0");
83+
pkg_config::probe_library("hidapi-libusb").expect("Unable to find hidapi-libusb");
84+
println!("cargo:rustc-cfg=libusb");
85+
println!("cargo:rustc-cfg=hidapi");
86+
}),
87+
("LINUX_NATIVE", &|| {
88+
// The udev crate takes care of finding its library
89+
}),
10690
];
10791

10892
let mut backends = avail_backends
@@ -143,31 +127,24 @@ fn compile_illumos() {
143127
// First check the features enabled for the crate.
144128
// Only one illumos backend should be enabled at a time.
145129

146-
let avail_backends: [(&'static str, Box<dyn Fn()>); 2] = [
147-
(
148-
"ILLUMOS_STATIC_LIBUSB",
149-
Box::new(|| {
150-
let mut config = cc::Build::new();
151-
config
152-
.file("etc/hidapi/libusb/hid.c")
153-
.include("etc/hidapi/hidapi");
154-
let lib =
155-
pkg_config::find_library("libusb-1.0").expect("Unable to find libusb-1.0");
156-
for path in lib.include_paths {
157-
config.include(
158-
path.to_str()
159-
.expect("Failed to convert include path to str"),
160-
);
161-
}
162-
config.compile("libhidapi.a");
163-
}),
164-
),
165-
(
166-
"ILLUMOS_SHARED_LIBUSB",
167-
Box::new(|| {
168-
pkg_config::probe_library("hidapi-libusb").expect("Unable to find hidapi-libusb");
169-
}),
170-
),
130+
let avail_backends: [(&str, &dyn Fn()); 2] = [
131+
("ILLUMOS_STATIC_LIBUSB", &|| {
132+
let mut config = cc::Build::new();
133+
config
134+
.file("etc/hidapi/libusb/hid.c")
135+
.include("etc/hidapi/hidapi");
136+
let lib = pkg_config::find_library("libusb-1.0").expect("Unable to find libusb-1.0");
137+
for path in lib.include_paths {
138+
config.include(
139+
path.to_str()
140+
.expect("Failed to convert include path to str"),
141+
);
142+
}
143+
config.compile("libhidapi.a");
144+
}),
145+
("ILLUMOS_SHARED_LIBUSB", &|| {
146+
pkg_config::probe_library("hidapi-libusb").expect("Unable to find hidapi-libusb");
147+
}),
171148
];
172149

173150
let mut backends = avail_backends

0 commit comments

Comments
 (0)