| Index: tools/gn/ninja_binary_target_writer_unittest.cc
|
| diff --git a/tools/gn/ninja_binary_target_writer_unittest.cc b/tools/gn/ninja_binary_target_writer_unittest.cc
|
| index f2297fbf206e22f3af71e2a3e119a2024004acac..1cfdb56f2e96b7afa77bdd015356ff7cac2f8258 100644
|
| --- a/tools/gn/ninja_binary_target_writer_unittest.cc
|
| +++ b/tools/gn/ninja_binary_target_writer_unittest.cc
|
| @@ -854,3 +854,85 @@ TEST(NinjaBinaryTargetWriter, DupeObjFileError) {
|
| // Should have issued an error.
|
| EXPECT_TRUE(scheduler.is_failed());
|
| }
|
| +
|
| +// This tests that output extension and output dir overrides apply, and input
|
| +// dependencies are applied.
|
| +TEST(NinjaBinaryTargetWriter, InputFiles) {
|
| + TestWithScope setup;
|
| + Err err;
|
| +
|
| + setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
|
| +
|
| + // This target has one input.
|
| + {
|
| + Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
|
| + target.set_output_type(Target::SOURCE_SET);
|
| + target.visibility().SetPublic();
|
| + target.sources().push_back(SourceFile("//foo/input1.cc"));
|
| + target.sources().push_back(SourceFile("//foo/input2.cc"));
|
| + target.inputs().push_back(SourceFile("//foo/input.data"));
|
| + target.SetToolchain(setup.toolchain());
|
| + ASSERT_TRUE(target.OnResolved(&err));
|
| +
|
| + std::ostringstream out;
|
| + NinjaBinaryTargetWriter writer(&target, out);
|
| + writer.Run();
|
| +
|
| + const char expected[] =
|
| + "defines =\n"
|
| + "include_dirs =\n"
|
| + "cflags =\n"
|
| + "cflags_cc =\n"
|
| + "root_out_dir = .\n"
|
| + "target_out_dir = obj/foo\n"
|
| + "target_output_name = bar\n"
|
| + "\n"
|
| + "build obj/foo/bar.input1.o: cxx ../../foo/input1.cc"
|
| + " | ../../foo/input.data\n"
|
| + "build obj/foo/bar.input2.o: cxx ../../foo/input2.cc"
|
| + " | ../../foo/input.data\n"
|
| + "\n"
|
| + "build obj/foo/bar.stamp: stamp obj/foo/bar.input1.o "
|
| + "obj/foo/bar.input2.o\n";
|
| +
|
| + EXPECT_EQ(expected, out.str());
|
| + }
|
| +
|
| + // This target has multiple inputs.
|
| + {
|
| + Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
|
| + target.set_output_type(Target::SOURCE_SET);
|
| + target.visibility().SetPublic();
|
| + target.sources().push_back(SourceFile("//foo/input1.cc"));
|
| + target.sources().push_back(SourceFile("//foo/input2.cc"));
|
| + target.inputs().push_back(SourceFile("//foo/input1.data"));
|
| + target.inputs().push_back(SourceFile("//foo/input2.data"));
|
| + target.SetToolchain(setup.toolchain());
|
| + ASSERT_TRUE(target.OnResolved(&err));
|
| +
|
| + std::ostringstream out;
|
| + NinjaBinaryTargetWriter writer(&target, out);
|
| + writer.Run();
|
| +
|
| + const char expected[] =
|
| + "defines =\n"
|
| + "include_dirs =\n"
|
| + "cflags =\n"
|
| + "cflags_cc =\n"
|
| + "root_out_dir = .\n"
|
| + "target_out_dir = obj/foo\n"
|
| + "target_output_name = bar\n"
|
| + "\n"
|
| + "build obj/foo/bar.inputs.stamp: stamp"
|
| + " ../../foo/input1.data ../../foo/input2.data\n"
|
| + "build obj/foo/bar.input1.o: cxx ../../foo/input1.cc"
|
| + " | obj/foo/bar.inputs.stamp\n"
|
| + "build obj/foo/bar.input2.o: cxx ../../foo/input2.cc"
|
| + " | obj/foo/bar.inputs.stamp\n"
|
| + "\n"
|
| + "build obj/foo/bar.stamp: stamp obj/foo/bar.input1.o "
|
| + "obj/foo/bar.input2.o\n";
|
| +
|
| + EXPECT_EQ(expected, out.str());
|
| + }
|
| +}
|
|
|