Skip to content

Commit

Permalink
Check for unknown rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
dillof committed Aug 6, 2024
1 parent fab3e5a commit 70cbe00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include "File.h"
#include <Exception.h>

Build::Build(const File* file, Tokenizer& tokenizer): ScopedDirective(file) {
outputs = Dependencies{tokenizer, true};
Expand All @@ -45,6 +46,10 @@ Build::Build(const File* file, Tokenizer& tokenizer): ScopedDirective(file) {
Build::Build(const File* file, std::string rule_name, Dependencies outputs, Dependencies inputs, Bindings bindings): ScopedDirective{file, std::move(bindings)}, rule_name{std::move(rule_name)}, outputs{std::move(outputs)}, inputs{std::move(inputs)} {}

void Build::process(const File& file) {
rule = file.find_rule(rule_name);
if (!rule) {
throw Exception("unknown rule %s", rule_name.c_str());
}
inputs.resolve(file);
bindings.resolve(file);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/filename-source-vs-build.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rule a
command = a $in $out

build file: a input
build output: file sub/file
build output: a file sub/file

subninja sub/build.fninja
end-of-inline-data
Expand All @@ -32,7 +32,7 @@ rule fast-ninja

build file : a ../input

build output : file sub/file
build output : a file sub/file

build build.ninja sub/build.ninja : fast-ninja ../build.fninja ../sub/build.fninja

Expand Down

0 comments on commit 70cbe00

Please sign in to comment.