build: python proto generation in api_build_system.bzl. (#39)

pull/43/head
htuch 8 years ago committed by GitHub
parent 461d2f8f4b
commit 2600ee4ec2
  1. 27
      WORKSPACE
  2. 15
      bazel/api_build_system.bzl

@ -6,7 +6,7 @@ new_git_repository(
commit = "5c6df0cd18c6a429eab739fb711c27f6e1393366",
remote = "https://github.com/googleapis/googleapis.git",
build_file_content = """
load("@protobuf//:protobuf.bzl", "cc_proto_library")
load("@protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library")
cc_proto_library(
name = "http_api_protos",
@ -19,6 +19,19 @@ cc_proto_library(
visibility = ["//visibility:public"],
deps = ["@protobuf//:cc_wkt_protos"],
)
py_proto_library(
name = "http_api_protos_py",
srcs = [
"google/api/annotations.proto",
"google/api/http.proto",
],
include = ".",
default_runtime = "@protobuf//:protobuf_python",
protoc = "@protobuf//:protoc",
visibility = ["//visibility:public"],
deps = ["@protobuf//:protobuf_python"],
)
""",
)
@ -28,3 +41,15 @@ git_repository(
commit = "455b61c6b0f39ac269b26969877dd3c6f3e32270",
remote = "https://github.com/google/protobuf.git",
)
new_http_archive(
name = "six_archive",
build_file = "@protobuf//:six.BUILD",
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55",
)
bind(
name = "six",
actual = "@six_archive//:six",
)

@ -1,4 +1,4 @@
load("@protobuf//:protobuf.bzl", "cc_proto_library")
load("@protobuf//:protobuf.bzl", "cc_proto_library", "py_proto_library")
# TODO(htuch): has_services is currently ignored but will in future support
# gRPC stub generation.
@ -12,4 +12,17 @@ def api_proto_library(name, srcs = [], deps = [], has_services = 0):
"@googleapis//:http_api_protos",
"@protobuf//:cc_wkt_protos",
],
visibility = ["//visibility:public"],
)
py_proto_library(
name = name + "_py",
srcs = srcs,
default_runtime = "@protobuf//:protobuf_python",
protoc = "@protobuf//:protoc",
deps = [d + "_py" for d in deps] + [
"@googleapis//:http_api_protos_py",
"@protobuf//:protobuf_python",
],
visibility = ["//visibility:public"],
)

Loading…
Cancel
Save