pull/24478/head
Richard Belleville 4 years ago
parent 79f54e9d57
commit b0dfa295a0
  1. 10
      tools/distrib/python/grpcio_tools/BUILD.bazel
  2. 15
      tools/distrib/python/grpcio_tools/grpcio_tools.bzl

@ -39,10 +39,10 @@ pyx_library(
)
internal_copied_filegroup(
name = "well_known_protos",
srcs = ["@com_google_protobuf//:well_known_protos"],
strip_prefix = "src/",
dest = "grpc_tools/_proto/",
name = "well_known_protos",
srcs = ["@com_google_protobuf//:well_known_protos"],
dest = "grpc_tools/_proto/",
strip_prefix = "src/",
)
py_library(
@ -51,6 +51,7 @@ py_library(
"grpc_tools/__init__.py",
"grpc_tools/protoc.py",
],
data = [":well_known_protos"],
imports = ["."],
srcs_version = "PY2AND3",
deps = [
@ -58,5 +59,4 @@ py_library(
"//src/python/grpcio/grpc:grpcio",
"@com_google_protobuf//:protobuf_python",
],
data = [":well_known_protos"],
)

@ -23,10 +23,12 @@ def _generate_copied_files_impl(ctx):
if f.path.startswith("external"):
external_separator = f.path.find("/")
repository_separator = f.path.find("/", external_separator + 1)
destination_path = f.path[repository_separator+1:]
destination_path = f.path[repository_separator + 1:]
if not destination_path.startswith(strip_prefix):
fail("File '{}' did not start with '{}'.".format(
destination_path, strip_prefix))
destination_path,
strip_prefix,
))
destination_path = dest + destination_path[len(strip_prefix):]
destination_dir = destination_path.rfind("/")
out_file = ctx.actions.declare_file(destination_path)
@ -35,12 +37,14 @@ def _generate_copied_files_impl(ctx):
inputs = [f],
outputs = [out_file],
command = "mkdir -p {0} && cp {1} {2}".format(
out_file.dirname, f.path, out_file.path),
out_file.dirname,
f.path,
out_file.path,
),
)
return [DefaultInfo(files = depset(direct = outs))]
_generate_copied_files = rule(
attrs = {
"srcs": attr.label_list(
@ -52,12 +56,11 @@ _generate_copied_files = rule(
),
"dest": attr.string(
mandatory = True,
)
),
},
implementation = _generate_copied_files_impl,
)
def internal_copied_filegroup(name, srcs, strip_prefix, dest):
"""Copies a file group to the current package.

Loading…
Cancel
Save