Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Bazel dependency management for GoogleTest #4713

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions googletest_deps.bzl
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
"""Load dependencies needed to use the googletest library as a 3rd-party consumer."""
"""Load dependencies required for using the GoogleTest library as a third-party consumer."""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//:fake_fuchsia_sdk.bzl", "fake_fuchsia_sdk")

def googletest_deps():
"""Loads common dependencies needed to use the googletest library."""

if not native.existing_rule("re2"):
def maybe_http_archive(name, sha256, strip_prefix, urls):
"""Helper function to conditionally load an http_archive if it doesn't exist."""
if not native.existing_rule(name):
http_archive(
name = "re2",
sha256 = "eb2df807c781601c14a260a507a5bb4509be1ee626024cb45acbd57cb9d4032b",
strip_prefix = "re2-2024-07-02",
urls = ["https://github.com/google/re2/releases/download/2024-07-02/re2-2024-07-02.tar.gz"],
name = name,
sha256 = sha256,
strip_prefix = strip_prefix,
urls = urls,
)

if not native.existing_rule("abseil-cpp"):
http_archive(
name = "abseil-cpp",
sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc",
strip_prefix = "abseil-cpp-20240116.2",
urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240116.2/abseil-cpp-20240116.2.tar.gz"],
)
def googletest_deps():
"""Loads required dependencies for using GoogleTest."""

maybe_http_archive(
name = "re2",
sha256 = "eb2df807c781601c14a260a507a5bb4509be1ee626024cb45acbd57cb9d4032b",
strip_prefix = "re2-2024-07-02",
urls = ["https://github.com/google/re2/releases/download/2024-07-02/re2-2024-07-02.tar.gz"],
)

maybe_http_archive(
name = "abseil-cpp",
sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc",
strip_prefix = "abseil-cpp-20240116.2",
urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240116.2/abseil-cpp-20240116.2.tar.gz"],
)

if not native.existing_rule("fuchsia_sdk"):
fake_fuchsia_sdk(
name = "fuchsia_sdk",
)
fake_fuchsia_sdk(name = "fuchsia_sdk")