Skip to content

Commit

Permalink
Migrate to MODULE.bazel for Bazel 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
hchataing committed Feb 1, 2025
1 parent e3b0b0a commit 01d9a43
Show file tree
Hide file tree
Showing 30 changed files with 62 additions and 2,341 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Cargo.lock
MODULE.bazel.lock
target/
bazel-*
43 changes: 14 additions & 29 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_rust//rust:defs.bzl", "rust_static_library")
load("@rules_rust//rust:defs.bzl", "rust_library")
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")

package(default_visibility = ["//visibility:private"])
licenses(["notice"])
Expand Down Expand Up @@ -35,18 +32,6 @@ cc_proto_library(
deps = [":rootcanal_proto"],
)

rust_library(
name = "pdl_runtime",
srcs = glob(["third_party/pdl/pdl-runtime/**/*.rs"]),
crate_root = "third_party/pdl/pdl-runtime/src/lib.rs",
edition = "2018",
version = "2.0.0",
deps = [
"//rust/cargo:bytes",
"//rust/cargo:thiserror",
],
)

genrule(
name = "lmp_packets_rs",
cmd = "pdlc --output-format rust $(location rust/lmp_packets.pdl) > $(location lmp_packets.rs)",
Expand Down Expand Up @@ -103,18 +88,18 @@ rust_static_library(
"lmp_packets.rs",
],
proc_macro_deps = [
"//rust/cargo:num_derive",
"//rust/cargo:paste",
"@crates//:num-derive",
"@crates//:paste",
],
deps = [
":pdl_runtime",
"//rust/cargo:bytes",
"//rust/cargo:num_bigint",
"//rust/cargo:num_integer",
"//rust/cargo:num_traits",
"//rust/cargo:pin_utils",
"//rust/cargo:rand",
"//rust/cargo:thiserror",
"@crates//:bytes",
"@crates//:num-bigint",
"@crates//:num-integer",
"@crates//:num-traits",
"@crates//:pdl-runtime",
"@crates//:pin-utils",
"@crates//:rand",
"@crates//:thiserror",
],
)

Expand Down Expand Up @@ -211,9 +196,6 @@ cc_library(
"-I.",
"-fmacro-prefix-map=external/rootcanal/=",
],
linkopts = [
"-lcrypto",
],
defines = [
"NDEBUG",
"_GNU_SOURCE",
Expand All @@ -229,6 +211,7 @@ cc_library(
":rootcanal_rs",
"//packets:generated",
"@fmtlib",
"@openssl",
"@pdl//:packet_runtime",
],
)
Expand Down Expand Up @@ -296,8 +279,9 @@ cc_binary(
":rootcanal_log",
":rootcanal_rs",
"//packets:generated",
"@fmtlib",
"@pdl//:packet_runtime",
"@fmtlib",
"@openssl",
],
)

Expand All @@ -316,5 +300,6 @@ cc_binary(
":rootcanal_rs",
"@gflags",
"@fmtlib",
"@openssl",
],
)
47 changes: 47 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2025 Google Inc. All Rights Reserved.

module(
name = "rootcanal",
repo_name = "com_github_google_rootcanal",
)

bazel_dep(name = "rules_cc", version = "0.1.0")
bazel_dep(name = "rules_rust", version = "0.57.1")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "rules_python", version = "1.1.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")

bazel_dep(name = "openssl", version = "3.3.1.bcr.1")
bazel_dep(name = "gflags", version = "2.2.2")

local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")

new_local_repository(
name = "fmtlib",
path = "third_party/fmtlib",
build_file = "//:BUILD.fmtlib",
)

new_local_repository(
name = "pdl",
path = "third_party/pdl",
build_file = "//:BUILD.pdl",
)

crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")

crate.spec(package = "bytes", version = "1.0.1")
crate.spec(package = "num-bigint", version = "0.4.3")
crate.spec(package = "num-derive", version = "0.3.3")
crate.spec(package = "num-integer", version = "0.1.45")
crate.spec(package = "num-traits", version = "0.2.14")
crate.spec(package = "paste", version = "1.0.4")
crate.spec(package = "pdl-runtime", version = "0.2.2")
crate.spec(package = "pin-utils", version = "0.1.0")
crate.spec(package = "rand", version = "0.8.3")
crate.spec(package = "thiserror", version = "1.0.23")
crate.spec(package = "bytes", version = "1.0.1")

crate.from_specs()
use_repo(crate, "crates")
77 changes: 0 additions & 77 deletions WORKSPACE

This file was deleted.

94 changes: 0 additions & 94 deletions rust/cargo/BUILD.bazel

This file was deleted.

Loading

0 comments on commit 01d9a43

Please sign in to comment.