| 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
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f57bb19d2dc5291c05a4abb0618758d90d3a7f3c
|
| --- /dev/null
|
| +++ b/tools/gn/ninja_binary_target_writer_unittest.cc
|
| @@ -0,0 +1,89 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <sstream>
|
| +
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "tools/gn/ninja_binary_target_writer.h"
|
| +#include "tools/gn/test_with_scope.h"
|
| +
|
| +TEST(NinjaBinaryTargetWriter, SourceSet) {
|
| + TestWithScope setup;
|
| + setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
|
| + setup.settings()->set_target_os(Settings::WIN);
|
| +
|
| + Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
|
| + target.set_output_type(Target::SOURCE_SET);
|
| + target.sources().push_back(SourceFile("//foo/input1.cc"));
|
| + target.sources().push_back(SourceFile("//foo/input2.cc"));
|
| + target.OnResolved();
|
| +
|
| + // Source set itself.
|
| + {
|
| + std::ostringstream out;
|
| + NinjaBinaryTargetWriter writer(&target, out);
|
| + writer.Run();
|
| +
|
| + // TODO(brettw) I think we'll need to worry about backslashes here
|
| + // depending if we're on actual Windows or Linux pretending to be Windows.
|
| + const char expected_win[] =
|
| + "arch = environment.x86\n"
|
| + "defines =\n"
|
| + "includes =\n"
|
| + "cflags =\n"
|
| + "cflags_c =\n"
|
| + "cflags_cc =\n"
|
| + "cflags_objc =\n"
|
| + "cflags_objcc =\n"
|
| + "\n"
|
| + "build obj/foo/bar.input1.obj: tc_cxx ../../foo/input1.cc\n"
|
| + "build obj/foo/bar.input2.obj: tc_cxx ../../foo/input2.cc\n"
|
| + "\n"
|
| + "build obj/foo/bar.stamp: tc_stamp obj/foo/bar.input1.obj obj/foo/bar.input2.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);
|
| + }
|
| +
|
| + // 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(&target);
|
| + shlib_target.OnResolved();
|
| +
|
| + {
|
| + std::ostringstream out;
|
| + NinjaBinaryTargetWriter writer(&shlib_target, out);
|
| + writer.Run();
|
| +
|
| + // TODO(brettw) I think we'll need to worry about backslashes here
|
| + // depending if we're on actual Windows or Linux pretending to be Windows.
|
| + const char expected_win[] =
|
| + "arch = environment.x86\n"
|
| + "defines =\n"
|
| + "includes =\n"
|
| + "cflags =\n"
|
| + "cflags_c =\n"
|
| + "cflags_cc =\n"
|
| + "cflags_objc =\n"
|
| + "cflags_objcc =\n"
|
| + "\n"
|
| + "\n"
|
| + "manifests = obj/foo/shlib.intermediate.manifest\n"
|
| + "ldflags = /MANIFEST /ManifestFile:obj/foo/shlib.intermediate.manifest\n"
|
| + "libs =\n"
|
| + "build shlib.dll shlib.dll.lib: tc_solink obj/foo/bar.input1.obj obj/foo/bar.input2.obj\n"
|
| + " soname = shlib.dll\n"
|
| + " lib = shlib.dll\n"
|
| + " dll = shlib.dll\n"
|
| + " implibflag = /IMPLIB:shlib.dll.lib\n\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);
|
| + }
|
| +}
|
|
|