bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.15k stars 4.05k forks source link

Expose Artifact#isSymlink() to Starlark #11209

Open Yannic opened 4 years ago

Yannic commented 4 years ago

This is a feature request to expose Artifact#isSymlink() to Starlark so users can check whether a file is a symlink. Note that this only makes sense for unresolved symlinks, which are still experimental (--experimental_allow_unresolved_symlinks).

//cc @brandjon

brandjon commented 4 years ago

I requested this in #10695. Given that using the wrong kind of file in the wrong place causes an error, I figured there should be a mechanism for code to distinguish between them.

That said, the use is hypothetical, and I think it's fine to not prioritize unless/until real use cases pop up.

Documentation for the field should be clear that it only refers to whether the File was declared as a symlink, e.g. by using ctx.actions.declare_symlink(). In particular, even when is_symlink is false, the physical file path can still be a symlink that points to another File.