-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy rules_directory to bazel-skylib. (#510)
Original implementation is at https://github.com/matts1/rules_directory
- Loading branch information
Showing
23 changed files
with
975 additions
and
2 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
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,23 @@ | ||
<!-- Generated with Stardoc: http://skydoc.bazel.build --> | ||
|
||
Skylib module containing rules to create metadata about directories. | ||
|
||
<a id="directory"></a> | ||
|
||
## directory | ||
|
||
<pre> | ||
directory(<a href="#directory-name">name</a>, <a href="#directory-srcs">srcs</a>) | ||
</pre> | ||
|
||
|
||
|
||
**ATTRIBUTES** | ||
|
||
|
||
| Name | Description | Type | Mandatory | Default | | ||
| :------------- | :------------- | :------------- | :------------- | :------------- | | ||
| <a id="directory-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | | ||
| <a id="directory-srcs"></a>srcs | - | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | | ||
|
||
|
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,46 @@ | ||
<!-- Generated with Stardoc: http://skydoc.bazel.build --> | ||
|
||
Skylib module containing providers for directories. | ||
|
||
<a id="DirectoryInfo"></a> | ||
|
||
## DirectoryInfo | ||
|
||
<pre> | ||
DirectoryInfo(<a href="#DirectoryInfo-entries">entries</a>, <a href="#DirectoryInfo-transitive_files">transitive_files</a>, <a href="#DirectoryInfo-path">path</a>, <a href="#DirectoryInfo-human_readable">human_readable</a>, <a href="#DirectoryInfo-get_path">get_path</a>, <a href="#DirectoryInfo-get_file">get_file</a>, <a href="#DirectoryInfo-get_subdirectory">get_subdirectory</a>) | ||
</pre> | ||
|
||
Information about a directory | ||
|
||
**FIELDS** | ||
|
||
|
||
| Name | Description | | ||
| :------------- | :------------- | | ||
| <a id="DirectoryInfo-entries"></a>entries | (Dict[str, Either[File, DirectoryInfo]]) The entries contained directly within. Ordered by filename | | ||
| <a id="DirectoryInfo-transitive_files"></a>transitive_files | (depset[File]) All files transitively contained within this directory. | | ||
| <a id="DirectoryInfo-path"></a>path | (string) Path to all files contained within this directory. | | ||
| <a id="DirectoryInfo-human_readable"></a>human_readable | (string) A human readable identifier for a directory. Useful for providing error messages to a user. | | ||
| <a id="DirectoryInfo-get_path"></a>get_path | (Function(str) -> DirectoryInfo\|File) A function to return the entry corresponding to the joined path. | | ||
| <a id="DirectoryInfo-get_file"></a>get_file | (Function(str) -> File) A function to return the entry corresponding to the joined path. | | ||
| <a id="DirectoryInfo-get_subdirectory"></a>get_subdirectory | (Function(str) -> DirectoryInfo) A function to return the entry corresponding to the joined path. | | ||
|
||
|
||
<a id="create_directory_info"></a> | ||
|
||
## create_directory_info | ||
|
||
<pre> | ||
create_directory_info(<a href="#create_directory_info-kwargs">kwargs</a>) | ||
</pre> | ||
|
||
|
||
|
||
**PARAMETERS** | ||
|
||
|
||
| Name | Description | Default Value | | ||
| :------------- | :------------- | :------------- | | ||
| <a id="create_directory_info-kwargs"></a>kwargs | <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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- Generated with Stardoc: http://skydoc.bazel.build --> | ||
|
||
Skylib module containing rules to create metadata about subdirectories. | ||
|
||
<a id="subdirectory"></a> | ||
|
||
## subdirectory | ||
|
||
<pre> | ||
subdirectory(<a href="#subdirectory-name">name</a>, <a href="#subdirectory-parent">parent</a>, <a href="#subdirectory-path">path</a>) | ||
</pre> | ||
|
||
|
||
|
||
**ATTRIBUTES** | ||
|
||
|
||
| Name | Description | Type | Mandatory | Default | | ||
| :------------- | :------------- | :------------- | :------------- | :------------- | | ||
| <a id="subdirectory-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | | ||
| <a id="subdirectory-parent"></a>parent | A label corresponding to the parent directory (or subdirectory). | <a href="https://bazel.build/concepts/labels">Label</a> | required | | | ||
| <a id="subdirectory-path"></a>path | A path within the parent directory (eg. "path/to/subdir") | String | required | | | ||
|
||
|
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,54 @@ | ||
<!-- Generated with Stardoc: http://skydoc.bazel.build --> | ||
|
||
Skylib module containing utility functions related to directories. | ||
|
||
<a id="get_child"></a> | ||
|
||
## get_child | ||
|
||
<pre> | ||
get_child(<a href="#get_child-directory">directory</a>, <a href="#get_child-name">name</a>, <a href="#get_child-require_dir">require_dir</a>, <a href="#get_child-require_file">require_file</a>) | ||
</pre> | ||
|
||
Gets the direct child of a directory. | ||
|
||
**PARAMETERS** | ||
|
||
|
||
| Name | Description | Default Value | | ||
| :------------- | :------------- | :------------- | | ||
| <a id="get_child-directory"></a>directory | (DirectoryInfo) The directory to look within. | none | | ||
| <a id="get_child-name"></a>name | (string) The name of the directory/file to look for. | none | | ||
| <a id="get_child-require_dir"></a>require_dir | (bool) If true, throws an error if the value is not a directory. | `False` | | ||
| <a id="get_child-require_file"></a>require_file | (bool) If true, throws an error if the value is not a file. | `False` | | ||
|
||
**RETURNS** | ||
|
||
(File|DirectoryInfo) The content contained within. | ||
|
||
|
||
<a id="get_relative"></a> | ||
|
||
## get_relative | ||
|
||
<pre> | ||
get_relative(<a href="#get_relative-directory">directory</a>, <a href="#get_relative-path">path</a>, <a href="#get_relative-require_dir">require_dir</a>, <a href="#get_relative-require_file">require_file</a>) | ||
</pre> | ||
|
||
Gets a subdirectory contained within a tree of another directory. | ||
|
||
**PARAMETERS** | ||
|
||
|
||
| Name | Description | Default Value | | ||
| :------------- | :------------- | :------------- | | ||
| <a id="get_relative-directory"></a>directory | (DirectoryInfo) The directory to look within. | none | | ||
| <a id="get_relative-path"></a>path | (string) The path of the directory to look for within it. | none | | ||
| <a id="get_relative-require_dir"></a>require_dir | (bool) If true, throws an error if the value is not a directory. | `False` | | ||
| <a id="get_relative-require_file"></a>require_file | (bool) If true, throws an error if the value is not a file. | `False` | | ||
|
||
**RETURNS** | ||
|
||
(File|DirectoryInfo) The directory contained within. | ||
|
||
|
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,37 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
|
||
licenses(["notice"]) | ||
|
||
# export bzl files for the documentation | ||
exports_files( | ||
glob(["*.bzl"]), | ||
visibility = ["//:__subpackages__"], | ||
) | ||
|
||
bzl_library( | ||
name = "directory", | ||
srcs = ["directory.bzl"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
":providers", | ||
"//lib:paths", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "providers", | ||
srcs = ["providers.bzl"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//rules/directory/private:paths", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "subdirectory", | ||
srcs = ["subdirectory.bzl"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
":providers", | ||
], | ||
) |
Oops, something went wrong.