tools

various tools I have been using throughout the years
Log | Files | Refs | README | LICENSE

BUILD (1221B)


      1 load("@crates//:defs.bzl", "all_crate_deps")
      2 load("@rules_rust//rust:defs.bzl", "rust_binary")
      3 load("//bazel:rust.bzl", "rust_app", "rust_lib")
      4 
      5 # The library carries all the logic (and the unit tests); the binary is a thin
      6 # entry point, so the same code can be reused to generate the man page.
      7 rust_lib(
      8     name = "dam_lib",
      9     srcs = glob(
     10         ["src/**/*.rs"],
     11         exclude = ["src/main.rs"],
     12     ),
     13     crate_name = "dam",
     14     deps = all_crate_deps(),
     15 )
     16 
     17 rust_app(
     18     name = "dam",
     19     srcs = ["src/main.rs"],
     20     deps = all_crate_deps() + [":dam_lib"],
     21 )
     22 
     23 # Man-page generator (the `mangen` example). Tagged manual so `//...` builds and
     24 # the shipped binary stay free of clap_mangen; it is built only when the man
     25 # page is generated.
     26 rust_binary(
     27     name = "mangen",
     28     srcs = ["examples/mangen.rs"],
     29     edition = "2024",
     30     tags = ["manual"],
     31     deps = all_crate_deps() + all_crate_deps(normal_dev = True) + [":dam_lib"],
     32 )
     33 
     34 # `bazel build //dam:man` renders the man page into bazel-out; to refresh the
     35 # committed dam/dam.1 in place run `make man-gen` (cargo run --example mangen).
     36 genrule(
     37     name = "man",
     38     outs = ["man/dam.1"],
     39     cmd = "$(execpath :mangen) $@",
     40     tools = [":mangen"],
     41 )