|
| 1 | +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| 2 | +load("@rules_python//python:pip.bzl", "pip_import") |
| 3 | + |
| 4 | +def gapic_generator_python(): |
| 5 | + _maybe( |
| 6 | + pip_import, |
| 7 | + name = "gapic_generator_python_pip_deps", |
| 8 | + python_interpreter = "python3", |
| 9 | + requirements = "@gapic_generator_python//:requirements.txt", |
| 10 | + ) |
| 11 | + |
| 12 | + _protobuf_version = "3.11.2" |
| 13 | + _protobuf_version_in_link = "v%s" % _protobuf_version |
| 14 | + _maybe( |
| 15 | + http_archive, |
| 16 | + name = "com_google_protobuf", |
| 17 | + urls = ["https://github.com/protocolbuffers/protobuf/archive/%s.zip" % _protobuf_version_in_link], |
| 18 | + strip_prefix = "protobuf-%s" % _protobuf_version, |
| 19 | + ) |
| 20 | + |
| 21 | + _maybe( |
| 22 | + http_archive, |
| 23 | + name = "bazel_skylib", |
| 24 | + strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b", |
| 25 | + urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"], |
| 26 | + ) |
| 27 | + |
| 28 | + _maybe( |
| 29 | + http_archive, |
| 30 | + name = "com_google_api_codegen", |
| 31 | + strip_prefix = "gapic-generator-b32c73219d617f90de70bfa6ff0ea0b0dd638dfe", |
| 32 | + urls = ["https://github.com/googleapis/gapic-generator/archive/b32c73219d617f90de70bfa6ff0ea0b0dd638dfe.zip"], |
| 33 | + ) |
| 34 | + |
| 35 | +def _maybe(repo_rule, name, strip_repo_prefix = "", **kwargs): |
| 36 | + if not name.startswith(strip_repo_prefix): |
| 37 | + return |
| 38 | + repo_name = name[len(strip_repo_prefix):] |
| 39 | + if repo_name in native.existing_rules(): |
| 40 | + return |
| 41 | + repo_rule(name = repo_name, **kwargs) |
0 commit comments