[llvm] r349704 - [gn build] Make `ninja check-lld` also run LLD's unit tests
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 19 16:04:11 PST 2018
Author: nico
Date: Wed Dec 19 16:04:10 2018
New Revision: 349704
URL: http://llvm.org/viewvc/llvm-project?rev=349704&view=rev
Log:
[gn build] Make `ninja check-lld` also run LLD's unit tests
And add build files for gtest.
With this, the build files for //lld are complete.
Differential Revision: https://reviews.llvm.org/D55838
Added:
llvm/trunk/utils/gn/secondary/lld/unittests/
llvm/trunk/utils/gn/secondary/lld/unittests/BUILD.gn
llvm/trunk/utils/gn/secondary/lld/unittests/DriverTests/
llvm/trunk/utils/gn/secondary/lld/unittests/DriverTests/BUILD.gn
llvm/trunk/utils/gn/secondary/lld/unittests/MachOTests/
llvm/trunk/utils/gn/secondary/lld/unittests/MachOTests/BUILD.gn
llvm/trunk/utils/gn/secondary/llvm/utils/unittest/
llvm/trunk/utils/gn/secondary/llvm/utils/unittest/BUILD.gn
llvm/trunk/utils/gn/secondary/llvm/utils/unittest/UnitTestMain/
llvm/trunk/utils/gn/secondary/llvm/utils/unittest/UnitTestMain/BUILD.gn
Modified:
llvm/trunk/utils/gn/secondary/lld/test/BUILD.gn
Modified: llvm/trunk/utils/gn/secondary/lld/test/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/lld/test/BUILD.gn?rev=349704&r1=349703&r2=349704&view=diff
==============================================================================
--- llvm/trunk/utils/gn/secondary/lld/test/BUILD.gn (original)
+++ llvm/trunk/utils/gn/secondary/lld/test/BUILD.gn Wed Dec 19 16:04:10 2018
@@ -80,6 +80,7 @@ group("test") {
":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",
@@ -101,8 +102,6 @@ group("test") {
"//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.
Added: llvm/trunk/utils/gn/secondary/lld/unittests/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/lld/unittests/BUILD.gn?rev=349704&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/lld/unittests/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/lld/unittests/BUILD.gn Wed Dec 19 16:04:10 2018
@@ -0,0 +1,7 @@
+group("unittests") {
+ deps = [
+ "DriverTests",
+ "MachOTests",
+ ]
+ testonly = true
+}
Added: llvm/trunk/utils/gn/secondary/lld/unittests/DriverTests/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/lld/unittests/DriverTests/BUILD.gn?rev=349704&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/lld/unittests/DriverTests/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/lld/unittests/DriverTests/BUILD.gn Wed Dec 19 16:04:10 2018
@@ -0,0 +1,15 @@
+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
+}
Added: llvm/trunk/utils/gn/secondary/lld/unittests/MachOTests/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/lld/unittests/MachOTests/BUILD.gn?rev=349704&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/lld/unittests/MachOTests/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/lld/unittests/MachOTests/BUILD.gn Wed Dec 19 16:04:10 2018
@@ -0,0 +1,19 @@
+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
+}
Added: llvm/trunk/utils/gn/secondary/llvm/utils/unittest/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/utils/unittest/BUILD.gn?rev=349704&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/utils/unittest/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/llvm/utils/unittest/BUILD.gn Wed Dec 19 16:04:10 2018
@@ -0,0 +1,40 @@
+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
+}
Added: llvm/trunk/utils/gn/secondary/llvm/utils/unittest/UnitTestMain/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/secondary/llvm/utils/unittest/UnitTestMain/BUILD.gn?rev=349704&view=auto
==============================================================================
--- llvm/trunk/utils/gn/secondary/llvm/utils/unittest/UnitTestMain/BUILD.gn (added)
+++ llvm/trunk/utils/gn/secondary/llvm/utils/unittest/UnitTestMain/BUILD.gn Wed Dec 19 16:04:10 2018
@@ -0,0 +1,25 @@
+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
+}
More information about the llvm-commits
mailing list