Skip to content

Commit

Permalink
Move rules_proto and protocolbuffers/ubp to distdir_deps.bzl
Browse files Browse the repository at this point in the history
- generate @rules_proto workspace inclusions in tests
- src/test/java/com/google/devtools/build/lib/blackbox/framework/BlackBoxTestEnvironment.java will be done in a future CL. That will be the first case where we need to generate Java code. It requires some design up front.

Context: bazelbuild#12081
  • Loading branch information
aiuto committed Jan 13, 2021
1 parent f431b0c commit dfd6b97
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 83 deletions.
44 changes: 1 addition & 43 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,12 @@ distdir_tar(
archives = [
"coverage_output_generator-v2.5.zip",
"android_tools_pkg-0.19.0rc3.tar.gz",
# bazelbuild/rules_proto
"7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
# protocolbuffers/upb
"382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz",
],
dirname = "derived/distdir",
dist_deps = {dep: attrs for dep, attrs in DIST_DEPS.items() if "additional_distfiles" in attrs["used_in"]},
sha256 = {
"coverage_output_generator-v2.5.zip": "cd14f1cb4559e4723e63b7e7b06d09fcc3bd7ba58d03f354cdff1439bd936a7d",
"android_tools_pkg-0.19.0rc3.tar.gz": "ea5c0589a01e2a9f43c20e5c145d3530e3b3bdbe7322789bc5da38d0ca49b837",
# bazelbuild/rules_proto
"7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz": "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da",
# protocolbuffers/upb
"382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz": "7992217989f3156f8109931c1fc6db3434b7414957cb82371552377beaeb9d6c",
},
urls = {
"coverage_output_generator-v2.5.zip": [
Expand All @@ -153,16 +145,6 @@ distdir_tar(
"android_tools_pkg-0.19.0rc3.tar.gz": [
"https://mirror.bazel.build/bazel_android_tools/android_tools_pkg-0.19.0rc3.tar.gz",
],
# bazelbuild/rules_proto
"7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz": [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
],
# protocolbuffers/upb
"382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz": [
"https://mirror.bazel.build/github.com/protocolbuffers/upb/archive/382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz",
"https://github.com/protocolbuffers/upb/archive/382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz",
],
},
)

Expand Down Expand Up @@ -330,16 +312,10 @@ dist_http_archive(
patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_FILE_WIN,
)

http_archive(
dist_http_archive(
name = "rules_proto",
patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE,
patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN,
sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da",
strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
],
)

# For testing, have an distdir_tar with all the archives implicit in every
Expand All @@ -354,10 +330,6 @@ distdir_tar(
"zulu11.37.17-ca-jdk11.0.6-macosx_x64.tar.gz",
"zulu11.37.17-ca-jdk11.0.6-win_x64.zip",
"android_tools_pkg-0.19.0rc3.tar.gz",
# bazelbuild/rules_proto
"7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
# protocolbuffers/upb
"382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz",
],
dirname = "test_WORKSPACE/distdir",
dist_deps = {dep: attrs for dep, attrs in DIST_DEPS.items() if "test_WORKSPACE_files" in attrs["used_in"]},
Expand All @@ -368,10 +340,6 @@ distdir_tar(
"zulu11.37.17-ca-jdk11.0.6-macosx_x64.tar.gz": "e1fe56769f32e2aaac95e0a8f86b5a323da5af3a3b4bba73f3086391a6cc056f",
"zulu11.37.17-ca-jdk11.0.6-win_x64.zip": "a9695617b8374bfa171f166951214965b1d1d08f43218db9a2a780b71c665c18",
"android_tools_pkg-0.19.0rc3.tar.gz": "ea5c0589a01e2a9f43c20e5c145d3530e3b3bdbe7322789bc5da38d0ca49b837",
# bazelbuild/rules_proto
"7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz": "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da",
# protocolbuffers/upb
"382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz": "7992217989f3156f8109931c1fc6db3434b7414957cb82371552377beaeb9d6c",
},
urls = {
"coverage_output_generator-v2.5.zip": ["https://mirror.bazel.build/bazel_coverage_output_generator/releases/coverage_output_generator-v2.5.zip"],
Expand All @@ -382,16 +350,6 @@ distdir_tar(
"android_tools_pkg-0.19.0rc3.tar.gz": [
"https://mirror.bazel.build/bazel_android_tools/android_tools_pkg-0.19.0rc3.tar.gz",
],
# bazelbuild/rules_proto
"7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz": [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
],
# protocolbuffers/upb
"382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz": [
"https://mirror.bazel.build/github.com/protocolbuffers/upb/archive/382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz",
"https://github.com/protocolbuffers/upb/archive/382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz",
],
},
)

Expand Down
27 changes: 27 additions & 0 deletions distdir_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ DIST_DEPS = {
"test_WORKSPACE_files",
],
},
# TODO(aiuto): Update src/test/java/com/google/devtools/build/lib/blackbox/framework/BlackBoxTestEnvironment.java to use
# this dynamically.
"rules_proto": {
"archive": "7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
"sha256": "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da",
"strip_prefix": "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488",
"urls": [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
],
"used_in": [
"additional_distfiles",
"test_WORKSPACE_files",
],
},
#################################################
#
# Dependencies which are part of the Bazel binary
Expand All @@ -93,6 +108,18 @@ DIST_DEPS = {
"test_WORKSPACE_files",
],
},
"protocolbuffers": {
"archive": "382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz",
"sha256": "7992217989f3156f8109931c1fc6db3434b7414957cb82371552377beaeb9d6c",
"urls": [
"https://mirror.bazel.build/github.com/protocolbuffers/upb/archive/382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz",
"https://github.com/protocolbuffers/upb/archive/382d5afc60e05470c23e8de19b19fc5ad231e732.tar.gz",
],
"used_in": [
"additional_distfiles",
"test_WORKSPACE_files",
],
},
"com_github_grpc_grpc": {
"archive": "v1.32.0.tar.gz",
"sha256": "f880ebeb2ccf0e47721526c10dd97469200e40b5f101a0d9774eb69efa0bd07a",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ gen_workspace_stanza(
"remote_java_tools_darwin",
"rules_cc",
"rules_java",
"rules_proto",
],
template = "jdk.WORKSPACE.tmpl",
use_maybe = True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,6 @@ maybe(
{rules_cc}

# Needed only because of java_tools.
maybe(
http_archive,
"rules_proto",
sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da",
strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
],
)
{rules_proto}

register_toolchains("@bazel_tools//tools/jdk:all")
1 change: 1 addition & 0 deletions src/test/shell/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ gen_workspace_stanza(
repos = [
"rules_cc",
"rules_java",
"rules_proto",
],
template = "testenv.sh.tmpl",
visibility = ["//visibility:public"],
Expand Down
15 changes: 14 additions & 1 deletion src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("//:distdir_deps.bzl", "gen_workspace_stanza")

package(default_visibility = ["//visibility:private"])

filegroup(
Expand All @@ -20,6 +22,14 @@ genrule(
cmd = "cp $< $@",
)

gen_workspace_stanza(
name = "rules_proto_stanza",
out = "rules_proto_stanza.txt",
repos = [
"rules_proto",
],
)

filegroup(
name = "test-deps",
testonly = 1,
Expand Down Expand Up @@ -326,7 +336,10 @@ sh_test(
name = "bazel_proto_library_test",
size = "large", # Downloads and compiles protobuf for *every* *test* *case*
srcs = ["bazel_proto_library_test.sh"],
data = [":test-deps"],
data = [
":rules_proto_stanza.txt",
":test-deps",
],
exec_compatible_with = ["//:highcpu_machine"],
tags = ["no_windows"], # Doesn't work on Windows for unknown reason
)
Expand Down
13 changes: 3 additions & 10 deletions src/test/shell/bazel/bazel_proto_library_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,9 @@ new_local_repository(
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_proto",
strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488",
sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
],
)
EOF
cat $(rlocation io_bazel/src/tests/shell/bazel/rules_proto_stanza.txt) >> "$workspace"WORKSPACE
cat >> "$workspace"WORKSPACE << EOF
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()
Expand Down
10 changes: 10 additions & 0 deletions src/test/shell/integration/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("//:distdir_deps.bzl", "gen_workspace_stanza")
load("@rules_cc//cc:defs.bzl", "cc_binary")

package(default_visibility = ["//visibility:private"])
Expand Down Expand Up @@ -36,6 +37,14 @@ filegroup(
],
)

gen_workspace_stanza(
name = "rules_proto_stanza",
out = "rules_proto_stanza.txt",
repos = [
"rules_proto",
],
)

sh_test(
name = "progress_reporting_test",
size = "large",
Expand Down Expand Up @@ -355,6 +364,7 @@ sh_test(
name = "modify_execution_info_test",
srcs = ["modify_execution_info_test.sh"],
data = [
":rules_proto_stanza.txt",
":test-deps",
"@bazel_tools//tools/bash/runfiles",
],
Expand Down
13 changes: 3 additions & 10 deletions src/test/shell/integration/modify_execution_info_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,9 @@ new_local_repository(
build_file = "$(rlocation io_bazel/third_party/rules_python/BUILD)",
workspace_file = "$(rlocation io_bazel/third_party/rules_python/rules_python.WORKSPACE)",
)
http_archive(
name = "rules_proto",
strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488",
sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
],
)
EOF
cat "$(rlocation "io_bazel/src/test/shell/integration/rules_proto_stanza.txt")" >>WORKSPACE
cat >> WORKSPACE << EOF
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()
Expand Down
10 changes: 1 addition & 9 deletions src/test/shell/testenv.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,7 @@ function add_rules_proto_to_workspace() {
cat >> "$1"<<EOF
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_proto",
sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da",
strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz",
],
)
{rules_proto}
EOF
}

Expand Down

0 comments on commit dfd6b97

Please sign in to comment.