diff --git a/src/Filename.cc b/src/Filename.cc index cc7e0a2..d4d6c9c 100644 --- a/src/Filename.cc +++ b/src/Filename.cc @@ -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; } } diff --git a/tests/filename-source-vs-build.test b/tests/filename-source-vs-build.test new file mode 100644 index 0000000..3d1fd1e --- /dev/null +++ b/tests/filename-source-vs-build.test @@ -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