fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

David MarcinAllow rust_bindgen rules to disable rustfmt with an attr (#1024)b3933996

0.8.1
1.1 KiB52 linesraw
1load("@rules_cc//cc:defs.bzl", "cc_library")
2load("@rules_rust//bindgen:bindgen.bzl", "rust_bindgen_library")
3load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test")
4
5cc_library(
6    name = "simple",
7    srcs = ["simple.h"],
8)
9
10rust_bindgen_library(
11    name = "simple_bindgen",
12    bindgen_flags = [
13        "--allowlist-var=SIMPLE_.*",
14    ],
15    cc_lib = ":simple",
16    header = "simple.h",
17)
18
19rust_binary(
20    name = "simple_example",
21    srcs = ["main.rs"],
22    deps = [":simple_bindgen"],
23)
24
25rust_test(
26    name = "simple_test",
27    crate = ":simple_example",
28)
29
30# Same as above, except disabling formatting on bindgen.
31rust_bindgen_library(
32    name = "simple_bindgen_unformatted",
33    bindgen_flags = [
34        "--allowlist-var=SIMPLE_.*",
35    ],
36    cc_lib = ":simple",
37    crate_name = "simple_bindgen",
38    header = "simple.h",
39    rustfmt = False,
40)
41
42rust_binary(
43    name = "simple_example_unformatted",
44    srcs = ["main.rs"],
45    crate_name = "simple_example",
46    deps = [":simple_bindgen_unformatted"],
47)
48
49rust_test(
50    name = "simple_test_unformatted",
51    crate = ":simple_example_unformatted",
52)