Move transitive dependencies of googletest to googletest_deps.bzl to allow other bazel projects to depend on that rule instead of googletests' transitive dependencies directly.
PiperOrigin-RevId: 517166391
Change-Id: I9158e24d3f9613f3bcc811c028e1a15f213b7c40
diff --git a/WORKSPACE b/WORKSPACE
index cb5f83f..1c8ea24 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,24 +1,11 @@
workspace(name = "com_google_googletest")
+load("//:googletest_deps.bzl", "googletest_deps")
+googletest_deps()
+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
- name = "com_google_absl", # 2023-02-27T15:50:25Z
- sha256 = "baf8e734ac3ce213a889ce7c248b981ee1730e2093e32808e0f0a910dc985f76",
- strip_prefix = "abseil-cpp-0c1114c4fb83c844c7fd74708338cca1d3d9b0dc",
- urls = ["https://github.com/abseil/abseil-cpp/archive/0c1114c4fb83c844c7fd74708338cca1d3d9b0dc.zip"],
-)
-
-# Note this must use a commit from the `abseil` branch of the RE2 project.
-# https://github.com/google/re2/tree/abseil
-http_archive(
- name = "com_googlesource_code_re2", # 2022-12-21T14:29:10Z
- sha256 = "b9ce3a51beebb38534d11d40f8928d40509b9e18a735f6a4a97ad3d014c87cb5",
- strip_prefix = "re2-d0b1f8f2ecc2ea74956c7608b6f915175314ff0e",
- urls = ["https://github.com/google/re2/archive/d0b1f8f2ecc2ea74956c7608b6f915175314ff0e.zip"],
-)
-
-http_archive(
name = "rules_python", # 2023-01-10T22:00:51Z
sha256 = "5de54486a60ad8948dabe49605bb1c08053e04001a431ab3e96745b4d97a4419",
strip_prefix = "rules_python-70cce26432187a60b4e950118791385e6fb3c26f",
diff --git a/googletest_deps.bzl b/googletest_deps.bzl
new file mode 100644
index 0000000..7fe8096
--- /dev/null
+++ b/googletest_deps.bzl
@@ -0,0 +1,22 @@
+"""Load dependencies needed to use the googletest library as a 3rd-party consumer."""
+
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+def googletest_deps():
+ """Loads common dependencies needed to use the googletest library."""
+
+ if not native.existing_rule("com_googlesource_code_re2"):
+ http_archive(
+ name = "com_googlesource_code_re2", # 2022-12-21T14:29:10Z
+ sha256 = "b9ce3a51beebb38534d11d40f8928d40509b9e18a735f6a4a97ad3d014c87cb5",
+ strip_prefix = "re2-d0b1f8f2ecc2ea74956c7608b6f915175314ff0e",
+ urls = ["https://github.com/google/re2/archive/d0b1f8f2ecc2ea74956c7608b6f915175314ff0e.zip"],
+ )
+
+ if not native.existing_rule("com_google_absl"):
+ http_archive(
+ name = "com_google_absl", # 2023-02-27T15:50:25Z
+ sha256 = "baf8e734ac3ce213a889ce7c248b981ee1730e2093e32808e0f0a910dc985f76",
+ strip_prefix = "abseil-cpp-0c1114c4fb83c844c7fd74708338cca1d3d9b0dc",
+ urls = ["https://github.com/abseil/abseil-cpp/archive/0c1114c4fb83c844c7fd74708338cca1d3d9b0dc.zip"],
+ )