Skip to content

Commit 06ae07a

Browse files
committed
Add a further special case and fix the example
1 parent 97bd4b1 commit 06ae07a

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

designs/2022-07-21-locating-runfiles-with-bzlmod.md

+4-18
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ The repository mapping manifest would then look as follows:
7676
2. Every triple `(C, A, repo_mapping(C, A))` is written as a single line terminated by `\n`, with the three components separated by `,`.
7777
Since neither canonical nor apparent repository names can contain commas, this is unambiguous.
7878
As a special case, if `repo_mapping(C, A)` is the empty string (i.e., when the apparent name resolves to the main repository), it is serialized as the workspace name (either the value of the `name` attribute of the `workspace` function or `__main__`) instead.
79-
This is necessary since the main repository is stored under this name.
79+
This is necessary since the main repository is stored under this name in the runfiles tree.
80+
As a further special case, if `A` is the empty string, which happens only for the main workspace, the corresponding entry is skipped.
8081
3. The lines of the manifest are sorted lexicographically.
8182
This ordering is equivalent to the lexicographical ordering of the triples comprising the repository mapping.
8283
4. The repository mapping manifest for an executable target `T` consists only of those entries `(C, A, repo_mapping(C, A))` for which both of the following conditions are satisfied:
@@ -114,36 +115,21 @@ cc_binary(
114115
],
115116
deps = ["@bazel_tools//tools/cpp/runfiles"],
116117
)
117-
cc_binary(
118-
name = "other_tool",
119-
srcs = ["main.cpp"],
120-
data = [
121-
"@my_protobuf//:protoc",
122-
],
123-
deps = ["@bazel_tools//tools/cpp/runfiles"],
124-
)
125118
```
126119

127120
With `my_module` as the root module and Bzlmod enabled, the repository mapping manifest of `//:some_tool` would look as follows:
128121

129122
```
130123
,my_module,my_workspace
131-
,my_workspace,my_workspace
132124
,my_protobuf,@protobuf~3.19.2
125+
,my_workspace,my_workspace
133126
```
134127

135128
* The manifest contains the canonical repository name for the workspace and module name since `//:some_tool` has a data dependency on `//:data.txt` and a direct dependency on a runfiles library.
136129
* The manifest contains the canonical repository name for protobuf since `//:some_tool` has a data dependency on `@my_protobuf//:protoc` and a direct dependency on a runfiles library.
137130
* The manifest does *not* contain any entries where `C` is `@protobuf~3.19.2` since the `//:protoc` target does not transitively depend on a runfiles library.
138131
* The manifest does *not* contain any entries referencing `rules_go`, even though the main module depends on it. `rules_go` neither contributes any runfiles to `//:some_tool` nor any target that depends on a runfiles library.
139-
140-
The repository mapping manifest of `//:other_tool` would look as follows:
141-
142-
```
143-
,my_protobuf,@protobuf~3.19.2
144-
```
145-
146-
This manifest does *not* contain any entries where `repo_mapping(C, A)` is `my_workspace` since the target does not include any runfiles from the main repository.
132+
* The manifest does *not* contain any entries where `repo_mapping(C, A)` is `bazel_tool` since the target does not include any runfiles from that repository.
147133

148134
If a module `other_module` depends on `my_module` and contains a target that depends on `@my_module//:some_tool`, then that target's repository mapping manifest would contain the following lines (among others):
149135

0 commit comments

Comments
 (0)