/bin/path/to/file`
+e.g. `<execroot>/path/to/file -> <execroot>/bazel-out/<platform>/bin/path/to/file`
If a file passed in is already in the output tree is then it is added directly to the
DefaultInfo provided by the rule without a copy.
diff --git a/docs/copy_to_directory.md b/docs/copy_to_directory.md
index 64f5e5e..581e7f4 100644
--- a/docs/copy_to_directory.md
+++ b/docs/copy_to_directory.md
@@ -55,20 +55,20 @@ for more information on supported globbing patterns.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
-| allow_overwrites | If True, allow files to be overwritten if the same output file is copied to twice.
The order of srcs matters as the last copy of a particular file will win when overwriting. Performance of copy_to_directory will be slightly degraded when allow_overwrites is True since copies cannot be parallelized out as they are calculated. Instead all copy paths must be calculated before any copies can be started. | Boolean | optional | False |
-| exclude_prefixes | List of path prefixes (with glob support) to exclude from output directory.
DEPRECATED: use exclude_srcs_patterns
instead
Files in srcs are not copied to the output directory if their output directory path, after applying root_paths
, starts with or fully matches one of the patterns specified.
Forward slashes (/
) should be used as path separators.
Files that do not have matching output directory paths are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.
Globs are supported (see rule docstring above). | List of strings | optional | [] |
-| exclude_srcs_packages | List of Bazel packages (with glob support) to exclude from output directory.
Files in srcs are not copied to the output directory if the Bazel package of the file matches one of the patterns specified.
Forward slashes (/
) should be used as path separators. A first character of "."
will be replaced by the target's package path.
Files that have do not have matching Bazel packages are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.
Globs are supported (see rule docstring above). | List of strings | optional | [] |
-| exclude_srcs_patterns | List of paths (with glob support) to exclude from output directory.
Files in srcs are not copied to the output directory if their output directory path, after applying root_paths
, matches one of the patterns specified.
Forward slashes (/
) should be used as path separators.
Files that do not have matching output directory paths are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.
Globs are supported (see rule docstring above). | List of strings | optional | [] |
-| hardlink | Controls when to use hardlinks to files instead of making copies.
Creating hardlinks is much faster than making copies of files with the caveat that hardlinks share file permissions with their source.
Since Bazel removes write permissions on files in the output tree after an action completes, hardlinks to source files are not recommended since write permissions will be inadvertently removed from sources files.
- auto
: hardlinks are used for generated files already in the output tree - off
: all files are copied - on
: hardlinks are used for all files (not recommended) | String | optional | "auto" |
-| include_external_repositories | List of external repository names (with glob support) to include in the output directory.
Files from external repositories are only copied into the output directory if the external repository they come from matches one of the external repository patterns specified or if they are in the same external repository as this target.
When copied from an external repository, the file path in the output directory defaults to the file's path within the external repository. The external repository name is _not_ included in that path.
For example, the following copies @external_repo//path/to:file
to path/to/file
within the output directory.
copy_to_directory( name = "dir", include_external_repositories = ["external_*"], srcs = ["@external_repo//path/to:file"], )
Files that come from matching external are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be. The external repository name of the file from an external repository is not included in the output directory path and is considered in subsequent filters and transformations.
Globs are supported (see rule docstring above). | List of strings | optional | [] |
-| include_srcs_packages | List of Bazel packages (with glob support) to include in output directory.
Files in srcs are only copied to the output directory if the Bazel package of the file matches one of the patterns specified.
Forward slashes (/
) should be used as path separators. A first character of "."
will be replaced by the target's package path.
Defaults to ["**"]
which includes sources from all packages.
Files that have matching Bazel packages are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.
Globs are supported (see rule docstring above). | List of strings | optional | ["**"] |
-| include_srcs_patterns | List of paths (with glob support) to include in output directory.
Files in srcs are only copied to the output directory if their output directory path, after applying root_paths
, matches one of the patterns specified.
Forward slashes (/
) should be used as path separators.
Defaults to ["**"]
which includes all sources.
Files that have matching output directory paths are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.
Globs are supported (see rule docstring above). | List of strings | optional | ["**"] |
-| out | Path of the output directory, relative to this package.
If not set, the name of the target is used. | String | optional | "" |
-| replace_prefixes | Map of paths prefixes (with glob support) to replace in the output directory path when copying files.
If the output directory path for a file starts with or fully matches a a key in the dict then the matching portion of the output directory path is replaced with the dict value for that key. The final path segment matched can be a partial match of that segment and only the matching portion will be replaced. If there are multiple keys that match, the longest match wins.
Forward slashes (/
) should be used as path separators.
Replace prefix transformation are the final step in the list of filters and transformations. The final output path of a file being copied into the output directory is determined at this step.
Globs are supported (see rule docstring above). | Dictionary: String -> String | optional | {} |
-| root_paths | List of paths (with glob support) that are roots in the output directory.
If any parent directory of a file being copied matches one of the root paths patterns specified, the output directory path will be the path relative to the root path instead of the path relative to the file's workspace. If there are multiple root paths that match, the longest match wins.
Matching is done on the parent directory of the output file path so a trailing '**' glob patterm will match only up to the last path segment of the dirname and will not include the basename. Only complete path segments are matched. Partial matches on the last segment of the root path are ignored.
Forward slashes (/
) should be used as path separators.
A "."
value expands to the target's package path (ctx.label.package
).
Defaults to ["."]
which results in 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.
Globs are supported (see rule docstring above). | List of strings | optional | ["."] |
-| srcs | Files and/or directories or targets that provide DirectoryPathInfo
to copy into the output directory. | List of labels | optional | [] |
-| verbose | If true, prints out verbose logs to stdout | Boolean | optional | False |
+| name | A unique name for this target. | Name | required | |
+| allow_overwrites | If True, allow files to be overwritten if the same output file is copied to twice.
The order of srcs matters as the last copy of a particular file will win when overwriting. Performance of copy_to_directory will be slightly degraded when allow_overwrites is True since copies cannot be parallelized out as they are calculated. Instead all copy paths must be calculated before any copies can be started. | Boolean | optional | False
|
+| exclude_prefixes | List of path prefixes (with glob support) to exclude from output directory.
DEPRECATED: use exclude_srcs_patterns
instead
Files in srcs are not copied to the output directory if their output directory path, after applying root_paths
, starts with or fully matches one of the patterns specified.
Forward slashes (/
) should be used as path separators.
Files that do not have matching output directory paths are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.
Globs are supported (see rule docstring above). | List of strings | optional | []
|
+| exclude_srcs_packages | List of Bazel packages (with glob support) to exclude from output directory.
Files in srcs are not copied to the output directory if the Bazel package of the file matches one of the patterns specified.
Forward slashes (/
) should be used as path separators. A first character of "."
will be replaced by the target's package path.
Files that have do not have matching Bazel packages are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.
Globs are supported (see rule docstring above). | List of strings | optional | []
|
+| exclude_srcs_patterns | List of paths (with glob support) to exclude from output directory.
Files in srcs are not copied to the output directory if their output directory path, after applying root_paths
, matches one of the patterns specified.
Forward slashes (/
) should be used as path separators.
Files that do not have matching output directory paths are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.
Globs are supported (see rule docstring above). | List of strings | optional | []
|
+| hardlink | Controls when to use hardlinks to files instead of making copies.
Creating hardlinks is much faster than making copies of files with the caveat that hardlinks share file permissions with their source.
Since Bazel removes write permissions on files in the output tree after an action completes, hardlinks to source files are not recommended since write permissions will be inadvertently removed from sources files.
- auto
: hardlinks are used for generated files already in the output tree - off
: all files are copied - on
: hardlinks are used for all files (not recommended) | String | optional | "auto"
|
+| include_external_repositories | List of external repository names (with glob support) to include in the output directory.
Files from external repositories are only copied into the output directory if the external repository they come from matches one of the external repository patterns specified or if they are in the same external repository as this target.
When copied from an external repository, the file path in the output directory defaults to the file's path within the external repository. The external repository name is _not_ included in that path.
For example, the following copies @external_repo//path/to:file
to path/to/file
within the output directory.
copy_to_directory( name = "dir", include_external_repositories = ["external_*"], srcs = ["@external_repo//path/to:file"], )
Files that come from matching external are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be. The external repository name of the file from an external repository is not included in the output directory path and is considered in subsequent filters and transformations.
Globs are supported (see rule docstring above). | List of strings | optional | []
|
+| include_srcs_packages | List of Bazel packages (with glob support) to include in output directory.
Files in srcs are only copied to the output directory if the Bazel package of the file matches one of the patterns specified.
Forward slashes (/
) should be used as path separators. A first character of "."
will be replaced by the target's package path.
Defaults to ["**"]
which includes sources from all packages.
Files that have matching Bazel packages are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.
Globs are supported (see rule docstring above). | List of strings | optional | ["**"]
|
+| include_srcs_patterns | List of paths (with glob support) to include in output directory.
Files in srcs are only copied to the output directory if their output directory path, after applying root_paths
, matches one of the patterns specified.
Forward slashes (/
) should be used as path separators.
Defaults to ["**"]
which includes all sources.
Files that have matching output directory paths are subject to subsequent filters and transformations to determine if they are copied and what their path in the output directory will be.
Globs are supported (see rule docstring above). | List of strings | optional | ["**"]
|
+| out | Path of the output directory, relative to this package.
If not set, the name of the target is used. | String | optional | ""
|
+| replace_prefixes | Map of paths prefixes (with glob support) to replace in the output directory path when copying files.
If the output directory path for a file starts with or fully matches a a key in the dict then the matching portion of the output directory path is replaced with the dict value for that key. The final path segment matched can be a partial match of that segment and only the matching portion will be replaced. If there are multiple keys that match, the longest match wins.
Forward slashes (/
) should be used as path separators.
Replace prefix transformation are the final step in the list of filters and transformations. The final output path of a file being copied into the output directory is determined at this step.
Globs are supported (see rule docstring above). | Dictionary: String -> String | optional | {}
|
+| root_paths | List of paths (with glob support) that are roots in the output directory.
If any parent directory of a file being copied matches one of the root paths patterns specified, the output directory path will be the path relative to the root path instead of the path relative to the file's workspace. If there are multiple root paths that match, the longest match wins.
Matching is done on the parent directory of the output file path so a trailing '**' glob patterm will match only up to the last path segment of the dirname and will not include the basename. Only complete path segments are matched. Partial matches on the last segment of the root path are ignored.
Forward slashes (/
) should be used as path separators.
A "."
value expands to the target's package path (ctx.label.package
).
Defaults to ["."]
which results in 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.
Globs are supported (see rule docstring above). | List of strings | optional | ["."]
|
+| srcs | Files and/or directories or targets that provide DirectoryPathInfo
to copy into the output directory. | List of labels | optional | []
|
+| verbose | If true, prints out verbose logs to stdout | Boolean | optional | False
|
diff --git a/docs/directory_path.md b/docs/directory_path.md
index f738326..dc29a4d 100644
--- a/docs/directory_path.md
+++ b/docs/directory_path.md
@@ -21,8 +21,8 @@ Otherwise there is no way to give a Bazel label for it.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
-| directory | a TreeArtifact (ctx.actions.declare_directory) | Label | required | |
+| name | A unique name for this target. | Name | required | |
+| directory | a TreeArtifact (ctx.actions.declare_directory) | Label | required | |
| path | path relative to the directory | String | required | |
diff --git a/docs/expand_make_vars.md b/docs/expand_make_vars.md
index 728e613..d5ee85f 100644
--- a/docs/expand_make_vars.md
+++ b/docs/expand_make_vars.md
@@ -29,8 +29,8 @@ This is of the format:
- `./file`
- `path/to/file`
- `external/external_repo/path/to/file`
-- `/path/to/file`
-- `/external/external_repo/path/to/file`
+- `<bin_dir>/path/to/file`
+- `<bin_dir>/external/external_repo/path/to/file`
The deprecated `$(location)` and `$(locations)` expansions returns either the execpath or rootpath depending on the context.
diff --git a/docs/expand_template.md b/docs/expand_template.md
index 989af81..e59911d 100644
--- a/docs/expand_template.md
+++ b/docs/expand_template.md
@@ -28,14 +28,14 @@ such as `$(BINDIR)`, `$(TARGET_CPU)`, and `$(COMPILATION_MODE)` as documented in
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
-| data | List of targets for additional lookup information. | List of labels | optional | [] |
-| is_executable | Whether to mark the output file as executable. | Boolean | optional | False |
-| out | Where to write the expanded file.
If unset, the template must be a source file and the output file will be named the same as the template file and outputted to the same workspace-relative path. In this case there will be no pre-declared label for the output file. It can be referenced by the target label instead. This pattern is similar to copy_to_bin
but with substitutions on the copy. | Label | optional | |
-| stamp | Whether to encode build information into the output. Possible values:
- stamp = 1
: Always stamp the build information into the output, even in [--nostamp](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) builds. This setting should be avoided, since it is non-deterministic. It potentially causes remote cache misses for the target and any downstream actions that depend on the result. - stamp = 0
: Never stamp, instead replace build information by constant values. This gives good build result caching. - stamp = -1
: Embedding of build information is controlled by the [--[no]stamp](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) flag. Stamped targets are not rebuilt unless their dependencies change. | Integer | optional | -1 |
-| stamp_substitutions | Mapping of strings to substitutions.
There are overlayed on top of substitutions when stamping is enabled for the target.
Substitutions can contain $(execpath :target) and $(rootpath :target) expansions, $(MAKEVAR) expansions and {{STAMP_VAR}} expansions when stamping is enabled for the target. | Dictionary: String -> String | optional | {} |
-| substitutions | Mapping of strings to substitutions.
Substitutions can contain $(execpath :target) and $(rootpath :target) expansions, $(MAKEVAR) expansions and {{STAMP_VAR}} expansions when stamping is enabled for the target. | Dictionary: String -> String | optional | {} |
-| template | The template file to expand. | Label | required | |
+| name | A unique name for this target. | Name | required | |
+| data | List of targets for additional lookup information. | List of labels | optional | []
|
+| is_executable | Whether to mark the output file as executable. | Boolean | optional | False
|
+| out | Where to write the expanded file.
If unset, the template must be a source file and the output file will be named the same as the template file and outputted to the same workspace-relative path. In this case there will be no pre-declared label for the output file. It can be referenced by the target label instead. This pattern is similar to copy_to_bin
but with substitutions on the copy. | Label | optional | |
+| stamp | Whether to encode build information into the output. Possible values:
- stamp = 1
: Always stamp the build information into the output, even in [--nostamp](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) builds. This setting should be avoided, since it is non-deterministic. It potentially causes remote cache misses for the target and any downstream actions that depend on the result. - stamp = 0
: Never stamp, instead replace build information by constant values. This gives good build result caching. - stamp = -1
: Embedding of build information is controlled by the [--[no]stamp](https://docs.bazel.build/versions/main/user-manual.html#flag--stamp) flag. Stamped targets are not rebuilt unless their dependencies change. | Integer | optional | -1
|
+| stamp_substitutions | Mapping of strings to substitutions.
There are overlayed on top of substitutions when stamping is enabled for the target.
Substitutions can contain $(execpath :target) and $(rootpath :target) expansions, $(MAKEVAR) expansions and {{STAMP_VAR}} expansions when stamping is enabled for the target. | Dictionary: String -> String | optional | {}
|
+| substitutions | Mapping of strings to substitutions.
Substitutions can contain $(execpath :target) and $(rootpath :target) expansions, $(MAKEVAR) expansions and {{STAMP_VAR}} expansions when stamping is enabled for the target. | Dictionary: String -> String | optional | {}
|
+| template | The template file to expand. | Label | required | |
diff --git a/docs/host_repo.md b/docs/host_repo.md
index 5da26ca..a3e4321 100644
--- a/docs/host_repo.md
+++ b/docs/host_repo.md
@@ -17,7 +17,7 @@ Exposes information about the host platform
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this repository. | Name | required | |
-| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar"
declares that, for any time this repository depends on @foo
(such as a dependency on @foo//some:target
, it should actually resolve that dependency within globally-declared @bar
(@bar//some:target
). | Dictionary: String -> String | required | |
+| name | A unique name for this repository. | Name | required | |
+| repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar"
declares that, for any time this repository depends on @foo
(such as a dependency on @foo//some:target
, it should actually resolve that dependency within globally-declared @bar
(@bar//some:target
). | Dictionary: String -> String | required | |
diff --git a/docs/jq.md b/docs/jq.md
index d96dad5..521f2d5 100644
--- a/docs/jq.md
+++ b/docs/jq.md
@@ -93,7 +93,7 @@ jq(
"--raw-input",
"--slurp",
],
- filter = "{ deps: split("\n") | map(select(. | length > 0)) }",
+ filter = "{ deps: split("\n") | map(select(. | length > 0)) }",
)
# With --stamp, causes properties to be replaced by version control info.
@@ -105,7 +105,7 @@ jq(
# This 'as' syntax results in $stamp being null in unstamped builds.
"$ARGS.named.STAMP as $stamp",
# Provide a default using the "alternative operator" in case $stamp is null.
- ".version = ($stamp.BUILD_EMBED_LABEL // "")",
+ ".version = ($stamp.BUILD_EMBED_LABEL // "<unstamped>")",
]),
)
```
@@ -118,7 +118,7 @@ genrule(
name = "case_genrule",
srcs = ["a.json"],
outs = ["genrule_output.json"],
- cmd = "$(JQ_BIN) '.' $(location a.json) > $@",
+ cmd = "$(JQ_BIN) '.' $(location a.json) > $@",
toolchains = ["@jq_toolchains//:resolved_toolchain"],
)
```
diff --git a/docs/output_files.md b/docs/output_files.md
index 26e2562..97d2303 100644
--- a/docs/output_files.md
+++ b/docs/output_files.md
@@ -18,10 +18,10 @@ A rule that provides file(s) specific via DefaultInfo from a given target's Defa
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
-| output_group | if set, we look in the specified output group for paths instead of DefaultInfo | String | optional | "" |
+| name | A unique name for this target. | Name | required | |
+| output_group | if set, we look in the specified output group for paths instead of DefaultInfo | String | optional | ""
|
| paths | the paths of the file(s), relative to their roots, to provide via DefaultInfo from the given target's DefaultInfo or OutputGroupInfo | List of strings | required | |
-| target | the target to look in for requested paths in its' DefaultInfo or OutputGroupInfo | Label | required | |
+| target | the target to look in for requested paths in its' DefaultInfo or OutputGroupInfo | Label | required | |
diff --git a/docs/paths.md b/docs/paths.md
index 293c286..0c03d71 100644
--- a/docs/paths.md
+++ b/docs/paths.md
@@ -46,20 +46,20 @@ This produces the same value as the `rlocationpath` predefined source/output pat
From https://bazel.build/reference/be/make-variables#predefined_genrule_variables:
-> `rlocationpath`: The path a built binary can pass to the `Rlocation` function of a runfiles
-> library to find a dependency at runtime, either in the runfiles directory (if available)
-> or using the runfiles manifest.
+> `rlocationpath`: The path a built binary can pass to the `Rlocation` function of a runfiles
+> library to find a dependency at runtime, either in the runfiles directory (if available)
+> or using the runfiles manifest.
-> This is similar to root path (a.k.a. [short_path](https://bazel.build/rules/lib/File#short_path))
-> in that it does not contain configuration prefixes, but differs in that it always starts with the
-> name of the repository.
+> This is similar to root path (a.k.a. [short_path](https://bazel.build/rules/lib/File#short_path))
+> in that it does not contain configuration prefixes, but differs in that it always starts with the
+> name of the repository.
-> The rlocation path of a `File` in an external repository repo will start with `repo/`, followed by the
-> repository-relative path.
+> The rlocation path of a `File` in an external repository repo will start with `repo/`, followed by the
+> repository-relative path.
-> Passing this path to a binary and resolving it to a file system path using the runfiles libraries
-> is the preferred approach to find dependencies at runtime. Compared to root path, it has the
-> advantage that it works on all platforms and even if the runfiles directory is not available.
+> Passing this path to a binary and resolving it to a file system path using the runfiles libraries
+> is the preferred approach to find dependencies at runtime. Compared to root path, it has the
+> advantage that it works on all platforms and even if the runfiles directory is not available.
**PARAMETERS**
@@ -139,20 +139,20 @@ This produces the same value as the `rlocationpath` predefined source/output pat
From https://bazel.build/reference/be/make-variables#predefined_genrule_variables:
-> `rlocationpath`: The path a built binary can pass to the `Rlocation` function of a runfiles
-> library to find a dependency at runtime, either in the runfiles directory (if available)
-> or using the runfiles manifest.
+> `rlocationpath`: The path a built binary can pass to the `Rlocation` function of a runfiles
+> library to find a dependency at runtime, either in the runfiles directory (if available)
+> or using the runfiles manifest.
-> This is similar to root path (a.k.a. [short_path](https://bazel.build/rules/lib/File#short_path))
-> in that it does not contain configuration prefixes, but differs in that it always starts with the
-> name of the repository.
+> This is similar to root path (a.k.a. [short_path](https://bazel.build/rules/lib/File#short_path))
+> in that it does not contain configuration prefixes, but differs in that it always starts with the
+> name of the repository.
-> The rlocation path of a `File` in an external repository repo will start with `repo/`, followed by the
-> repository-relative path.
+> The rlocation path of a `File` in an external repository repo will start with `repo/`, followed by the
+> repository-relative path.
-> Passing this path to a binary and resolving it to a file system path using the runfiles libraries
-> is the preferred approach to find dependencies at runtime. Compared to root path, it has the
-> advantage that it works on all platforms and even if the runfiles directory is not available.
+> Passing this path to a binary and resolving it to a file system path using the runfiles libraries
+> is the preferred approach to find dependencies at runtime. Compared to root path, it has the
+> advantage that it works on all platforms and even if the runfiles directory is not available.
**PARAMETERS**
diff --git a/docs/repo_utils.md b/docs/repo_utils.md
index 8b80669..50d80c6 100644
--- a/docs/repo_utils.md
+++ b/docs/repo_utils.md
@@ -145,8 +145,8 @@ Returns a normalized name of the host os and CPU architecture.
Alias archictures names are normalized:
-x86_64 => amd64
-aarch64 => arm64
+x86_64 => amd64
+aarch64 => arm64
The result can be used to generate repository names for host toolchain
repositories for toolchains that use these normalized names.
@@ -171,6 +171,6 @@ Common os & architecture pairs that are returned are,
**RETURNS**
-The normalized "_" string of the host os and CPU architecture.
+The normalized "<os>_<arch>" string of the host os and CPU architecture.
diff --git a/docs/stamping.md b/docs/stamping.md
index 401c497..972be9c 100644
--- a/docs/stamping.md
+++ b/docs/stamping.md
@@ -9,8 +9,8 @@ See [the Bazel workspace status docs](https://docs.bazel.build/versions/master/u
To stamp a build, you pass the `--stamp` argument to Bazel.
-> Note: https://github.com/bazelbuild/bazel/issues/14341 proposes that Bazel enforce this by
-> only giving constant values to rule implementations when stamping isn't enabled.
+> Note: https://github.com/bazelbuild/bazel/issues/14341 proposes that Bazel enforce this by
+> only giving constant values to rule implementations when stamping isn't enabled.
Stamping is typically performed on a later action in the graph, like on a linking or packaging rule (`pkg_*`).
This means that a changed status variable only causes that action, not re-compilation and thus does not cause cascading re-builds.
@@ -31,13 +31,13 @@ The value of this flag is a path to a script that prints space-separated key/val
#!/usr/bin/env bash
echo STABLE_GIT_COMMIT $(git rev-parse HEAD)
```
-> For a more full-featured script, take a look at this [example in Angular]
+> For a more full-featured script, take a look at this [example in Angular]
Make sure you set the executable bit, eg. `chmod +x tools/bazel_stamp_vars.sh`.
-> **NOTE** keys that start with `STABLE_` will cause a re-build when they change.
-> Other keys will NOT cause a re-build, so stale values can appear in your app.
-> Non-stable (volatile) keys should typically be things like timestamps that always vary between builds.
+> **NOTE** keys that start with `STABLE_` will cause a re-build when they change.
+> Other keys will NOT cause a re-build, so stale values can appear in your app.
+> Non-stable (volatile) keys should typically be things like timestamps that always vary between builds.
You might like to encode your setup using an entry in `.bazelrc` such as:
diff --git a/docs/transitions.md b/docs/transitions.md
index bf172c4..83b6561 100644
--- a/docs/transitions.md
+++ b/docs/transitions.md
@@ -17,10 +17,10 @@ Transitions the binary to use the provided platform.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
-| basename | - | String | optional | "" |
-| binary | - | Label | optional | None |
-| target_platform | The target platform to transition the binary. | Label | required | |
+| name | A unique name for this target. | Name | required | |
+| basename | - | String | optional | ""
|
+| binary | - | Label | optional | None
|
+| target_platform | The target platform to transition the binary. | Label | required | |
@@ -38,8 +38,8 @@ Transitions the srcs to use the provided platform. The filegroup will contain ar
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
-| name | A unique name for this target. | Name | required | |
-| srcs | The input to be transitioned to the target platform. | List of labels | optional | [] |
-| target_platform | The target platform to transition the srcs. | Label | required | |
+| name | A unique name for this target. | Name | required | |
+| srcs | The input to be transitioned to the target platform. | List of labels | optional | []
|
+| target_platform | The target platform to transition the srcs. | Label | required | |
diff --git a/docs/utils.md b/docs/utils.md
index be23999..8c28e12 100644
--- a/docs/utils.md
+++ b/docs/utils.md
@@ -46,15 +46,15 @@ Provide a sane default for *_test timeout attribute.
The [test-encyclopedia](https://bazel.build/reference/test-encyclopedia) says:
-> Tests may return arbitrarily fast regardless of timeout.
-> A test is not penalized for an overgenerous timeout, although a warning may be issued:
-> you should generally set your timeout as tight as you can without incurring any flakiness.
+> Tests may return arbitrarily fast regardless of timeout.
+> A test is not penalized for an overgenerous timeout, although a warning may be issued:
+> you should generally set your timeout as tight as you can without incurring any flakiness.
However Bazel's default for timeout is medium, which is dumb given this guidance.
It also says:
-> Tests which do not explicitly specify a timeout have one implied based on the test's size as follows
+> Tests which do not explicitly specify a timeout have one implied based on the test's size as follows
Therefore if size is specified, we should allow timeout to take its implied default.
If neither is set, then we can fix Bazel's wrong default here to avoid warnings under
diff --git a/docs/yq.md b/docs/yq.md
index bd1dc2a..e9938cc 100644
--- a/docs/yq.md
+++ b/docs/yq.md
@@ -91,7 +91,7 @@ genrule(
name = "generate",
srcs = ["farm.yaml"],
outs = ["genrule_output.yaml"],
- cmd = "$(YQ_BIN) '.moo = "cow"' $(location farm.yaml) > $@",
+ cmd = "$(YQ_BIN) '.moo = "cow"' $(location farm.yaml) > $@",
toolchains = ["@yq_toolchains//:resolved_toolchain"],
)
```
@@ -104,7 +104,7 @@ yq(
expression = "|".join([
"load(strenv(STAMP)) as $stamp",
# Provide a default using the "alternative operator" in case $stamp is empty dict.
- ".version = ($stamp.BUILD_EMBED_LABEL // "")",
+ ".version = ($stamp.BUILD_EMBED_LABEL // "<unstamped>")",
]),
)
```
diff --git a/e2e/external_copy_to_directory/MODULE.bazel b/e2e/external_copy_to_directory/MODULE.bazel
new file mode 100644
index 0000000..0fd0d89
--- /dev/null
+++ b/e2e/external_copy_to_directory/MODULE.bazel
@@ -0,0 +1,12 @@
+module(
+ name = "external_copy_to_directory",
+ version = "0.0.0",
+ compatibility_level = 1,
+)
+
+bazel_dep(name = "bazel_skylib", version = "1.4.2")
+bazel_dep(name = "aspect_bazel_lib", version = "0.0.0")
+local_path_override(
+ module_name = "aspect_bazel_lib",
+ path = "../..",
+)
diff --git a/e2e/external_copy_to_directory/WORKSPACE.bzlmod b/e2e/external_copy_to_directory/WORKSPACE.bzlmod
new file mode 100644
index 0000000..e69de29
diff --git a/e2e/run_jq_symlinked_bin.sh b/e2e/run_jq_symlinked_bin.sh
index ed748b3..f9613cf 100755
--- a/e2e/run_jq_symlinked_bin.sh
+++ b/e2e/run_jq_symlinked_bin.sh
@@ -1,13 +1,15 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
+BZLMOD_FLAG="${BZLMOD_FLAG:-}"
+
case "$(uname -s)" in
CYGWIN*|MINGW32*|MSYS*|MINGW*)
- bazel run @jq//:jq.exe -- --null-input .a=5
+ bazel run $BZLMOD_FLAG @jq//:jq.exe -- --null-input .a=5
;;
*)
- bazel run @jq//:jq -- --null-input .a=5
+ bazel run $BZLMOD_FLAG @jq//:jq -- --null-input .a=5
;;
esac
diff --git a/e2e/run_yq_symlinked_bin.sh b/e2e/run_yq_symlinked_bin.sh
index cc3a0df..a3fb7b9 100755
--- a/e2e/run_yq_symlinked_bin.sh
+++ b/e2e/run_yq_symlinked_bin.sh
@@ -1,12 +1,14 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
+BZLMOD_FLAG="${BZLMOD_FLAG:-}"
+
case "$(uname -s)" in
CYGWIN*|MINGW32*|MSYS*|MINGW*)
- bazel run @yq//:yq.exe -- --null-input .a=5
+ bazel run $BZLMOD_FLAG @yq//:yq.exe -- --null-input .a=5
;;
*)
- bazel run @yq//:yq -- --null-input .a=5
+ bazel run $BZLMOD_FLAG @yq//:yq -- --null-input .a=5
;;
-esac
\ No newline at end of file
+esac
diff --git a/e2e/write_source_files.sh b/e2e/write_source_files.sh
index 1896cd3..4dcbd3b 100755
--- a/e2e/write_source_files.sh
+++ b/e2e/write_source_files.sh
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
+BZLMOD_FLAG="${BZLMOD_FLAG:-}"
+
function run_test {
- bazel run //lib/tests/write_source_files:write_dist
+ bazel run $BZLMOD_FLAG //lib/tests/write_source_files:write_dist
local expected_out="lib/tests/write_source_files/dist.js"
if [ ! -e "$expected_out" ]; then
echo "ERROR: expected $expected_out to exist"
@@ -13,7 +15,7 @@ function run_test {
exit 1
fi
- bazel run //lib/tests/write_source_files:write_dist_executable
+ bazel run $BZLMOD_FLAG //lib/tests/write_source_files:write_dist_executable
local expected_out="lib/tests/write_source_files/dist_executable.js"
if [ ! -e "$expected_out" ]; then
echo "ERROR: expected $expected_out to exist"
diff --git a/e2e/write_source_files_root.sh b/e2e/write_source_files_root.sh
index 1dd39a0..aaa9c43 100755
--- a/e2e/write_source_files_root.sh
+++ b/e2e/write_source_files_root.sh
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
+BZLMOD_FLAG="${BZLMOD_FLAG:-}"
+
function run_test {
- bazel run //:write_source_file_root-test
+ bazel run $BZLMOD_FLAG //:write_source_file_root-test
local expected_out="test-out/dist/write_source_file_root-test/test.txt"
if [ ! -e "$expected_out" ]; then
echo "ERROR: expected $expected_out to exist"
diff --git a/e2e/write_source_files_subdir.sh b/e2e/write_source_files_subdir.sh
index ea34a7c..658fd46 100755
--- a/e2e/write_source_files_subdir.sh
+++ b/e2e/write_source_files_subdir.sh
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
+BZLMOD_FLAG="${BZLMOD_FLAG:-}"
+
function run_test {
- bazel run //lib/tests/write_source_files:write_subdir
+ bazel run $BZLMOD_FLAG //lib/tests/write_source_files:write_subdir
local expected_out="lib/tests/write_source_files/subdir_test/a/b/c/test.txt"
if [ ! -e "$expected_out" ]; then
echo "ERROR: expected $expected_out to exist"
@@ -13,7 +15,7 @@ function run_test {
exit 1
fi
- bazel run //lib/tests/write_source_files:write_subdir_executable
+ bazel run $BZLMOD_FLAG //lib/tests/write_source_files:write_subdir_executable
local expected_out="lib/tests/write_source_files/subdir_executable_test/a/b/c/test.txt"
if [ ! -e "$expected_out" ]; then
echo "ERROR: expected $expected_out to exist"
diff --git a/e2e/write_source_files_symlinks.sh b/e2e/write_source_files_symlinks.sh
index 57b3556..cc35d44 100755
--- a/e2e/write_source_files_symlinks.sh
+++ b/e2e/write_source_files_symlinks.sh
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
+BZLMOD_FLAG="${BZLMOD_FLAG:-}"
+
function run_test {
- bazel run //lib/tests/write_source_files:write_symlinks
+ bazel run $BZLMOD_FLAG //lib/tests/write_source_files:write_symlinks
local expected_out="lib/tests/write_source_files/symlink_test/a/test.txt"
if [ ! -e "$expected_out" ]; then
diff --git a/internal_deps.bzl b/internal_deps.bzl
index fb8f7d7..5d28f7f 100644
--- a/internal_deps.bzl
+++ b/internal_deps.bzl
@@ -46,10 +46,10 @@ def bazel_lib_internal_deps():
http_archive(
name = "io_bazel_stardoc",
- sha256 = "aa814dae0ac400bbab2e8881f9915c6f47c49664bf087c409a15f90438d2c23e",
+ sha256 = "ec57139e466faae563f2fc39609da4948a479bb51b6d67aedd7d9b1b8059c433",
urls = [
- "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",
+ "https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.5.4/stardoc-0.5.4.tar.gz",
+ "https://github.com/bazelbuild/stardoc/releases/download/0.5.4/stardoc-0.5.4.tar.gz",
],
)
diff --git a/lib/tests/expand_template/a.tmpl b/lib/tests/expand_template/a.tmpl
index 7388dd8..abe382f 100644
--- a/lib/tests/expand_template/a.tmpl
+++ b/lib/tests/expand_template/a.tmpl
@@ -3,4 +3,4 @@ VERSION: {{VERSION}}
TMPL_PATH: {{TMPL_PATH}}
WORKSPACE: {{WORKSPACE}}
VERSION: {{VERSION}}
-TMPL_PATH: {{TMPL_PATH}}
\ No newline at end of file
+TMPL_PATH: {{TMPL_PATH}}
diff --git a/lib/tests/expand_template/a_expected b/lib/tests/expand_template/a_expected
index 662651f..05c7b4a 100644
--- a/lib/tests/expand_template/a_expected
+++ b/lib/tests/expand_template/a_expected
@@ -3,4 +3,4 @@ VERSION: v0.0.0
TMPL_PATH: lib/tests/expand_template/a.tmpl
WORKSPACE: aspect_bazel_lib
VERSION: v0.0.0
-TMPL_PATH: lib/tests/expand_template/a.tmpl
\ No newline at end of file
+TMPL_PATH: lib/tests/expand_template/a.tmpl
diff --git a/lib/tests/expand_template/a_stamp_expected b/lib/tests/expand_template/a_stamp_expected
index 040438f..e7961a0 100644
--- a/lib/tests/expand_template/a_stamp_expected
+++ b/lib/tests/expand_template/a_stamp_expected
@@ -3,4 +3,4 @@ VERSION: v1.2.3
TMPL_PATH: lib/tests/expand_template/a.tmpl
WORKSPACE: aspect_bazel_lib
VERSION: v1.2.3
-TMPL_PATH: lib/tests/expand_template/a.tmpl
\ No newline at end of file
+TMPL_PATH: lib/tests/expand_template/a.tmpl
diff --git a/lib/tests/paths_test.bzl b/lib/tests/paths_test.bzl
index 2c11ecb..6fb8b05 100644
--- a/lib/tests/paths_test.bzl
+++ b/lib/tests/paths_test.bzl
@@ -237,7 +237,23 @@ def paths_test_suite():
unittest.suite(
"paths_tests",
partial.make(relative_file_test, timeout = "short"),
- partial.make(rlocation_path_test, timeout = "short"),
- partial.make(output_relative_path_test, timeout = "short"),
+ partial.make(
+ rlocation_path_test,
+ timeout = "short",
+ # TODO: rlocation_path tests don't work under bzlmod
+ target_compatible_with = select({
+ "@aspect_bazel_lib//lib:bzlmod": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ }),
+ ),
+ partial.make(
+ output_relative_path_test,
+ timeout = "short",
+ # TODO: output_relative_path tests don't work under bzlmod
+ target_compatible_with = select({
+ "@aspect_bazel_lib//lib:bzlmod": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ }),
+ ),
partial.make(repository_relative_path_test, timeout = "short"),
)
diff --git a/lib/tests/run_binary_expansions/BUILD.bazel b/lib/tests/run_binary_expansions/BUILD.bazel
index 5b3db3f..73f094c 100644
--- a/lib/tests/run_binary_expansions/BUILD.bazel
+++ b/lib/tests/run_binary_expansions/BUILD.bazel
@@ -1,6 +1,6 @@
"tests for run_binary"
-load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file")
+load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("//lib:run_binary.bzl", "run_binary")
@@ -55,8 +55,11 @@ run_binary(
tool = ":expansions_sh",
)
-write_source_file(
- name = "write_expansions_golden",
- in_file = "expansions_out",
- out_file = "expansions_golden",
+diff_test(
+ name = "expansions_golden_test",
+ file1 = ":expansions_out",
+ file2 = select({
+ "@aspect_bazel_lib//lib:bzlmod": "expansions_golden_bzlmod",
+ "//conditions:default": "expansions_golden",
+ }),
)
diff --git a/lib/tests/run_binary_expansions/expansions_golden_bzlmod b/lib/tests/run_binary_expansions/expansions_golden_bzlmod
new file mode 100644
index 0000000..5070125
--- /dev/null
+++ b/lib/tests/run_binary_expansions/expansions_golden_bzlmod
@@ -0,0 +1,19 @@
+bazel-out/PLATFORM-opt/bin/lib/tests/run_binary_expansions/expansions_out
+bazel-out/PLATFORM-opt/bin/lib/tests/run_binary_expansions
+lib/tests/run_binary_expansions/src_1
+lib/tests/run_binary_expansions/src_1
+bazel-out/PLATFORM-opt/bin/lib/tests/run_binary_expansions/src_1
+bazel-out/PLATFORM-opt/bin/lib/tests/run_binary_expansions/src_1
+_main/lib/tests/run_binary_expansions/src_1
+_main/lib/tests/run_binary_expansions/src_1
+bazel-out/PLATFORM-opt/bin/lib/tests/run_binary_expansions/src_1
+bazel-out/PLATFORM-opt/bin/lib/tests/run_binary_expansions/src_1
+opt
+bazel-out/PLATFORM-opt/bin
+bazel-out/PLATFORM-opt/bin
+PLATFORM
+lib/tests/run_binary_expansions/BUILD.bazel
+bazel-out/volatile-status.txt
+bazel-out/stable-status.txt
+//lib/tests/run_binary_expansions:expansions
+_main
diff --git a/lib/tests/utils_test.bzl b/lib/tests/utils_test.bzl
index c1f0952..46acb81 100644
--- a/lib/tests/utils_test.bzl
+++ b/lib/tests/utils_test.bzl
@@ -59,7 +59,7 @@ def _is_external_label_test_impl(ctx):
asserts.false(env, utils.is_external_label("@@//some/label"))
# assert that labels and string that give a workspace return true
- asserts.true(env, utils.is_external_label(Label("@foo//some/label")))
+ asserts.true(env, utils.is_external_label(Label("@bazel_skylib//some/label")))
asserts.true(env, ctx.attr.external_as_string)
return unittest.end(env)
@@ -134,7 +134,7 @@ def _consistent_label_str_impl(ctx):
asserts.equals(env, "@//foo:bar", utils.consistent_label_str(ctx, Label("//foo:bar")))
asserts.equals(env, "@//foo:bar", utils.consistent_label_str(ctx, Label("@//foo:bar")))
asserts.equals(env, "@//foo:bar", utils.consistent_label_str(ctx, Label("@aspect_bazel_lib//foo:bar")))
- asserts.equals(env, "@external_workspace//foo:bar", utils.consistent_label_str(ctx, Label("@external_workspace//foo:bar")))
+ asserts.equals(env, "@bazel_skylib//foo:bar", utils.consistent_label_str(ctx, Label("@bazel_skylib//foo:bar")))
return unittest.end(env)
@@ -178,13 +178,22 @@ def file_exists_test():
# buildifier: disable=function-docstring
def utils_test_suite():
- to_label_test(name = "to_label_tests", relative_asserts = {
- utils.to_label(":utils_test.bzl"): "//lib/tests:utils_test.bzl",
- }, timeout = "short")
+ to_label_test(
+ name = "to_label_tests",
+ relative_asserts = {
+ utils.to_label(":utils_test.bzl"): "//lib/tests:utils_test.bzl",
+ },
+ timeout = "short",
+ # TODO: to_label tests don't work under bzlmod
+ target_compatible_with = select({
+ "@aspect_bazel_lib//lib:bzlmod": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ }),
+ )
is_external_label_test(
name = "is_external_label_tests",
- external_as_string = utils.is_external_label("@foo//some/label"),
+ external_as_string = utils.is_external_label("@bazel_skylib//some/label"),
internal_with_workspace_as_string = utils.is_external_label("@aspect_bazel_lib//some/label"),
timeout = "short",
)
@@ -212,6 +221,11 @@ def utils_test_suite():
consistent_label_str_test(
name = "consistent_label_str_tests",
timeout = "short",
+ # TODO: consistent_label_str tests don't work under bzlmod
+ target_compatible_with = select({
+ "@aspect_bazel_lib//lib:bzlmod": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ }),
)
file_exists_test()
diff --git a/tools/release.bzl b/tools/release.bzl
index 2c21a0a..0e2e0f3 100644
--- a/tools/release.bzl
+++ b/tools/release.bzl
@@ -79,6 +79,11 @@ def release(name, targets, **kwargs):
for target in targets
]),
tools = [":create_versions.sh"],
+ # TODO: the hashes change when bzlmol is enabled
+ target_compatible_with = kwargs.pop("target_compatible_with", select({
+ "@aspect_bazel_lib//lib:bzlmod": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })),
**kwargs
)