And add build files for gtest.
With this, the build files for //lld are complete.
Differential Revision: https://reviews.llvm.org/D55838
llvm-svn: 349704
":lit_site_cfg",
":lit_unit_site_cfg",
"//lld/tools/lld:symlinks",
+ "//lld/unittests",
"//llvm/tools/llc",
"//llvm/tools/llvm-ar:symlinks",
"//llvm/tools/llvm-as",
"//llvm/utils/not",
]
testonly = true
-
- # FIXME: Add dep on "//lld/unittests" target once it exists.
}
# This is the action that runs all of lld's tests, check-lld.
--- /dev/null
+group("unittests") {
+ deps = [
+ "DriverTests",
+ "MachOTests",
+ ]
+ testonly = true
+}
--- /dev/null
+executable("DriverTests") {
+ # test/Unit/lit.cfg expects unittests in LLD_BINARY_DIR/unittest
+ output_dir = target_out_dir
+
+ configs += [ "//llvm/utils/gn/build:lld_code" ]
+ deps = [
+ "//lld/lib/Driver",
+ "//lld/lib/ReaderWriter/MachO",
+ "//llvm/utils/unittest/UnitTestMain",
+ ]
+ sources = [
+ "DarwinLdDriverTest.cpp",
+ ]
+ testonly = true
+}
--- /dev/null
+executable("MachOTests") {
+ # test/Unit/lit.cfg expects unittests in LLD_BINARY_DIR/unittest
+ output_dir = target_out_dir
+
+ configs += [ "//llvm/utils/gn/build:lld_code" ]
+ deps = [
+ "//lld/lib/Driver",
+ "//lld/lib/ReaderWriter/MachO",
+ "//lld/lib/ReaderWriter/YAML",
+ "//llvm/utils/unittest/UnitTestMain",
+ ]
+ sources = [
+ "MachONormalizedFileBinaryReaderTests.cpp",
+ "MachONormalizedFileBinaryWriterTests.cpp",
+ "MachONormalizedFileToAtomsTests.cpp",
+ "MachONormalizedFileYAMLTests.cpp",
+ ]
+ testonly = true
+}
--- /dev/null
+import("//llvm/utils/gn/build/libs/pthread/enable.gni")
+
+# Used to push the gtest include directories to things depending on :googletest.
+config("googletest_config") {
+ include_dirs = [
+ "googlemock/include",
+ "googletest/include",
+ ]
+
+ # LLVM requires C++11 but gtest doesn't correctly detect the availability
+ # of C++11 on MSVC, so we force it on.
+ defines = [
+ "GTEST_LANG_CXX11",
+ "GTEST_HAS_TR1_TUPLE=0",
+ ]
+ if (host_os == "win") {
+ defines += [ "GTEST_OS_WINDOWS" ]
+ }
+ if (!llvm_enable_threads) {
+ defines += [ "GTEST_HAS_PTHREAD=0" ]
+ }
+ defines += [ "GTEST_HAS_RTTI=0" ]
+}
+
+static_library("gtest") {
+ deps = [
+ "//llvm/lib/Support",
+ ]
+ include_dirs = [
+ "googletest", # For including src/gtest.cc
+ "googlemock", # For including src/gmock.cc
+ ]
+ public_configs = [ ":googletest_config" ]
+ configs -= [ "//llvm/utils/gn/build:warn_covered_switch_default" ]
+ sources = [
+ "googlemock/src/gmock-all.cc",
+ "googletest/src/gtest-all.cc",
+ ]
+ testonly = true
+}
--- /dev/null
+source_set("UnitTestMain") {
+ deps = [
+ "//llvm/lib/Support",
+ ]
+
+ # Make targets depending on this also depend on gtest, to get the gtest
+ # include_dir.
+ public_deps = [
+ "..:gtest",
+ ]
+ sources = [
+ "TestMain.cpp",
+ ]
+ testonly = true
+}
+
+# Nothing depends on this target, but llvm-config expects it to exist when
+# it runs with `--link-static --system-libs`, so humor it.
+static_library("gtest_main") {
+ deps = [
+ ":UnitTestMain",
+ ]
+ complete_static_lib = true
+ testonly = true
+}