From 9980a5ddd160e2f7d9cd11ef0ae8362c18cc06d8 Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Wed, 5 Feb 2020 19:13:49 +0100 Subject: [PATCH] Make rules_scala compatible with --incompatible_load_proto_rules_from_bzl --- manual_test/scalac_jvm_opts/BUILD | 6 +-- scala/private/macros/scala_repositories.bzl | 44 ++++++++++++++++--- scala_proto/private/scalapb_aspect.bzl | 6 +-- scala_proto/scala_proto.bzl | 4 ++ test/proto/BUILD | 1 + test/proto2/BUILD | 2 + test/proto3/BUILD | 1 + .../proto_source_root/dependency/BUILD | 2 + .../proto_source_root/user/BUILD | 1 + .../version_specific_tests_dir/proto/BUILD | 1 + .../version_specific_tests_dir/proto2/BUILD | 2 + third_party/bazel/src/main/protobuf/BUILD | 2 + 12 files changed, 59 insertions(+), 13 deletions(-) diff --git a/manual_test/scalac_jvm_opts/BUILD b/manual_test/scalac_jvm_opts/BUILD index 65d39b83ab..0c20353c13 100644 --- a/manual_test/scalac_jvm_opts/BUILD +++ b/manual_test/scalac_jvm_opts/BUILD @@ -1,9 +1,7 @@ +load("@rules_proto//proto:defs.bzl", "proto_library") load("//scala:scala_toolchain.bzl", "scala_toolchain") load("//scala:scala.bzl", "scala_library") -load( - "//scala_proto:scala_proto.bzl", - "scala_proto_library", -) +load("//scala_proto:scala_proto.bzl", "scala_proto_library") scala_toolchain( name = "failing_toolchain_impl", diff --git a/scala/private/macros/scala_repositories.bzl b/scala/private/macros/scala_repositories.bzl index a822993a39..013ffda10d 100644 --- a/scala/private/macros/scala_repositories.bzl +++ b/scala/private/macros/scala_repositories.bzl @@ -134,15 +134,49 @@ def scala_repositories( if not native.existing_rule("com_google_protobuf"): http_archive( name = "com_google_protobuf", - sha256 = "d82eb0141ad18e98de47ed7ed415daabead6d5d1bef1b8cccb6aa4d108a9008f", - strip_prefix = "protobuf-b4f193788c9f0f05d7e0879ea96cd738630e5d51", - # Commit from 2019-05-15, update to protobuf 3.8 when available. + sha256 = "cf754718b0aa945b00550ed7962ddc167167bd922b842199eeb6505e6f344852", + strip_prefix = "protobuf-3.11.3", urls = [ - "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/b4f193788c9f0f05d7e0879ea96cd738630e5d51.tar.gz", - "https://github.com/protocolbuffers/protobuf/archive/b4f193788c9f0f05d7e0879ea96cd738630e5d51.tar.gz", + "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.11.3.tar.gz", + "https://github.com/protocolbuffers/protobuf/archive/v3.11.3.tar.gz", ], ) + if not native.existing_rule("rules_cc"): + http_archive( + name = "rules_cc", + sha256 = "29daf0159f0cf552fcff60b49d8bcd4f08f08506d2da6e41b07058ec50cfeaec", + strip_prefix = "rules_cc-b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e", + urls = ["https://github.com/bazelbuild/rules_cc/archive/b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e.tar.gz"], + ) + + if not native.existing_rule("rules_java"): + http_archive( + name = "rules_java", + sha256 = "f5a3e477e579231fca27bf202bb0e8fbe4fc6339d63b38ccb87c2760b533d1c3", + strip_prefix = "rules_java-981f06c3d2bd10225e85209904090eb7b5fb26bd", + urls = ["https://github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz"], + ) + + if not native.existing_rule("rules_proto"): + http_archive( + name = "rules_proto", + sha256 = "4d421d51f9ecfe9bf96ab23b55c6f2b809cbaf0eea24952683e397decfbd0dd0", + strip_prefix = "rules_proto-f6b8d89b90a7956f6782a4a3609b2f0eee3ce965", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/f6b8d89b90a7956f6782a4a3609b2f0eee3ce965.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/f6b8d89b90a7956f6782a4a3609b2f0eee3ce965.tar.gz", + ], + ) + + if not native.existing_rule("rules_python"): + http_archive( + name = "rules_python", + sha256 = "e5470e92a18aa51830db99a4d9c492cc613761d5bdb7131c04bd92b9834380f6", + strip_prefix = "rules_python-4b84ad270387a7c439ebdccfd530e2339601ef27", + urls = ["https://github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz"], + ) + if not native.existing_rule("zlib"): # needed by com_google_protobuf http_archive( name = "zlib", diff --git a/scala_proto/private/scalapb_aspect.bzl b/scala_proto/private/scalapb_aspect.bzl index 0d51cfb65a..4848ff6216 100644 --- a/scala_proto/private/scalapb_aspect.bzl +++ b/scala_proto/private/scalapb_aspect.bzl @@ -1,7 +1,5 @@ -load( - "//scala/private:common.bzl", - "write_manifest_file", -) +load("@rules_proto//proto:defs.bzl", "ProtoInfo") +load("//scala/private:common.bzl", "write_manifest_file") load("//scala/private:rule_impls.bzl", "compile_scala") load("//scala_proto/private:proto_to_scala_src.bzl", "proto_to_scala_src") diff --git a/scala_proto/scala_proto.bzl b/scala_proto/scala_proto.bzl index ce3f5762f6..2dd296f868 100644 --- a/scala_proto/scala_proto.bzl +++ b/scala_proto/scala_proto.bzl @@ -1,3 +1,7 @@ +load( + "@rules_proto//proto:defs.bzl", + "ProtoInfo", +) load( "//scala:scala_cross_version.bzl", _default_maven_server_urls = "default_maven_server_urls", diff --git a/test/proto/BUILD b/test/proto/BUILD index b8d41b41c2..291295c320 100644 --- a/test/proto/BUILD +++ b/test/proto/BUILD @@ -1,3 +1,4 @@ +load("@rules_proto//proto:defs.bzl", "proto_library") load( "//scala_proto:scala_proto.bzl", "scala_proto_library", diff --git a/test/proto2/BUILD b/test/proto2/BUILD index 96e963557c..2087f7626b 100644 --- a/test/proto2/BUILD +++ b/test/proto2/BUILD @@ -1,3 +1,5 @@ +load("@rules_proto//proto:defs.bzl", "proto_library") + proto_library( name = "test", srcs = ["test.proto"], diff --git a/test/proto3/BUILD b/test/proto3/BUILD index 441040e726..2d28654fbf 100644 --- a/test/proto3/BUILD +++ b/test/proto3/BUILD @@ -2,6 +2,7 @@ load( "//scala_proto:scala_proto.bzl", "scala_proto_library", ) +load("@rules_proto//proto:defs.bzl", "proto_library") genrule( name = "generated", diff --git a/test_expect_failure/proto_source_root/dependency/BUILD b/test_expect_failure/proto_source_root/dependency/BUILD index 37ca7370a6..a514e80b95 100644 --- a/test_expect_failure/proto_source_root/dependency/BUILD +++ b/test_expect_failure/proto_source_root/dependency/BUILD @@ -1,3 +1,5 @@ +load("@rules_proto//proto:defs.bzl", "proto_library") + proto_library( name = "dependency", srcs = glob(["*.proto"]), diff --git a/test_expect_failure/proto_source_root/user/BUILD b/test_expect_failure/proto_source_root/user/BUILD index 4431a28766..34ce095985 100644 --- a/test_expect_failure/proto_source_root/user/BUILD +++ b/test_expect_failure/proto_source_root/user/BUILD @@ -1,3 +1,4 @@ +load("@rules_proto//proto:defs.bzl", "proto_library") load( "//scala_proto:scala_proto.bzl", "scala_proto_library", diff --git a/test_version/version_specific_tests_dir/proto/BUILD b/test_version/version_specific_tests_dir/proto/BUILD index 98f34bea6c..fae744efa4 100644 --- a/test_version/version_specific_tests_dir/proto/BUILD +++ b/test_version/version_specific_tests_dir/proto/BUILD @@ -2,6 +2,7 @@ load( "@io_bazel_rules_scala//scala_proto:scala_proto.bzl", "scala_proto_library", ) +load("@rules_proto//proto:defs.bzl", "proto_library") proto_library( name = "test2", diff --git a/test_version/version_specific_tests_dir/proto2/BUILD b/test_version/version_specific_tests_dir/proto2/BUILD index 96e963557c..2087f7626b 100644 --- a/test_version/version_specific_tests_dir/proto2/BUILD +++ b/test_version/version_specific_tests_dir/proto2/BUILD @@ -1,3 +1,5 @@ +load("@rules_proto//proto:defs.bzl", "proto_library") + proto_library( name = "test", srcs = ["test.proto"], diff --git a/third_party/bazel/src/main/protobuf/BUILD b/third_party/bazel/src/main/protobuf/BUILD index 1ef5c946bd..b4b6c743ba 100644 --- a/third_party/bazel/src/main/protobuf/BUILD +++ b/third_party/bazel/src/main/protobuf/BUILD @@ -1,3 +1,5 @@ +load("@rules_proto//proto:defs.bzl", "proto_library") + licenses(["notice"]) package(default_visibility = ["//visibility:public"])