2
0
Fork 0
mirror of https://github.com/bazelbuild/bazel-skylib synced 2024-11-28 08:43:51 +00:00
bazel-skylib/docs/write_file_doc.md
Alexandre Rostovtsev 6e30a77347
Update internal dependencies to modern versions. Bazel Federation repo is deprecated. (#327)
See https://github.com/bazelbuild/bazel-federation/pull/127

In particular, this allows us to use a modern Stardoc release to fix generated md docs.

And we can remove internal_deps.bzl/internal_setup.bzl - it's unnecessary complexity
needed only for deprecated Federation setup.
2021-10-27 09:13:59 -04:00

1.8 KiB
Executable file

A rule that writes a UTF-8 encoded text file from user-specified contents.

native.genrule() is sometimes used to create a text file. The 'write_file' and macro does this with a simpler interface than genrule.

The rules generated by the macro do not use Bash or any other shell to write the file. Instead they use Starlark's built-in file writing action (ctx.actions.write).

write_file

write_file(name, out, content, is_executable, newline, kwargs)

Creates a UTF-8 encoded text file.

PARAMETERS

Name Description Default Value
name Name of the rule. none
out Path of the output file, relative to this package. none
content A list of strings. Lines of text, the contents of the file. Newlines are added automatically after every line except the last one. []
is_executable A boolean. Whether to make the output file executable. When True, the rule's output can be executed using bazel run and can be in the srcs of binary and test rules that require executable sources. False
newline one of ["auto", "unix", "windows"]: line endings to use. "auto" for platform-determined, "unix" for LF, and "windows" for CRLF. "auto"
kwargs further keyword arguments, e.g. <code>visibility</code> none