Skip to content

Commit

Permalink
feat: provide toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
opicaud committed Sep 9, 2023
1 parent 0d997fa commit 90fdd1e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
18 changes: 18 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package(default_visibility = ["//visibility:public"])
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
load("@rules_rust//cargo:defs.bzl", "cargo_build_script")
load("@crate_index_protobuf//:defs.bzl", "all_crate_deps")
load("//:toolchains.bzl", "pact_protobuf_plugin_toolchain")

# This will run the build script from the root of the workspace, and
# collect the outputs.
Expand Down Expand Up @@ -44,3 +45,20 @@ filegroup(
srcs = ['pact-plugin.json'],
visibility = ["//visibility:public"],
)

pact_protobuf_plugin_toolchain(
name = "toolchain_impl",
protobuf_plugin = ":pact_protobuf_plugin_bin",
manifest = ":pact-plugin"
)

toolchain(
name = "toolchain",
toolchain = ":toolchain_impl",
toolchain_type = ":toolchain_type",
)

toolchain_type(
name = "toolchain_type",
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def repos():
git_repository,
name = "source_protobuf",
remote = "https://github.com/opicaud/pact-protobuf-plugin",
commit = "3a2b8b621beb044b675c5809389844a304574370",
branch = "toolchain"
)

24 changes: 24 additions & 0 deletions toolchains.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""pact_protobuf_plugin toolchain implementation"""

def _pact_protobuf_plugin_toolchain_impl(ctx):
return platform_common.ToolchainInfo(
protobuf_plugin = ctx.file.protobuf_plugin,
manifest = ctx.file.manifest
)

pact_protobuf_plugin_toolchain = rule(
implementation = _pact_protobuf_plugin_toolchain_impl,
doc = "A pact protobuf plugin toolchain",
attrs = {
"protobuf_plugin": attr.label(
doc = "A pact protobuf plugin binary",
allow_single_file = True,
mandatory = True,
),
"manifest": attr.label(
doc = "A json manifest",
allow_single_file = True,
mandatory = True,
)
},
)

0 comments on commit 90fdd1e

Please sign in to comment.