-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to bazel modules #1320
Comments
This is still not as easy as it should be. I've gone through the current dependencies in the WORKSPACE and found this list:
The rules repositories have full module support and there are ways to add non-module repos like we currently do (OCMock, FMDB, MOL*). The most problematic repository right now is com_google_protobuf, which is in the bazel central registry but not the current version that we're in the middle of upgrading to (26.1) and the old version that is in the registry (23.1) won't compile on macOS ( While we wait for that to be fixed, I can get on with adding MODULE.bazel files to the MOL* repositories, which will make using those much easier. For ref, here's the MODULE.bazel I have right now: module(name = "santa")
bazel_dep(name = "apple_support", version = "1.15.1", repo_name = "build_bazel_apple_support")
bazel_dep(name = "abseil-cpp", version = "20240116.1")
bazel_dep(name = "rules_python", version = "0.31.0")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_apple", version = "3.5.0", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_swift", version = "1.18.0")
bazel_dep(name = "protobuf", version = "23.1", repo_name = "com_google_protobuf")
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
commit = "0e990032f3c5a866e72615cf67e5ce22186dcb97",
# Replace the commit hash (above) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main).
# Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
)
non_module_deps = use_extension("//:non_module_deps.bzl", "non_module_deps")
use_repo(non_module_deps, "MOLAuthenticatingURLSession")
use_repo(non_module_deps, "MOLCodesignChecker")
use_repo(non_module_deps, "MOLCertificate")
use_repo(non_module_deps, "MOLXPCConnection")
use_repo(non_module_deps, "FMDB")
use_repo(non_module_deps, "OCMock") The load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
def _non_module_deps_impl(ctx):
# Macops Library dependencies haven't (yet) upgraded to Bazel modules.
git_repository(
name = "MOLAuthenticatingURLSession",
remote = "https://github.com/google/macops-molauthenticatingurlsession.git",
commit = "38b5ee46edb262481b16f950266a11d8cb77127c",
shallow_since = "1671479898 -0500",
)
...
# FMDB is used to access SQLite from Objective-C(++) code.
git_repository(
name = "FMDB",
remote = "https://github.com/ccgus/fmdb.git",
commit = "61e51fde7f7aab6554f30ab061cc588b28a97d04",
shallow_since = "1589301502 -0700",
build_file_content = """
objc_library(
name = "FMDB",
srcs = glob(["src/fmdb/*.m"], exclude=["src/fmdb.m"]),
hdrs = glob(["src/fmdb/*.h"]),
includes = ["src"],
sdk_dylibs = ["sqlite3"],
visibility = ["//visibility:public"],
)
""",
)
non_module_deps = module_extension(implementation = _non_module_deps_impl) |
All that's left now is the Go dependencies to run Moroz for the integration test.
|
We make extensive use of dependency imports in our WORKSPACE file because we've been using bazel since pre-1.0. The modern version of this is to use a MODULE.bazel file (where available) to declare dependencies.
Some of our dependencies are not going to be in the Bazel Central Registry, so we'll either have to add them ourselves or use
use_repo_rule
.The text was updated successfully, but these errors were encountered: