|
| 1 | +module( |
| 2 | + name = "code", |
| 3 | + version = "0.1.0", |
| 4 | +) |
| 5 | + |
| 6 | +# -- bazel_dep definitions -- # |
| 7 | + |
| 8 | +bazel_dep(name = "gazelle", version = "0.45.0") |
| 9 | +bazel_dep(name = "rules_cc", version = "0.2.3") |
| 10 | +bazel_dep(name = "rules_go", version = "0.57.0") |
| 11 | +bazel_dep(name = "toolchains_llvm", version = "1.5.0") |
| 12 | +bazel_dep(name = "rules_oci", version = "2.2.6") |
| 13 | + |
| 14 | +# NOTE from the Bzlmod migration: |
| 15 | +# For the dependencies below, a higher version was used compared to what was in |
| 16 | +# WORKSPACE. The reason is that the WORKSPACE versions were often arbitrary |
| 17 | +# commit hashes and I couldn't be arsed to do overrides, and figured that these |
| 18 | +# dependencies had stable enough APIs that I can probably live with a later |
| 19 | +# version too. |
| 20 | +bazel_dep(name = "abseil-cpp", version = "20250814.0") |
| 21 | +bazel_dep(name = "google_benchmark", version = "1.9.4") |
| 22 | +bazel_dep(name = "googletest", version = "1.17.0") |
| 23 | +bazel_dep(name = "re2", version = "2025-08-12") |
| 24 | + |
| 25 | +bazel_dep(name = "hedron_compile_commands") |
| 26 | +git_override( |
| 27 | + module_name = "hedron_compile_commands", |
| 28 | + commit = "abb61a688167623088f8768cc9264798df6a9d10", |
| 29 | + remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git", |
| 30 | +) |
| 31 | + |
| 32 | +# For some completely incomprehensible reason, there appears to be a dependency version problem in the combination of |
| 33 | +# - the `github.com/docker/docker` Go module |
| 34 | +# - the `re2` Bazel module |
| 35 | +# - the `rules_cc` Bazel module |
| 36 | +# - the `abseil-cpp` Bazel module |
| 37 | +# that causes build errors for me. They look like this: |
| 38 | +# |
| 39 | +# $ bazel build //... |
| 40 | +# ERROR: /home/saser/.cache/bazel/_bazel_saser/06ad534583e887506ca6aa175f8ed7b5/external/abseil-cpp+/absl/utility/BUILD.bazel: no such target '@@abseil-cpp+//absl/utility:if_constexpr': target 'if_constexpr' not declared in package 'absl/utility' defined by /home/saser/.cache/bazel/_bazel_saser/06ad534583e887506ca6aa175f8ed7b5/external/abseil-cpp+/absl/utility/BUILD.bazel |
| 41 | +# ERROR: /home/saser/.cache/bazel/_bazel_saser/06ad534583e887506ca6aa175f8ed7b5/external/protobuf+/src/google/protobuf/BUILD.bazel:483:11: no such target '@@abseil-cpp+//absl/utility:if_constexpr': target 'if_constexpr' not declared in package 'absl/utility' defined by /home/saser/.cache/bazel/_bazel_saser/06ad534583e887506ca6aa175f8ed7b5/external/abseil-cpp+/absl/utility/BUILD.bazel and referenced by '@@protobuf+//src/google/protobuf:protobuf_lite' |
| 42 | +# ERROR: Analysis of target '//docker/dockertest:dockertest' failed; build aborted: Analysis failed |
| 43 | +# INFO: Elapsed time: 0.734s, Critical Path: 0.00s |
| 44 | +# INFO: 1 process: 1 internal. |
| 45 | +# ERROR: Build did NOT complete successfully |
| 46 | +# |
| 47 | +# And somehow, bumping the version of Protobuf (it resolves to 29.0 otherwise) |
| 48 | +# fixes this problem. I don't know why, but I'm keeping it here until further |
| 49 | +# notice. I might start relying on it anyway to run `protoc`, who knows. |
| 50 | +bazel_dep(name = "protobuf", version = "32.0") |
| 51 | + |
| 52 | +# NOTE: there was a dependency on bazel_skylib but I dropped it because I |
| 53 | +# couldn't find any references to it in this repo... can't remember why I added |
| 54 | +# it either, maybe to fix some transitive dependency? |
| 55 | + |
| 56 | +# -- use_repo_rule statements -- # |
| 57 | + |
| 58 | +# -- repo definitions -- # |
| 59 | + |
| 60 | +llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm") |
| 61 | +llvm.toolchain( |
| 62 | + llvm_version = "15.0.6", |
| 63 | +) |
| 64 | +use_repo(llvm, "llvm_toolchain") |
| 65 | + |
| 66 | +register_toolchains("@llvm_toolchain//:all") |
| 67 | + |
| 68 | +go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk") |
| 69 | +go_sdk.from_file(go_mod = "//:go.mod") |
| 70 | + |
| 71 | +go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps") |
| 72 | +go_deps.from_file(go_mod = "//:go.mod") |
| 73 | + |
| 74 | +# See the README file located next to the patch file for an explanation of what |
| 75 | +# it does. |
| 76 | +go_deps.module_override( |
| 77 | + patch_strip = 1, |
| 78 | + patches = ["//patches/com_github_docker_cli:01-fix-broken-embeds.patch"], |
| 79 | + path = "github.com/docker/cli", |
| 80 | +) |
| 81 | + |
| 82 | +# All *direct* Go dependencies of the module have to be listed explicitly. |
| 83 | +use_repo(go_deps, "cc_mvdan_gofumpt", "com_github_bazelbuild_buildtools", "com_github_cenkalti_backoff_v4", "com_github_google_go_cmp", "com_github_google_uuid", "com_github_jackc_pgerrcode", "com_github_jackc_pgx_v5", "com_github_jonboulle_clockwork", "com_github_masterminds_squirrel", "com_github_ory_dockertest_v3", "com_github_stretchr_testify", "io_k8s_klog_v2", "org_golang_google_grpc", "org_golang_google_grpc_cmd_protoc_gen_go_grpc", "org_golang_google_protobuf") |
| 84 | + |
| 85 | +oci = use_extension("@rules_oci//oci:extensions.bzl", "oci") |
| 86 | +oci.pull( |
| 87 | + name = "distroless_base", |
| 88 | + digest = "sha256:d605e138bb398428779e5ab490a6bbeeabfd2551bd919578b1044718e5c30798", |
| 89 | + image = "gcr.io/distroless/base", |
| 90 | + platforms = ["linux/amd64"], |
| 91 | +) |
| 92 | +oci.pull( |
| 93 | + name = "hello_world", |
| 94 | + digest = "sha256:a0dfb02aac212703bfcb339d77d47ec32c8706ff250850ecc0e19c8737b18567", |
| 95 | + image = "hello-world", |
| 96 | + platforms = ["linux/amd64"], |
| 97 | +) |
| 98 | +oci.pull( |
| 99 | + name = "nginx", |
| 100 | + # 'latest' as of 2025-09-13. |
| 101 | + digest = "sha256:d5f28ef21aabddd098f3dbc21fe5b7a7d7a184720bc07da0b6c9b9820e97f25e", |
| 102 | + image = "nginx", |
| 103 | + platforms = ["linux/amd64"], |
| 104 | +) |
| 105 | +oci.pull( |
| 106 | + name = "postgres", |
| 107 | + # 'latest' as of 2025-09-13. |
| 108 | + digest = "sha256:feff5b24fedd610975a1f5e743c51a4b360437f4dc3a11acf740dcd708f413f6", |
| 109 | + image = "postgres", |
| 110 | + platforms = ["linux/amd64"], |
| 111 | +) |
| 112 | + |
| 113 | +# For each oci.pull call, repeat the "name" here to expose them as dependencies. |
| 114 | +use_repo(oci, "distroless_base", "distroless_base_linux_amd64", "hello_world", "hello_world_linux_amd64", "nginx", "nginx_linux_amd64", "postgres", "postgres_linux_amd64") |
0 commit comments