From 5cea7dda5b632703cf4e0424ba09cd7c5bd6fc06 Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 25 Oct 2022 01:21:53 -0700 Subject: [PATCH] Improve the documentation for ctx.actions.symlink. This API does two different things and users occasionally get confused by it (see e.g. https://github.com/bazelbuild/bazel/issues/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 --- .../StarlarkActionFactoryApi.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java index a13a1ba458c1d9..aa6dcb07ed3572 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java @@ -163,19 +163,21 @@ public interface StarlarkActionFactoryApi extends StarlarkValue { @StarlarkMethod( name = "symlink", doc = - "Creates an action that writes a symlink in the file system." - + "

This function must be called with exactly one of target_file or " - + "target_path specified.

" - + "

If target_file is used, then output must be declared " - + "by declare_file() or " - + "declare_directory() and match the " - + "type of target_file. In this case, output will be a " - + "symlink whose contents are the path of target_file.

" - + "

Otherwise, if target_path is used, then output must " - + "be declared with " - + "declare_symlink()). In this case, " - + "output will be a symlink whose contents are target_path." - + "This can be used to create a dangling symlink.

", + "Creates an action that writes a symlink in the file system.

This function must be" + + " called with exactly one of target_file or target_path" + + " specified.

When you use target_file, declare" + + " output with declare_file() or declare_directory() and match the" + + " type of target_file. This makes the symlink point to" + + " target_file. Bazel invalidates the output of this action whenever" + + " the target of the symlink or its contents change.

Otherwise, when you use" + + " target_path, declare output with declare_symlink()). In this case, the" + + " symlink points to target_path. Bazel never resolves the symlink" + + " and the output of this action is invalidated only when the text contents of the" + + " symlink (that is, the value of readlink()) changes. In particular," + + " this can be used to create a dangling symlink.

", parameters = { @Param( name = "output",