diff --git a/fud2/fud-core/src/run.rs b/fud2/fud-core/src/run.rs index b3fef72f6..50a1a8b62 100644 --- a/fud2/fud-core/src/run.rs +++ b/fud2/fud-core/src/run.rs @@ -183,11 +183,6 @@ impl EmitBuild for RulesOp { )?; } - // If the sequences of rules was empty, output a phoney rule creating the desired output. - if self.cmds.is_empty() { - emitter.build_cmd(outputs, "phony", inputs, &[])?; - } - Ok(()) } } diff --git a/fud2/fud-core/src/script/error.rs b/fud2/fud-core/src/script/error.rs index 2a803b4e4..903e4794b 100644 --- a/fud2/fud-core/src/script/error.rs +++ b/fud2/fud-core/src/script/error.rs @@ -21,6 +21,7 @@ pub(super) enum RhaiSystemErrorKind { ExpectedString(String), ExpectedShell, ExpectedShellDeps, + EmptyOp, } impl RhaiSystemError { @@ -90,6 +91,13 @@ impl RhaiSystemError { } } + pub(super) fn empty_op() -> Self { + Self { + kind: RhaiSystemErrorKind::EmptyOp, + position: rhai::Position::NONE, + } + } + pub(super) fn with_pos(mut self, p: rhai::Position) -> Self { self.position = p; self @@ -126,6 +134,9 @@ impl Display for RhaiSystemError { RhaiSystemErrorKind::ExpectedShellDeps => { write!(f, "Expected `shell_deps`, got shell. Ops may contain only one of `shell` or `shell_deps` calls, not calls to both") } + RhaiSystemErrorKind::EmptyOp => { + write!(f, "Error: Op must contain at least one call to `shell` or `shell_deps`.") + } } } } diff --git a/fud2/fud-core/src/script/plugin.rs b/fud2/fud-core/src/script/plugin.rs index 040e32db3..0158d485b 100644 --- a/fud2/fud-core/src/script/plugin.rs +++ b/fud2/fud-core/src/script/plugin.rs @@ -352,8 +352,16 @@ impl ScriptContext { c } Some(ShellCommands::Cmds(c)) => c.clone(), - None => vec![], + + None => { + // If cmds is empty, then the op doesn't do anything and should be considered + // erroneous. + return Err(RhaiSystemError::empty_op() + .with_pos(pos) + .into()); + } }; + let op_name = name.clone(); let config_vars = config_vars.clone(); let op_emitter = crate::run::RulesOp {