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

Add MODULE.bazel to support bzlmod #4368

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
19 changes: 12 additions & 7 deletions .github/workflows/gtest-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,45 @@ on:
push:
pull_request:

env:
BAZEL_CXXOPTS: -std=c++14

jobs:
Linux:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Tests
run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ...

- name: Tests with bzlmod
run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors --enable_bzlmod ...

macOS:
runs-on: macos-latest
steps:

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Tests
run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ...
run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ...

- name: Tests with bzlmod
run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors --enable_bzlmod ...

Windows:
runs-on: windows-latest
steps:

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Tests
run: bazel test --cxxopt=/std:c++14 --features=external_include_paths --test_output=errors ...

- name: Tests with bzlmod
run: bazel test --cxxopt=/std:c++14 --features=external_include_paths --test_output=errors --enable_bzlmod ...
42 changes: 42 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module(
name = "googletest",
compatibility_level = 1,
)

bazel_dep(name = "abseil-cpp", version = "20230802.0", repo_name = "com_google_absl")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "platforms", version = "0.0.7")
bazel_dep(name = "re2", version = "2021-09-01", repo_name = "com_googlesource_code_re2")
bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "rules_python", version = "0.25.0")

archive_override(
module_name = "rules_python", # 2023-07-31T20:39:27Z
strip_prefix = "rules_python-e355becc30275939d87116a4ec83dad4bb50d9e1",
urls = ["https://github.com/bazelbuild/rules_python/archive/e355becc30275939d87116a4ec83dad4bb50d9e1.zip"],
)

archive_override(
module_name = "bazel_skylib", # 2023-05-31T19:24:07Z
strip_prefix = "bazel-skylib-288731ef9f7f688932bd50e704a91a45ec185f9b",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/288731ef9f7f688932bd50e704a91a45ec185f9b.zip"],
)

archive_override(
module_name = "platforms", # 2023-07-28T19:44:27Z
strip_prefix = "platforms-4ad40ef271da8176d4fc0194d2089b8a76e19d7b",
urls = ["https://github.com/bazelbuild/platforms/archive/4ad40ef271da8176d4fc0194d2089b8a76e19d7b.zip"],
)

archive_override(
module_name = "com_googlesource_code_re2", # 2023-03-17T11:36:51Z
strip_prefix = "re2-578843a516fd1da7084ae46209a75f3613b6065e",
urls = ["https://github.com/google/re2/archive/578843a516fd1da7084ae46209a75f3613b6065e.zip"],
)

archive_override(
module_name = "abseil-cpp", # 2023-08-01T14:59:13Z
patches = ["//:module_dot_bazel.patch"],
strip_prefix = "abseil-cpp-22091f4c0d6626b3ef40446ce3d4ccab19425ca3",
urls = ["https://github.com/abseil/abseil-cpp/archive/22091f4c0d6626b3ef40446ce3d4ccab19425ca3.zip"],
)
25 changes: 13 additions & 12 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
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 = "rules_python", # 2023-07-31T20:39:27Z
sha256 = "1250b59a33c591a1c4ba68c62e95fc88a84c334ec35a2e23f46cbc1b9a5a8b55",
strip_prefix = "rules_python-e355becc30275939d87116a4ec83dad4bb50d9e1",
urls = ["https://github.com/bazelbuild/rules_python/archive/e355becc30275939d87116a4ec83dad4bb50d9e1.zip"],
name = "rules_python", # 2023-07-31T20:39:27Z
sha256 = "1250b59a33c591a1c4ba68c62e95fc88a84c334ec35a2e23f46cbc1b9a5a8b55",
strip_prefix = "rules_python-e355becc30275939d87116a4ec83dad4bb50d9e1",
urls = ["https://github.com/bazelbuild/rules_python/archive/e355becc30275939d87116a4ec83dad4bb50d9e1.zip"],
)

http_archive(
name = "bazel_skylib", # 2023-05-31T19:24:07Z
sha256 = "08c0386f45821ce246bbbf77503c973246ed6ee5c3463e41efc197fa9bc3a7f4",
strip_prefix = "bazel-skylib-288731ef9f7f688932bd50e704a91a45ec185f9b",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/288731ef9f7f688932bd50e704a91a45ec185f9b.zip"],
name = "bazel_skylib", # 2023-05-31T19:24:07Z
sha256 = "08c0386f45821ce246bbbf77503c973246ed6ee5c3463e41efc197fa9bc3a7f4",
strip_prefix = "bazel-skylib-288731ef9f7f688932bd50e704a91a45ec185f9b",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/288731ef9f7f688932bd50e704a91a45ec185f9b.zip"],
)

http_archive(
name = "platforms", # 2023-07-28T19:44:27Z
sha256 = "40eb313613ff00a5c03eed20aba58890046f4d38dec7344f00bb9a8867853526",
strip_prefix = "platforms-4ad40ef271da8176d4fc0194d2089b8a76e19d7b",
urls = ["https://github.com/bazelbuild/platforms/archive/4ad40ef271da8176d4fc0194d2089b8a76e19d7b.zip"],
name = "platforms", # 2023-07-28T19:44:27Z
sha256 = "40eb313613ff00a5c03eed20aba58890046f4d38dec7344f00bb9a8867853526",
strip_prefix = "platforms-4ad40ef271da8176d4fc0194d2089b8a76e19d7b",
urls = ["https://github.com/bazelbuild/platforms/archive/4ad40ef271da8176d4fc0194d2089b8a76e19d7b.zip"],
)
3 changes: 3 additions & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# When using Bzlmod WORKSPACE.bzlmod will take precedence before the WORKSPACE file.
# Via this "empty" WORKSPACE.bzlmod file we can assure that Bzlmod works without the legacy WORKSPACE file
# and everything is prepared for a "pure" Bzlmod approach
14 changes: 14 additions & 0 deletions module_dot_bazel.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- MODULE.bazel
+++ MODULE.bazel
@@ -0,0 +1,11 @@
+"""Module definition for Abseil LTS 20230802.0."""
+module(
+ name = "abseil-cpp",
+ version = "20230802.0",
+ compatibility_level = 1,
+)
+bazel_dep(name = "rules_cc", version = "0.0.8")
+bazel_dep(name = "platforms", version = "0.0.7")
+bazel_dep(name = "bazel_skylib", version = "1.4.2")
+bazel_dep(name = "googletest", version = "1.14.0", repo_name = "com_google_googletest")
+bazel_dep(name = "google_benchmark", version = "1.8.2", repo_name = "com_github_google_benchmark")