diff options
author | Melody Horn <melody@boringcactus.com> | 2021-03-23 23:27:45 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-03-23 23:27:45 -0600 |
commit | 1844cb79ae82e71610573f133c5ed7aeeb0c50b6 (patch) | |
tree | 5f304a13473e67440d411ab0fee15d116a57d126 /src/main.rs | |
parent | 05b8b6339c4b00b0e898c8456677be2883c8a072 (diff) | |
download | makers-1844cb79ae82e71610573f133c5ed7aeeb0c50b6.tar.gz makers-1844cb79ae82e71610573f133c5ed7aeeb0c50b6.zip |
man i don't even fuckin know anymore
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 2316546..4048886 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,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 args = Args::from_env_and_args(); - dbg!(args); + 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); + }; + } } |