-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add directory_path rule and DirectoryPathInfo for specifying fi…
…les within tree artifacts (#42)
- Loading branch information
1 parent
f788d28
commit 0fd56dc
Showing
25 changed files
with
616 additions
and
178 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<!-- Generated with Stardoc: http://skydoc.bazel.build --> | ||
|
||
Rule and corresponding provider that joins a label pointing to a TreeArtifact | ||
with a path nested within that directory | ||
|
||
|
||
<a id="#directory_path"></a> | ||
|
||
## directory_path | ||
|
||
<pre> | ||
directory_path(<a href="#directory_path-name">name</a>, <a href="#directory_path-directory">directory</a>, <a href="#directory_path-path">path</a>) | ||
</pre> | ||
|
||
Provide DirectoryPathInfo to reference some path within a directory. | ||
|
||
Otherwise there is no way to give a Bazel label for it. | ||
|
||
**ATTRIBUTES** | ||
|
||
|
||
| Name | Description | Type | Mandatory | Default | | ||
| :------------- | :------------- | :------------- | :------------- | :------------- | | ||
| <a id="directory_path-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | | | ||
| <a id="directory_path-directory"></a>directory | a TreeArtifact (ctx.actions.declare_directory) | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | | | ||
| <a id="directory_path-path"></a>path | path relative to the directory | String | required | | | ||
|
||
|
||
<a id="#DirectoryPathInfo"></a> | ||
|
||
## DirectoryPathInfo | ||
|
||
<pre> | ||
DirectoryPathInfo(<a href="#DirectoryPathInfo-directory">directory</a>, <a href="#DirectoryPathInfo-path">path</a>) | ||
</pre> | ||
|
||
Joins a label pointing to a TreeArtifact with a path nested within that directory. | ||
|
||
**FIELDS** | ||
|
||
|
||
| Name | Description | | ||
| :------------- | :------------- | | ||
| <a id="DirectoryPathInfo-directory"></a>directory | a TreeArtifact (ctx.actions.declare_directory) | | ||
| <a id="DirectoryPathInfo-path"></a>path | path relative to the directory | | ||
|
||
|
||
<a id="#make_directory_path"></a> | ||
|
||
## make_directory_path | ||
|
||
<pre> | ||
make_directory_path(<a href="#make_directory_path-name">name</a>, <a href="#make_directory_path-directory">directory</a>, <a href="#make_directory_path-path">path</a>) | ||
</pre> | ||
|
||
Helper function to convert generate a directory_path target and return its label. | ||
|
||
**PARAMETERS** | ||
|
||
|
||
| Name | Description | Default Value | | ||
| :------------- | :------------- | :------------- | | ||
| <a id="make_directory_path-name"></a>name | Unique name for the generated <code>directory_path</code> target. | none | | ||
| <a id="make_directory_path-directory"></a>directory | a TreeArtifact (ctx.actions.declare_directory) | none | | ||
| <a id="make_directory_path-path"></a>path | path relative to the directory | none | | ||
|
||
**RETURNS** | ||
|
||
The label `name` | ||
|
||
|
||
<a id="#make_directory_paths"></a> | ||
|
||
## make_directory_paths | ||
|
||
<pre> | ||
make_directory_paths(<a href="#make_directory_paths-name">name</a>, <a href="#make_directory_paths-dict">dict</a>) | ||
</pre> | ||
|
||
Helper function to convert a dict of directory to path mappings to directory_path targets and labels. | ||
|
||
For example, | ||
|
||
``` | ||
make_directory_paths("my_name", { | ||
"//directory/artifact:target_1": "file/path", | ||
"//directory/artifact:target_2": ["file/path1", "file/path2"], | ||
}) | ||
``` | ||
|
||
generates the targets, | ||
|
||
``` | ||
directory_path( | ||
name = "my_name_0", | ||
directory = "//directory/artifact:target_1", | ||
path = "file/path" | ||
) | ||
directory_path( | ||
name = "my_name_1", | ||
directory = "//directory/artifact:target_2", | ||
path = "file/path1" | ||
) | ||
directory_path( | ||
name = "my_name_2", | ||
directory = "//directory/artifact:target_2", | ||
path = "file/path2" | ||
) | ||
``` | ||
|
||
and the list of targets is returned, | ||
|
||
``` | ||
[ | ||
"my_name_0", | ||
"my_name_1", | ||
"my_name_2", | ||
] | ||
``` | ||
|
||
|
||
**PARAMETERS** | ||
|
||
|
||
| Name | Description | Default Value | | ||
| :------------- | :------------- | :------------- | | ||
| <a id="make_directory_paths-name"></a>name | The target name to use for the generated targets & labels.<br><br>The names are generated as zero-indexed <code>name + "_" + i</code> | none | | ||
| <a id="make_directory_paths-dict"></a>dict | The dictionary of directory keys to path or path list values. | none | | ||
|
||
**RETURNS** | ||
|
||
The label of the generated `directory_path` targets named `name + "_" + i` | ||
|
||
|
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,30 @@ | ||
# 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. | ||
|
||
"""Rule and corresponding provider that joins a label pointing to a TreeArtifact | ||
with a path nested within that directory | ||
""" | ||
|
||
load( | ||
"//lib/private:directory_path.bzl", | ||
_DirectoryPathInfo = "DirectoryPathInfo", | ||
_directory_path = "directory_path", | ||
_make_directory_path = "make_directory_path", | ||
_make_directory_paths = "make_directory_paths", | ||
) | ||
|
||
directory_path = _directory_path | ||
make_directory_path = _make_directory_path | ||
make_directory_paths = _make_directory_paths | ||
DirectoryPathInfo = _DirectoryPathInfo |
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.