Skip to content

Commit 5cea7dd

Browse files
tjgqcopybara-github
authored andcommitted
Improve the documentation for ctx.actions.symlink.
This API does two different things and users occasionally get confused by it (see e.g. bazelbuild#16070). In particular, it is crucial to understand whether Bazel tracks the symlink on its own or the contents of its target. PiperOrigin-RevId: 483604065 Change-Id: Iab14c264eb320cd324b64b3af2a400df948dbf3c
1 parent 1a38552 commit 5cea7dd

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java

+15-13
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,21 @@ public interface StarlarkActionFactoryApi extends StarlarkValue {
163163
@StarlarkMethod(
164164
name = "symlink",
165165
doc =
166-
"Creates an action that writes a symlink in the file system."
167-
+ "<p>This function must be called with exactly one of <code>target_file</code> or "
168-
+ "<code>target_path</code> specified.</p>"
169-
+ "<p>If <code>target_file</code> is used, then <code>output</code> must be declared "
170-
+ "by <a href=\"#declare_file\"><code>declare_file()</code></a> or "
171-
+ "<a href=\"#declare_directory\"><code>declare_directory()</code></a> and match the "
172-
+ "type of <code>target_file</code>. In this case, <code>output</code> will be a "
173-
+ "symlink whose contents are the path of <code>target_file</code>.</p>"
174-
+ "<p>Otherwise, if <code>target_path</code> is used, then <code>output</code> must "
175-
+ "be declared with "
176-
+ "<a href=\"#declare_symlink\"><code>declare_symlink()</code></a>). In this case, "
177-
+ "<code>output</code> will be a symlink whose contents are <code>target_path</code>."
178-
+ "This can be used to create a dangling symlink.</p>",
166+
"Creates an action that writes a symlink in the file system.<p>This function must be"
167+
+ " called with exactly one of <code>target_file</code> or <code>target_path</code>"
168+
+ " specified.</p><p>When you use <code>target_file</code>, declare"
169+
+ " <code>output</code> with <a"
170+
+ " href=\"#declare_file\"><code>declare_file()</code></a> or <a"
171+
+ " href=\"#declare_directory\"><code>declare_directory()</code></a> and match the"
172+
+ " type of <code>target_file</code>. This makes the symlink point to"
173+
+ " <code>target_file</code>. Bazel invalidates the output of this action whenever"
174+
+ " the target of the symlink or its contents change.</p><p>Otherwise, when you use"
175+
+ " <code>target_path</code>, declare <code>output</code> with <a"
176+
+ " href=\"#declare_symlink\"><code>declare_symlink()</code></a>). In this case, the"
177+
+ " symlink points to <code>target_path</code>. Bazel never resolves the symlink"
178+
+ " and the output of this action is invalidated only when the text contents of the"
179+
+ " symlink (that is, the value of <code>readlink()</code>) changes. In particular,"
180+
+ " this can be used to create a dangling symlink.</p>",
179181
parameters = {
180182
@Param(
181183
name = "output",

0 commit comments

Comments
 (0)