| 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 5e0387167c9bda4d03246468644fdc2a4b611241..20f9a8bee96d16788ce5d9cd77203537ca46e9d9 100644
|
| --- a/tools/gn/ninja_binary_target_writer_unittest.cc
|
| +++ b/tools/gn/ninja_binary_target_writer_unittest.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "tools/gn/ninja_binary_target_writer.h"
|
| +#include "tools/gn/target.h"
|
| #include "tools/gn/test_with_scope.h"
|
|
|
| TEST(NinjaBinaryTargetWriter, SourceSet) {
|
| @@ -21,119 +22,107 @@ TEST(NinjaBinaryTargetWriter, SourceSet) {
|
| // dependents to link.
|
| target.sources().push_back(SourceFile("//foo/input3.o"));
|
| target.sources().push_back(SourceFile("//foo/input4.obj"));
|
| + target.SetToolchain(setup.toolchain());
|
| target.OnResolved();
|
|
|
| // Source set itself.
|
| {
|
| std::ostringstream out;
|
| - NinjaBinaryTargetWriter writer(&target, setup.toolchain(), out);
|
| + NinjaBinaryTargetWriter writer(&target, out);
|
| writer.Run();
|
|
|
| - const char expected_win[] =
|
| + const char expected[] =
|
| "defines =\n"
|
| - "includes =\n"
|
| + "include_dirs =\n"
|
| "cflags =\n"
|
| "cflags_c =\n"
|
| "cflags_cc =\n"
|
| "cflags_objc =\n"
|
| "cflags_objcc =\n"
|
| - "target_name = bar\n"
|
| - "target_out_dir = obj/foo\n"
|
| "root_out_dir = \n"
|
| + "target_out_dir = obj/foo\n"
|
| + "target_output_name = bar\n"
|
| "\n"
|
| - "build obj/foo/bar.input1.obj: cxx ../../foo/input1.cc\n"
|
| - "build obj/foo/bar.input2.obj: cxx ../../foo/input2.cc\n"
|
| + "build obj/foo/bar.input1.o: cxx ../../foo/input1.cc\n"
|
| + "build obj/foo/bar.input2.o: cxx ../../foo/input2.cc\n"
|
| "\n"
|
| - "build obj/foo/bar.stamp: stamp obj/foo/bar.input1.obj "
|
| - "obj/foo/bar.input2.obj ../../foo/input3.o ../../foo/input4.obj\n";
|
| + "build obj/foo/bar.stamp: stamp obj/foo/bar.input1.o "
|
| + "obj/foo/bar.input2.o ../../foo/input3.o ../../foo/input4.obj\n";
|
| std::string out_str = out.str();
|
| -#if defined(OS_WIN)
|
| - std::replace(out_str.begin(), out_str.end(), '\\', '/');
|
| -#endif
|
| - EXPECT_EQ(expected_win, out_str);
|
| + EXPECT_EQ(expected, out_str);
|
| }
|
|
|
| // A shared library that depends on the source set.
|
| Target shlib_target(setup.settings(), Label(SourceDir("//foo/"), "shlib"));
|
| shlib_target.set_output_type(Target::SHARED_LIBRARY);
|
| shlib_target.deps().push_back(LabelTargetPair(&target));
|
| + shlib_target.SetToolchain(setup.toolchain());
|
| shlib_target.OnResolved();
|
|
|
| {
|
| std::ostringstream out;
|
| - NinjaBinaryTargetWriter writer(&shlib_target, setup.toolchain(), out);
|
| + NinjaBinaryTargetWriter writer(&shlib_target, out);
|
| writer.Run();
|
|
|
| - const char expected_win[] =
|
| + const char expected[] =
|
| "defines =\n"
|
| - "includes =\n"
|
| + "include_dirs =\n"
|
| "cflags =\n"
|
| "cflags_c =\n"
|
| "cflags_cc =\n"
|
| "cflags_objc =\n"
|
| "cflags_objcc =\n"
|
| - "target_name = shlib\n"
|
| - "target_out_dir = obj/foo\n"
|
| "root_out_dir = \n"
|
| + "target_out_dir = obj/foo\n"
|
| + "target_output_name = libshlib\n"
|
| "\n"
|
| "\n"
|
| - "manifests = obj/foo/shlib.intermediate.manifest\n"
|
| - "ldflags = /MANIFEST /ManifestFile:obj/foo/shlib.intermediate."
|
| - "manifest\n"
|
| - "libs =\n"
|
| // Ordering of the obj files here should come out in the order
|
| // specified, with the target's first, followed by the source set's, in
|
| // order.
|
| - "build shlib.dll shlib.dll.lib: solink obj/foo/bar.input1.obj "
|
| - "obj/foo/bar.input2.obj ../../foo/input3.o "
|
| - "../../foo/input4.obj\n"
|
| - " soname = shlib.dll\n"
|
| - " lib = shlib.dll\n"
|
| - " dll = shlib.dll\n"
|
| - " implibflag = /IMPLIB:shlib.dll.lib\n\n";
|
| + "build libshlib.so: solink obj/foo/bar.input1.o "
|
| + "obj/foo/bar.input2.o ../../foo/input3.o ../../foo/input4.obj\n"
|
| + " ldflags =\n"
|
| + " libs =\n"
|
| + " output_extension = .so\n";
|
| std::string out_str = out.str();
|
| -#if defined(OS_WIN)
|
| - std::replace(out_str.begin(), out_str.end(), '\\', '/');
|
| -#endif
|
| - EXPECT_EQ(expected_win, out_str);
|
| + EXPECT_EQ(expected, out_str);
|
| }
|
|
|
| // A static library that depends on the source set (should not link it).
|
| Target stlib_target(setup.settings(), Label(SourceDir("//foo/"), "stlib"));
|
| stlib_target.set_output_type(Target::STATIC_LIBRARY);
|
| stlib_target.deps().push_back(LabelTargetPair(&target));
|
| + stlib_target.SetToolchain(setup.toolchain());
|
| stlib_target.OnResolved();
|
|
|
| {
|
| std::ostringstream out;
|
| - NinjaBinaryTargetWriter writer(&stlib_target, setup.toolchain(), out);
|
| + NinjaBinaryTargetWriter writer(&stlib_target, out);
|
| writer.Run();
|
|
|
| - const char expected_win[] =
|
| + const char expected[] =
|
| "defines =\n"
|
| - "includes =\n"
|
| + "include_dirs =\n"
|
| "cflags =\n"
|
| "cflags_c =\n"
|
| "cflags_cc =\n"
|
| "cflags_objc =\n"
|
| "cflags_objcc =\n"
|
| - "target_name = stlib\n"
|
| - "target_out_dir = obj/foo\n"
|
| "root_out_dir = \n"
|
| + "target_out_dir = obj/foo\n"
|
| + "target_output_name = libstlib\n"
|
| "\n"
|
| "\n"
|
| - "manifests = obj/foo/stlib.intermediate.manifest\n"
|
| - "ldflags = /MANIFEST /ManifestFile:obj/foo/stlib.intermediate.manifest\n"
|
| - "libs =\n"
|
| - // There are no sources so there are no params to alink.
|
| - "build obj/foo/stlib.lib: alink\n\n";
|
| + // There are no sources so there are no params to alink. (In practice
|
| + // this will probably fail in the archive tool.)
|
| + "build obj/foo/libstlib.a: alink\n"
|
| + " ldflags =\n"
|
| + " libs =\n"
|
| + " output_extension = \n";
|
| std::string out_str = out.str();
|
| -#if defined(OS_WIN)
|
| - std::replace(out_str.begin(), out_str.end(), '\\', '/');
|
| -#endif
|
| - EXPECT_EQ(expected_win, out_str);
|
| + EXPECT_EQ(expected, out_str);
|
| }
|
| -
|
| }
|
|
|
| TEST(NinjaBinaryTargetWriter, ProductExtension) {
|
| @@ -147,39 +136,35 @@ TEST(NinjaBinaryTargetWriter, ProductExtension) {
|
| target.set_output_extension(std::string("so.6"));
|
| target.sources().push_back(SourceFile("//foo/input1.cc"));
|
| target.sources().push_back(SourceFile("//foo/input2.cc"));
|
| + target.SetToolchain(setup.toolchain());
|
| target.OnResolved();
|
|
|
| std::ostringstream out;
|
| - NinjaBinaryTargetWriter writer(&target, setup.toolchain(), out);
|
| + NinjaBinaryTargetWriter writer(&target, out);
|
| writer.Run();
|
|
|
| const char expected[] =
|
| "defines =\n"
|
| - "includes =\n"
|
| + "include_dirs =\n"
|
| "cflags =\n"
|
| "cflags_c =\n"
|
| "cflags_cc =\n"
|
| "cflags_objc =\n"
|
| "cflags_objcc =\n"
|
| - "target_name = shlib\n"
|
| - "target_out_dir = obj/foo\n"
|
| "root_out_dir = \n"
|
| + "target_out_dir = obj/foo\n"
|
| + "target_output_name = libshlib\n"
|
| "\n"
|
| - "build obj/foo/shlib.input1.o: cxx ../../foo/input1.cc\n"
|
| - "build obj/foo/shlib.input2.o: cxx ../../foo/input2.cc\n"
|
| + "build obj/foo/libshlib.input1.o: cxx ../../foo/input1.cc\n"
|
| + "build obj/foo/libshlib.input2.o: cxx ../../foo/input2.cc\n"
|
| "\n"
|
| - "ldflags =\n"
|
| - "libs =\n"
|
| - "build libshlib.so.6: solink obj/foo/shlib.input1.o "
|
| - "obj/foo/shlib.input2.o\n"
|
| - " soname = libshlib.so.6\n"
|
| - " lib = libshlib.so.6\n"
|
| - "\n";
|
| + "build libshlib.so.6: solink obj/foo/libshlib.input1.o "
|
| + "obj/foo/libshlib.input2.o\n"
|
| + " ldflags =\n"
|
| + " libs =\n"
|
| + " output_extension = .so.6\n";
|
|
|
| std::string out_str = out.str();
|
| -#if defined(OS_WIN)
|
| - std::replace(out_str.begin(), out_str.end(), '\\', '/');
|
| -#endif
|
| EXPECT_EQ(expected, out_str);
|
| }
|
|
|
| @@ -196,36 +181,34 @@ TEST(NinjaBinaryTargetWriter, EmptyProductExtension) {
|
| target.sources().push_back(SourceFile("//foo/input1.cc"));
|
| target.sources().push_back(SourceFile("//foo/input2.cc"));
|
|
|
| + target.SetToolchain(setup.toolchain());
|
| + target.OnResolved();
|
| +
|
| std::ostringstream out;
|
| - NinjaBinaryTargetWriter writer(&target, setup.toolchain(), out);
|
| + NinjaBinaryTargetWriter writer(&target, out);
|
| writer.Run();
|
|
|
| const char expected[] =
|
| "defines =\n"
|
| - "includes =\n"
|
| + "include_dirs =\n"
|
| "cflags =\n"
|
| "cflags_c =\n"
|
| "cflags_cc =\n"
|
| "cflags_objc =\n"
|
| "cflags_objcc =\n"
|
| - "target_name = shlib\n"
|
| - "target_out_dir = obj/foo\n"
|
| "root_out_dir = \n"
|
| + "target_out_dir = obj/foo\n"
|
| + "target_output_name = libshlib\n"
|
| "\n"
|
| - "build obj/foo/shlib.input1.o: cxx ../../foo/input1.cc\n"
|
| - "build obj/foo/shlib.input2.o: cxx ../../foo/input2.cc\n"
|
| + "build obj/foo/libshlib.input1.o: cxx ../../foo/input1.cc\n"
|
| + "build obj/foo/libshlib.input2.o: cxx ../../foo/input2.cc\n"
|
| "\n"
|
| - "ldflags =\n"
|
| - "libs =\n"
|
| - "build libshlib.so: solink obj/foo/shlib.input1.o "
|
| - "obj/foo/shlib.input2.o\n"
|
| - " soname = libshlib.so\n"
|
| - " lib = libshlib.so\n"
|
| - "\n";
|
| + "build libshlib.so: solink obj/foo/libshlib.input1.o "
|
| + "obj/foo/libshlib.input2.o\n"
|
| + " ldflags =\n"
|
| + " libs =\n"
|
| + " output_extension = .so\n";
|
|
|
| std::string out_str = out.str();
|
| -#if defined(OS_WIN)
|
| - std::replace(out_str.begin(), out_str.end(), '\\', '/');
|
| -#endif
|
| EXPECT_EQ(expected, out_str);
|
| }
|
|
|