Merge remote-tracking branch 'origin/main' into HEAD

This commit is contained in:
Philipp Schrader 2022-09-13 19:57:26 -07:00
commit 6765506092
44 changed files with 338 additions and 142 deletions

View File

@ -96,4 +96,18 @@ tasks:
- "--test_env=LOCALAPPDATA"
- "--test_tag_filters=-no_windows"
ubuntu1804_last_green_bzlmod:
name: "Last Green Bazel (with bzlmod)"
platform: ubuntu1804
bazel: last_green
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--experimental_enable_bzlmod"
test_flags:
- "--experimental_enable_bzlmod"
- "--test_env=PATH"
buildifier: latest

6
BUILD
View File

@ -7,7 +7,10 @@ package(default_visibility = ["//visibility:public"])
# buildifier: disable=skylark-comment
# gazelle:exclude skylark_library.bzl
exports_files(["LICENSE"])
exports_files([
"LICENSE",
"MODULE.bazel",
])
filegroup(
name = "test_deps",
@ -69,6 +72,7 @@ filegroup(
"BUILD",
"CODEOWNERS",
"CONTRIBUTORS",
"WORKSPACE.bzlmod",
"//lib:distribution",
"//rules:distribution",
"//rules/private:distribution",

View File

@ -1,3 +1,26 @@
Release 1.3.0
**New Features**
- Added `dicts.omit` and `dicts.pick` (#304)
- Added `expand_template` rule (#330)
- Added `subpackages` module (#348)
- Added `copy_directory` rule (#366)
- Added `bzlmod` support (#385)
**Incompatible Changes**
- `native_binary` and `native_test` now use symlinks instead of copying, if
the OS supports it (#340)
- `native_binary` and `native_test` now build in target configuration instead
of host configuration (#341)
- `copy_file` no longer adds non-executables to `default_runfiles` (#326)
**Contributors**
Alex Eagle, Alexandre Rostovtsev, Barry McNamara, Derek Cormier, Fabian
Meumertzheim, Geoffrey Martin-Noble, hchsiao, Kevin Kres, nickgooding,
Vertexwahn, Vinh Tran
Release 1.2.1
Bugfix release: fixes build failure with --incompatible_disallow_empty_glob

33
MODULE.bazel Normal file
View File

@ -0,0 +1,33 @@
module(
name = "bazel_skylib",
compatibility_level = 1,
version = "1.3.0",
)
register_toolchains(
"//toolchains/unittest:cmd_toolchain",
"//toolchains/unittest:bash_toolchain",
)
bazel_dep(name = "platforms", version = "0.0.4")
### INTERNAL ONLY - lines after this are not included in the release packaging.
# Gazelle extension is experimental
bazel_dep(name = "rules_go", repo_name = "io_bazel_rules_go", version = "0.33.0")
bazel_dep(name = "gazelle", repo_name = "bazel_gazelle", version = "0.26.0")
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
go_deps.module(
path = "github.com/bazelbuild/buildtools",
sum = "h1:fmdo+fvvWlhldUcqkhAMpKndSxMN3vH5l7yow5cEaiQ=",
version = "v0.0.0-20220531122519-a43aed7014c8",
)
use_repo(go_deps, "com_github_bazelbuild_buildtools")
# Build-only / test-only dependencies
bazel_dep(name = "stardoc", dev_dependency = True, repo_name = "io_bazel_stardoc", version = "0.5.1")
bazel_dep(name = "rules_pkg", dev_dependency = True, version = "0.5.1")
bazel_dep(name = "rules_cc", dev_dependency = True, version = "0.0.1")

View File

@ -61,8 +61,14 @@ s = shell.quote(p)
* [analysis_test](docs/analysis_test_doc.md)
* [build_test](docs/build_test_doc.md)
* [common_settings](docs/common_settings_doc.md)
* [copy_directory](docs/copy_directory_doc.md)
* [copy_file](docs/copy_file_doc.md)
* [diff_test](docs/diff_test_doc.md)
* [expand_template](docs/expand_template_doc.md)
* [native_binary and native_test](docs/native_binary_doc.md)
* [run_binary](docs/run_binary_doc.md)
* [select_file](docs/select_file_doc.md)
* [write_file](docs/write_file_doc.md)
## Writing a new module

View File

@ -6,10 +6,10 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
maybe(
name = "io_bazel_rules_go",
repo_rule = http_archive,
sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f",
sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
],
)
@ -26,10 +26,10 @@ go_register_toolchains(version = "1.17.1")
maybe(
http_archive,
name = "io_bazel_stardoc",
sha256 = "c9794dcc8026a30ff67cf7cf91ebe245ca294b20b071845d12c192afe243ad72",
sha256 = "aa814dae0ac400bbab2e8881f9915c6f47c49664bf087c409a15f90438d2c23e",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.5.0/stardoc-0.5.0.tar.gz",
"https://github.com/bazelbuild/stardoc/releases/download/0.5.0/stardoc-0.5.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.5.1/stardoc-0.5.1.tar.gz",
"https://github.com/bazelbuild/stardoc/releases/download/0.5.1/stardoc-0.5.1.tar.gz",
],
)

2
WORKSPACE.bzlmod Normal file
View File

@ -0,0 +1,2 @@
# Workaround so that targets prefixed with @bazel_skylib still work
workspace(name = "bazel_skylib")

View File

@ -6,10 +6,20 @@ package(
default_visibility = ["//visibility:private"],
)
genrule(
name = "distro_module_bazel",
srcs = ["//:MODULE.bazel"],
outs = ["MODULE.bazel"],
cmd = "sed -e '/### INTERNAL ONLY/,$$d' $(location //:MODULE.bazel) >$@",
)
# Build the artifact to put on the github release page.
pkg_tar(
name = "bazel-skylib-%s" % version,
srcs = ["//:distribution"],
srcs = [
"distro_module_bazel",
"//:distribution",
],
extension = "tar.gz",
mode = "0644",
# Make it owned by root so it does not have the uid of the CI robot.

View File

@ -3,21 +3,25 @@ load("//docs/private:stardoc_with_diff_test.bzl", "stardoc_with_diff_test", "upd
licenses(["notice"])
stardoc_with_diff_test(
name = "analysis_test",
bzl_library_target = "//rules:analysis_test",
out_label = "//docs:analysis_test_doc.md",
)
stardoc_with_diff_test(
name = "build_test",
bzl_library_target = "//rules:build_test",
out_label = "//docs:build_test_doc.md",
)
stardoc_with_diff_test(
name = "collections",
bzl_library_target = "//lib:collections",
out_label = "//docs:collections_doc.md",
)
stardoc_with_diff_test(
name = "common_settings",
bzl_library_target = "//rules:common_settings",
out_label = "//docs:common_settings_doc.md",
)
@ -28,91 +32,115 @@ stardoc_with_diff_test(
)
stardoc_with_diff_test(
name = "copy_directory",
bzl_library_target = "//rules:copy_directory",
out_label = "//docs:copy_directory_doc.md",
)
stardoc_with_diff_test(
name = "copy_file",
bzl_library_target = "//rules:copy_file",
out_label = "//docs:copy_file_doc.md",
)
stardoc_with_diff_test(
name = "dicts",
bzl_library_target = "//lib:dicts",
out_label = "//docs:dicts_doc.md",
)
stardoc_with_diff_test(
name = "diff_test",
bzl_library_target = "//rules:diff_test",
out_label = "//docs:diff_test_doc.md",
)
stardoc_with_diff_test(
name = "expand_template",
bzl_library_target = "//rules:expand_template",
out_label = "//docs:expand_template_doc.md",
)
stardoc_with_diff_test(
name = "native_binary",
bzl_library_target = "//rules:native_binary",
out_label = "//docs:native_binary_doc.md",
)
stardoc_with_diff_test(
name = "new_sets",
bzl_library_target = "//lib:new_sets",
out_label = "//docs:new_sets_doc.md",
)
stardoc_with_diff_test(
name = "partial",
bzl_library_target = "//lib:partial",
out_label = "//docs:partial_doc.md",
)
stardoc_with_diff_test(
name = "paths",
bzl_library_target = "//lib:paths",
out_label = "//docs:paths_doc.md",
)
stardoc_with_diff_test(
name = "run_binary",
bzl_library_target = "//rules:run_binary",
out_label = "//docs:run_binary_doc.md",
)
stardoc_with_diff_test(
name = "selects",
bzl_library_target = "//lib:selects",
out_label = "//docs:selects_doc.md",
)
stardoc_with_diff_test(
name = "select_file",
bzl_library_target = "//rules:select_file",
out_label = "//docs:select_file_doc.md",
)
stardoc_with_diff_test(
name = "shell",
bzl_library_target = "//lib:shell",
out_label = "//docs:shell_doc.md",
)
stardoc_with_diff_test(
name = "structs",
bzl_library_target = "//lib:structs",
out_label = "//docs:structs_doc.md",
)
stardoc_with_diff_test(
name = "subpackages",
bzl_library_target = "//lib:subpackages",
out_label = "//docs:subpackages_doc.md",
)
stardoc_with_diff_test(
name = "types",
bzl_library_target = "//lib:types",
out_label = "//docs:types_doc.md",
)
stardoc_with_diff_test(
name = "unittest",
bzl_library_target = "//lib:unittest",
out_label = "//docs:unittest_doc.md",
)
stardoc_with_diff_test(
name = "versions",
bzl_library_target = "//lib:versions",
out_label = "//docs:versions_doc.md",
)
stardoc_with_diff_test(
name = "write_file",
bzl_library_target = "//rules:write_file",
out_label = "//docs:write_file_doc.md",
)

View File

@ -2,7 +2,7 @@
A test verifying other targets can be successfully analyzed as part of a `bazel test`
<a id="#analysis_test"></a>
<a id="analysis_test"></a>
## analysis_test

View File

@ -2,7 +2,7 @@
A test verifying other targets build as part of a `bazel test`
<a id="#build_test"></a>
<a id="build_test"></a>
## build_test
@ -36,6 +36,6 @@ Typical usage:
| :------------- | :------------- | :------------- |
| <a id="build_test-name"></a>name | The name of the test rule. | none |
| <a id="build_test-targets"></a>targets | A list of targets to ensure build. | none |
| <a id="build_test-kwargs"></a>kwargs | The &lt;a href="https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes-tests"&gt;common attributes for tests&lt;/a&gt;. | none |
| <a id="build_test-kwargs"></a>kwargs | The &lt;a href="https://bazel.build/reference/be/common-definitions#common-attributes-tests"&gt;common attributes for tests&lt;/a&gt;. | none |

View File

@ -2,7 +2,7 @@
Skylib module containing functions that operate on collections.
<a id="#collections.after_each"></a>
<a id="collections.after_each"></a>
## collections.after_each
@ -25,7 +25,7 @@ Inserts `separator` after each item in `iterable`.
A new list with `separator` after each item in `iterable`.
<a id="#collections.before_each"></a>
<a id="collections.before_each"></a>
## collections.before_each
@ -48,7 +48,7 @@ Inserts `separator` before each item in `iterable`.
A new list with `separator` before each item in `iterable`.
<a id="#collections.uniq"></a>
<a id="collections.uniq"></a>
## collections.uniq

View File

@ -6,10 +6,10 @@ These rules return a BuildSettingInfo with the value of the build setting.
For label-typed settings, use the native label_flag and label_setting rules.
More documentation on how to use build settings at
https://docs.bazel.build/versions/main/skylark/config.html#user-defined-build-settings
https://bazel.build/extending/config#user-defined-build-settings
<a id="#bool_flag"></a>
<a id="bool_flag"></a>
## bool_flag
@ -27,7 +27,7 @@ A bool-typed build setting that can be set on the command line
| <a id="bool_flag-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
<a id="#bool_setting"></a>
<a id="bool_setting"></a>
## bool_setting
@ -45,7 +45,7 @@ A bool-typed build setting that cannot be set on the command line
| <a id="bool_setting-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
<a id="#int_flag"></a>
<a id="int_flag"></a>
## int_flag
@ -63,7 +63,7 @@ An int-typed build setting that can be set on the command line
| <a id="int_flag-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
<a id="#int_setting"></a>
<a id="int_setting"></a>
## int_setting
@ -81,7 +81,7 @@ An int-typed build setting that cannot be set on the command line
| <a id="int_setting-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
<a id="#string_flag"></a>
<a id="string_flag"></a>
## string_flag
@ -100,7 +100,7 @@ A string-typed build setting that can be set on the command line
| <a id="string_flag-values"></a>values | The list of allowed values for this setting. An error is raised if any other value is given. | List of strings | optional | [] |
<a id="#string_list_flag"></a>
<a id="string_list_flag"></a>
## string_list_flag
@ -118,7 +118,7 @@ A string list-typed build setting that can be set on the command line
| <a id="string_list_flag-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
<a id="#string_list_setting"></a>
<a id="string_list_setting"></a>
## string_list_setting
@ -136,7 +136,7 @@ A string list-typed build setting that cannot be set on the command line
| <a id="string_list_setting-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
<a id="#string_setting"></a>
<a id="string_setting"></a>
## string_setting
@ -155,7 +155,7 @@ A string-typed build setting that cannot be set on the command line
| <a id="string_setting-values"></a>values | The list of allowed values for this setting. An error is raised if any other value is given. | List of strings | optional | [] |
<a id="#BuildSettingInfo"></a>
<a id="BuildSettingInfo"></a>
## BuildSettingInfo

View File

@ -6,7 +6,7 @@ The rule uses a Bash command on Linux/macOS/non-Windows, and a cmd.exe command
on Windows (no Bash is required).
<a id="#copy_directory"></a>
<a id="copy_directory"></a>
## copy_directory
@ -36,7 +36,7 @@ for more context.
| <a id="copy_directory-kwargs"></a>kwargs | further keyword arguments, e.g. <code>visibility</code> | none |
<a id="#copy_directory_action"></a>
<a id="copy_directory_action"></a>
## copy_directory_action

View File

@ -9,7 +9,7 @@ The rule uses a Bash command on Linux/macOS/non-Windows, and a cmd.exe command
on Windows (no Bash is required).
<a id="#copy_file"></a>
<a id="copy_file"></a>
## copy_file

View File

@ -2,7 +2,7 @@
Skylib module containing functions that operate on dictionaries.
<a id="#dicts.add"></a>
<a id="dicts.add"></a>
## dicts.add
@ -34,7 +34,7 @@ dictionary, and the sum of a single dictionary is a copy of itself.
A new `dict` that has all the entries of the given dictionaries.
<a id="#dicts.omit"></a>
<a id="dicts.omit"></a>
## dicts.omit
@ -57,7 +57,7 @@ Returns a new `dict` that has all the entries of `dictionary` with keys not in `
A new `dict` that has all the entries of `dictionary` with keys not in `keys`.
<a id="#dicts.pick"></a>
<a id="dicts.pick"></a>
## dicts.pick

View File

@ -6,7 +6,7 @@ The rule uses a Bash command (diff) on Linux/macOS/non-Windows, and a cmd.exe
command (fc.exe) on Windows (no Bash is required).
<a id="#diff_test"></a>
<a id="diff_test"></a>
## diff_test
@ -28,6 +28,6 @@ The test succeeds if the files' contents match.
| <a id="diff_test-file1"></a>file1 | Label of the file to compare to &lt;code&gt;file2&lt;/code&gt;. | none |
| <a id="diff_test-file2"></a>file2 | Label of the file to compare to &lt;code&gt;file1&lt;/code&gt;. | none |
| <a id="diff_test-failure_message"></a>failure_message | Additional message to log if the files' contents do not match. | <code>None</code> |
| <a id="diff_test-kwargs"></a>kwargs | The &lt;a href="https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes-tests"&gt;common attributes for tests&lt;/a&gt;. | none |
| <a id="diff_test-kwargs"></a>kwargs | The &lt;a href="https://bazel.build/reference/be/common-definitions#common-attributes-tests"&gt;common attributes for tests&lt;/a&gt;. | none |

View File

@ -3,7 +3,7 @@
A rule that performes template expansion.
<a id="#expand_template"></a>
<a id="expand_template"></a>
## expand_template

View File

@ -72,7 +72,8 @@ Name 1, Name 2, Name 3 (alphabetically from `git log`)
--------------------------------------------------------------------------------
2. Bump `version` in version.bzl to the new version.
2. Bump `version` in version.bzl *and* MODULE.bazel to the new version.
TODO(#386): add a test to make sure the two versions are in sync.
3. Ensure that the commits for steps 1 and 2 have been merged. All further
steps must be performed on a single, known-good git commit.
4. `bazel build //distribution:bazel-skylib-$VERSION.tar.gz`
@ -81,7 +82,7 @@ Name 1, Name 2, Name 3 (alphabetically from `git log`)
can obtain them via `gcloud init`):
```
gsutil cp bazel-bin/distro/bazel-skylib-$VERSION.tar.gz gs://bazel-mirror/github.com/bazelbuild/bazel-skylib/releases/download/$VERSION/bazel-skylib-$VERSION.tar.gz
gsutil cp bazel-bin/distribution/bazel-skylib-$VERSION.tar.gz gs://bazel-mirror/github.com/bazelbuild/bazel-skylib/releases/download/$VERSION/bazel-skylib-$VERSION.tar.gz
gsutil setmeta -h "Cache-Control: public, max-age=31536000" "gs://bazel-mirror/github.com/bazelbuild/bazel-skylib/releases/download/$VERSION/bazel-skylib-$VERSION.tar.gz"
```

View File

@ -8,7 +8,7 @@ do, but they run the wrapped binary directly, instead of through Bash, so they
don't depend on Bash and work with --shell_executable="".
<a id="#native_binary"></a>
<a id="native_binary"></a>
## native_binary
@ -29,12 +29,12 @@ in genrule.tools for example. You can also augment the binary with runfiles.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="native_binary-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="native_binary-data"></a>data | data dependencies. See https://docs.bazel.build/versions/main/be/common-definitions.html#typical.data | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="native_binary-data"></a>data | data dependencies. See https://bazel.build/reference/be/common-definitions#typical.data | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="native_binary-out"></a>out | An output name for the copy of the binary | String | required | |
| <a id="native_binary-src"></a>src | path of the pre-built executable | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
<a id="#native_test"></a>
<a id="native_test"></a>
## native_test
@ -55,7 +55,7 @@ the binary with runfiles.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="native_test-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="native_test-data"></a>data | data dependencies. See https://docs.bazel.build/versions/main/be/common-definitions.html#typical.data | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="native_test-data"></a>data | data dependencies. See https://bazel.build/reference/be/common-definitions#typical.data | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="native_test-out"></a>out | An output name for the copy of the binary | String | required | |
| <a id="native_test-src"></a>src | path of the pre-built executable | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |

View File

@ -11,7 +11,7 @@ Skylib module containing common hash-set algorithms.
`types.is_set()` method in types.bzl.
<a id="#sets.make"></a>
<a id="sets.make"></a>
## sets.make
@ -36,7 +36,7 @@ All elements must be hashable.
A set containing the passed in values.
<a id="#sets.copy"></a>
<a id="sets.copy"></a>
## sets.copy
@ -58,7 +58,7 @@ Creates a new set from another set.
A new set containing the same elements as `s`.
<a id="#sets.to_list"></a>
<a id="sets.to_list"></a>
## sets.to_list
@ -80,7 +80,7 @@ Creates a list from the values in the set.
A list of values inserted into the set.
<a id="#sets.insert"></a>
<a id="sets.insert"></a>
## sets.insert
@ -106,7 +106,7 @@ Element must be hashable. This mutates the original set.
The set `s` with `e` included.
<a id="#sets.contains"></a>
<a id="sets.contains"></a>
## sets.contains
@ -129,7 +129,7 @@ Checks for the existence of an element in a set.
True if the element exists in the set, False if the element does not.
<a id="#sets.is_equal"></a>
<a id="sets.is_equal"></a>
## sets.is_equal
@ -152,7 +152,7 @@ Returns whether two sets are equal.
True if `a` is equal to `b`, False otherwise.
<a id="#sets.is_subset"></a>
<a id="sets.is_subset"></a>
## sets.is_subset
@ -175,7 +175,7 @@ Returns whether `a` is a subset of `b`.
True if `a` is a subset of `b`, False otherwise.
<a id="#sets.disjoint"></a>
<a id="sets.disjoint"></a>
## sets.disjoint
@ -201,7 +201,7 @@ Two sets are disjoint if they have no elements in common.
True if `a` and `b` are disjoint, False otherwise.
<a id="#sets.intersection"></a>
<a id="sets.intersection"></a>
## sets.intersection
@ -224,7 +224,7 @@ Returns the intersection of two sets.
A set containing the elements that are in both `a` and `b`.
<a id="#sets.union"></a>
<a id="sets.union"></a>
## sets.union
@ -246,7 +246,7 @@ Returns the union of several sets.
The set union of all sets in `*args`.
<a id="#sets.difference"></a>
<a id="sets.difference"></a>
## sets.difference
@ -269,7 +269,7 @@ Returns the elements in `a` that are not in `b`.
A set containing the elements that are in `a` but not in `b`.
<a id="#sets.length"></a>
<a id="sets.length"></a>
## sets.length
@ -291,7 +291,7 @@ Returns the number of elements in a set.
An integer representing the number of elements in the set.
<a id="#sets.remove"></a>
<a id="sets.remove"></a>
## sets.remove
@ -317,7 +317,7 @@ Element must be hashable. This mutates the original set.
The set `s` with `e` removed.
<a id="#sets.repr"></a>
<a id="sets.repr"></a>
## sets.repr
@ -339,7 +339,7 @@ Returns a string value representing the set.
A string representing the set.
<a id="#sets.str"></a>
<a id="sets.str"></a>
## sets.str

View File

@ -7,7 +7,7 @@ Partial function objects allow some parameters are bound before the call.
Similar to https://docs.python.org/3/library/functools.html#functools.partial.
<a id="#partial.make"></a>
<a id="partial.make"></a>
## partial.make
@ -123,7 +123,7 @@ partial.call(func, x=2)
A new `partial` that can be called using `call`
<a id="#partial.call"></a>
<a id="partial.call"></a>
## partial.call
@ -147,7 +147,7 @@ Calls a partial created using `make`.
Whatever the function in the partial returns.
<a id="#partial.is_instance"></a>
<a id="partial.is_instance"></a>
## partial.is_instance

View File

@ -7,7 +7,7 @@ path separators (forward slash, "/"); they do not handle Windows-style paths
with backslash separators or drive letters.
<a id="#paths.basename"></a>
<a id="paths.basename"></a>
## paths.basename
@ -35,7 +35,7 @@ the final slash).
The basename of the path, which includes the extension.
<a id="#paths.dirname"></a>
<a id="paths.dirname"></a>
## paths.dirname
@ -62,7 +62,7 @@ included, unless omitting them would make the dirname empty.
The dirname of the path.
<a id="#paths.is_absolute"></a>
<a id="paths.is_absolute"></a>
## paths.is_absolute
@ -84,7 +84,7 @@ Returns `True` if `path` is an absolute path.
`True` if `path` is an absolute path.
<a id="#paths.join"></a>
<a id="paths.join"></a>
## paths.join
@ -116,7 +116,7 @@ If any component is an absolute path, all previous components are discarded.
A string containing the joined paths.
<a id="#paths.normalize"></a>
<a id="paths.normalize"></a>
## paths.normalize
@ -153,7 +153,7 @@ POSIX platforms; specifically:
The normalized path.
<a id="#paths.relativize"></a>
<a id="paths.relativize"></a>
## paths.relativize
@ -185,7 +185,7 @@ the path both start with the same initial parent references.
The portion of `path` that is relative to `start`.
<a id="#paths.replace_extension"></a>
<a id="paths.replace_extension"></a>
## paths.replace_extension
@ -211,7 +211,7 @@ If the path has no extension, the new extension is added to it.
The path with the extension replaced (or added, if it did not have one).
<a id="#paths.split_extension"></a>
<a id="paths.split_extension"></a>
## paths.split_extension

View File

@ -1,3 +1,17 @@
# Copyright 2022 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.
"""Helpers for keeping stardoc documentation up-to-date.
These are currently a private API in bazel-skylib.
@ -14,6 +28,7 @@ load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
def stardoc_with_diff_test(
name,
bzl_library_target,
out_label):
"""Creates a stardoc target coupled with a `diff_test` for a given `bzl_library`.
@ -21,15 +36,15 @@ def stardoc_with_diff_test(
This is helpful for minimizing boilerplate in repos wih lots of stardoc targets.
Args:
name: the stardoc target name
bzl_library_target: the label of the `bzl_library` target to generate documentation for
out_label: the label of the output MD file
"""
out_file = out_label.replace("//", "").replace(":", "/")
# Generate MD from .bzl
stardoc(
name = out_file.replace("/", "_").replace(".md", "-docgen"),
name = name,
out = out_file.replace(".md", "-docgen.md"),
input = bzl_library_target + ".bzl",
deps = [bzl_library_target],

View File

@ -6,7 +6,7 @@ run_binary() build rule implementation.
Runs a binary as a build action. This rule does not require Bash (unlike native.genrule()).
<a id="#run_binary"></a>
<a id="run_binary"></a>
## run_binary
@ -22,8 +22,8 @@ Runs a binary as a build action.<br/><br/>This rule does not require Bash (unlik
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="run_binary-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="run_binary-args"></a>args | Command line arguments of the binary.&lt;br/&gt;&lt;br/&gt;Subject to&lt;code&gt;&lt;a href="https://docs.bazel.build/versions/main/be/make-variables.html#location"&gt;$(location)&lt;/a&gt;&lt;/code&gt; expansion. | List of strings | optional | [] |
| <a id="run_binary-env"></a>env | Environment variables of the action.&lt;br/&gt;&lt;br/&gt;Subject to &lt;code&gt;&lt;a href="https://docs.bazel.build/versions/main/be/make-variables.html#location"&gt;$(location)&lt;/a&gt;&lt;/code&gt; expansion. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
| <a id="run_binary-args"></a>args | Command line arguments of the binary.&lt;br/&gt;&lt;br/&gt;Subject to&lt;code&gt;&lt;a href="https://bazel.build/reference/be/make-variables#predefined_label_variables"&gt;$(location)&lt;/a&gt;&lt;/code&gt; expansion. | List of strings | optional | [] |
| <a id="run_binary-env"></a>env | Environment variables of the action.&lt;br/&gt;&lt;br/&gt;Subject to &lt;code&gt;&lt;a href="https://bazel.build/reference/be/make-variables#predefined_label_variables"&gt;$(location)&lt;/a&gt;&lt;/code&gt; expansion. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
| <a id="run_binary-outs"></a>outs | Output files generated by the action.&lt;br/&gt;&lt;br/&gt;These labels are available for &lt;code&gt;$(location)&lt;/code&gt; expansion in &lt;code&gt;args&lt;/code&gt; and &lt;code&gt;env&lt;/code&gt;. | List of labels | required | |
| <a id="run_binary-srcs"></a>srcs | Additional inputs of the action.&lt;br/&gt;&lt;br/&gt;These labels are available for &lt;code&gt;$(location)&lt;/code&gt; expansion in &lt;code&gt;args&lt;/code&gt; and &lt;code&gt;env&lt;/code&gt;. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="run_binary-tool"></a>tool | The tool to run in the action.&lt;br/&gt;&lt;br/&gt;Must be the label of a *_binary rule, of a rule that generates an executable file, or of a file that can be executed as a subprocess (e.g. an .exe or .bat file on Windows or a binary with executable permission on Linux). This label is available for &lt;code&gt;$(location)&lt;/code&gt; expansion in &lt;code&gt;args&lt;/code&gt; and &lt;code&gt;env&lt;/code&gt;. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |

28
docs/select_file_doc.md Executable file
View File

@ -0,0 +1,28 @@
<!-- Generated with Stardoc: http://skydoc.bazel.build -->
select_file() build rule implementation.
Selects a single file from the outputs of a target by given relative path.
<a id="select_file"></a>
## select_file
<pre>
select_file(<a href="#select_file-name">name</a>, <a href="#select_file-srcs">srcs</a>, <a href="#select_file-subpath">subpath</a>)
</pre>
Selects a single file from the outputs of a target by given relative path
**ATTRIBUTES**
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="select_file-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="select_file-srcs"></a>srcs | The target producing the file among other outputs | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
| <a id="select_file-subpath"></a>subpath | Relative path to the file | String | required | |

View File

@ -2,7 +2,7 @@
Skylib module containing convenience interfaces for select().
<a id="#selects.with_or"></a>
<a id="selects.with_or"></a>
## selects.with_or
@ -48,7 +48,7 @@ to
```
<a id="#selects.with_or_dict"></a>
<a id="selects.with_or_dict"></a>
## selects.with_or_dict
@ -74,7 +74,7 @@ macros.
A dictionary usable by a native `select()`.
<a id="#selects.config_setting_group"></a>
<a id="selects.config_setting_group"></a>
## selects.config_setting_group

View File

@ -2,7 +2,7 @@
Skylib module containing shell utility functions.
<a id="#shell.array_literal"></a>
<a id="shell.array_literal"></a>
## shell.array_literal
@ -33,7 +33,7 @@ A string that represents the sequence as a shell array; that is,
parentheses containing the quoted elements.
<a id="#shell.quote"></a>
<a id="shell.quote"></a>
## shell.quote

View File

@ -2,7 +2,7 @@
Skylib module containing functions that operate on structs.
<a id="#structs.to_dict"></a>
<a id="structs.to_dict"></a>
## structs.to_dict

View File

@ -3,7 +3,7 @@
Skylib module containing common functions for working with native.subpackages()
<a id="#subpackages.all"></a>
<a id="subpackages.all"></a>
## subpackages.all
@ -46,7 +46,7 @@ A mutable sorted list containing all sub-packages of the current Bazel
package.
<a id="#subpackages.exists"></a>
<a id="subpackages.exists"></a>
## subpackages.exists
@ -82,7 +82,7 @@ NOTE: fail()s if native.subpackages() is not supported in the current Bazel vers
True if 'relative_path' is a subpackage of the current package.
<a id="#subpackages.supported"></a>
<a id="subpackages.supported"></a>
## subpackages.supported

View File

@ -2,7 +2,7 @@
Skylib module containing functions checking types.
<a id="#types.is_list"></a>
<a id="types.is_list"></a>
## types.is_list
@ -24,7 +24,7 @@ Returns True if v is an instance of a list.
True if v is an instance of a list, False otherwise.
<a id="#types.is_string"></a>
<a id="types.is_string"></a>
## types.is_string
@ -46,7 +46,7 @@ Returns True if v is an instance of a string.
True if v is an instance of a string, False otherwise.
<a id="#types.is_bool"></a>
<a id="types.is_bool"></a>
## types.is_bool
@ -68,7 +68,7 @@ Returns True if v is an instance of a bool.
True if v is an instance of a bool, False otherwise.
<a id="#types.is_none"></a>
<a id="types.is_none"></a>
## types.is_none
@ -90,7 +90,7 @@ Returns True if v has the type of None.
True if v is None, False otherwise.
<a id="#types.is_int"></a>
<a id="types.is_int"></a>
## types.is_int
@ -112,7 +112,7 @@ Returns True if v is an instance of a signed integer.
True if v is an instance of a signed integer, False otherwise.
<a id="#types.is_tuple"></a>
<a id="types.is_tuple"></a>
## types.is_tuple
@ -134,7 +134,7 @@ Returns True if v is an instance of a tuple.
True if v is an instance of a tuple, False otherwise.
<a id="#types.is_dict"></a>
<a id="types.is_dict"></a>
## types.is_dict
@ -156,7 +156,7 @@ Returns True if v is an instance of a dict.
True if v is an instance of a dict, False otherwise.
<a id="#types.is_function"></a>
<a id="types.is_function"></a>
## types.is_function
@ -178,7 +178,7 @@ Returns True if v is an instance of a function.
True if v is an instance of a function, False otherwise.
<a id="#types.is_depset"></a>
<a id="types.is_depset"></a>
## types.is_depset
@ -200,7 +200,7 @@ Returns True if v is an instance of a `depset`.
True if v is an instance of a `depset`, False otherwise.
<a id="#types.is_set"></a>
<a id="types.is_set"></a>
## types.is_set

View File

@ -16,7 +16,7 @@ See https://bazel.build/extending/concepts for background about macros, rules,
and the different phases of a build.
<a id="#unittest_toolchain"></a>
<a id="unittest_toolchain"></a>
## unittest_toolchain
@ -41,7 +41,7 @@ unittest_toolchain(<a href="#unittest_toolchain-name">name</a>, <a href="#unitte
| <a id="unittest_toolchain-success_templ"></a>success_templ | Test script generated when the test passes. Should exit with status 0. | String | required | |
<a id="#analysistest.make"></a>
<a id="analysistest.make"></a>
## analysistest.make
@ -95,7 +95,7 @@ A rule definition that should be stored in a global whose name ends in
`_test`.
<a id="#analysistest.begin"></a>
<a id="analysistest.begin"></a>
## analysistest.begin
@ -125,7 +125,7 @@ A test environment struct that must be passed to assertions and finally to
struct as it may change.
<a id="#analysistest.end"></a>
<a id="analysistest.end"></a>
## analysistest.end
@ -151,7 +151,7 @@ that the results are reported.
A list of providers needed to automatically register the analysis test result.
<a id="#analysistest.fail"></a>
<a id="analysistest.fail"></a>
## analysistest.fail
@ -170,7 +170,7 @@ Unconditionally causes the current test to fail.
| <a id="analysistest.fail-msg"></a>msg | The message to log describing the failure. | none |
<a id="#analysistest.target_actions"></a>
<a id="analysistest.target_actions"></a>
## analysistest.target_actions
@ -192,7 +192,7 @@ Returns a list of actions registered by the target under test.
A list of actions registered by the target under test
<a id="#analysistest.target_bin_dir_path"></a>
<a id="analysistest.target_bin_dir_path"></a>
## analysistest.target_bin_dir_path
@ -214,7 +214,7 @@ Returns ctx.bin_dir.path for the target under test.
Output bin dir path string.
<a id="#analysistest.target_under_test"></a>
<a id="analysistest.target_under_test"></a>
## analysistest.target_under_test
@ -236,7 +236,7 @@ Returns the target under test.
The target under test.
<a id="#asserts.expect_failure"></a>
<a id="asserts.expect_failure"></a>
## asserts.expect_failure
@ -259,7 +259,7 @@ This requires that the analysis test is created with `analysistest.make()` and
| <a id="asserts.expect_failure-expected_failure_msg"></a>expected_failure_msg | The error message to expect as a result of analysis failures. | <code>""</code> |
<a id="#asserts.equals"></a>
<a id="asserts.equals"></a>
## asserts.equals
@ -280,7 +280,7 @@ Asserts that the given `expected` and `actual` values are equal.
| <a id="asserts.equals-msg"></a>msg | An optional message that will be printed that describes the failure. If omitted, a default will be used. | <code>None</code> |
<a id="#asserts.false"></a>
<a id="asserts.false"></a>
## asserts.false
@ -300,7 +300,7 @@ Asserts that the given `condition` is false.
| <a id="asserts.false-msg"></a>msg | An optional message that will be printed that describes the failure. If omitted, a default will be used. | <code>"Expected condition to be false, but was true."</code> |
<a id="#asserts.set_equals"></a>
<a id="asserts.set_equals"></a>
## asserts.set_equals
@ -321,7 +321,7 @@ Asserts that the given `expected` and `actual` sets are equal.
| <a id="asserts.set_equals-msg"></a>msg | An optional message that will be printed that describes the failure. If omitted, a default will be used. | <code>None</code> |
<a id="#asserts.new_set_equals"></a>
<a id="asserts.new_set_equals"></a>
## asserts.new_set_equals
@ -342,7 +342,7 @@ Asserts that the given `expected` and `actual` sets are equal.
| <a id="asserts.new_set_equals-msg"></a>msg | An optional message that will be printed that describes the failure. If omitted, a default will be used. | <code>None</code> |
<a id="#asserts.true"></a>
<a id="asserts.true"></a>
## asserts.true
@ -362,7 +362,7 @@ Asserts that the given `condition` is true.
| <a id="asserts.true-msg"></a>msg | An optional message that will be printed that describes the failure. If omitted, a default will be used. | <code>"Expected condition to be true, but was false."</code> |
<a id="#loadingtest.make"></a>
<a id="loadingtest.make"></a>
## loadingtest.make
@ -384,7 +384,7 @@ Creates a loading phase test environment and test_suite.
loading phase environment passed to other loadingtest functions
<a id="#loadingtest.equals"></a>
<a id="loadingtest.equals"></a>
## loadingtest.equals
@ -409,7 +409,7 @@ Creates a test case for asserting state at LOADING phase.
None, creates test case
<a id="#register_unittest_toolchains"></a>
<a id="register_unittest_toolchains"></a>
## register_unittest_toolchains
@ -421,7 +421,7 @@ Registers the toolchains for unittest users.
<a id="#unittest.make"></a>
<a id="unittest.make"></a>
## unittest.make
@ -469,7 +469,7 @@ A rule definition that should be stored in a global whose name ends in
`_test`.
<a id="#unittest.suite"></a>
<a id="unittest.suite"></a>
## unittest.suite
@ -525,7 +525,7 @@ name each target.
| <a id="unittest.suite-test_rules"></a>test_rules | A list of test rules defines by <code>unittest.test</code>. | none |
<a id="#unittest.begin"></a>
<a id="unittest.begin"></a>
## unittest.begin
@ -555,7 +555,7 @@ A test environment struct that must be passed to assertions and finally to
struct as it may change.
<a id="#unittest.end"></a>
<a id="unittest.end"></a>
## unittest.end
@ -581,7 +581,7 @@ that the results are reported.
A list of providers needed to automatically register the test result.
<a id="#unittest.fail"></a>
<a id="unittest.fail"></a>
## unittest.fail

View File

@ -2,7 +2,7 @@
Skylib module containing functions for checking Bazel versions.
<a id="#versions.get"></a>
<a id="versions.get"></a>
## versions.get
@ -14,7 +14,7 @@ Returns the current Bazel version
<a id="#versions.parse"></a>
<a id="versions.parse"></a>
## versions.parse
@ -39,7 +39,7 @@ int tuples can be compared directly using binary operators (<, >).
An int 3-tuple of a (major, minor, patch) version.
<a id="#versions.check"></a>
<a id="versions.check"></a>
## versions.check
@ -59,7 +59,7 @@ Check that the version of Bazel is valid within the specified range.
| <a id="versions.check-bazel_version"></a>bazel_version | the version of Bazel to check. Used for testing, defaults to native.bazel_version | <code>None</code> |
<a id="#versions.is_at_most"></a>
<a id="versions.is_at_most"></a>
## versions.is_at_most
@ -82,7 +82,7 @@ Check that a version is lower or equals to a threshold.
True if version <= threshold.
<a id="#versions.is_at_least"></a>
<a id="versions.is_at_least"></a>
## versions.is_at_least

View File

@ -10,7 +10,7 @@ file. Instead they use Starlark's built-in file writing action
(ctx.actions.write).
<a id="#write_file"></a>
<a id="write_file"></a>
## write_file

View File

@ -63,7 +63,7 @@ def build_test(name, targets, **kwargs):
Args:
name: The name of the test rule.
targets: A list of targets to ensure build.
**kwargs: The <a href="https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes-tests">common attributes for tests</a>.
**kwargs: The <a href="https://bazel.build/reference/be/common-definitions#common-attributes-tests">common attributes for tests</a>.
"""
if len(targets) == 0:
fail("targets must be non-empty", "targets")

View File

@ -18,7 +18,7 @@ These rules return a BuildSettingInfo with the value of the build setting.
For label-typed settings, use the native label_flag and label_setting rules.
More documentation on how to use build settings at
https://docs.bazel.build/versions/main/skylark/config.html#user-defined-build-settings
https://bazel.build/extending/config#user-defined-build-settings
"""
BuildSettingInfo = provider(
@ -69,13 +69,22 @@ string_list_setting = rule(
doc = "A string list-typed build setting that cannot be set on the command line",
)
def _no_at_str(label):
"""Strips any leading '@'s for labels in the main repo, so that the error string is more friendly."""
s = str(label)
if s.startswith("@@//"):
return s[2:]
if s.startswith("@//"):
return s[1:]
return s
def _string_impl(ctx):
allowed_values = ctx.attr.values
value = ctx.build_setting_value
if len(allowed_values) == 0 or value in ctx.attr.values:
return BuildSettingInfo(value = value)
else:
fail("Error setting " + str(ctx.label) + ": invalid value '" + value + "'. Allowed values are " + str(allowed_values))
fail("Error setting " + _no_at_str(ctx.label) + ": invalid value '" + value + "'. Allowed values are " + str(allowed_values))
string_flag = rule(
implementation = _string_impl,

View File

@ -164,7 +164,7 @@ def diff_test(name, file1, file2, failure_message = None, **kwargs):
file1: Label of the file to compare to <code>file2</code>.
file2: Label of the file to compare to <code>file1</code>.
failure_message: Additional message to log if the files' contents do not match.
**kwargs: The <a href="https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes-tests">common attributes for tests</a>.
**kwargs: The <a href="https://bazel.build/reference/be/common-definitions#common-attributes-tests">common attributes for tests</a>.
"""
_diff_test(
name = name,

View File

@ -61,7 +61,7 @@ _ATTRS = {
"data": attr.label_list(
allow_files = True,
doc = "data dependencies. See" +
" https://docs.bazel.build/versions/main/be/common-definitions.html#typical.data",
" https://bazel.build/reference/be/common-definitions#typical.data",
),
# "out" is attr.string instead of attr.output, so that it is select()'able.
"out": attr.string(mandatory = True, doc = "An output name for the copy of the binary"),

View File

@ -22,11 +22,7 @@ COPY_EXECUTION_REQUIREMENTS = {
# ----------------+-----------------------------------------------------------------------------
# no-cache | Results in the action or test never being cached (remotely or locally)
# ----------------+-----------------------------------------------------------------------------
# local | Precludes the action or test from being remotely cached, remotely executed,
# | or run inside the sandbox. For genrules and tests, marking the rule with the
# | local = True attribute has the same effect.
# ----------------+-----------------------------------------------------------------------------
# See https://bazel.google.cn/reference/be/common-definitions?hl=en&authuser=0#common-attributes
# See https://bazel.build/reference/be/common-definitions#common-attributes
#
# Copying file & directories is entirely IO-bound and there is no point doing this work
# remotely.
@ -44,11 +40,6 @@ COPY_EXECUTION_REQUIREMENTS = {
# disk cache stores the directory artifact as a single entry, but the slight performance bump
# comes at the cost of heavy disk cache usage, which is an unmanaged directory that grow beyond
# the bounds of the physical disk.
#
# Sandboxing for this action is wasteful as well since there is a 1:1 mapping of input
# file/directory to output file/directory and no room for non-hermetic inputs to sneak in to the
# input.
"no-remote": "1",
"no-cache": "1",
"local": "1",
}

View File

@ -76,7 +76,7 @@ run_binary = rule(
),
"env": attr.string_dict(
doc = "Environment variables of the action.<br/><br/>Subject to " +
" <code><a href=\"https://docs.bazel.build/versions/main/be/make-variables.html#location\">$(location)</a></code>" +
" <code><a href=\"https://bazel.build/reference/be/make-variables#predefined_label_variables\">$(location)</a></code>" +
" expansion.",
),
"srcs": attr.label_list(
@ -91,7 +91,7 @@ run_binary = rule(
),
"args": attr.string_list(
doc = "Command line arguments of the binary.<br/><br/>Subject to" +
"<code><a href=\"https://docs.bazel.build/versions/main/be/make-variables.html#location\">$(location)</a></code>" +
"<code><a href=\"https://bazel.build/reference/be/make-variables#predefined_label_variables\">$(location)</a></code>" +
" expansion.",
),
},

View File

@ -15,7 +15,7 @@
"""
select_file() build rule implementation.
Selects a single file from the outputs of some target by given relative path.
Selects a single file from the outputs of a target by given relative path.
"""
def _impl(ctx):
@ -38,8 +38,7 @@ def _impl(ctx):
select_file = rule(
implementation = _impl,
doc = "Selects a single file from the outputs of some target \
by given relative path",
doc = "Selects a single file from the outputs of a target by given relative path",
attrs = {
"srcs": attr.label(
allow_files = True,

View File

@ -1,6 +1,7 @@
# This package aids testing the 'copy_directory' rule.
load("//rules:copy_directory.bzl", "copy_directory")
load(":empty_directory.bzl", "empty_directory")
licenses(["notice"])
@ -13,10 +14,8 @@ copy_directory(
out = "dir_copy",
)
genrule(
name = "empty_directory",
outs = ["empty_dir"],
cmd = "mkdir $@",
empty_directory(
name = "empty_dir",
)
copy_directory(

View File

@ -0,0 +1,34 @@
# Copyright 2022 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.
"""Creates an empty directory."""
def _empty_directory_impl(ctx):
out = ctx.actions.declare_directory(ctx.attr.name)
ctx.actions.run_shell(
outputs = [out],
command = "mkdir -p $@",
arguments = [out.path],
mnemonic = "EmptyDirectory",
progress_message = "Creating empty directory %s" % out.path,
use_default_shell_env = True,
execution_requirements = {"no-remote": "1"}, # see rules/private/copy_directory_private.bzl
)
return [DefaultInfo(files = depset(direct = [out]))]
empty_directory = rule(
implementation = _empty_directory_impl,
provides = [DefaultInfo],
doc = "Creates an empty directory with the same name as the target",
)

View File

@ -13,4 +13,4 @@
# limitations under the License.
"""The version of bazel-skylib."""
version = "1.2.1"
version = "1.3.0"