2
0
Fork 0
mirror of https://github.com/bazelbuild/bazel-skylib synced 2024-11-30 10:41:18 +00:00
bazel-skylib/docs/write_file_doc.md
László Csomor 6bf6443975
write_file: support different line endings (#150)
The user can specify which line endings they want
write_file to use. This helps avoiding line ending
mismatches with diff_test.

Example: diff_test verifies that a rule generates
correct output by comparing it to a checked-in
"golden" file. Both files are text files, and the
user builds on Windows but the golden file was
written on Linux and git checkout preserved
original line endings.

Without explicitly specifying which line endings
to use, this diff_test would fail on an otherwise
good output.

With explicit line endings we don't need to check
in the golden file to git, we can just generate it
with "auto" line endings.
2019-05-09 15:29:44 +02:00

2.1 KiB
Executable file

write_file

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

Creates a UTF-8 encoded text file.

Parameters

name required.

Name of the rule.

out required.

Path of the output file, relative to this package.

content optional. default is []

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 optional. default is False

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.

newline optional. default is "auto"

one of ["auto", "unix", "windows"]: line endings to use. "auto" for platform-determined, "unix" for LF, and "windows" for CRLF.

kwargs optional.

further keyword arguments, e.g. visibility