Powershell rules
Rules
Providers
pwsh_binary
load("@rules_powershell//powershell:defs.bzl", "pwsh_binary")
pwsh_binary(name, deps, srcs, data, env)
The pwsh_binary rule is used to declare executable powershell scripts.
(pwsh_binary is a misnomer: its outputs aren't necessarily binaries.) This rule ensures
that all dependencies are built, and appear in the runfiles area at execution time.
We recommend that you name your pwsh_binary() rules after the name of the script minus
the extension (e.g. .ps1); the rule name and the file name must be distinct.
For a simple Powershell script with no dependencies and some data files:
pwsh_binary(
name = "foo",
srcs = ["foo.ps1"],
data = glob(["datafiles/*.txt"]),
)
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | The list of "library" targets to be aggregated into this target. See general comments about deps at Typical attributes defined by most build rules. This attribute should be used to list other sh_library rules that provide interpreted program source code depended on by the code in srcs. The files provided by these rules will be present among the runfiles of this target. | List of labels | optional | [] |
| srcs | The list of source (.ps1) files that are processed to create the target. | List of labels | optional | [] |
| data | Files needed by this rule at runtime. May list file or rule targets. Generally allows any target. | List of labels | optional | [] |
| env | Dictionary of strings; values are subject to $(location) and "Make variable" substitution. | Dictionary: String -> String | optional | {} |
pwsh_library
load("@rules_powershell//powershell:defs.bzl", "pwsh_library")
pwsh_library(name, deps, srcs, data)
The main use for this rule is to aggregate together a logical "library" consisting of related scripts and modules.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | The list of "library" targets to be aggregated into this target. See general comments about deps at Typical attributes defined by most build rules. This attribute should be used to list other sh_library rules that provide interpreted program source code depended on by the code in srcs. The files provided by these rules will be present among the runfiles of this target. | List of labels | optional | [] |
| srcs | The list of source files that are processed to create the target. | List of labels | optional | [] |
| data | Files needed by this rule at runtime. May list file or rule targets. Generally allows any target. | List of labels | optional | [] |
pwsh_test
load("@rules_powershell//powershell:defs.bzl", "pwsh_test")
pwsh_test(name, deps, srcs, data, env, env_inherit)
A pwsh_test rule creates a test written as a Powershell script.
pwsh_test(
name = "foo_integration_test",
size = "small",
srcs = ["foo_integration_test.ps1"],
deps = [":foo_sh_lib"],
data = glob(["testdata/*.txt"]),
)
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | The list of "library" targets to be aggregated into this target. See general comments about deps at Typical attributes defined by most build rules. This attribute should be used to list other sh_library rules that provide interpreted program source code depended on by the code in srcs. The files provided by these rules will be present among the runfiles of this target. | List of labels | optional | [] |
| srcs | The list of source (.ps1) files that are processed to create the target. | List of labels | optional | [] |
| data | Files needed by this rule at runtime. May list file or rule targets. Generally allows any target. | List of labels | optional | [] |
| env | Dictionary of strings; values are subject to $(location) and "Make variable" substitution. | Dictionary: String -> String | optional | {} |
| env_inherit | Specifies additional environment variables to inherit from the external environment when the test is executed by bazel test. | List of strings | optional | [] |
PwshInfo
load("@rules_powershell//powershell:defs.bzl", "PwshInfo")
PwshInfo(imports, srcs)
A provider for Powershell rules.
FIELDS