-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotbuild.rs
117 lines (107 loc) · 6.17 KB
/
notbuild.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
use std::env;
use std::path::PathBuf;
#[warn(non_snake_case)]
fn main() {
return;
//let CLANG_PATH = env::var("LIBCLANG_PATH").unwrap();
let arduino_hardware_path = PathBuf::from(env::var("ARDUINO_HARDWARE").unwrap());
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
//println!("cargo:rustc-link-lib=static={}", out_dir.join("arduino_c++").display());
println!("cargo:rerun-if-changed=dht11/dht.cpp");
println!("cargo:rerun-if-changed=dht11/dht.h");
println!("cargo:rustc-link-search={}", arduino_hardware_path.join("/arduino/avr/cores/arduino").display());
println!("cargo:rustc-link-search={}", arduino_hardware_path.join("/arduino/avr/variants/standard").display());
println!("cargo:rustc-link-search={}", arduino_hardware_path.join("/tools/avr/avr/lib").display());
println!("cargo:rustc-link-search={}", out_dir.display());
//println!("cargo:rustc-link-search={}", arduino_hardware_path.join("/tools/avr/avr/lib/avr5/").display());
//println!("cargo:rustc-link-search={}", arduino_hardware_path.join("arduion/avr/v").display());
//println!("cargo:rerun-if-changed=OneWire-2.3.7/OneWire.h");
/*
cc::Build::new()
.compiler("avr-gcc")
.cpp(false)
.flag("-std=gnu11")
.include("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/cores/arduino/")
.include("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/variants/standard")
.include("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/tools/avr/avr/include/")
.include("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/tools/avr/avr/include/util")
.include("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/tools/avr/avr/include/avr")
.include("DHT11/src")
.file("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/cores/arduino/wiring_digital.c")
.file("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/cores/arduino/wiring_analog.c")
.file("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/cores/arduino/hooks.c")
.file("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/cores/arduino/wiring.c")
.flag("-fpermissive")
.flag("-fno-exceptions")
.flag("-ffunction-sections")
.flag("-fdata-sections")
.flag("-fno-threadsafe-statics")
.define("F_CPU", "16000000L")
.define("ARDUINO", "10807")
.define("ARDUINO_AVR_UNO", None)
.define("ARDUINO_ARCH_AVR", None)
.flag("-mmcu=atmega328p")
.flag("-Os")
.compile("libarduino_c.a");
println!("cargo:rustc-link-lib=static=arduino_c");
*/
cc::Build::new()
.compiler("avr-g++")
.cpp(true)
.include("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/cores/arduino/")
.include("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/variants/standard")
.include("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/tools/avr/avr/include/")
.include("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/tools/avr/avr/include/util")
.include("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/tools/avr/avr/include/avr")
.include("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/libraries/Wire/src/")
.include(out_dir.to_str().unwrap())
.include("DHT11/src")
//.file("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/libraries/Wire/src/Wire.cpp")
//.file("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/cores/arduino/wiring_digital.c")
.object("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/tools/avr/avr/lib/avr5/crtatmega328p.o")
//.file("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/cores/arduino/hooks.c")
.file("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/cores/arduino/wiring.c")
.file("DHT11/src/DHT11.cpp")
//.file("/nix/store/sr5hx0nml4h35r9njzfspbcr4l7z14ks-arduino-1.8.19/share/arduino/hardware/arduino/avr/cores/arduino/main.cpp")
.define("F_CPU", "16000000L")
.define("ARDUINO", "10807")
.define("ARDUINO_AVR_UNO", None)
.define("ARDUINO_ARCH_AVR", None)
.flag("-mmcu=atmega328p")
.flag("-Os")
.flag("-std=gnu++11")
.cpp_set_stdlib(None)
.flag("-fpermissive")
.flag("-fno-exceptions")
.flag("-ffunction-sections")
.flag("-fdata-sections")
.flag("-fno-threadsafe-statics")
.compile("libarduino_c++.a");
println!("cargo:rustc-link-lib=static=arduino_c++");
let bindings = bindgen::Builder::default()
.header("DHT11/src/DHT11.h")
//.clang_arg("-x").clang_arg("c++").clang_arg("-std=gnu++11")
.clang_args(&[
"-DF_CPU=16000000L",
"-DARDUINO=10807",
"-DARDUINO_AVR_UNO",
"-DARDUINO_ARCH_AVR",
"-mmcu=atmega328p",
"-v",
"-x",
"c++",
"-std=gnu++11",
"--target=avr",
"-nostdlibinc",
//"--gcc-install-dir /nix/store/vc2s0x87l7kykmzc4ad3kbq6ndal6k5m-avr-stage-final-gcc-12.3.0/lib/gcc/avr/12.3.0"
])
.size_t_is_usize(false)
.use_core()
.layout_tests(false)
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings");
}