diff --git a/docs/write_source_files.md b/docs/write_source_files.md index 892ede4..09c5d93 100644 --- a/docs/write_source_files.md +++ b/docs/write_source_files.md @@ -2,6 +2,41 @@ Public API for write_source_files + + +## write_source_file + +
+write_source_file(name, in_file, out_file, executable, additional_update_targets,
+                  suggested_update_target, diff_test, kwargs)
+
+ +Write a file or directory to the source tree. + +By default, `diff_test` targets are generated that ensure the source tree file or directory to be written to +is up to date and the rule also checks that the source tree file or directory to be written to exists. +To disable the exists check and up-to-date test set `diff_test` to `False`. + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| name | Name of the runnable target that creates or updates the source tree file or directory. | none | +| in_file | File or directory to use as the desired content to write to out_file.

This is typically a file or directory output of another target. If in_file is a directory then entire directory contents are copied. | None | +| out_file | The file or directory to write to in the source tree. Must be within the same bazel package as the target. | None | +| executable | Whether source tree file or files within the source tree directory written should be made executable. | False | +| additional_update_targets | List of other write_source_files or write_source_file targets to call in the same run. | [] | +| suggested_update_target | Label of the write_source_files or write_source_file target to suggest running when files are out of date. | None | +| diff_test | Test that the source tree file or directory exist and is up to date. | True | +| kwargs | Other common named parameters such as tags or visibility | none | + +**RETURNS** + +Name of the generated test target if requested, otherwise None. + + ## write_source_files @@ -103,8 +138,8 @@ NOTE: If you run formatters or linters on your codebase, it is advised that you | name | Name of the runnable target that creates or updates the source tree files and/or directories. | none | | files | A dict where the keys are files or directories in the source tree to write to and the values are labels pointing to the desired content, typically file or directory outputs of other targets.

Source tree files and directories must be within the same bazel package as the target. | {} | | executable | Whether source tree files written should be made executable.

This applies to all source tree files written by this target. This attribute is not propagated to additional_update_targets.

To set different executable permissions on different source tree files use multiple write_source_files targets. | False | -| additional_update_targets | List of other write_source_files or other executable updater targets to call in the same run. | [] | -| suggested_update_target | Label of the write_source_files target to suggest running when files are out of date. | None | +| additional_update_targets | List of other write_source_files or write_source_file targets to call in the same run. | [] | +| suggested_update_target | Label of the write_source_files or write_source_file target to suggest running when files are out of date. | None | | diff_test | Test that the source tree files and/or directories exist and are up to date. | True | | kwargs | Other common named parameters such as tags or visibility | none | diff --git a/lib/private/write_source_file.bzl b/lib/private/write_source_file.bzl index b0baa35..e0ffacf 100644 --- a/lib/private/write_source_file.bzl +++ b/lib/private/write_source_file.bzl @@ -38,7 +38,7 @@ def write_source_file( executable: Whether source tree file or files within the source tree directory written should be made executable. - additional_update_targets: List of other `write_source_files`, write_source_file` or other executable updater targets to call in the same run. + additional_update_targets: List of other `write_source_files` or `write_source_file` targets to call in the same run. suggested_update_target: Label of the `write_source_files` or `write_source_file` target to suggest running when files are out of date. diff --git a/lib/write_source_files.bzl b/lib/write_source_files.bzl index 8e20dc9..82f6c7b 100644 --- a/lib/write_source_files.bzl +++ b/lib/write_source_files.bzl @@ -5,9 +5,6 @@ load( _write_source_file = "write_source_file", ) -# TODO: Make write_source_file part of the public API -# write_source_file = _write_source_file - def write_source_files( name, files = {}, @@ -113,9 +110,9 @@ def write_source_files( To set different executable permissions on different source tree files use multiple `write_source_files` targets. - additional_update_targets: List of other `write_source_files` or other executable updater targets to call in the same run. + additional_update_targets: List of other `write_source_files` or `write_source_file` targets to call in the same run. - suggested_update_target: Label of the `write_source_files` target to suggest running when files are out of date. + suggested_update_target: Label of the `write_source_files` or `write_source_file` target to suggest running when files are out of date. diff_test: Test that the source tree files and/or directories exist and are up to date. @@ -168,3 +165,5 @@ def write_source_files( diff_test = False, **kwargs ) + +write_source_file = _write_source_file