diff --git a/WORKSPACE b/WORKSPACE index 450028075..4dcf29602 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,15 +1,9 @@ workspace(name = "io_bazel_rules_scala") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("//scala:deps.bzl", "load_rules_dependencies") -http_archive( - name = "bazel_skylib", - sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz", - ], -) +load_rules_dependencies() load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") @@ -17,15 +11,31 @@ bazel_skylib_workspace() http_archive( name = "rules_python", - sha256 = "ca77768989a7f311186a29747e3e95c936a41dffac779aff6b443db22290d913", - strip_prefix = "rules_python-0.36.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.36.0/rules_python-0.36.0.tar.gz", + sha256 = "ca2671529884e3ecb5b79d6a5608c7373a82078c3553b1fa53206e6b9dddab34", + strip_prefix = "rules_python-0.38.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.38.0/rules_python-0.38.0.tar.gz", ) load("@rules_python//python:repositories.bzl", "py_repositories") py_repositories() +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") + +protobuf_deps() + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") + +rules_proto_dependencies() + +load("@rules_proto//proto:setup.bzl", "rules_proto_setup") + +rules_proto_setup() + +load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains") + +rules_proto_toolchains() + load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config") scala_config(enable_compiler_dependency_tracking = True) @@ -47,22 +57,6 @@ register_toolchains( "@io_bazel_rules_scala_toolchains//...:all", ) -load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") - -rules_proto_dependencies() - -load("@rules_proto//proto:setup.bzl", "rules_proto_setup") - -rules_proto_setup() - -load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains") - -rules_proto_toolchains() - -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") - -protobuf_deps() - # needed for the cross repo proto test local_repository( name = "proto_cross_repo_boundary", @@ -81,10 +75,10 @@ local_repository( http_archive( name = "io_bazel_rules_go", - sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996", + sha256 = "f4a9314518ca6acfa16cc4ab43b0b8ce1e4ea64b81c38d8a3772883f153346b8", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", - "https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.1.zip", + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.50.1/rules_go-v0.50.1.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.50.1/rules_go-v0.50.1.zip", ], ) @@ -96,7 +90,7 @@ load( go_rules_dependencies() -go_register_toolchains(version = "1.19.5") +go_register_toolchains(version = "1.23.0") http_archive( name = "bazelci_rules", diff --git a/scala/deps.bzl b/scala/deps.bzl new file mode 100644 index 000000000..47015de9a --- /dev/null +++ b/scala/deps.bzl @@ -0,0 +1,58 @@ +"""Macro for instantiating repos required for core functionality.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +def load_rules_dependencies(): + """Instantiates repos needed by rules provided by `rules_scala`.""" + maybe( + http_archive, + name = "bazel_skylib", + sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", + ], + ) + + maybe( + http_archive, + name = "rules_cc", + urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"], + sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf", + strip_prefix = "rules_cc-0.0.9", + ) + + # Needed by protobuf-21.7 and Bazel 6.5.0, as later versions require C++14. + maybe( + http_archive, + name = "com_google_absl", + sha256 = "91ac87d30cc6d79f9ab974c51874a704de9c2647c40f6932597329a282217ba8", + strip_prefix = "abseil-cpp-20220623.1", + url = "https://github.com/abseil/abseil-cpp/archive/refs/tags/20220623.1.tar.gz", + ) + + maybe( + http_archive, + name = "rules_java", + urls = [ + "https://github.com/bazelbuild/rules_java/releases/download/7.9.0/rules_java-7.9.0.tar.gz", + ], + sha256 = "41131de4417de70b9597e6ebd515168ed0ba843a325dc54a81b92d7af9a7b3ea", + ) + + maybe( + http_archive, + name = "com_google_protobuf", + sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae", + strip_prefix = "protobuf-21.7", + url = "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v21.7.tar.gz", + ) + + maybe( + http_archive, + name = "rules_proto", + sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295", + strip_prefix = "rules_proto-6.0.2", + url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz", + ) diff --git a/scala/private/macros/scala_repositories.bzl b/scala/private/macros/scala_repositories.bzl index 8e02640ef..17754f895 100644 --- a/scala/private/macros/scala_repositories.bzl +++ b/scala/private/macros/scala_repositories.bzl @@ -1,3 +1,4 @@ +load("//scala:deps.bzl", "load_rules_dependencies") load( "//scala:scala_cross_version.bzl", "extract_major_version", @@ -117,59 +118,6 @@ def dt_patched_compiler_setup(scala_version, scala_compiler_srcjar = None): integrity = srcjar.get("integrity"), ) -def load_rules_dependencies(): - if not native.existing_rule("bazel_skylib"): - http_archive( - name = "bazel_skylib", - sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz", - ], - ) - - # Needed by protobuf-21.7 and Bazel 6.5.0, as later versions require C++14. - if not native.existing_rule("com_google_absl"): - http_archive( - name = "com_google_absl", - sha256 = "91ac87d30cc6d79f9ab974c51874a704de9c2647c40f6932597329a282217ba8", - strip_prefix = "abseil-cpp-20220623.1", - url = "https://github.com/abseil/abseil-cpp/archive/refs/tags/20220623.1.tar.gz", - ) - - if not native.existing_rule("com_google_protobuf"): - http_archive( - name = "com_google_protobuf", - sha256 = "75be42bd736f4df6d702a0e4e4d30de9ee40eac024c4b845d17ae4cc831fe4ae", - strip_prefix = "protobuf-21.7", - url = "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v21.7.tar.gz", - ) - - if not native.existing_rule("rules_cc"): - http_archive( - name = "rules_cc", - urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.6/rules_cc-0.0.6.tar.gz"], - sha256 = "3d9e271e2876ba42e114c9b9bc51454e379cbf0ec9ef9d40e2ae4cec61a31b40", - strip_prefix = "rules_cc-0.0.6", - ) - - if not native.existing_rule("rules_java"): - http_archive( - name = "rules_java", - urls = [ - "https://github.com/bazelbuild/rules_java/releases/download/7.9.0/rules_java-7.9.0.tar.gz", - ], - sha256 = "41131de4417de70b9597e6ebd515168ed0ba843a325dc54a81b92d7af9a7b3ea", - ) - - if not native.existing_rule("rules_proto"): - http_archive( - name = "rules_proto", - sha256 = "6fb6767d1bef535310547e03247f7518b03487740c11b6c6adb7952033fe1295", - strip_prefix = "rules_proto-6.0.2", - url = "https://github.com/bazelbuild/rules_proto/releases/download/6.0.2/rules_proto-6.0.2.tar.gz", - ) - def setup_scala_compiler_sources(srcjars = {}): """Generates Scala compiler source repos used internally by rules_scala.