diff --git a/shim/shims.bzl b/shim/shims.bzl index c99042b1..f48e8583 100644 --- a/shim/shims.bzl +++ b/shim/shims.bzl @@ -49,6 +49,12 @@ _HEADER_SUFFIXES = ( "-defs.tcc", ) +CPP_UNITTEST_MAIN_DEP = "shim//third-party/googletest:cpp_unittest_main" +CPP_UNITTEST_LIB_DEPS = [ + "shim//third-party/googletest:gtest", + "shim//third-party/googletest:gmock", +] + def _get_headers_from_sources(srcs): """ Return the headers likely associated with the given sources @@ -198,14 +204,12 @@ def cpp_unittest( extract_helper_lib = None, compiler_specific_flags = None, default_strip_mode = None, - srcs = [], **kwargs): _unused = (supports_static_listing, allocator, owner, tags, emails, extract_helper_lib, compiler_specific_flags, default_strip_mode) # @unused - srcs = srcs + ["shim//third-party/googletest:gtest_main.cpp"] + deps = deps + [CPP_UNITTEST_MAIN_DEP] + CPP_UNITTEST_LIB_DEPS prelude.cxx_test( deps = _maybe_select_map(deps + external_deps_to_targets(external_deps), _fix_deps), visibility = visibility, - srcs = srcs, **kwargs ) diff --git a/shim/third-party/googletest/BUCK b/shim/third-party/googletest/BUCK index bacd7d77..a4dc8e95 100644 --- a/shim/third-party/googletest/BUCK +++ b/shim/third-party/googletest/BUCK @@ -5,7 +5,6 @@ # License, Version 2.0 found in the LICENSE-APACHE file in the root directory # of this source tree. -load("@shim//build_defs:export_files.bzl", "export_file") load("@shim//third-party:third_party.bzl", "third_party_library") oncall("open_source") @@ -16,12 +15,15 @@ third_party_library( pkgconfig_name = "gtest", ) -alias( +third_party_library( name = "gmock", - actual = ":gtest", - visibility = ["PUBLIC"], + homebrew_package_name = "googletest", + pkgconfig_name = "gmock", ) -export_file( - name = "gtest_main.cpp", +cxx_library( + name = "cpp_unittest_main", + srcs = ["gtest_main.cpp"], + visibility = ["PUBLIC"], + deps = [":gtest"], )