-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
87 lines (62 loc) · 1.04 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
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
use std::error::Error;
use std::io;
use std::io::Write;
use std::fs::File;
fn main () {
match main_real () {
Ok (_) => (),
Err (error) => {
writeln! (
& mut io::stderr (),
"{}",
error,
).unwrap_or (());
},
};
}
fn main_real (
) -> Result <(), String> {
write_metadata (
).map_err (
|io_error|
format! (
"Error writing metadata: {}",
io_error.description ())
) ?;
Ok (())
}
fn write_metadata (
) -> Result <(), io::Error> {
let mut file =
File::create (
"src/metadata.rs",
) ?;
writeln! (
& mut file,
"// WARNING: this file is generated by build.rs, changes will be lost.",
) ?;
writeln! (
& mut file,
"",
) ?;
writeln! (
& mut file,
"pub const VERSION: & 'static str = \"{}\";",
env! ("CARGO_PKG_VERSION"),
) ?;
writeln! (
& mut file,
"pub const AUTHOR: & 'static str = \"{}\";",
"James Pharaoh <[email protected]>",
) ?;
writeln! (
& mut file,
"",
) ?;
writeln! (
& mut file,
"// ex: noet ts=4 filetype=rust",
) ?;
Ok (())
}
// ex: noet ts=4 filetype=rust