2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-12-03 11:52:43 +00:00
bazel-lib/docs/copy_directory.md

101 lines
5.2 KiB
Markdown
Raw Normal View History

2022-04-04 00:52:03 +00:00
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
A rule that copies a directory to another place.
The rule uses a Bash command on Linux/macOS/non-Windows, and a cmd.exe command
on Windows (no Bash is required).
2022-06-10 20:05:19 +00:00
<a id="copy_directory"></a>
2022-04-04 00:52:03 +00:00
## copy_directory
<pre>
copy_directory(<a href="#copy_directory-name">name</a>, <a href="#copy_directory-src">src</a>, <a href="#copy_directory-out">out</a>, <a href="#copy_directory-hardlink">hardlink</a>, <a href="#copy_directory-kwargs">kwargs</a>)
2022-04-04 00:52:03 +00:00
</pre>
Copies a directory to another location.
This rule uses a Bash command on Linux/macOS/non-Windows, and a cmd.exe command on Windows (no Bash is required).
If using this rule with source directories, it is recommended that you use the
`--host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1` startup option so that changes
to files within source directories are detected. See
https://github.com/bazelbuild/bazel/commit/c64421bc35214f0414e4f4226cc953e8c55fa0d2
for more context.
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="copy_directory-name"></a>name | Name of the rule. | none |
| <a id="copy_directory-src"></a>src | The directory to make a copy of. Can be a source directory or TreeArtifact. | none |
2022-04-04 00:52:03 +00:00
| <a id="copy_directory-out"></a>out | Path of the output directory, relative to this package. | none |
| <a id="copy_directory-hardlink"></a>hardlink | Controls when to use hardlinks to files instead of making copies.<br><br>Creating hardlinks is much faster than making copies of files with the caveat that hardlinks share file permissions with their source.<br><br>Since Bazel removes write permissions on files in the output tree after an action completes, hardlinks to source files within source directories is not recommended since write permissions will be inadvertently removed from sources files.<br><br>- "auto": hardlinks are used if src is a tree artifact already in the output tree - "off": files are always copied - "on": hardlinks are always used (not recommended) | <code>"auto"</code> |
2022-04-04 00:52:03 +00:00
| <a id="copy_directory-kwargs"></a>kwargs | further keyword arguments, e.g. <code>visibility</code> | none |
2022-06-10 20:05:19 +00:00
<a id="copy_directory_action"></a>
## copy_directory_action
<pre>
copy_directory_action(<a href="#copy_directory_action-ctx">ctx</a>, <a href="#copy_directory_action-src">src</a>, <a href="#copy_directory_action-dst">dst</a>, <a href="#copy_directory_action-is_windows">is_windows</a>)
</pre>
Legacy factory function that creates an action to copy a directory from src to dst.
For improved analysis and runtime performance, it is recommended the switch
to `copy_directory_bin_action` which takes a tool binary, typically the
`@aspect_bazel_lib//tools/copy_to_directory` `go_binary` either built from
source or provided by a toolchain and creates hard links instead of performing full
file copies.
This helper is used by copy_directory. It is exposed as a public API so it can be used within
other rule implementations.
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="copy_directory_action-ctx"></a>ctx | The rule context. | none |
| <a id="copy_directory_action-src"></a>src | The directory to make a copy of. Can be a source directory or TreeArtifact. | none |
| <a id="copy_directory_action-dst"></a>dst | The directory to copy to. Must be a TreeArtifact. | none |
| <a id="copy_directory_action-is_windows"></a>is_windows | Deprecated and unused | <code>None</code> |
<a id="copy_directory_bin_action"></a>
## copy_directory_bin_action
<pre>
copy_directory_bin_action(<a href="#copy_directory_bin_action-ctx">ctx</a>, <a href="#copy_directory_bin_action-src">src</a>, <a href="#copy_directory_bin_action-dst">dst</a>, <a href="#copy_directory_bin_action-copy_directory_bin">copy_directory_bin</a>, <a href="#copy_directory_bin_action-hardlink">hardlink</a>, <a href="#copy_directory_bin_action-verbose">verbose</a>)
</pre>
Factory function that creates an action to copy a directory from src to dst using a tool binary.
The tool binary will typically be the `@aspect_bazel_lib//tools/copy_directory` `go_binary`
either built from source or provided by a toolchain.
This helper is used by the copy_directory rule. It is exposed as a public API so it can be used
within other rule implementations.
**PARAMETERS**
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="copy_directory_bin_action-ctx"></a>ctx | The rule context. | none |
| <a id="copy_directory_bin_action-src"></a>src | The source directory to copy. | none |
| <a id="copy_directory_bin_action-dst"></a>dst | The directory to copy to. Must be a TreeArtifact. | none |
| <a id="copy_directory_bin_action-copy_directory_bin"></a>copy_directory_bin | Copy to directory tool binary. | none |
| <a id="copy_directory_bin_action-hardlink"></a>hardlink | Controls when to use hardlinks to files instead of making copies.<br><br>See copy_directory rule documentation for more details. | <code>"auto"</code> |
| <a id="copy_directory_bin_action-verbose"></a>verbose | If true, prints out verbose logs to stdout | <code>False</code> |