Skip to content

Commit

Permalink
feat: migrate to bazel 6
Browse files Browse the repository at this point in the history
  • Loading branch information
opicaud committed Jul 22, 2023
1 parent c4e43d9 commit 00c1785
Show file tree
Hide file tree
Showing 10 changed files with 443 additions and 7 deletions.
1 change: 1 addition & 0 deletions rust/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build --enable_bzlmod
364 changes: 364 additions & 0 deletions rust/MODULE.bazel

Large diffs are not rendered by default.

Empty file added rust/WORKSPACE.bzlmod
Empty file.
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": "6aa0e9d2a6be650c803f3c656bde25ba7be33bc50c5b7471e819389c519300fd",
"checksum": "a9249e8f5069fc2af9656ae999b104dacb8a0c19f854d3987f7838e7cffc33df",
"crates": {
"addr2line 0.19.0": {
"name": "addr2line",
Expand Down
4 changes: 0 additions & 4 deletions rust/create_crate.bzl

This file was deleted.

9 changes: 9 additions & 0 deletions rust/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("//:repositories2.bzl", "crate_bazel_deps")

def _non_module_deps_impl(ctx):
crate_bazel_deps()


pact_ref_deps = module_extension(
implementation = _non_module_deps_impl,
)
9 changes: 9 additions & 0 deletions rust/extensions2.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@crate_index//:defs.bzl", "crate_repositories")
def _non_module_deps_impl(ctx):
crate_repositories()


blob = module_extension(
implementation = _non_module_deps_impl,
)

2 changes: 1 addition & 1 deletion rust/pact_verifier/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ rust_library(
srcs = glob(
["src/*.rs"]
),
proc_macro_deps = all_crate_deps(proc_macro = True),
proc_macro_deps = all_crate_deps(package_name = "pact_verifier", proc_macro = True),
deps = ["//pact_matching"] + all_crate_deps(package_name = "pact_verifier"),
)
2 changes: 1 addition & 1 deletion rust/pact_verifier_cli/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("@rules_rust//rust:defs.bzl", "rust_binary")
rust_binary(
name = "pact_verifier_cli",
srcs = glob(["src/*.rs"]),
deps = all_crate_deps(normal = "True") + ["//pact_verifier"],
deps = all_crate_deps(package_name = "pact_verifier_cli", normal = "True") + ["//pact_verifier"],
visibility = ["//visibility:public"],

)
57 changes: 57 additions & 0 deletions rust/repositories2.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_repository")

def crate_bazel_deps():
crates_repository(
name = "crate_index",
cargo_lockfile = "//:Cargo.lock",
generator = "@cargo_bazel_bootstrap//:cargo-bazel",
lockfile = "//:cargo-bazel-lock.json",
rust_toolchain_cargo_template = "@rust_host_tools//:bin/cargo",
rust_toolchain_rustc_template = "@rust_host_tools//:bin/rustc",
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"
)],
},
render_config = '{"build_file_template": "//:BUILD.{name}-{version}.bazel", "crate_label_template": "@crate_index__{name}-{version}//:{target}", "crate_repository_template": "crate_index__{name}-{version}", "crates_module_template": "//:{file}", "default_package_name": "None", "platforms_template": "@rules_rust//rust/platform:{triple}"}'
)

def render_config(
build_file_template = "//:BUILD.{name}-{version}.bazel",
crate_label_template = "@{repository}__{name}-{version}//:{target}",
crate_repository_template = "{repository}__{name}-{version}",
crates_module_template = "//:{file}",
default_package_name = None,
platforms_template = "@rules_rust//rust/platform:{triple}",
regen_command = None,
vendor_mode = None):
return json.encode(struct(
build_file_template = build_file_template,
crate_label_template = crate_label_template,
crate_repository_template = crate_repository_template,
crates_module_template = crates_module_template,
default_package_name = default_package_name,
platforms_template = platforms_template,
regen_command = regen_command,
vendor_mode = vendor_mode,
))

0 comments on commit 00c1785

Please sign in to comment.