-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: copy_to_directory copies files and directories to an output dir…
…ectory
- Loading branch information
1 parent
905cbb5
commit 0d2981f
Showing
115 changed files
with
849 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!-- Generated with Stardoc: http://skydoc.bazel.build --> | ||
|
||
Copy files and directories to an output directory | ||
|
||
<a id="#copy_to_directory"></a> | ||
|
||
## copy_to_directory | ||
|
||
<pre> | ||
copy_to_directory(<a href="#copy_to_directory-name">name</a>, <a href="#copy_to_directory-is_windows">is_windows</a>, <a href="#copy_to_directory-replace_prefixes">replace_prefixes</a>, <a href="#copy_to_directory-root_paths">root_paths</a>, <a href="#copy_to_directory-srcs">srcs</a>) | ||
</pre> | ||
|
||
Copies files and directories to an output directory. | ||
|
||
Files and directories can be arranged as needed in the output directory using | ||
the `root_paths` and `replace_prefixes` attributes. | ||
|
||
NB: This rule is not yet implemented for Windows | ||
|
||
|
||
**ATTRIBUTES** | ||
|
||
|
||
| Name | Description | Type | Mandatory | Default | | ||
| :------------- | :------------- | :------------- | :------------- | :------------- | | ||
| <a id="copy_to_directory-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | | | ||
| <a id="copy_to_directory-is_windows"></a>is_windows | - | Boolean | required | | | ||
| <a id="copy_to_directory-replace_prefixes"></a>replace_prefixes | Map of paths prefixes to replace in the output directory path when copying files.<br><br>If the output directory path for a file or directory starts with or is equal to a key in the dict then the matching portion of the output directory path is replaced with the dict value for that key.<br><br>Forward slashes (<code>/</code>) should be used as path separators. The final path segment of the key can be a partial match in the corresponding segment of the output directory path.<br><br>If there are multiple keys that match, the longest match wins. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} | | ||
| <a id="copy_to_directory-root_paths"></a>root_paths | List of paths that are roots in the output directory. If a file or directory being copied is in one of the listed paths or one of its subpaths, the output directory path is the path relative to the root path instead of the path relative to the file's workspace.<br><br>Forward slashes (<code>/</code>) should be used as path separators. Partial matches on the final path segment of a root path against the corresponding segment in the full workspace relative path of a file are not matched.<br><br>If there are multiple root paths that match, the longest match wins.<br><br>Defaults to [package_name()] so that the output directory path of files in the target's package and and sub-packages are relative to the target's package and files outside of that retain their full workspace relative paths. | List of strings | optional | [] | | ||
| <a id="copy_to_directory-srcs"></a>srcs | Files and/or directories to copy into the output directory | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] | | ||
|
||
|
||
<a id="#copy_to_directory_lib.impl"></a> | ||
|
||
## copy_to_directory_lib.impl | ||
|
||
<pre> | ||
copy_to_directory_lib.impl(<a href="#copy_to_directory_lib.impl-ctx">ctx</a>) | ||
</pre> | ||
|
||
|
||
|
||
**PARAMETERS** | ||
|
||
|
||
| Name | Description | Default Value | | ||
| :------------- | :------------- | :------------- | | ||
| <a id="copy_to_directory_lib.impl-ctx"></a>ctx | <p align="center"> - </p> | none | | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2019 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# LOCAL MODIFICATIONS | ||
# this has two PRs patched in on top of the original | ||
# https://github.com/bazelbuild/bazel-skylib/blob/7b859037a673db6f606661323e74c5d4751595e6/rules/private/copy_file_private.bzl | ||
# 1) https://github.com/bazelbuild/bazel-skylib/pull/323 | ||
# 2) https://github.com/bazelbuild/bazel-skylib/pull/324 | ||
|
||
"""A rule that copies a file to another place. | ||
native.genrule() is sometimes used to copy files (often wishing to rename them). | ||
The 'copy_file' rule does this with a simpler interface than genrule. | ||
The rule uses a Bash command on Linux/macOS/non-Windows, and a cmd.exe command | ||
on Windows (no Bash is required). | ||
""" | ||
|
||
load( | ||
"//lib/private:copy_file.bzl", | ||
_copy_file = "copy_file", | ||
) | ||
|
||
copy_file = _copy_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"Public API for copy_to_directory" | ||
|
||
load( | ||
"//lib/private:copy_to_directory.bzl", | ||
lib = "copy_to_directory_lib", | ||
) | ||
|
||
_copy_to_directory = rule( | ||
implementation = lib.impl, | ||
provides = lib.provides, | ||
attrs = lib.attrs, | ||
) | ||
|
||
def copy_to_directory(name, root_paths = None, **kwargs): | ||
if root_paths == None: | ||
root_paths = [native.package_name()] | ||
_copy_to_directory( | ||
name = name, | ||
root_paths = root_paths, | ||
is_windows = select({ | ||
"@bazel_tools//src/conditions:host_windows": True, | ||
"//conditions:default": False, | ||
}), | ||
**kwargs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.