Skip to content

Commit 0773e9d

Browse files
committed
Cover top-level BUILD.bazel + MODULE.bazel in mdbook Bazel chapter.
This commit is motivated by the discussion in #1676. Including the top-level `BUILD.bazel` will hopefully help to hightlight how the same `version` is used across `cxxbridge`, `cxxbridge-macro`, and `cxx` targets.
1 parent 6c3e01d commit 0773e9d

File tree

1 file changed

+14
-75
lines changed

1 file changed

+14
-75
lines changed

book/src/build/bazel.md

Lines changed: 14 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -35,84 +35,23 @@ as an illustration of one possible working pattern.
3535
```python
3636
# tools/bazel/rust_cxx_bridge.bzl
3737

38-
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
39-
load("@rules_cc//cc:defs.bzl", "cc_library")
40-
41-
def rust_cxx_bridge(name, src, deps = []):
42-
native.alias(
43-
name = "%s/header" % name,
44-
actual = src + ".h",
45-
)
46-
47-
native.alias(
48-
name = "%s/source" % name,
49-
actual = src + ".cc",
50-
)
51-
52-
run_binary(
53-
name = "%s/generated" % name,
54-
srcs = [src],
55-
outs = [
56-
src + ".h",
57-
src + ".cc",
58-
],
59-
args = [
60-
"$(location %s)" % src,
61-
"-o",
62-
"$(location %s.h)" % src,
63-
"-o",
64-
"$(location %s.cc)" % src,
65-
],
66-
tool = "//:codegen",
67-
)
68-
69-
cc_library(
70-
name = name,
71-
srcs = [src + ".cc"],
72-
deps = deps + [":%s/include" % name],
73-
)
74-
75-
cc_library(
76-
name = "%s/include" % name,
77-
hdrs = [src + ".h"],
78-
)
38+
{{#include ../../../tools/bazel/rust_cxx_bridge.bzl}}
7939
```
8040

8141
```python
8242
# demo/BUILD.bazel
8343

84-
load("@rules_cc//cc:defs.bzl", "cc_library")
85-
load("@rules_rust//rust:defs.bzl", "rust_binary")
86-
load("//tools/bazel:rust_cxx_bridge.bzl", "rust_cxx_bridge")
87-
88-
rust_binary(
89-
name = "demo",
90-
srcs = glob(["src/**/*.rs"]),
91-
deps = [
92-
":blobstore-sys",
93-
":bridge",
94-
"//:cxx",
95-
],
96-
)
97-
98-
rust_cxx_bridge(
99-
name = "bridge",
100-
src = "src/main.rs",
101-
deps = [":blobstore-include"],
102-
)
103-
104-
cc_library(
105-
name = "blobstore-sys",
106-
srcs = ["src/blobstore.cc"],
107-
deps = [
108-
":blobstore-include",
109-
":bridge/include",
110-
],
111-
)
112-
113-
cc_library(
114-
name = "blobstore-include",
115-
hdrs = ["include/blobstore.h"],
116-
deps = ["//:core"],
117-
)
44+
{{#include ../../../demo/BUILD.bazel}}
45+
```
46+
47+
```python
48+
# BUILD.bazel
49+
50+
{{#include ../../../BUILD.bazel}}
51+
```
52+
53+
```python
54+
# MODULE.bazel
55+
56+
{{#include ../../../MODULE.bazel}}
11857
```

0 commit comments

Comments
 (0)