From 062df9e8b223e2687a63f289bfd9ca3d7a3e787b Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Wed, 5 Feb 2020 19:13:49 +0100 Subject: [PATCH 1/3] 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 | 16 ++----- 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, 61 insertions(+), 21 deletions(-) diff --git a/manual_test/scalac_jvm_opts/BUILD b/manual_test/scalac_jvm_opts/BUILD index 65d39b83a..0c20353c1 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 a822993a3..013ffda10 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 d76fd18ce..0844933f2 100644 --- a/scala_proto/private/scalapb_aspect.bzl +++ b/scala_proto/private/scalapb_aspect.bzl @@ -1,15 +1,7 @@ -load( - "//scala/private:common.bzl", - "write_manifest_file", -) -load( - "//scala/private:dependency.bzl", - "legacy_unclear_dependency_info_for_protobuf_scrooge", -) -load( - "//scala/private:rule_impls.bzl", - "compile_scala", -) +load("@rules_proto//proto:defs.bzl", "ProtoInfo") +load("//scala/private:common.bzl", "write_manifest_file") +load("//scala/private:dependency.bzl", "legacy_unclear_dependency_info_for_protobuf_scrooge") +load("//scala/private:rule_impls.bzl", "compile_scala") load("//scala_proto/private:proto_to_scala_src.bzl", "proto_to_scala_src") ScalaPBAspectInfo = provider(fields = [ diff --git a/scala_proto/scala_proto.bzl b/scala_proto/scala_proto.bzl index ce3f5762f..2dd296f86 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 b8d41b41c..291295c32 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 96e963557..2087f7626 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 441040e72..2d28654fb 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 37ca7370a..a514e80b9 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 4431a2876..34ce09598 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 98f34bea6..fae744efa 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 96e963557..2087f7626 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 1ef5c946b..b4b6c743b 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"]) From 67e8f82a835e97cc3c46a5b5ac9a82d6ff8316f2 Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Sat, 8 Feb 2020 13:40:47 +0100 Subject: [PATCH 2/3] Use rules_java@0.1.1 --- scala/private/macros/scala_repositories.bzl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scala/private/macros/scala_repositories.bzl b/scala/private/macros/scala_repositories.bzl index 013ffda10..2de55e4c2 100644 --- a/scala/private/macros/scala_repositories.bzl +++ b/scala/private/macros/scala_repositories.bzl @@ -153,9 +153,8 @@ def scala_repositories( 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"], + sha256 = "220b87d8cfabd22d1c6d8e3cdb4249abd4c93dcc152e0667db061fb1b957ee68", + urls = ["https://github.com/bazelbuild/rules_java/releases/download/0.1.1/rules_java-0.1.1.tar.gz",], ) if not native.existing_rule("rules_proto"): @@ -180,7 +179,7 @@ def scala_repositories( if not native.existing_rule("zlib"): # needed by com_google_protobuf http_archive( name = "zlib", - build_file = "@com_google_protobuf//:third_party/zlib.BUILD", + build_file = "@com_google_protobuf//third_party:zlib.BUILD", sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", strip_prefix = "zlib-1.2.11", urls = [ From c497b11c0887b48e9365840e2d6e82847c5225be Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Sat, 8 Feb 2020 14:30:51 +0100 Subject: [PATCH 3/3] Run ./lint.sh --- scala/private/macros/scala_repositories.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scala/private/macros/scala_repositories.bzl b/scala/private/macros/scala_repositories.bzl index 2de55e4c2..2f84dc292 100644 --- a/scala/private/macros/scala_repositories.bzl +++ b/scala/private/macros/scala_repositories.bzl @@ -154,7 +154,7 @@ def scala_repositories( http_archive( name = "rules_java", sha256 = "220b87d8cfabd22d1c6d8e3cdb4249abd4c93dcc152e0667db061fb1b957ee68", - urls = ["https://github.com/bazelbuild/rules_java/releases/download/0.1.1/rules_java-0.1.1.tar.gz",], + urls = ["https://github.com/bazelbuild/rules_java/releases/download/0.1.1/rules_java-0.1.1.tar.gz"], ) if not native.existing_rule("rules_proto"):