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
use std::{path::PathBuf, sync::Arc};
#[derive(Clone)]
pub struct BuildConfig {
pub(crate) canonical_root_module: Arc<PathBuf>,
pub(crate) print_intermediate_asm: bool,
pub(crate) print_finalized_asm: bool,
pub(crate) print_ir: bool,
}
impl BuildConfig {
pub fn root_from_file_name_and_manifest_path(
root_module: PathBuf,
canonical_manifest_dir: PathBuf,
) -> Self {
assert!(
canonical_manifest_dir.has_root(),
"manifest dir must be a canonical path",
);
let canonical_root_module = match root_module.has_root() {
true => root_module,
false => {
assert!(
root_module.starts_with(canonical_manifest_dir.file_stem().unwrap()),
"file_name must be either absolute or relative to manifest directory",
);
canonical_manifest_dir
.parent()
.expect("unable to retrieve manifest directory parent")
.join(&root_module)
}
};
Self {
canonical_root_module: Arc::new(canonical_root_module),
print_intermediate_asm: false,
print_finalized_asm: false,
print_ir: false,
}
}
pub fn print_intermediate_asm(self, a: bool) -> Self {
Self {
print_intermediate_asm: a,
..self
}
}
pub fn print_finalized_asm(self, a: bool) -> Self {
Self {
print_finalized_asm: a,
..self
}
}
pub fn print_ir(self, a: bool) -> Self {
Self {
print_ir: a,
..self
}
}
pub fn canonical_root_module(&self) -> Arc<PathBuf> {
self.canonical_root_module.clone()
}
}