Skip to content

Commit

Permalink
Fix preferring build files over source files.
Browse files Browse the repository at this point in the history
  • Loading branch information
dillof committed May 3, 2024
1 parent 4f1d577 commit e36e662
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Filename.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void Filename::resolve(const ResolveContext& context) {
if (context.scope.is_output_file((file->build_directory / name).lexically_normal())) {
type = Type::BUILD;
}
if (std::filesystem::exists(file->source_directory / name)) {
else if (std::filesystem::exists(file->source_directory / name)) {
type = Type::SOURCE;
}
}
Expand Down
49 changes: 49 additions & 0 deletions tests/filename-source-vs-build.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
arguments ..
file input empty
file file empty
file sub/file empty
file build.fninja <>
rule a
command = a $in $out

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

subninja sub/build.fninja
end-of-inline-data
file sub/build.fninja <>
build file: a ../input
end-of-inline-data
file build/build.ninja {} <>
# This file is automatically created by fast-ninja from ../build.fninja
# Do not edit.

build_directory = .
source_directory = ..
top_build_directory = .
top_source_directory = ..

rule a
command = a $in $out

rule fast-ninja
command = fast-ninja ..
generator = 1

build file : a ../input

build output : file sub/file

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

subninja sub/build.ninja
end-of-inline-data
file build/sub/build.ninja {} <>
# This file is automatically created by fast-ninja from ../sub/build.fninja
# Do not edit.

build_directory = sub
source_directory = ../sub

build sub/file : a ../input
end-of-inline-data

0 comments on commit e36e662

Please sign in to comment.