protobuf/protobuf_release.bzl
Derek Perez 3a4d9316aa
Creates a protoc release zip (#9188)
* Creates a protoc release zip

Mimics what we're doing manually today but powered by Bazel.

* don't special case this.

* Addressing feedback.

* adding comment about _cc_toolchain
2021-11-04 15:57:29 -07:00

29 lines
857 B
Python

"""
Generates package naming variables for use with rules_pkg.
"""
load("@rules_pkg//:providers.bzl", "PackageVariablesInfo")
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
load(":protobuf_version.bzl", "PROTOBUF_VERSION")
def _package_naming_impl(ctx):
values = {}
values["version"] = PROTOBUF_VERSION
# infer from the current cpp toolchain.
toolchain = find_cpp_toolchain(ctx)
values["cpu"] = toolchain.cpu
return PackageVariablesInfo(values = values)
package_naming = rule(
implementation = _package_naming_impl,
attrs = {
# Necessary data dependency for find_cpp_toolchain.
"_cc_toolchain": attr.label(default = Label("@bazel_tools//tools/cpp:current_cc_toolchain")),
},
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
incompatible_use_toolchain_transition = True,
)