-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.rs
40 lines (33 loc) · 1.07 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
extern crate inflector;
#[macro_use] extern crate log;
#[macro_use] #[no_link]
extern crate matches;
#[macro_use] extern crate nom;
#[path = "src/clientgen/mod.rs"]
mod clientgen;
use std::ffi::OsString;
use std::fs;
use std::path::Path;
fn main() {
let out_dir = std::env::var_os("OUT_DIR").unwrap();
clients(&out_dir);
}
fn clients(out_dir: &OsString) {
struct WarningLogger;
impl log::Log for WarningLogger {
fn enabled(&self, metadata: &log::LogMetadata) -> bool {
metadata.level() <= log::LogLevel::Warn
}
fn log(&self, record: &log::LogRecord) {
if self.enabled(record.metadata()) {
println!("cargo:warning={}", record.args());
}
}
}
log::set_logger(|max_log_level| {
max_log_level.set(log::LogLevelFilter::Warn);
Box::new(WarningLogger)
}).unwrap();
let mut dst_file = fs::File::create(Path::new(out_dir).join("clients.rs")).unwrap();
clientgen::generate_clients(&mut dst_file, "./CoreTweet/ApiTemplates", "./api_templates_override").unwrap();
}