From f57557de70ebbc493e4e73d14c9ce050298cb8d0 Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Wed, 9 Nov 2022 20:48:11 -0800 Subject: [PATCH] [bazel] Update gtest move to third-party a11cd0d94ed3cabf0998a0289aead05da94c86eb moved googletest to third-party. This creates a corresponding BUILD file in third-party/unittest, moved from the chunk in llvm/BUILD.bazel. We must refine the .bazelignore which is setup to ignore the benchmarking library so that we don't ignore the new dir here. --- utils/bazel/llvm-project-overlay/.bazelignore | 2 +- utils/bazel/llvm-project-overlay/clang/BUILD.bazel | 2 +- .../clang/unittests/BUILD.bazel | 102 ++++++++-------- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel | 99 +--------------- .../llvm/unittests/BUILD.bazel | 128 ++++++++++----------- .../mlir/unittests/BUILD.bazel | 36 +++--- .../third-party/unittest/BUILD.bazel | 109 ++++++++++++++++++ 7 files changed, 248 insertions(+), 230 deletions(-) create mode 100644 utils/bazel/llvm-project-overlay/third-party/unittest/BUILD.bazel diff --git a/utils/bazel/llvm-project-overlay/.bazelignore b/utils/bazel/llvm-project-overlay/.bazelignore index fad56ed..f3d19a9 100644 --- a/utils/bazel/llvm-project-overlay/.bazelignore +++ b/utils/bazel/llvm-project-overlay/.bazelignore @@ -3,4 +3,4 @@ utils/bazel # Ignore third-party projects. These should be configured separately and some # include Bazel configs. libcxx/utils/google-benchmark -third-party +third-party/benchmark diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel index 9fba1a8..8de5cd5 100644 --- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel @@ -1009,7 +1009,7 @@ cc_library( ":basic", ":frontend", "//llvm:Support", - "//llvm:gtest", + "//third-party/unittest:gtest", ], ) diff --git a/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel index bf2d5dd..4dfdab8 100644 --- a/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/clang/unittests/BUILD.bazel @@ -30,9 +30,9 @@ cc_test( "//llvm:Core", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gmock", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -48,7 +48,7 @@ cc_library( "//clang:frontend", "//clang:testing", "//clang:tooling", - "//llvm:gtest", + "//third-party/unittest:gtest", ], ) @@ -68,8 +68,8 @@ cc_test( "//clang:tooling", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -87,8 +87,8 @@ cc_test( "//clang:frontend", "//clang:tooling", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -111,9 +111,9 @@ cc_test( "//clang:parse", "//clang:tooling", "//llvm:Support", - "//llvm:gmock", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -137,9 +137,9 @@ cc_test( "//llvm:Support", "//llvm:TestingADT", "//llvm:TestingSupport", - "//llvm:gmock", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -157,9 +157,9 @@ cc_test( "//llvm:Support", "//llvm:TestingSupport", "//llvm:config", - "//llvm:gmock", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -183,8 +183,8 @@ cc_test( "//clang:sema", "//llvm:Core", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -207,9 +207,9 @@ cc_test( "//clang:frontend", "//clang:tooling_core", "//llvm:Support", - "//llvm:gmock", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -231,9 +231,9 @@ cc_test( "//clang:sema", "//clang:serialization", "//llvm:Support", - "//llvm:gmock", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -257,9 +257,9 @@ cc_test( "//clang:serialization", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gmock", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -281,7 +281,7 @@ cc_library( "//clang:tooling", "//clang:tooling_core", "//llvm:Support", - "//llvm:gtest", + "//third-party/unittest:gtest", ], ) @@ -306,8 +306,8 @@ cc_test( "//clang:tooling", "//clang:tooling_refactoring", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -321,8 +321,8 @@ cc_test( deps = [ "//clang:rewrite", "//clang:tooling", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -343,9 +343,9 @@ cc_test( "//clang:sema", "//clang:tooling", "//llvm:TestingSupport", - "//llvm:gmock", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -364,7 +364,7 @@ cc_library( "//clang:static_analyzer_frontend", "//clang:testing", "//clang:tooling", - "//llvm:gtest", + "//third-party/unittest:gtest", ], ) @@ -388,8 +388,8 @@ cc_test( "//clang:tooling", "//llvm:Support", "//llvm:config", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -421,9 +421,9 @@ cc_test( "//clang:transformer", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gmock", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -445,7 +445,7 @@ cc_library( "//clang:tooling", "//clang:tooling_core", "//llvm:Support", - "//llvm:gtest", + "//third-party/unittest:gtest", ], ) @@ -468,9 +468,9 @@ cc_test( "//clang:tooling_syntax", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gmock", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -496,9 +496,9 @@ cc_test( "//clang:tooling_syntax", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gmock", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -522,7 +522,7 @@ cc_test( deps = [ "//clang:libclang", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel index 8a6edcb..0b4871c 100644 --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -3700,8 +3700,8 @@ cc_binary( ":BinaryFormat", ":CodeGen", ":DebugInfo", - ":Debuginfod", ":DebugInfoDWARF", + ":Debuginfod", ":Demangle", ":MC", ":MCDisassembler", @@ -4249,97 +4249,6 @@ cc_library( ], ) -# A hacky library to expose some internal headers of gtest to its own -# implementation source files using a stripped include prefix rather than -# file-relative-inclusion. -# -# FIXME: This file should be in `textual_hdrs` instead of `hdrs`, but -# unfortunately that doesn't work with `strip_include_prefix`: -# https://github.com/bazelbuild/bazel/issues/12424 -# -# For now, simply disable parsing and header modules. -cc_library( - name = "gtest_internal_headers", - testonly = True, - hdrs = ["utils/unittest/googletest/src/gtest-internal-inl.h"], - features = [ - "-parse_headers", - "-header_modules", - ], - strip_include_prefix = "utils/unittest/googletest", -) - -cc_library( - name = "gtest", - testonly = True, - srcs = glob( - [ - "utils/unittest/googletest/include/**/*.h", - "utils/unittest/googletest/src/*.cc", - ], - exclude = [ - "utils/unittest/googletest/src/gtest-all.cc", - "utils/unittest/googletest/include/gtest/gtest_pred_impl.h", - ], - ) + [ - ], - hdrs = ["utils/unittest/googletest/include/gtest/gtest.h"], - copts = llvm_copts, - defines = [ - "GTEST_HAS_RTTI=0", - "__STDC_LIMIT_MACROS", - "__STDC_CONSTANT_MACROS", - ] + select({ - "@bazel_tools//src/conditions:windows": ["GTEST_USE_OWN_TR1_TUPLE=0"], - "//conditions:default": ["GTEST_USE_OWN_TR1_TUPLE=1"], - }), - includes = [ - "include", - "utils/unittest/googletest/include", - ], - textual_hdrs = [ - "utils/unittest/googletest/include/gtest/gtest_pred_impl.h", - ], - deps = [ - ":Support", - ":gtest_internal_headers", - ], -) - -cc_library( - name = "gtest_main", - testonly = True, - srcs = ["utils/unittest/UnitTestMain/TestMain.cpp"], - copts = llvm_copts, - deps = [ - ":Support", - ":gmock", - ":gtest", - ], -) - -cc_library( - name = "gmock", - testonly = True, - srcs = glob( - [ - "utils/unittest/googlemock/include/**/*.h", - "utils/unittest/googlemock/src/*.cc", - ], - exclude = ["utils/unittest/googlemock/src/gmock-all.cc"], - ), - hdrs = [ - "utils/unittest/googlemock/include/gmock/gmock.h", - "utils/unittest/googlemock/include/gmock/gmock-matchers.h", - ], - copts = llvm_copts, - includes = [ - "include", - "utils/unittest/googlemock/include", - ], - deps = [":gtest"], -) - py_binary( name = "lit", testonly = True, @@ -4355,7 +4264,7 @@ cc_library( copts = llvm_copts, deps = [ ":Support", - ":gmock", + "//third-party/unittest:gmock", ], ) @@ -4373,8 +4282,8 @@ cc_library( deps = [ ":Support", ":config", - ":gmock", - ":gtest", + "//third-party/unittest:gmock", + "//third-party/unittest:gtest", ], ) diff --git a/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel index d181709..3478c1d 100644 --- a/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel @@ -23,8 +23,8 @@ cc_test( "//llvm:Core", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -49,8 +49,8 @@ cc_test( "//llvm:Support", "//llvm:TestingSupport", "//llvm:TransformUtils", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -65,8 +65,8 @@ cc_test( "//llvm:AsmParser", "//llvm:Core", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -83,8 +83,8 @@ cc_test( "//llvm:BitWriter", "//llvm:Core", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -99,8 +99,8 @@ cc_test( "//llvm:BitstreamReader", "//llvm:BitstreamWriter", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -136,8 +136,8 @@ cc_test( "//llvm:Support", "//llvm:Target", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -162,8 +162,8 @@ cc_test( "//llvm:FileCheckLib", "//llvm:Support", "//llvm:Target", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -195,8 +195,8 @@ cc_test( "//llvm:ObjectYAML", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -206,8 +206,8 @@ cc_test( deps = [ "//llvm:Debuginfod", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -225,8 +225,8 @@ cc_test( "//llvm:ExecutionEngine", "//llvm:Interpreter", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -251,8 +251,8 @@ cc_test( "//llvm:MCJIT", "//llvm:Passes", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -276,8 +276,8 @@ cc_test( "//llvm:OrcJIT", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -292,8 +292,8 @@ cc_test( "//llvm:FileCheckLib", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -320,8 +320,8 @@ cc_test( "//llvm:Support", "//llvm:TestingSupport", "//llvm:config", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -335,8 +335,8 @@ cc_test( deps = [ "//llvm:LineEditor", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -353,8 +353,8 @@ cc_test( "//llvm:FrontendOpenMP", "//llvm:Passes", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -370,8 +370,8 @@ cc_test( "//llvm:Core", "//llvm:Linker", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -388,8 +388,8 @@ cc_test( "//llvm:MC", "//llvm:MCDisassembler", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -407,8 +407,8 @@ cc_test( "//llvm:Core", "//llvm:Support", "//llvm:Target", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -423,8 +423,8 @@ cc_test( "//llvm:Object", "//llvm:ObjectYAML", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -439,8 +439,8 @@ cc_test( "//llvm:Object", "//llvm:ObjectYAML", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -457,8 +457,8 @@ cc_test( "//llvm:ObjectYAML", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -515,8 +515,8 @@ cc_test( ":option_tests_gen", "//llvm:Option", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -531,9 +531,9 @@ cc_test( "//llvm:BitReader", "//llvm:Remarks", "//llvm:Support", - "//llvm:gtest", - "//llvm:gtest_main", "//llvm:remark_linker", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -550,8 +550,8 @@ cc_test( "//llvm:ProfileData", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -584,8 +584,8 @@ cc_test( "//llvm:Support", "//llvm:TestingSupport", "//llvm:config", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -601,8 +601,8 @@ cc_test( "//llvm:AllTargetsCodeGens", "//llvm:Support", "//llvm:config", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -620,9 +620,9 @@ cc_test( ":automata_tables_gen", "//llvm:Support", "//llvm:TableGen", - "//llvm:gtest", - "//llvm:gtest_main", "//llvm:tblgen", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -638,8 +638,8 @@ cc_test( ], deps = [ "//llvm:AArch64CodeGen", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -655,8 +655,8 @@ cc_test( deps = [ "//llvm:Support", "//llvm:TestingADT", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -680,8 +680,8 @@ cc_test( "//llvm:Support", "//llvm:TestingSupport", "//llvm:TransformUtils", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) @@ -706,7 +706,7 @@ cc_test( "//llvm:MCDisassembler", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gtest", - "//llvm:gtest_main", + "//third-party/unittest:gtest", + "//third-party/unittest:gtest_main", ], ) diff --git a/utils/bazel/llvm-project-overlay/mlir/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/unittests/BUILD.bazel index 32e0a14..d938033 100644 --- a/utils/bazel/llvm-project-overlay/mlir/unittests/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/unittests/BUILD.bazel @@ -19,9 +19,9 @@ cc_test( ]), deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:IR", "//mlir/test:TestDialect", + "//third-party/unittest:gtest_main", ], ) @@ -34,7 +34,6 @@ cc_test( ]), deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:ControlFlowInterfaces", "//mlir:DLTIDialect", "//mlir:DataLayoutInterfaces", @@ -43,6 +42,7 @@ cc_test( "//mlir:InferIntRangeInterface", "//mlir:InferTypeOpInterface", "//mlir:Parser", + "//third-party/unittest:gtest_main", ], ) @@ -56,8 +56,8 @@ cc_test( deps = [ "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:Support", + "//third-party/unittest:gtest_main", ], ) @@ -70,11 +70,11 @@ cc_test( ]), deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:Analysis", "//mlir:FuncDialect", "//mlir:IR", "//mlir:Pass", + "//third-party/unittest:gtest_main", ], ) @@ -86,9 +86,9 @@ cc_test( "Rewrite/*.h", ]), deps = [ - "//llvm:gtest_main", "//mlir:IR", "//mlir:Rewrite", + "//third-party/unittest:gtest_main", ], ) @@ -101,8 +101,8 @@ cc_test( ]), deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:Dialect", + "//third-party/unittest:gtest_main", ], ) @@ -115,8 +115,8 @@ cc_test( ]), deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:MemRefDialect", + "//third-party/unittest:gtest_main", ], ) @@ -129,9 +129,9 @@ cc_test( ]), deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:QuantOps", "//mlir:Transforms", + "//third-party/unittest:gtest_main", ], ) @@ -143,10 +143,10 @@ cc_test( "Dialect/SCF/*.h", ]), deps = [ - "//llvm:gtest_main", "//mlir:FuncDialect", "//mlir:Parser", "//mlir:SCFDialect", + "//third-party/unittest:gtest_main", ], ) @@ -159,8 +159,8 @@ cc_test( ]), deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:SparseTensorUtils", + "//third-party/unittest:gtest_main", ], ) @@ -173,10 +173,10 @@ cc_test( ]), deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:SPIRVDeserialization", "//mlir:SPIRVDialect", "//mlir:SPIRVSerialization", + "//third-party/unittest:gtest_main", ], ) @@ -189,9 +189,9 @@ cc_test( ]), deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:FuncDialect", "//mlir:TransformDialect", + "//third-party/unittest:gtest_main", ], ) @@ -204,8 +204,8 @@ cc_test( ]), deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:DialectUtils", + "//third-party/unittest:gtest_main", ], ) @@ -260,10 +260,10 @@ cc_test( ":PassIncGen", "//llvm:Support", "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:IR", "//mlir:TableGen", "//mlir/test:TestDialect", + "//third-party/unittest:gtest_main", ], ) @@ -275,13 +275,13 @@ cc_test( "Transforms/*.h", ]), deps = [ - "//llvm:gtest_main", "//mlir:AffineAnalysis", "//mlir:IR", "//mlir:Parser", "//mlir:Pass", "//mlir:TransformUtils", "//mlir:Transforms", + "//third-party/unittest:gtest_main", ], ) @@ -296,11 +296,11 @@ cc_test( ]), deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:AffineAnalysis", "//mlir:Analysis", "//mlir:IR", "//mlir:Parser", + "//third-party/unittest:gtest_main", ], ) @@ -314,9 +314,9 @@ cc_test( "Conversion/*/*.h", ]), deps = [ - "//llvm:gtest_main", "//mlir:ArithDialect", "//mlir:PDLToPDLInterp", + "//third-party/unittest:gtest_main", ], ) @@ -332,7 +332,6 @@ cc_test( ], deps = [ "//llvm:TestingSupport", - "//llvm:gtest_main", "//mlir:AllPassesAndDialects", "//mlir:Analysis", "//mlir:ExecutionEngine", @@ -341,5 +340,6 @@ cc_test( "//mlir:MemRefToLLVM", "//mlir:mlir_c_runner_utils", "//mlir:mlir_runner_utils", + "//third-party/unittest:gtest_main", ], ) diff --git a/utils/bazel/llvm-project-overlay/third-party/unittest/BUILD.bazel b/utils/bazel/llvm-project-overlay/third-party/unittest/BUILD.bazel new file mode 100644 index 0000000..fc025fc --- /dev/null +++ b/utils/bazel/llvm-project-overlay/third-party/unittest/BUILD.bazel @@ -0,0 +1,109 @@ +# This file is licensed under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) + +exports_files(["LICENSE.TXT"]) + +# It may be tempting to add compiler flags here, but that should be avoided. +# The necessary warnings and other compile flags should be provided by the +# toolchain or the `.bazelrc` file. This is just a workaround until we have a +# widely available feature to enable unlimited stack frame instead of using +# this `Make` variable. +llvm_copts = [ + "$(STACK_FRAME_UNLIMITED)", +] + +# A hacky library to expose some internal headers of gtest to its own +# implementation source files using a stripped include prefix rather than +# file-relative-inclusion. +# +# FIXME: This file should be in `textual_hdrs` instead of `hdrs`, but +# unfortunately that doesn't work with `strip_include_prefix`: +# https://github.com/bazelbuild/bazel/issues/12424 +# +# For now, simply disable parsing and header modules. +cc_library( + name = "gtest_internal_headers", + testonly = True, + hdrs = ["googletest/src/gtest-internal-inl.h"], + features = [ + "-parse_headers", + "-header_modules", + ], + strip_include_prefix = "googletest", +) + +cc_library( + name = "gtest", + testonly = True, + srcs = glob( + [ + "googletest/include/**/*.h", + "googletest/src/*.cc", + ], + exclude = [ + "googletest/src/gtest-all.cc", + "googletest/include/gtest/gtest_pred_impl.h", + ], + ) + [ + ], + hdrs = ["googletest/include/gtest/gtest.h"], + copts = llvm_copts, + defines = [ + "GTEST_HAS_RTTI=0", + "__STDC_LIMIT_MACROS", + "__STDC_CONSTANT_MACROS", + ] + select({ + "@bazel_tools//src/conditions:windows": ["GTEST_USE_OWN_TR1_TUPLE=0"], + "//conditions:default": ["GTEST_USE_OWN_TR1_TUPLE=1"], + }), + includes = [ + "googletest/include", + "include", + ], + textual_hdrs = [ + "googletest/include/gtest/gtest_pred_impl.h", + ], + deps = [ + ":gtest_internal_headers", + "//llvm:Support", + ], +) + +cc_library( + name = "gtest_main", + testonly = True, + srcs = ["UnitTestMain/TestMain.cpp"], + copts = llvm_copts, + deps = [ + ":gmock", + ":gtest", + "//llvm:Support", + ], +) + +cc_library( + name = "gmock", + testonly = True, + srcs = glob( + [ + "googlemock/include/**/*.h", + "googlemock/src/*.cc", + ], + exclude = ["googlemock/src/gmock-all.cc"], + ), + hdrs = [ + "googlemock/include/gmock/gmock.h", + "googlemock/include/gmock/gmock-matchers.h", + ], + copts = llvm_copts, + includes = [ + "googlemock/include", + "include", + ], + deps = [":gtest"], +) -- 2.7.4