protocrap 0.3.2

A small, efficient, and flexible protobuf implementation
Documentation
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")

# Generate embedded const from JSON test data
genrule(
    name = "test_embed_generated",
    srcs = [
        "//test-protos:descriptor_set",
        "test_data.json",
    ],
    outs = ["src/test_embed.pc.rs"],
    cmd = "$(execpath //:protocrap-codegen) $(location //test-protos:descriptor_set) --embed $(location test_data.json):Test --crate-path 'test_protos' -o $@",
    tools = ["//:protocrap-codegen"],
)

# Codegen tests library
rust_library(
    name = "codegen_tests_lib",
    srcs = [
        "src/lib.rs",
        ":test_embed_generated",
    ],
    crate_name = "codegen_tests",
    edition = "2024",
    visibility = ["//visibility:public"],
    deps = [
        "//:protocrap",
        "//test-protos:test_protos",
        "@crates//:allocator-api2",
        "@crates//:serde",
        "@crates//:serde_json",
    ],
)

# Codegen tests
rust_test(
    name = "codegen_tests",
    crate = ":codegen_tests_lib",
    deps = [
        "@crates//:criterion",
        "@crates//:rand",
    ],
)