| 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 f4e4065f3a63381a2653bdf9b29ebea22387f2a3..2ad816ac14b2e893da9450d30442809885c3ae2c 100644
|
| --- a/tools/gn/ninja_binary_target_writer_unittest.cc
|
| +++ b/tools/gn/ninja_binary_target_writer_unittest.cc
|
| @@ -38,10 +38,7 @@ TEST(NinjaBinaryTargetWriter, SourceSet) {
|
| "defines =\n"
|
| "include_dirs =\n"
|
| "cflags =\n"
|
| - "cflags_c =\n"
|
| "cflags_cc =\n"
|
| - "cflags_objc =\n"
|
| - "cflags_objcc =\n"
|
| "root_out_dir = .\n"
|
| "target_out_dir = obj/foo\n"
|
| "target_output_name = bar\n"
|
| @@ -70,11 +67,6 @@ TEST(NinjaBinaryTargetWriter, SourceSet) {
|
| const char expected[] =
|
| "defines =\n"
|
| "include_dirs =\n"
|
| - "cflags =\n"
|
| - "cflags_c =\n"
|
| - "cflags_cc =\n"
|
| - "cflags_objc =\n"
|
| - "cflags_objcc =\n"
|
| "root_out_dir = .\n"
|
| "target_out_dir = obj/foo\n"
|
| "target_output_name = libshlib\n"
|
| @@ -108,11 +100,6 @@ TEST(NinjaBinaryTargetWriter, SourceSet) {
|
| const char expected[] =
|
| "defines =\n"
|
| "include_dirs =\n"
|
| - "cflags =\n"
|
| - "cflags_c =\n"
|
| - "cflags_cc =\n"
|
| - "cflags_objc =\n"
|
| - "cflags_objcc =\n"
|
| "root_out_dir = .\n"
|
| "target_out_dir = obj/foo\n"
|
| "target_output_name = libstlib\n"
|
| @@ -138,11 +125,6 @@ TEST(NinjaBinaryTargetWriter, SourceSet) {
|
| const char expected[] =
|
| "defines =\n"
|
| "include_dirs =\n"
|
| - "cflags =\n"
|
| - "cflags_c =\n"
|
| - "cflags_cc =\n"
|
| - "cflags_objc =\n"
|
| - "cflags_objcc =\n"
|
| "root_out_dir = .\n"
|
| "target_out_dir = obj/foo\n"
|
| "target_output_name = libstlib\n"
|
| @@ -196,10 +178,7 @@ TEST(NinjaBinaryTargetWriter, ProductExtensionAndInputDeps) {
|
| "defines =\n"
|
| "include_dirs =\n"
|
| "cflags =\n"
|
| - "cflags_c =\n"
|
| "cflags_cc =\n"
|
| - "cflags_objc =\n"
|
| - "cflags_objcc =\n"
|
| "root_out_dir = .\n"
|
| "target_out_dir = obj/foo\n"
|
| "target_output_name = libshlib\n"
|
| @@ -249,10 +228,7 @@ TEST(NinjaBinaryTargetWriter, EmptyProductExtension) {
|
| "defines =\n"
|
| "include_dirs =\n"
|
| "cflags =\n"
|
| - "cflags_c =\n"
|
| "cflags_cc =\n"
|
| - "cflags_objc =\n"
|
| - "cflags_objcc =\n"
|
| "root_out_dir = .\n"
|
| "target_out_dir = obj/foo\n"
|
| "target_output_name = libshlib\n"
|
| @@ -305,10 +281,7 @@ TEST(NinjaBinaryTargetWriter, SourceSetDataDeps) {
|
| "defines =\n"
|
| "include_dirs =\n"
|
| "cflags =\n"
|
| - "cflags_c =\n"
|
| "cflags_cc =\n"
|
| - "cflags_objc =\n"
|
| - "cflags_objcc =\n"
|
| "root_out_dir = .\n"
|
| "target_out_dir = obj/foo\n"
|
| "target_output_name = inter\n"
|
| @@ -340,10 +313,7 @@ TEST(NinjaBinaryTargetWriter, SourceSetDataDeps) {
|
| "defines =\n"
|
| "include_dirs =\n"
|
| "cflags =\n"
|
| - "cflags_c =\n"
|
| "cflags_cc =\n"
|
| - "cflags_objc =\n"
|
| - "cflags_objcc =\n"
|
| "root_out_dir = .\n"
|
| "target_out_dir = obj/foo\n"
|
| "target_output_name = exe\n"
|
| @@ -380,10 +350,7 @@ TEST(NinjaBinaryTargetWriter, SharedLibraryModuleDefinitionFile) {
|
| "defines =\n"
|
| "include_dirs =\n"
|
| "cflags =\n"
|
| - "cflags_c =\n"
|
| "cflags_cc =\n"
|
| - "cflags_objc =\n"
|
| - "cflags_objcc =\n"
|
| "root_out_dir = .\n"
|
| "target_out_dir = obj/foo\n"
|
| "target_output_name = libbar\n"
|
| @@ -396,3 +363,99 @@ TEST(NinjaBinaryTargetWriter, SharedLibraryModuleDefinitionFile) {
|
| " output_extension = .so\n";
|
| EXPECT_EQ(expected, out.str());
|
| }
|
| +
|
| +TEST(NinjaBinaryTargetWriter, WinPrecompiledHeaders) {
|
| + Err err;
|
| +
|
| + // This setup's toolchain does not have precompiled headers defined.
|
| + TestWithScope setup;
|
| +
|
| + // A precompiled header toolchain.
|
| + Settings pch_settings(setup.build_settings(), "withpch/");
|
| + Toolchain pch_toolchain(&pch_settings,
|
| + Label(SourceDir("//toolchain/"), "withpch"));
|
| +
|
| + // Declare a C++ compiler that supports PCH.
|
| + scoped_ptr<Tool> cxx_tool(new Tool);
|
| + TestWithScope::SetCommandForTool(
|
| + "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} "
|
| + "-o {{output}}",
|
| + cxx_tool.get());
|
| + cxx_tool->set_outputs(SubstitutionList::MakeForTest(
|
| + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o"));
|
| + cxx_tool->set_precompiled_header_type(Tool::PCH_MSVC);
|
| + pch_toolchain.SetTool(Toolchain::TYPE_CXX, cxx_tool.Pass());
|
| + pch_toolchain.ToolchainSetupComplete();
|
| +
|
| + // This target doesn't specify precompiled headers.
|
| + {
|
| + Target no_pch_target(&pch_settings,
|
| + Label(SourceDir("//foo/"), "no_pch_target"));
|
| + no_pch_target.set_output_type(Target::SOURCE_SET);
|
| + no_pch_target.visibility().SetPublic();
|
| + no_pch_target.sources().push_back(SourceFile("//foo/input1.cc"));
|
| + no_pch_target.SetToolchain(&pch_toolchain);
|
| + ASSERT_TRUE(no_pch_target.OnResolved(&err));
|
| +
|
| + std::ostringstream out;
|
| + NinjaBinaryTargetWriter writer(&no_pch_target, out);
|
| + writer.Run();
|
| +
|
| + const char no_pch_expected[] =
|
| + "defines =\n"
|
| + "include_dirs =\n"
|
| + "cflags =\n"
|
| + "cflags_cc =\n"
|
| + "target_output_name = no_pch_target\n"
|
| + "\n"
|
| + "build withpch/obj/foo/no_pch_target.input1.o: "
|
| + "cxx ../../foo/input1.cc\n"
|
| + "\n"
|
| + "build withpch/obj/foo/no_pch_target.stamp: "
|
| + "stamp withpch/obj/foo/no_pch_target.input1.o\n";
|
| + EXPECT_EQ(no_pch_expected, out.str());
|
| + }
|
| +
|
| + // This target specifies PCH.
|
| + {
|
| + Target pch_target(&pch_settings,
|
| + Label(SourceDir("//foo/"), "pch_target"));
|
| + pch_target.config_values().set_precompiled_header("build/precompile.h");
|
| + pch_target.config_values().set_precompiled_source(
|
| + SourceFile("//build/precompile.cc"));
|
| + pch_target.set_output_type(Target::SOURCE_SET);
|
| + pch_target.visibility().SetPublic();
|
| + pch_target.sources().push_back(SourceFile("//foo/input1.cc"));
|
| + pch_target.SetToolchain(&pch_toolchain);
|
| + ASSERT_TRUE(pch_target.OnResolved(&err));
|
| +
|
| + std::ostringstream out;
|
| + NinjaBinaryTargetWriter writer(&pch_target, out);
|
| + writer.Run();
|
| +
|
| + const char pch_win_expected[] =
|
| + "defines =\n"
|
| + "include_dirs =\n"
|
| + "cflags =\n"
|
| + // There should only be one .pch file created, for C++ files.
|
| + "cflags_cc = /Fpwithpch/obj/foo/pch_target_cc.pch "
|
| + "/Yubuild/precompile.h\n"
|
| + "target_output_name = pch_target\n"
|
| + "\n"
|
| + // Compile the precompiled source file with /Yc.
|
| + "build withpch/obj/build/pch_target.precompile.cc.o: "
|
| + "cxx ../../build/precompile.cc\n"
|
| + " cflags_cc = ${cflags_cc} /Ycbuild/precompile.h\n"
|
| + "\n"
|
| + "build withpch/obj/foo/pch_target.input1.o: "
|
| + "cxx ../../foo/input1.cc | "
|
| + // Explicit dependency on the PCH build step.
|
| + "withpch/obj/build/pch_target.precompile.cc.o\n"
|
| + "\n"
|
| + "build withpch/obj/foo/pch_target.stamp: "
|
| + "stamp withpch/obj/foo/pch_target.input1.o "
|
| + // The precompiled object file was added to the outputs.
|
| + "withpch/obj/build/pch_target.precompile.cc.o\n";
|
| + EXPECT_EQ(pch_win_expected, out.str());
|
| + }
|
| +}
|
|
|