From d76999015cb7bff540f1ceb749c961f2b913a71e Mon Sep 17 00:00:00 2001 From: Vertexwahn Date: Sat, 8 Jun 2024 16:02:59 +0200 Subject: [PATCH] feat(bazel): port to bzlmod (#1097) --- MODULE.bazel | 3 ++- README.rst | 2 +- WORKSPACE | 18 ------------------ WORKSPACE.bazel | 1 + bazel/example/BUILD.bazel | 2 +- bazel/glog.bzl | 4 ++-- 6 files changed, 7 insertions(+), 23 deletions(-) delete mode 100644 WORKSPACE create mode 100644 WORKSPACE.bazel diff --git a/MODULE.bazel b/MODULE.bazel index 04668eda7..d415d917d 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,4 +3,5 @@ module( compatibility_level = 1, ) -bazel_dep(name = "gflags", version = "2.2.2", repo_name = "com_github_gflags_gflags") +bazel_dep(name = "gflags", version = "2.2.2") +bazel_dep(name = "googletest", version = "1.14.0", dev_dependency = True) diff --git a/README.rst b/README.rst index 0adc84c44..3b2b661dc 100644 --- a/README.rst +++ b/README.rst @@ -95,7 +95,7 @@ your ``WORKSPACE`` file: load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( - name = "com_github_gflags_gflags", + name = "gflags", sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf", strip_prefix = "gflags-2.2.2", urls = ["https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"], diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index 6f8714baa..000000000 --- a/WORKSPACE +++ /dev/null @@ -1,18 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "com_github_gflags_gflags", - sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf", - strip_prefix = "gflags-2.2.2", - urls = [ - "https://mirror.bazel.build/github.com/gflags/gflags/archive/v2.2.2.tar.gz", - "https://github.com/gflags/gflags/archive/v2.2.2.tar.gz", - ], -) - -http_archive( - name = "com_github_google_googletest", - sha256 = "258f33ab1a8ee17adf48ec65e821d0ea9eafcbedeff6110f9eaed78472e73dde", - strip_prefix = "googletest-15460959cbbfa20e66ef0b5ab497367e47fc0a04", - urls = ["https://github.com/google/googletest/archive/15460959cbbfa20e66ef0b5ab497367e47fc0a04.tar.gz"], -) diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel new file mode 100644 index 000000000..364635b71 --- /dev/null +++ b/WORKSPACE.bazel @@ -0,0 +1 @@ +# WORKSPACE marker file needed by Bazel diff --git a/bazel/example/BUILD.bazel b/bazel/example/BUILD.bazel index 05ab0f3e7..10f64c62d 100644 --- a/bazel/example/BUILD.bazel +++ b/bazel/example/BUILD.bazel @@ -4,6 +4,6 @@ cc_test( srcs = ["main.cc"], deps = [ "//:glog", - "@com_github_gflags_gflags//:gflags", + "@gflags//:gflags", ], ) diff --git a/bazel/glog.bzl b/bazel/glog.bzl index a311d0d60..286346b3a 100644 --- a/bazel/glog.bzl +++ b/bazel/glog.bzl @@ -126,7 +126,7 @@ def glog_library(with_gflags = 1, **kwargs): "src/windows/port.h", ] - gflags_deps = ["@com_github_gflags_gflags//:gflags"] if with_gflags else [] + gflags_deps = ["@gflags//:gflags"] if with_gflags else [] final_lib_defines = select({ # GLOG_EXPORT is normally set by export.h, but that's not @@ -259,7 +259,7 @@ def glog_library(with_gflags = 1, **kwargs): copts = final_lib_copts + test_only_copts, deps = gflags_deps + [ ":glog", - "@com_github_google_googletest//:gtest", + "@googletest//:gtest", ], **kwargs )