You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: designs/2022-07-21-locating-runfiles-with-bzlmod.md
+5-18
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,8 @@ The repository mapping manifest would then look as follows:
76
76
2. Every triple `(C, A, repo_mapping(C, A))` is written as a single line terminated by `\n`, with the three components separated by `,`.
77
77
Since neither canonical nor apparent repository names can contain commas, this is unambiguous.
78
78
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.
80
81
3. The lines of the manifest are sorted lexicographically.
81
82
This ordering is equivalent to the lexicographical ordering of the triples comprising the repository mapping.
82
83
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,42 +115,28 @@ cc_binary(
114
115
],
115
116
deps= ["@bazel_tools//tools/cpp/runfiles"],
116
117
)
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
-
)
125
118
```
126
119
127
120
With `my_module` as the root module and Bzlmod enabled, the repository mapping manifest of `//:some_tool` would look as follows:
128
121
129
122
```
130
123
,my_module,my_workspace
131
-
,my_workspace,my_workspace
132
124
,my_protobuf,@protobuf~3.19.2
125
+
,my_workspace,my_workspace
133
126
```
134
127
135
128
* 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.
136
129
* 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.
137
130
* 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.
138
131
* 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.
147
133
148
134
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):
0 commit comments