blob: 404888651d351c2b98ab4d079cc80ddd75a52440 (
plain)
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
|
use std::fs::metadata;
use std::io::stdin;
use std::path::PathBuf;
mod args;
mod makefile;
use args::Args;
use makefile::Makefile;
fn main() {
let mut args = Args::from_env_and_args();
// If no makefile is specified, try some options.
if args.makefile.is_empty() {
if metadata("./makefile").is_ok() {
args.makefile = vec!["./makefile".into()];
} else if metadata("./Makefile").is_ok() {
args.makefile = vec!["./Makefile".into()];
} else {
// TODO handle error gracefully
panic!("no makefile found");
}
}
// Read in the makefile(s) specified.
// TODO dump command-line args into MAKEFLAGS
// TODO dump command-line macros into environment
// TODO add SHELL macro
let mut makefile = Makefile::new(args.clone());
if !args.no_builtin_rules {
makefile.add_builtins();
}
makefile.add_env();
for filename in &args.makefile {
if filename == &PathBuf::from("-") {
makefile.and_read(stdin().lock());
} else {
makefile.and_read_file(filename);
};
}
}
|