This repository was archived by the owner on Feb 26, 2020. It is now read-only.
forked from ruabmbua/hidapi-rs
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.rs
48 lines (42 loc) · 1.76 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// **************************************************************************
// Copyright (c) 2015 Roland Ruckerbauer All Rights Reserved.
//
// This file is part of hidapi_rust.
//
// hidapi_rust is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// hidapi_rust is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with hidapi_rust. If not, see <http://www.gnu.org/licenses/>.
// *************************************************************************
extern crate cc;
use std::env;
fn main() {
let target = env::var("TARGET").unwrap();
if target.contains("windows") {
cc::Build::new()
.file("etc/hidapi/windows/hid.c")
.include("etc/hidapi/hidapi")
.compile("libhidapi.a");
println!("cargo:rustc-link-lib=setupapi");
} else if target.contains("darwin") {
cc::Build::new()
.file("etc/hidapi/mac/hid.c")
.include("etc/hidapi/hidapi")
.compile("libhidapi.a");
println!("cargo:rustc-link-lib=framework=IOKit");
println!("cargo:rustc-link-lib=framework=CoreFoundation");
} else if target.contains("linux") {
let mut config = cc::Build::new();
config.file("etc/hidapi/linux/hid.c").include("etc/hidapi/hidapi");
config.compile("libhidapi.a");
println!("cargo:rustc-link-lib=udev");
}
}