Skip to content

Commit

Permalink
feat: add toolchain pact_verifier_cli
Browse files Browse the repository at this point in the history
  • Loading branch information
opicaud committed Sep 27, 2023
1 parent efde45b commit 18699af
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 45 deletions.
24 changes: 24 additions & 0 deletions rust/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_rust//cargo:defs.bzl", "cargo_bootstrap_repository")
load("//:toolchains.bzl", "pact_reference_toolchain")

filegroup(
name = "pact_verifier_cli",
Expand All @@ -7,3 +8,26 @@ filegroup(

)

pact_reference_toolchain(
name = "toolchain_impl",
pact_verifier_cli = ":pact_verifier_cli_archive",
)

genrule(
name = "pact_verifier_cli_archive",
outs = ["pact_verifier_cli_bin"],
srcs = ["@pact_verifier_cli_archive//file"],
cmd = "gzip -d - < $< > $@",
)

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

toolchain_type(
name = "toolchain_type",
visibility = ["//visibility:public"],
)

49 changes: 11 additions & 38 deletions rust/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,16 @@ rust_register_toolchains(
edition = "2021",
)

load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies")
crate_universe_dependencies(bootstrap = True)

load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_repository", "splicing_config")
load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "crate")
crates_repository(
name = "crate_index",
cargo_lockfile = "//:Cargo.lock",
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
lockfile = "//:cargo-bazel-lock.json",
manifests = [
"//:Cargo.toml",
"//:pact_cli/Cargo.toml",
"//:pact_consumer/Cargo.toml",
"//:pact_ffi/Cargo.toml",
"//:pact_matching/Cargo.toml",
"//:pact_mock_server/Cargo.toml",
"//:pact_mock_server_cli/Cargo.toml",
"//:pact_models/Cargo.toml",
"//:pact_verifier/Cargo.toml",
"//:pact_verifier_cli/Cargo.toml",
],
packages = {
"os_info": crate.spec(
version = "3.5.1",
),
},
annotations = {
"onig_sys": [crate.annotation(
shallow_since="1686508130 +0100"
)],
"onig": [crate.annotation(
shallow_since="1686508130 +0100"
)],
}
)
load("//:repositories.bzl", "repos")

repos()

load("//:deps.bzl", "deps")

deps()

load("//:create_crate.bzl", "create_crate_repositories")

load("@crate_index//:defs.bzl", "crate_repositories")
crate_repositories()
create_crate_repositories()

load("//:create_pact_binaries.bzl", "create_pact_binaries")
2 changes: 1 addition & 1 deletion rust/cargo-bazel-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "355450c2cfffc2a0e02989bde56bfd377f337cc9292c255db310e0365f52bc0c",
"checksum": "71a0c9a1502513d0738fec791fef1e31791a9d2978ee434d48bde073de851d51",
"crates": {
"addr2line 0.21.0": {
"name": "addr2line",
Expand Down
4 changes: 4 additions & 0 deletions rust/create_crate.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
load("@crate_index//:defs.bzl", "crate_repositories")

def create_crate_repositories():
crate_repositories()
2 changes: 1 addition & 1 deletion rust/pact_ffi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ rust_shared_library(
cc_library(
name = "pact_ffi",
deps = [":pact_ffi_lib"],
linkstatic=1,
#linkstatic=1,
visibility = ["//visibility:public"],
)
16 changes: 11 additions & 5 deletions rust/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@bazel_tools//tools/build_defs/repo:git.bzl","git_repository")

def repos():
maybe(
http_archive,
name = "rules_rust",
sha256 = "d125fb75432dc3b20e9b5a19347b45ec607fabe75f98c6c4ba9badaab9c193ce",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.17.0/rules_rust-v0.17.0.tar.gz"],
sha256 = "4a9cb4fda6ccd5b5ec393b2e944822a62e050c7c06f1ea41607f14c4fdec57a2",
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.25.1/rules_rust-v0.25.1.tar.gz"],
)

maybe(
git_repository,
name = "source",
remote = "https://github.com/opicaud/pact-reference",
commit = "34d1638af6f00d7fac449c71dce02aad3b9d6828",
shallow_since = "1688765558 +0200",
branch = "master",
strip_prefix = "rust",
)

maybe(
http_file,
name = "pact_verifier_cli_archive",
sha256 = "57c8ae7c95f46e4a48d3d6a251853dd5dd58917e866266ced665fc48a3fdecdd",
urls = ["https://github.com/pact-foundation/pact-reference/releases/download/pact_verifier_cli-v1.0.1/pact_verifier_cli-linux-x86_64.gz"],
)
18 changes: 18 additions & 0 deletions rust/toolchains.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""pact_reference toolchain implementation"""

def _pact_reference_toolchain_impl(ctx):
return platform_common.ToolchainInfo(
pact_verifier_cli = ctx.file.pact_verifier_cli,
)

pact_reference_toolchain = rule(
implementation = _pact_reference_toolchain_impl,
doc = "A pact reference toolchain",
attrs = {
"pact_verifier_cli": attr.label(
doc = "A pact reference binary",
allow_single_file = True,
mandatory = True,
),
},
)

0 comments on commit 18699af

Please sign in to comment.