From b4cf584547d57495312640a3bc01d8e0a7fe44a6 Mon Sep 17 00:00:00 2001 From: Marco Elver Date: Mon, 10 Jun 2024 09:15:12 -0700 Subject: [PATCH] Add Bzlmod support Introduce Bzlmod support for TCMalloc. Co-developed-by: Keith Smiley [elver: Add missing dependencies, license headers] Closes: https://github.com/google/tcmalloc/pull/230 PiperOrigin-RevId: 641923318 Change-Id: I3d681f72d0b514ee06a3c546b0c8242ee71964c6 --- .gitignore | 3 ++- BUILD | 13 +++++++++++++ MODULE.bazel | 30 ++++++++++++++++++++++++++++++ WORKSPACE.bzlmod | 25 +++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 BUILD create mode 100644 MODULE.bazel create mode 100644 WORKSPACE.bzlmod diff --git a/.gitignore b/.gitignore index d3967d0e3..3ce881718 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ # Bazel -bazel-* \ No newline at end of file +bazel-* +MODULE.bazel.lock diff --git a/BUILD b/BUILD new file mode 100644 index 000000000..9061795cc --- /dev/null +++ b/BUILD @@ -0,0 +1,13 @@ +# Copyright 2024 The TCMalloc Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 000000000..a2843f809 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,30 @@ +# Copyright 2024 The TCMalloc Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module( + name = "tcmalloc", + version = "0", + compatibility_level = 0, + repo_name = "com_google_tcmalloc", +) + +bazel_dep(name = "abseil-cpp", version = "20240116.2", repo_name = "com_google_absl") +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "google_benchmark", version = "1.8.3", repo_name = "com_github_google_benchmark") +bazel_dep(name = "googletest", version = "1.13.0", repo_name = "com_google_googletest") +bazel_dep(name = "protobuf", version = "26.0", repo_name = "com_google_protobuf") +bazel_dep(name = "re2", version = "2024-02-01", repo_name = "com_googlesource_code_re2") +bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "rules_fuzzing", version = "0.5.1") +bazel_dep(name = "rules_proto", version = "4.0.0") diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod new file mode 100644 index 000000000..61cc1ca5e --- /dev/null +++ b/WORKSPACE.bzlmod @@ -0,0 +1,25 @@ +# Copyright 2024 The TCMalloc Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# See MODULE.bazel for external dependencies setup. + +# Having both WORKSPACE and MODULE.bazel specify dependencies is brittle. +# fuzztest is not yet available via Bazel registry, but should be soon: +# https://github.com/bazelbuild/bazel-central-registry/issues/1391 +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +http_archive( + name = "com_google_fuzztest", + strip_prefix = "fuzztest-7e084905bce6ffa97b58cf8e8945e5cea2348a5a", + url = "https://github.com/google/fuzztest/archive/7e084905bce6ffa97b58cf8e8945e5cea2348a5a.zip", +)