From 85ff4d0e34833c128efd6a6a55f3105c55ab7389 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Fri, 17 May 2024 14:38:18 +0200 Subject: [PATCH] chore(bazel): add MODULE.bazel files for bzlmod Signed-off-by: Matthieu MOREL --- .bazelrc | 4 +-- .bazelversion | 2 +- MODULE.bazel | 62 ++++++++++++++++++++++++++++++++++++++++++++ WORKSPACE | 11 ++++---- WORKSPACE.bzlmod | 0 extensions.bzl | 11 ++++++++ googleapis_ext.bzl | 5 ++++ perf_benchmark/BUILD | 1 - repositories.bzl | 1 - test/BUILD | 1 - 10 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 MODULE.bazel create mode 100644 WORKSPACE.bzlmod create mode 100644 extensions.bzl create mode 100644 googleapis_ext.bzl diff --git a/.bazelrc b/.bazelrc index 1255602..65315fb 100644 --- a/.bazelrc +++ b/.bazelrc @@ -16,8 +16,8 @@ # https://github.com/bazelbuild/rules_fuzzing/blob/f6062a88d83463e2900e47bc218547ba046dad44/.bazelrc # Force the use of Clang for all builds. -build --action_env=CC=clang-10 -build --action_env=CXX=clang++-10 +build --action_env=CC=clang-14 +build --action_env=CXX=clang++-14 build --cxxopt=-std=c++14 build --host_cxxopt=-std=c++14 diff --git a/.bazelversion b/.bazelversion index 0c89fc9..4be2c72 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -4.0.0 \ No newline at end of file +6.5.0 \ No newline at end of file diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..c165dec --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,62 @@ +module( + name = "grpc-httpjson-transcoding", + version = "0.0.0-20230607-ff41eb3", +) + +bazel_dep( + name = "abseil-cpp", + version = "20240116.2", + repo_name = "com_google_absl", +) +bazel_dep( + name = "googletest", + version = "1.14.0.bcr.1", + repo_name = "com_google_googletest", + dev_dependency = True, +) +bazel_dep( + name = "google_benchmark", + version = "1.8.3", + repo_name = "com_google_benchmark", + dev_dependency = True, +) +bazel_dep( + name = "nlohmann_json", + version = "3.11.3", + repo_name = "com_github_nlohmann_json", +) +bazel_dep( + name = "proto-converter", + version = "0.0.0-20230607-d77ff30", + repo_name = "com_google_protoconverter", +) +bazel_dep( + name = "protobuf", + version = "26.0.bcr.1", + repo_name = "com_google_protobuf", +) +bazel_dep( + name = "rules_cc", + version = "0.0.9", +) +bazel_dep( + name = "rules_fuzzing", + version = "0.5.2", + dev_dependency = True, +) +bazel_dep( + name = "rules_proto", + version = "5.3.0-21.7", +) +bazel_dep( + name = "zlib", + version = "1.2.13", +) + +# -- bazel_dep definitions -- # + +non_module_deps = use_extension("//:extensions.bzl", "non_module_deps") +use_repo(non_module_deps, "com_google_googleapis") + +googleapis_ext = use_extension("//:googleapis_ext.bzl", "googleapis_ext") +use_repo(googleapis_ext, "com_google_googleapis_imports") diff --git a/WORKSPACE b/WORKSPACE index 692ab12..c0d7f34 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -15,6 +15,11 @@ ################################################################################ # +# See +# https://github.com/bazelbuild/rules_fuzzing/blob/master/README.md#configuring-the-workspace. +# The fuzzing rules must be first because if they are not, bazel will +# pull in incompatible versions of absl and rules_python. +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load( "//:repositories.bzl", "absl_repositories", @@ -27,12 +32,6 @@ load( "protoconverter_repositories", ) -# See -# https://github.com/bazelbuild/rules_fuzzing/blob/master/README.md#configuring-the-workspace. -# The fuzzing rules must be first because if they are not, bazel will -# pull in incompatible versions of absl and rules_python. -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - http_archive( name = "rules_fuzzing", sha256 = "d9002dd3cd6437017f08593124fdd1b13b3473c7b929ceb0e60d317cb9346118", diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod new file mode 100644 index 0000000..e69de29 diff --git a/extensions.bzl b/extensions.bzl new file mode 100644 index 0000000..8d8228e --- /dev/null +++ b/extensions.bzl @@ -0,0 +1,11 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def _non_module_deps_impl(_ctx): + http_archive( + name = "com_google_googleapis", + url = "https://github.com/googleapis/googleapis/archive/1d5522ad1056f16a6d593b8f3038d831e64daeea.tar.gz", + sha256 = "cd13e547cffaad217c942084fd5ae0985a293d0cce3e788c20796e5e2ea54758", + strip_prefix = "googleapis-1d5522ad1056f16a6d593b8f3038d831e64daeea", + ) + +non_module_deps = module_extension(implementation = _non_module_deps_impl) diff --git a/googleapis_ext.bzl b/googleapis_ext.bzl new file mode 100644 index 0000000..d25be43 --- /dev/null +++ b/googleapis_ext.bzl @@ -0,0 +1,5 @@ +load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") + +googleapis_ext = module_extension(implementation = lambda x: switched_rules_by_language( + name = "com_google_googleapis_imports", +)) diff --git a/perf_benchmark/BUILD b/perf_benchmark/BUILD index 14c0a35..287032b 100644 --- a/perf_benchmark/BUILD +++ b/perf_benchmark/BUILD @@ -15,7 +15,6 @@ ################################################################################ # load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@io_bazel_rules_docker//cc:image.bzl", "cc_image") load("@io_bazel_rules_docker//container:container.bzl", "container_push") diff --git a/repositories.bzl b/repositories.bzl index 68d98be..56ee95e 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -15,7 +15,6 @@ ################################################################################ # load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") def absl_repositories(bind = True): http_archive( diff --git a/test/BUILD b/test/BUILD index 657b77f..db96a6f 100644 --- a/test/BUILD +++ b/test/BUILD @@ -14,7 +14,6 @@ # ################################################################################ # -load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test") package(default_visibility = ["//visibility:public"])