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
#![cfg(target_os = "windows")]
#![deny(
clippy::all,
clippy::pedantic,
warnings,
future_incompatible,
rust_2018_idioms,
rustdoc,
unused,
deprecated_in_future,
missing_copy_implementations,
missing_debug_implementations,
non_ascii_idents,
trivial_casts,
trivial_numeric_casts,
unreachable_pub,
unused_import_braces,
unused_lifetimes,
unused_results
)]
#![allow(clippy::must_use_candidate, missing_doc_code_examples)]
#[macro_use(concat_string)]
extern crate concat_string;
#[cfg(target_env = "msvc")]
extern crate find_winsdk;
use std::io;
use std::path::{Path, PathBuf};
#[cfg(target_env = "gnu")]
#[path = "gnu.rs"]
mod imp;
#[cfg(target_env = "msvc")]
#[path = "msvc.rs"]
mod imp;
#[derive(Clone, Debug)]
pub struct Build {
extra_include_dirs: Vec<PathBuf>,
extra_cpp_defs: Vec<(String, Option<String>)>,
cpp_undefs: Vec<String>,
}
impl Build {
pub fn new() -> Self {
Self {
extra_include_dirs: Vec::new(),
extra_cpp_defs: Vec::new(),
cpp_undefs: Vec::new(),
}
}
pub fn include<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.extra_include_dirs.push(path.as_ref().to_owned());
self
}
pub fn define<'a, V: Into<Option<&'a str>>>(&mut self, name: &str, value: V) -> &mut Self {
self.extra_cpp_defs
.push((name.to_owned(), value.into().map(ToOwned::to_owned)));
self
}
pub fn undefine(&mut self, name: &str) -> &mut Self {
self.cpp_undefs.push(name.to_owned());
self
}
pub fn compile<P: AsRef<Path>>(&mut self, rc_file: P) -> io::Result<()> {
Self::find_resource_compiler().and_then(|compiler| self.compile_resource(rc_file, compiler))
}
}
impl Default for Build {
fn default() -> Self {
Self::new()
}
}