From 68db8d315e3ef67c608cb2eddca16fd5e5fddccb Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sun, 4 Apr 2021 12:01:03 -0600 Subject: logging! --- Cargo.lock | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 ++ README.md | 2 ++ src/main.rs | 1 + src/makefile/input.rs | 5 +++++ src/makefile/mod.rs | 7 +++++++ src/makefile/target.rs | 11 +++++++++++ 7 files changed, 76 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 46017a2..9e21f23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -196,6 +196,19 @@ dependencies = [ "winapi", ] +[[package]] +name = "env_logger" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "eyre" version = "0.6.5" @@ -264,6 +277,12 @@ dependencies = [ "libc", ] +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "indenter" version = "0.3.3" @@ -304,15 +323,26 @@ version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7" +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + [[package]] name = "makers" version = "0.4.0" dependencies = [ "dirs", + "env_logger", "eyre", "glob", "jane-eyre", "lazy_static", + "log", "nom", "regex", "structopt", @@ -618,6 +648,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -747,6 +786,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 6dbd509..550fcf9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,10 +16,12 @@ full = ['dirs', 'glob'] [dependencies] dirs = { version = "3.0.1", optional = true } +env_logger = "0.8.3" eyre = "0.6.5" glob = { version = "0.3.0", optional = true } jane-eyre = "0.3.0" lazy_static = "1.4.0" +log = "0.4.14" nom = "6.1.2" regex = "1.4.5" structopt = "0.3.21" diff --git a/README.md b/README.md index cb262cd..f8ff6e4 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ A (mostly) [POSIX-compatible](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html) make implemented in Rust. Not explicitly aiming for full support for [every GNU make feature](https://www.gnu.org/software/make/manual/html_node/index.html), but adding whichever features are strictly necessary to be compatible with existing GNUish makefiles. +You can get slightly more info by running with `RUST_LOG=makers=warn`, much more info with `RUST_LOG=makers=debug`, and an avalanche of info (probably only useful in small doses for debugging your makefile or makers itself) with `RUST_LOG=makers=trace`. + ## conformance - internationalization (`LANG`/`LC_ALL`/`LC_CTYPE`/`LC_MESSAGES`) not implemented diff --git a/src/main.rs b/src/main.rs index ceeb0cf..58d3cba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,6 +40,7 @@ const DEFAULT_PATHS: &[&str] = &[ ]; fn main() -> Result<()> { + env_logger::init(); jane_eyre::install()?; let mut args = Args::from_env_and_args(); diff --git a/src/makefile/input.rs b/src/makefile/input.rs index d6f6254..6ee5392 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -413,6 +413,11 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { inference_match.name("s2").unwrap().as_str().to_owned(), commands, ); + log::trace!( + "suffix-based inference rule defined by {:?} - {:?}", + &inference_match, + &new_rule, + ); self.inference_rules.retain(|existing_rule| { (&existing_rule.prerequisites, &existing_rule.products) diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index e13ecff..0f8cfd2 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -153,9 +153,16 @@ impl<'a> Makefile<'a> { .chain(self.builtin_inference_rules.iter()) .filter(|rule| rule.matches(name).unwrap_or(false)); for rule in inference_rule_candidates { + log::trace!( + "{:>58} considering rule to build {:?} from {:?}", + name, + &rule.products, + &rule.prerequisites + ); // whose prerequisite file ($*.s2) exists. let prereq_paths = rule .prereqs(name)? + .inspect(|x| log::trace!("{:>58} prereq {}", name, x)) .map(|prereq_path_name| { if name == prereq_path_name { // we can't build this based on itself! fuck outta here diff --git a/src/makefile/target.rs b/src/makefile/target.rs index ad46884..1c382d0 100644 --- a/src/makefile/target.rs +++ b/src/makefile/target.rs @@ -53,6 +53,12 @@ impl Target { .and_then(|t| self.newer_than(&t.borrow())) .unwrap_or(false) }); + log::trace!( + "{:>50} exists: {}, newer than dependencies: {}", + self.name, + exists, + newer_than_all_dependencies + ); exists && newer_than_all_dependencies } @@ -62,6 +68,10 @@ impl Target { .wrap_err_with(|| format!("as a dependency for target {}", self.name))?; } if !self.is_up_to_date(file) { + log::debug!("rebuilding {}...", self.name); + if self.commands.is_empty() { + log::warn!("no commands found to rebuild {}", self.name); + } self.execute_commands(file) .wrap_err_with(|| format!("while updating target {}", self.name))?; } @@ -72,6 +82,7 @@ impl Target { fn execute_commands(&self, file: &Makefile) -> Result<()> { for command in &self.commands { + log::trace!(" executing {}", command); command.execute(file, self)?; } -- cgit v1.2.3