mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
This sets things up to use `bazel` to run `clang-tidy` using https://github.com/erenon/bazel_clang_tidy. I'm fixing issues outside of explorer, and disabling clang-tidy for targets in explorer that have legacy issues. I was going to disable clang-tidy for targets in explorer such as interpreter anyways, because they're slow to parse, and just extended that to the currently failing targets.
148 lines
5.0 KiB
Python
148 lines
5.0 KiB
Python
# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
# Exceptions. See /LICENSE for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
"""Bazel modules.
|
|
|
|
If `MODULE.bazel.lock` changes locally, it means the host platform hasn't yet
|
|
been added to the lock file. Running `bazel mod deps` provides a canonical
|
|
update to `MODULE.bazel.lock`; create a PR with those changes in order to
|
|
include the host platform.
|
|
|
|
Platforms tested with GitHub actions are kept up-to-date. Other platforms may
|
|
fall out of sync on dependency changes, and should be updated with a PR the same
|
|
way a platform is added.
|
|
"""
|
|
|
|
module(name = "carbon")
|
|
|
|
http_archive = use_repo_rule(
|
|
"@bazel_tools//tools/build_defs/repo:http.bzl",
|
|
"http_archive",
|
|
)
|
|
|
|
bazel_dep(name = "bazel_skylib", version = "1.5.0")
|
|
bazel_dep(
|
|
name = "abseil-cpp",
|
|
version = "20230802.0",
|
|
repo_name = "com_google_absl",
|
|
)
|
|
bazel_dep(
|
|
name = "re2",
|
|
version = "2023-11-01",
|
|
repo_name = "com_googlesource_code_re2",
|
|
)
|
|
bazel_dep(
|
|
name = "googletest",
|
|
version = "1.14.0.bcr.1",
|
|
repo_name = "com_google_googletest",
|
|
)
|
|
bazel_dep(
|
|
name = "google_benchmark",
|
|
version = "1.8.3",
|
|
repo_name = "com_github_google_benchmark",
|
|
)
|
|
bazel_dep(name = "rules_bison", version = "0.2.2")
|
|
bazel_dep(name = "rules_flex", version = "0.2.1")
|
|
bazel_dep(name = "rules_m4", version = "0.2.3")
|
|
bazel_dep(name = "rules_cc", version = "0.0.9")
|
|
bazel_dep(name = "rules_proto", version = "6.0.0-rc1")
|
|
bazel_dep(
|
|
name = "protobuf",
|
|
version = "21.7",
|
|
repo_name = "com_google_protobuf",
|
|
)
|
|
|
|
libprotobuf_mutator_version = "1.1"
|
|
|
|
http_archive(
|
|
name = "com_google_libprotobuf_mutator",
|
|
build_file = "@//:third_party/libprotobuf_mutator/BUILD.txt",
|
|
sha256 = "fd299fd72c5cf664259d9bd43a72cb74dc6a8b9604d107fe2d2e90885aeb7c16",
|
|
strip_prefix = "libprotobuf-mutator-{0}".format(libprotobuf_mutator_version),
|
|
urls = ["https://github.com/google/libprotobuf-mutator/archive/v{0}.tar.gz".format(libprotobuf_mutator_version)],
|
|
)
|
|
|
|
clang_tidy_version = "d2aecc583d14c9554febeab185833c1e8cce5384"
|
|
|
|
http_archive(
|
|
name = "bazel_clang_tidy",
|
|
sha256 = "89c198a9f544beac119bb41904d16d8870686ccb5fe946442c1576934c9e6869",
|
|
strip_prefix = "bazel_clang_tidy-{0}".format(clang_tidy_version),
|
|
urls = ["https://github.com/erenon/bazel_clang_tidy/archive/{0}.tar.gz".format(clang_tidy_version)],
|
|
)
|
|
|
|
bazel_cc_toolchain = use_extension(
|
|
"//bazel/cc_toolchains:clang_configuration.bzl",
|
|
"clang_toolchain_extension",
|
|
)
|
|
use_repo(bazel_cc_toolchain, "bazel_cc_toolchain")
|
|
|
|
register_toolchains("@bazel_cc_toolchain//:all")
|
|
|
|
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
|
|
git_override(
|
|
module_name = "hedron_compile_commands",
|
|
# HEAD as of 2023-12-19.
|
|
commit = "af167878427c469db96444b65f026d064ec62a4f",
|
|
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
|
|
)
|
|
|
|
###############################################################################
|
|
# llvm-project
|
|
###############################################################################
|
|
|
|
# We pin to specific upstream commits and try to track top-of-tree reasonably
|
|
# closely rather than pinning to a specific release.
|
|
llvm_project_version = "3d51010a3350660160981c6b8e624dcc87c208a3"
|
|
|
|
# Required for llvm-project.
|
|
bazel_dep(name = "platforms", version = "0.0.8")
|
|
|
|
# zlib and zstd dependencies are copied from
|
|
bazel_dep(name = "zlib", version = "1.3", repo_name = "llvm_zlib")
|
|
bazel_dep(name = "zstd", version = "1.5.5", repo_name = "llvm_zstd")
|
|
|
|
# Load a repository for the raw llvm-project, pre-overlay.
|
|
http_archive(
|
|
name = "llvm-raw",
|
|
build_file_content = "# empty",
|
|
patch_args = ["-p1"],
|
|
patches = [
|
|
"@carbon//bazel/llvm_project:0001_Patch_for_mallinfo2_when_using_Bazel_build_system.patch",
|
|
"@carbon//bazel/llvm_project:0002_Added_Bazel_build_for_compiler_rt_fuzzer.patch",
|
|
"@carbon//bazel/llvm_project:0003_Add_library_for_clangd.patch",
|
|
],
|
|
sha256 = "efbca707a6eb1c714b849de120309070eef282660c0f4be5b68efef62cc95cf5",
|
|
strip_prefix = "llvm-project-{0}".format(llvm_project_version),
|
|
urls = ["https://github.com/llvm/llvm-project/archive/{0}.tar.gz".format(llvm_project_version)],
|
|
)
|
|
|
|
# Apply the overlay to produce llvm-project.
|
|
llvm_project = use_extension(
|
|
"//bazel/llvm_project:llvm_project.bzl",
|
|
"llvm_project",
|
|
)
|
|
use_repo(llvm_project, "llvm-project")
|
|
|
|
###############################################################################
|
|
# Python
|
|
###############################################################################
|
|
|
|
bazel_dep(name = "rules_python", version = "0.27.1")
|
|
|
|
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
|
|
python.toolchain(
|
|
python_version = "3.11",
|
|
)
|
|
use_repo(python, "python_versions")
|
|
|
|
# Create a central repo that knows about the pip dependencies.
|
|
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
|
|
pip.parse(
|
|
hub_name = "py_deps",
|
|
python_version = "3.11",
|
|
requirements_lock = "//github_tools:requirements.txt",
|
|
)
|
|
use_repo(pip, "py_deps")
|