parent
99f36cc298
commit
894ba445c4
|
@ -42,7 +42,7 @@ for more context.
|
|||
## 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>)
|
||||
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>)
|
||||
</pre>
|
||||
|
||||
Legacy factory function that creates an action to copy a directory from src to dst.
|
||||
|
@ -65,7 +65,6 @@ other rule implementations.
|
|||
| <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>
|
||||
|
|
|
@ -51,7 +51,7 @@ for more context.
|
|||
## copy_file_action
|
||||
|
||||
<pre>
|
||||
copy_file_action(<a href="#copy_file_action-ctx">ctx</a>, <a href="#copy_file_action-src">src</a>, <a href="#copy_file_action-dst">dst</a>, <a href="#copy_file_action-dir_path">dir_path</a>, <a href="#copy_file_action-is_windows">is_windows</a>)
|
||||
copy_file_action(<a href="#copy_file_action-ctx">ctx</a>, <a href="#copy_file_action-src">src</a>, <a href="#copy_file_action-dst">dst</a>, <a href="#copy_file_action-dir_path">dir_path</a>)
|
||||
</pre>
|
||||
|
||||
Factory function that creates an action to copy a file from src to dst.
|
||||
|
@ -72,6 +72,5 @@ other rule implementations.
|
|||
| <a id="copy_file_action-src"></a>src | The source file to copy or TreeArtifact to copy a single file out of. | none |
|
||||
| <a id="copy_file_action-dst"></a>dst | The destination file. | none |
|
||||
| <a id="copy_file_action-dir_path"></a>dir_path | If src is a TreeArtifact, the path within the TreeArtifact to the file to copy. | <code>None</code> |
|
||||
| <a id="copy_file_action-is_windows"></a>is_windows | Deprecated and unused | <code>None</code> |
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ https://github.com/bazelbuild/rules_nodejs/blob/8b5d27400db51e7027fe95ae413eeabe
|
|||
## copy_file_to_bin_action
|
||||
|
||||
<pre>
|
||||
copy_file_to_bin_action(<a href="#copy_file_to_bin_action-ctx">ctx</a>, <a href="#copy_file_to_bin_action-file">file</a>, <a href="#copy_file_to_bin_action-is_windows">is_windows</a>)
|
||||
copy_file_to_bin_action(<a href="#copy_file_to_bin_action-ctx">ctx</a>, <a href="#copy_file_to_bin_action-file">file</a>)
|
||||
</pre>
|
||||
|
||||
Factory function that creates an action to copy a file to the output tree.
|
||||
|
@ -33,7 +33,6 @@ without a copy action.
|
|||
| :------------- | :------------- | :------------- |
|
||||
| <a id="copy_file_to_bin_action-ctx"></a>ctx | The rule context. | none |
|
||||
| <a id="copy_file_to_bin_action-file"></a>file | The file to copy. | none |
|
||||
| <a id="copy_file_to_bin_action-is_windows"></a>is_windows | Deprecated and unused | <code>None</code> |
|
||||
|
||||
**RETURNS**
|
||||
|
||||
|
@ -45,7 +44,7 @@ A File in the output tree.
|
|||
## copy_files_to_bin_actions
|
||||
|
||||
<pre>
|
||||
copy_files_to_bin_actions(<a href="#copy_files_to_bin_actions-ctx">ctx</a>, <a href="#copy_files_to_bin_actions-files">files</a>, <a href="#copy_files_to_bin_actions-is_windows">is_windows</a>)
|
||||
copy_files_to_bin_actions(<a href="#copy_files_to_bin_actions-ctx">ctx</a>, <a href="#copy_files_to_bin_actions-files">files</a>)
|
||||
</pre>
|
||||
|
||||
Factory function that creates actions to copy files to the output tree.
|
||||
|
@ -64,7 +63,6 @@ directly to the result without a copy action.
|
|||
| :------------- | :------------- | :------------- |
|
||||
| <a id="copy_files_to_bin_actions-ctx"></a>ctx | The rule context. | none |
|
||||
| <a id="copy_files_to_bin_actions-files"></a>files | List of File objects. | none |
|
||||
| <a id="copy_files_to_bin_actions-is_windows"></a>is_windows | Deprecated and unused | <code>None</code> |
|
||||
|
||||
**RETURNS**
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ def _copy_bash(ctx, src, dst):
|
|||
)
|
||||
|
||||
# TODO(2.0): remove the legacy copy_directory_action helper
|
||||
def copy_directory_action(ctx, src, dst, is_windows = None):
|
||||
def copy_directory_action(ctx, src, dst):
|
||||
"""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
|
||||
|
@ -79,10 +79,8 @@ def copy_directory_action(ctx, src, dst, is_windows = None):
|
|||
ctx: The rule context.
|
||||
src: The directory to make a copy of. Can be a source directory or TreeArtifact.
|
||||
dst: The directory to copy to. Must be a TreeArtifact.
|
||||
is_windows: Deprecated and unused
|
||||
"""
|
||||
|
||||
# TODO(2.0): remove deprecated & unused is_windows parameter
|
||||
if not src.is_source and not dst.is_directory:
|
||||
fail("src must be a source directory or TreeArtifact")
|
||||
if dst.is_source or not dst.is_directory:
|
||||
|
@ -91,8 +89,7 @@ def copy_directory_action(ctx, src, dst, is_windows = None):
|
|||
# Because copy actions have "local" execution requirements, we can safely assume
|
||||
# the execution is the same as the host platform and generate different actions for Windows
|
||||
# and non-Windows host platforms
|
||||
is_windows = _platform_utils.host_platform_is_windows()
|
||||
if is_windows:
|
||||
if _platform_utils.host_platform_is_windows():
|
||||
_copy_cmd(ctx, src, dst)
|
||||
else:
|
||||
_copy_bash(ctx, src, dst)
|
||||
|
|
|
@ -84,7 +84,7 @@ def _copy_bash(ctx, src, src_path, dst):
|
|||
execution_requirements = _COPY_EXECUTION_REQUIREMENTS,
|
||||
)
|
||||
|
||||
def copy_file_action(ctx, src, dst, dir_path = None, is_windows = None):
|
||||
def copy_file_action(ctx, src, dst, dir_path = None):
|
||||
"""Factory function that creates an action to copy a file from src to dst.
|
||||
|
||||
If src is a TreeArtifact, dir_path must be specified as the path within
|
||||
|
@ -98,10 +98,8 @@ def copy_file_action(ctx, src, dst, dir_path = None, is_windows = None):
|
|||
src: The source file to copy or TreeArtifact to copy a single file out of.
|
||||
dst: The destination file.
|
||||
dir_path: If src is a TreeArtifact, the path within the TreeArtifact to the file to copy.
|
||||
is_windows: Deprecated and unused
|
||||
"""
|
||||
|
||||
# TODO(2.0): remove deprecated & unused is_windows parameter
|
||||
if dst.is_directory:
|
||||
fail("dst must not be a TreeArtifact")
|
||||
if src.is_directory:
|
||||
|
@ -114,8 +112,7 @@ def copy_file_action(ctx, src, dst, dir_path = None, is_windows = None):
|
|||
# Because copy actions have "local" execution requirements, we can safely assume
|
||||
# the execution is the same as the host platform and generate different actions for Windows
|
||||
# and non-Windows host platforms
|
||||
is_windows = _platform_utils.host_platform_is_windows()
|
||||
if is_windows:
|
||||
if _platform_utils.host_platform_is_windows():
|
||||
_copy_cmd(ctx, src, src_path, dst)
|
||||
else:
|
||||
_copy_bash(ctx, src, src_path, dst)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
load("@bazel_skylib//lib:paths.bzl", "paths")
|
||||
load(":copy_file.bzl", "copy_file_action")
|
||||
|
||||
def copy_file_to_bin_action(ctx, file, is_windows = None):
|
||||
def copy_file_to_bin_action(ctx, file):
|
||||
"""Factory function that creates an action to copy a file to the output tree.
|
||||
|
||||
File are copied to the same workspace-relative path. The resulting files is
|
||||
|
@ -29,13 +29,11 @@ def copy_file_to_bin_action(ctx, file, is_windows = None):
|
|||
Args:
|
||||
ctx: The rule context.
|
||||
file: The file to copy.
|
||||
is_windows: Deprecated and unused
|
||||
|
||||
Returns:
|
||||
A File in the output tree.
|
||||
"""
|
||||
|
||||
# TODO(2.0): remove deprecated & unused is_windows parameter
|
||||
if not file.is_source:
|
||||
return file
|
||||
if ctx.label.workspace_name != file.owner.workspace_name:
|
||||
|
@ -60,7 +58,7 @@ and/or correct the `glob` patterns that are including these files in the sources
|
|||
""".format(bin = first))
|
||||
|
||||
dst = ctx.actions.declare_file(file.basename, sibling = file)
|
||||
copy_file_action(ctx, file, dst, is_windows = is_windows)
|
||||
copy_file_action(ctx, file, dst)
|
||||
return dst
|
||||
|
||||
def _file_in_external_repo_error_msg(file):
|
||||
|
@ -91,7 +89,7 @@ target to {file_package} using:
|
|||
package = "%s//%s" % (curr_package_label.workspace_name, curr_package_label.package),
|
||||
)
|
||||
|
||||
def copy_files_to_bin_actions(ctx, files, is_windows = None):
|
||||
def copy_files_to_bin_actions(ctx, files):
|
||||
"""Factory function that creates actions to copy files to the output tree.
|
||||
|
||||
Files are copied to the same workspace-relative path. The resulting list of
|
||||
|
@ -103,14 +101,12 @@ def copy_files_to_bin_actions(ctx, files, is_windows = None):
|
|||
Args:
|
||||
ctx: The rule context.
|
||||
files: List of File objects.
|
||||
is_windows: Deprecated and unused
|
||||
|
||||
Returns:
|
||||
List of File objects in the output tree.
|
||||
"""
|
||||
|
||||
# TODO(2.0): remove deprecated & unused is_windows parameter
|
||||
return [copy_file_to_bin_action(ctx, file, is_windows = is_windows) for file in files]
|
||||
return [copy_file_to_bin_action(ctx, file) for file in files]
|
||||
|
||||
def _copy_to_bin_impl(ctx):
|
||||
files = copy_files_to_bin_actions(ctx, ctx.files.srcs)
|
||||
|
|
Loading…
Reference in New Issue