diff --git a/src/graph.rs b/src/graph.rs index 6d36753..f3577c1 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -317,6 +317,10 @@ impl GraphFiles { id }) } + + pub fn all_ids(&self) -> impl Iterator { + (0..self.by_id.next_id().0).map(|id| FileId(id)) + } } /// MTime info gathered for a file. This also models "file is absent". diff --git a/src/run.rs b/src/run.rs index 45d7565..7814448 100644 --- a/src/run.rs +++ b/src/run.rs @@ -77,7 +77,9 @@ fn build( work.want_file(target)?; } } else { - anyhow::bail!("no path specified and no default"); + work.progress + .log("no path specified and no default target; building everything"); + work.want_every_file(build_file_target)?; } let tasks = trace::scope("work.run", || work.run())?; diff --git a/src/work.rs b/src/work.rs index cd73a70..c8d6ca0 100644 --- a/src/work.rs +++ b/src/work.rs @@ -241,11 +241,11 @@ impl BuildStates { anyhow::bail!(err); } - stack.push(id); if let Some(bid) = graph.file(id).input { + stack.push(id); self.want_build(graph, stack, bid)?; + stack.pop(); } - stack.pop(); Ok(()) } @@ -309,7 +309,7 @@ pub struct Options { pub struct Work<'a> { graph: Graph, db: db::Writer, - progress: &'a mut dyn Progress, + pub progress: &'a mut dyn Progress, options: Options, file_state: FileState, last_hashes: Hashes, @@ -347,6 +347,18 @@ impl<'a> Work<'a> { self.build_states.want_file(&self.graph, &mut stack, id) } + pub fn want_every_file(&mut self, exclude: Option) -> anyhow::Result<()> { + for id in self.graph.files.all_ids() { + if let Some(exclude) = exclude { + if id == exclude { + continue; + } + } + self.want_file(id)?; + } + Ok(()) + } + /// Check whether a given build is ready, generally after one of its inputs /// has been updated. fn recheck_ready(&self, id: BuildId) -> bool { diff --git a/tests/e2e/basic.rs b/tests/e2e/basic.rs index 79db2c5..4e9b310 100644 --- a/tests/e2e/basic.rs +++ b/tests/e2e/basic.rs @@ -7,7 +7,7 @@ fn empty_file() -> anyhow::Result<()> { let out = space.run(&mut n2_command(vec![]))?; assert_eq!( std::str::from_utf8(&out.stdout)?, - "n2: error: no path specified and no default\n" + "no path specified and no default target; building everything\n" ); Ok(()) }