diff --git a/docs/base64.md b/docs/base64.md index 1acd72793..d1ad42f1d 100644 --- a/docs/base64.md +++ b/docs/base64.md @@ -9,6 +9,8 @@ See https://en.wikipedia.org/wiki/Base64. ## base64.decode
+load("@aspect_bazel_lib//lib:base64.bzl", "base64") + base64.decode(data)@@ -31,6 +33,8 @@ A string containing the decoded data ## base64.encode
+load("@aspect_bazel_lib//lib:base64.bzl", "base64") + base64.encode(data)diff --git a/docs/bats.md b/docs/bats.md index 8584ae4e7..4401a3375 100644 --- a/docs/bats.md +++ b/docs/bats.md @@ -26,6 +26,8 @@ bats_test( ## bats_test
+load("@aspect_bazel_lib//lib:bats.bzl", "bats_test") + bats_test(name, srcs, data, env)diff --git a/docs/bazelrc_presets.md b/docs/bazelrc_presets.md index 64cc5348d..30707f87c 100644 --- a/docs/bazelrc_presets.md +++ b/docs/bazelrc_presets.md @@ -9,7 +9,9 @@ See https://docs.aspect.build/guides/bazelrc ## write_aspect_bazelrc_presets
-write_aspect_bazelrc_presets(name, presets, kwargs) +load("@aspect_bazel_lib//lib:bazelrc_presets.bzl", "write_aspect_bazelrc_presets") + +write_aspect_bazelrc_presets(name, presets, **kwargs)Keeps your vendored copy of Aspect recommended `.bazelrc` presets up-to-date. diff --git a/docs/copy_directory.md b/docs/copy_directory.md index fdb72da33..c2e2d066b 100644 --- a/docs/copy_directory.md +++ b/docs/copy_directory.md @@ -22,7 +22,9 @@ there are two caveats to consider when using this feature: ## copy_directory
-copy_directory(name, src, out, hardlink, kwargs) +load("@aspect_bazel_lib//lib:copy_directory.bzl", "copy_directory") + +copy_directory(name, src, out, hardlink, **kwargs)Copies a directory to another location. @@ -53,6 +55,8 @@ for more context. ## copy_directory_bin_action
+load("@aspect_bazel_lib//lib:copy_directory.bzl", "copy_directory_bin_action") + copy_directory_bin_action(ctx, src, dst, copy_directory_bin, copy_directory_toolchain, hardlink, verbose, preserve_mtime)diff --git a/docs/copy_file.md b/docs/copy_file.md index 51d4ae71a..51e9a853c 100644 --- a/docs/copy_file.md +++ b/docs/copy_file.md @@ -15,7 +15,9 @@ This fork of bazel-skylib's copy_file adds `DirectoryPathInfo` support and allow ## copy_file
-copy_file(name, src, out, is_executable, allow_symlink, kwargs) +load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file") + +copy_file(name, src, out, is_executable, allow_symlink, **kwargs)Copies a file or directory to another location. @@ -49,6 +51,8 @@ for more context. ## copy_file_action
+load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file_action") + copy_file_action(ctx, src, dst, dir_path)diff --git a/docs/copy_to_bin.md b/docs/copy_to_bin.md index d7883f7c9..de2ce11bf 100644 --- a/docs/copy_to_bin.md +++ b/docs/copy_to_bin.md @@ -13,6 +13,8 @@ https://github.com/bazel-contrib/rules_nodejs/blob/8b5d27400db51e7027fe95ae413ee ## copy_file_to_bin_action
+load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_file_to_bin_action") + copy_file_to_bin_action(ctx, file)@@ -64,6 +66,8 @@ A File in the output tree. ## copy_files_to_bin_actions
+load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_files_to_bin_actions") + copy_files_to_bin_actions(ctx, files)@@ -94,7 +98,9 @@ List of File objects in the output tree. ## copy_to_bin
-copy_to_bin(name, srcs, kwargs) +load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin") + +copy_to_bin(name, srcs, **kwargs)Copies a source file to output tree at the same workspace-relative path. diff --git a/docs/copy_to_directory.md b/docs/copy_to_directory.md index b202598af..248375502 100644 --- a/docs/copy_to_directory.md +++ b/docs/copy_to_directory.md @@ -7,6 +7,8 @@ Copy files and directories to an output directory. ## copy_to_directory
+load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") + copy_to_directory(name, srcs, out, add_directory_to_runfiles, allow_overwrites, exclude_srcs_packages, exclude_srcs_patterns, hardlink, include_external_repositories, include_srcs_packages, include_srcs_patterns, @@ -70,6 +72,8 @@ for more information on supported globbing patterns. ## copy_to_directory_bin_action@@ -593,6 +633,8 @@ True if the Bazel version being used is greater than or equal to 6 (including pr ## utils.is_bazel_7_or_greater+load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory_bin_action") + copy_to_directory_bin_action(ctx, name, dst, copy_to_directory_bin, copy_to_directory_toolchain, files, targets, root_paths, include_external_repositories, include_srcs_packages, exclude_srcs_packages, include_srcs_patterns, @@ -116,6 +120,8 @@ other rule implementations where additional_files can also be passed in. ## copy_to_directory_lib.impl@@ -212,6 +224,8 @@ tar_lib.implementation(ctx) ## tar_lib.mtree_implementation+load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory_lib") + copy_to_directory_lib.impl(ctx)diff --git a/docs/diff_test.md b/docs/diff_test.md index 1eb1dda4b..a93a3c953 100644 --- a/docs/diff_test.md +++ b/docs/diff_test.md @@ -15,7 +15,9 @@ See also: [rules_diff](https://gitlab.arm.com/bazel/rules_diff) ## diff_test-diff_test(name, file1, file2, size, kwargs) +load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test") + +diff_test(name, file1, file2, size, **kwargs)A test that compares two files. diff --git a/docs/directory_path.md b/docs/directory_path.md index 61ac2a3e1..f237bb70e 100644 --- a/docs/directory_path.md +++ b/docs/directory_path.md @@ -8,6 +8,8 @@ with a path nested within that directory ## directory_path+load("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path") + directory_path(name, directory, path)@@ -30,6 +32,8 @@ Otherwise there is no way to give a Bazel label for it. ## DirectoryPathInfo+load("@aspect_bazel_lib//lib:directory_path.bzl", "DirectoryPathInfo") + DirectoryPathInfo(directory, path)@@ -37,7 +41,6 @@ Joins a label pointing to a TreeArtifact with a path nested within that director **FIELDS** - | Name | Description | | :------------- | :------------- | | directory | a TreeArtifact (ctx.actions.declare_directory) | @@ -49,7 +52,9 @@ Joins a label pointing to a TreeArtifact with a path nested within that director ## make_directory_path-make_directory_path(name, directory, path, kwargs) +load("@aspect_bazel_lib//lib:directory_path.bzl", "make_directory_path") + +make_directory_path(name, directory, path, **kwargs)Helper function to generate a directory_path target and return its label. @@ -74,7 +79,9 @@ The label `name` ## make_directory_paths-make_directory_paths(name, dict, kwargs) +load("@aspect_bazel_lib//lib:directory_path.bzl", "make_directory_paths") + +make_directory_paths(name, dict, **kwargs)Helper function to convert a dict of directory to path mappings to directory_path targets and labels. diff --git a/docs/docs.md b/docs/docs.md index f9b57e649..85857890f 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -7,7 +7,9 @@ Public API for docs helpers ## stardoc_with_diff_test-stardoc_with_diff_test(name, bzl_library_target, kwargs) +load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test") + +stardoc_with_diff_test(name, bzl_library_target, **kwargs)Creates a stardoc target that can be auto-detected by update_docs to write the generated doc to the source tree and test that it's up to date. @@ -30,7 +32,9 @@ This is helpful for minimizing boilerplate in repos with lots of stardoc targets ## update_docs-update_docs(name, kwargs) +load("@aspect_bazel_lib//lib:docs.bzl", "update_docs") + +update_docs(name, **kwargs)Stamps an executable run for writing all stardocs declared with stardoc_with_diff_test to the source tree. diff --git a/docs/expand_make_vars.md b/docs/expand_make_vars.md index f3ca49f3f..59f03d805 100644 --- a/docs/expand_make_vars.md +++ b/docs/expand_make_vars.md @@ -7,6 +7,8 @@ Public API for expanding variables ## expand_locations+load("@aspect_bazel_lib//lib:expand_make_vars.bzl", "expand_locations") + expand_locations(ctx, input, targets)@@ -58,6 +60,8 @@ Use vanilla `ctx.expand_location(input, targets = targets)` instead ## expand_variables+load("@aspect_bazel_lib//lib:expand_make_vars.bzl", "expand_variables") + expand_variables(ctx, s, outs, attribute_name)diff --git a/docs/expand_template.md b/docs/expand_template.md index 8e6d30861..9e34326a7 100644 --- a/docs/expand_template.md +++ b/docs/expand_template.md @@ -7,6 +7,8 @@ Public API for expand template ## expand_template_rule+load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template_rule") + expand_template_rule(name, data, out, is_executable, stamp, stamp_substitutions, substitutions, template)@@ -42,7 +44,9 @@ such as `$(BINDIR)`, `$(TARGET_CPU)`, and `$(COMPILATION_MODE)` as documented in ## expand_template-expand_template(name, template, kwargs) +load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template") + +expand_template(name, template, **kwargs)Wrapper macro for `expand_template_rule`. diff --git a/docs/glob_match.md b/docs/glob_match.md index b60e82095..7f537c4c3 100644 --- a/docs/glob_match.md +++ b/docs/glob_match.md @@ -7,6 +7,8 @@ Public API ## glob_match+load("@aspect_bazel_lib//lib:glob_match.bzl", "glob_match") + glob_match(expr, path, match_path_separator)@@ -38,6 +40,8 @@ True if the path matches the glob expression ## is_glob+load("@aspect_bazel_lib//lib:glob_match.bzl", "is_glob") + is_glob(expr)diff --git a/docs/host_repo.md b/docs/host_repo.md index 99c8c0aa1..cbd21b4a8 100644 --- a/docs/host_repo.md +++ b/docs/host_repo.md @@ -7,6 +7,8 @@ Public API ## host_repo+load("@aspect_bazel_lib//lib:host_repo.bzl", "host_repo") + host_repo(name, repo_mapping)diff --git a/docs/jq.md b/docs/jq.md index db834cfa0..2a61d34b9 100644 --- a/docs/jq.md +++ b/docs/jq.md @@ -127,7 +127,9 @@ genrule( ## jq-jq(name, srcs, filter, filter_file, args, out, data, expand_args, kwargs) +load("@aspect_bazel_lib//lib:jq.bzl", "jq") + +jq(name, srcs, filter, filter_file, args, out, data, expand_args, **kwargs)Invoke jq with a filter on a set of json input files. diff --git a/docs/lists.md b/docs/lists.md index 79e5960b8..f86f4a7a6 100644 --- a/docs/lists.md +++ b/docs/lists.md @@ -7,6 +7,8 @@ Functions for lists ## every+load("@aspect_bazel_lib//lib:lists.bzl", "every") + every(f, arr)@@ -34,6 +36,8 @@ True or False ## filter+load("@aspect_bazel_lib//lib:lists.bzl", "filter") + filter(f, arr)@@ -61,6 +65,8 @@ A new list containing items that passed the filter function. ## find+load("@aspect_bazel_lib//lib:lists.bzl", "find") + find(f, arr)@@ -89,6 +95,8 @@ Tuple (index, item) ## map+load("@aspect_bazel_lib//lib:lists.bzl", "map") + map(f, arr)@@ -116,6 +124,8 @@ A new list with all mapped items. ## once+load("@aspect_bazel_lib//lib:lists.bzl", "once") + once(f, arr)@@ -139,6 +149,8 @@ True or False ## pick+load("@aspect_bazel_lib//lib:lists.bzl", "pick") + pick(f, arr)@@ -166,6 +178,8 @@ item ## some+load("@aspect_bazel_lib//lib:lists.bzl", "some") + some(f, arr)@@ -193,6 +207,8 @@ True or False ## unique+load("@aspect_bazel_lib//lib:lists.bzl", "unique") + unique(arr)diff --git a/docs/output_files.md b/docs/output_files.md index 03ae825a4..c17e79d6d 100644 --- a/docs/output_files.md +++ b/docs/output_files.md @@ -9,6 +9,8 @@ See also [select_file](https://github.com/bazelbuild/bazel-skylib/blob/main/docs ## output_files+load("@aspect_bazel_lib//lib:output_files.bzl", "output_files") + output_files(name, output_group, paths, target)@@ -30,7 +32,9 @@ A rule that provides file(s) specific via DefaultInfo from a given target's Defa ## make_output_files-make_output_files(name, target, paths, kwargs) +load("@aspect_bazel_lib//lib:output_files.bzl", "make_output_files") + +make_output_files(name, target, paths, **kwargs)Helper function to generate a output_files target and return its label. diff --git a/docs/params_file.md b/docs/params_file.md index f9548d3bb..09125f6a9 100644 --- a/docs/params_file.md +++ b/docs/params_file.md @@ -7,7 +7,9 @@ params_file public API ## params_file-params_file(name, out, args, data, newline, kwargs) +load("@aspect_bazel_lib//lib:params_file.bzl", "params_file") + +params_file(name, out, args, data, newline, **kwargs)Generates a UTF-8 encoded params file from a list of arguments. diff --git a/docs/paths.md b/docs/paths.md index 5f19ff950..2f5eb13c2 100644 --- a/docs/paths.md +++ b/docs/paths.md @@ -7,6 +7,8 @@ Utilities for working with file paths. ## relative_file+load("@aspect_bazel_lib//lib:paths.bzl", "relative_file") + relative_file(to_file, frm_file)@@ -37,6 +39,8 @@ The relative path from frm_file to to_file, including the file name ## to_output_relative_path+load("@aspect_bazel_lib//lib:paths.bzl", "to_output_relative_path") + to_output_relative_path(file)@@ -59,6 +63,8 @@ The output relative path for the `File` ## to_repository_relative_path+load("@aspect_bazel_lib//lib:paths.bzl", "to_repository_relative_path") + to_repository_relative_path(file)@@ -87,6 +93,8 @@ The repository relative path for the `File` ## to_rlocation_path+load("@aspect_bazel_lib//lib:paths.bzl", "to_rlocation_path") + to_rlocation_path(ctx, file)diff --git a/docs/platform_utils.md b/docs/platform_utils.md index fd1f08d16..ac17d454a 100644 --- a/docs/platform_utils.md +++ b/docs/platform_utils.md @@ -7,6 +7,8 @@ Public API ## platform_utils.host_platform_is_darwin+load("@aspect_bazel_lib//lib:platform_utils.bzl", "platform_utils") + platform_utils.host_platform_is_darwin()@@ -19,6 +21,8 @@ platform_utils.host_platform_is_darwin() ## platform_utils.host_platform_is_linux+load("@aspect_bazel_lib//lib:platform_utils.bzl", "platform_utils") + platform_utils.host_platform_is_linux()@@ -31,6 +35,8 @@ platform_utils.host_platform_is_linux() ## platform_utils.host_platform_is_windows+load("@aspect_bazel_lib//lib:platform_utils.bzl", "platform_utils") + platform_utils.host_platform_is_windows()diff --git a/docs/repo_utils.md b/docs/repo_utils.md index 026768976..4d61bb219 100644 --- a/docs/repo_utils.md +++ b/docs/repo_utils.md @@ -7,6 +7,8 @@ Public API ## patch+load("@aspect_bazel_lib//lib:repo_utils.bzl", "patch") + patch(ctx, patches, patch_cmds, patch_cmds_win, patch_tool, patch_args, auth, patch_directory)@@ -38,6 +40,8 @@ then they are taken from `ctx.attr`. ## repo_utils.get_env_var+load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils") + repo_utils.get_env_var(rctx, name, default)@@ -62,6 +66,8 @@ The environment variable value or the default if it is not set ## repo_utils.get_home_directory+load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils") + repo_utils.get_home_directory(rctx)@@ -80,6 +86,8 @@ repo_utils.get_home_directory(rctx ## repo_utils.is_darwin+load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils") + repo_utils.is_darwin(rctx)@@ -98,6 +106,8 @@ Returns true if the host operating system is Darwin ## repo_utils.is_linux+load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils") + repo_utils.is_linux(rctx)@@ -116,6 +126,8 @@ Returns true if the host operating system is Linux ## repo_utils.is_windows+load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils") + repo_utils.is_windows(rctx)@@ -134,6 +146,8 @@ Returns true if the host operating system is Windows ## repo_utils.os+load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils") + repo_utils.os(rctx)@@ -156,6 +170,8 @@ The string "windows", "linux", "freebsd" or "darwin" that describes the host os ## repo_utils.platform+load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils") + repo_utils.platform(rctx)diff --git a/docs/repositories.md b/docs/repositories.md index 537cd1d61..513c3d6de 100644 --- a/docs/repositories.md +++ b/docs/repositories.md @@ -7,6 +7,8 @@ Macros for loading dependencies and registering toolchains ## aspect_bazel_lib_dependencies+load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") + aspect_bazel_lib_dependencies()@@ -19,6 +21,8 @@ Load dependencies required by aspect rules ## aspect_bazel_lib_register_toolchains+load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_register_toolchains") + aspect_bazel_lib_register_toolchains()@@ -34,6 +38,8 @@ call the individual toolchain registration macros. ## register_bats_toolchains+load("@aspect_bazel_lib//lib:repositories.bzl", "register_bats_toolchains") + register_bats_toolchains(name, core_version, support_version, assert_version, file_version, libraries, register)@@ -59,6 +65,8 @@ Registers bats toolchain and repositories ## register_copy_directory_toolchains+load("@aspect_bazel_lib//lib:repositories.bzl", "register_copy_directory_toolchains") + register_copy_directory_toolchains(name, register)@@ -78,6 +86,8 @@ Registers copy_directory toolchain and repositories ## register_copy_to_directory_toolchains+load("@aspect_bazel_lib//lib:repositories.bzl", "register_copy_to_directory_toolchains") + register_copy_to_directory_toolchains(name, register)@@ -97,6 +107,8 @@ Registers copy_to_directory toolchain and repositories ## register_coreutils_toolchains+load("@aspect_bazel_lib//lib:repositories.bzl", "register_coreutils_toolchains") + register_coreutils_toolchains(name, version, register)@@ -117,6 +129,8 @@ Registers coreutils toolchain and repositories ## register_expand_template_toolchains+load("@aspect_bazel_lib//lib:repositories.bzl", "register_expand_template_toolchains") + register_expand_template_toolchains(name, register)@@ -136,6 +150,8 @@ Registers expand_template toolchain and repositories ## register_jq_toolchains+load("@aspect_bazel_lib//lib:repositories.bzl", "register_jq_toolchains") + register_jq_toolchains(name, version, register)@@ -156,6 +172,8 @@ Registers jq toolchain and repositories ## register_tar_toolchains+load("@aspect_bazel_lib//lib:repositories.bzl", "register_tar_toolchains") + register_tar_toolchains(name, register)@@ -175,6 +193,8 @@ Registers bsdtar toolchain and repositories ## register_yq_toolchains+load("@aspect_bazel_lib//lib:repositories.bzl", "register_yq_toolchains") + register_yq_toolchains(name, version, register)@@ -195,6 +215,8 @@ Registers yq toolchain and repositories ## register_zstd_toolchains+load("@aspect_bazel_lib//lib:repositories.bzl", "register_zstd_toolchains") + register_zstd_toolchains(name, register)diff --git a/docs/resource_sets.md b/docs/resource_sets.md index 983910dff..57f553788 100644 --- a/docs/resource_sets.md +++ b/docs/resource_sets.md @@ -15,6 +15,8 @@ This seems to be the use case that Google engineers imagined. ## resource_set+load("@aspect_bazel_lib//lib:resource_sets.bzl", "resource_set") + resource_set(attr)diff --git a/docs/run_binary.md b/docs/run_binary.md index d324613d2..e65fe32f3 100644 --- a/docs/run_binary.md +++ b/docs/run_binary.md @@ -9,8 +9,10 @@ This fork of bazel-skylib's run_binary adds directory output support and better ## run_binary+load("@aspect_bazel_lib//lib:run_binary.bzl", "run_binary") + run_binary(name, tool, srcs, args, env, outs, out_dirs, mnemonic, progress_message, - execution_requirements, use_default_shell_env, stamp, kwargs) + execution_requirements, use_default_shell_env, stamp, **kwargs)Runs a binary as a build action. diff --git a/docs/stamping.md b/docs/stamping.md index da70e684b..7676cefbd 100644 --- a/docs/stamping.md +++ b/docs/stamping.md @@ -94,6 +94,8 @@ my_stamp_aware_rule = rule( ## maybe_stamp+load("@aspect_bazel_lib//lib:stamping.bzl", "maybe_stamp") + maybe_stamp(ctx)diff --git a/docs/strings.md b/docs/strings.md index 04b0289c0..56c53c1e1 100644 --- a/docs/strings.md +++ b/docs/strings.md @@ -7,6 +7,8 @@ Utilities for strings ## chr+load("@aspect_bazel_lib//lib:strings.bzl", "chr") + chr(i)@@ -33,6 +35,8 @@ unicode string of the position ## hex+load("@aspect_bazel_lib//lib:strings.bzl", "hex") + hex(number)@@ -55,6 +59,8 @@ hexadecimal representation of the number argument ## ord+load("@aspect_bazel_lib//lib:strings.bzl", "ord") + ord(c)@@ -85,6 +91,8 @@ codepoint of `c` argument. ## split_args+load("@aspect_bazel_lib//lib:strings.bzl", "split_args") + split_args(s)diff --git a/docs/tar.md b/docs/tar.md index ccdda5288..9468566e3 100644 --- a/docs/tar.md +++ b/docs/tar.md @@ -58,6 +58,8 @@ TODO: ## mtree_spec+load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec") + mtree_spec(name, srcs, out)@@ -78,6 +80,8 @@ Create an mtree specification to map a directory hierarchy. See https://man.free ## tar_rule+load("@aspect_bazel_lib//lib:tar.bzl", "tar_rule") + tar_rule(name, srcs, out, args, compress, compute_unused_inputs, mode, mtree)@@ -103,7 +107,9 @@ Rule that executes BSD `tar`. Most users should use the [`tar`](#tar) macro, rat ## mtree_mutate-mtree_mutate(name, mtree, strip_prefix, package_dir, mtime, owner, ownername, awk_script, kwargs) +load("@aspect_bazel_lib//lib:tar.bzl", "mtree_mutate") + +mtree_mutate(name, mtree, strip_prefix, package_dir, mtime, owner, ownername, awk_script, **kwargs)Modify metadata in an mtree file. @@ -129,7 +135,9 @@ Modify metadata in an mtree file. ## tar-tar(name, mtree, stamp, kwargs) +load("@aspect_bazel_lib//lib:tar.bzl", "tar") + +tar(name, mtree, stamp, **kwargs)Wrapper macro around [`tar_rule`](#tar_rule). @@ -175,6 +183,8 @@ https://man.freebsd.org/cgi/man.cgi?mtree(8) ## tar_lib.common.add_compression_args+load("@aspect_bazel_lib//lib:tar.bzl", "tar_lib") + tar_lib.common.add_compression_args(compress, args)@@ -194,6 +204,8 @@ tar_lib.common.add_compression_args(ctx)+load("@aspect_bazel_lib//lib:tar.bzl", "tar_lib") + tar_lib.mtree_implementation(ctx)diff --git a/docs/testing.md b/docs/testing.md index b9e6c2931..38250210e 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -7,7 +7,9 @@ Helpers for making test assertions ## assert_archive_contains-assert_archive_contains(name, archive, expected, type, kwargs) +load("@aspect_bazel_lib//lib:testing.bzl", "assert_archive_contains") + +assert_archive_contains(name, archive, expected, type, **kwargs)Assert that an archive file contains at least the given file entries. @@ -29,7 +31,9 @@ Assert that an archive file contains at least the given file entries. ## assert_contains-assert_contains(name, actual, expected, size, kwargs) +load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains") + +assert_contains(name, actual, expected, size, **kwargs)Generates a test target which fails if the file doesn't contain the string. @@ -54,7 +58,9 @@ Depends on bash, as it creates an sh_test target. ## assert_directory_contains-assert_directory_contains(name, directory, expected, kwargs) +load("@aspect_bazel_lib//lib:testing.bzl", "assert_directory_contains") + +assert_directory_contains(name, directory, expected, **kwargs)Assert that a directory contains at least the given file entries. @@ -75,7 +81,9 @@ Assert that a directory contains at least the given file entries. ## assert_json_matches-assert_json_matches(name, file1, file2, filter1, filter2, kwargs) +load("@aspect_bazel_lib//lib:testing.bzl", "assert_json_matches") + +assert_json_matches(name, file1, file2, filter1, filter2, **kwargs)Assert that the given json files have the same semantic content. @@ -105,7 +113,9 @@ setup notes for the `jq` toolchain. ## assert_outputs-assert_outputs(name, actual, expected, kwargs) +load("@aspect_bazel_lib//lib:testing.bzl", "assert_outputs") + +assert_outputs(name, actual, expected, **kwargs)Assert that the default outputs of a target are the expected ones. diff --git a/docs/transitions.md b/docs/transitions.md index 75c7ea648..07126163f 100644 --- a/docs/transitions.md +++ b/docs/transitions.md @@ -7,6 +7,8 @@ Rules for working with transitions. ## platform_transition_binary+load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_binary") + platform_transition_binary(name, basename, binary, target_platform)@@ -28,6 +30,8 @@ Transitions the binary to use the provided platform. Will forward RunEnvironment ## platform_transition_filegroup+load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") + platform_transition_filegroup(name, srcs, target_platform)@@ -48,6 +52,8 @@ Transitions the srcs to use the provided platform. The filegroup will contain ar ## platform_transition_test+load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_test") + platform_transition_test(name, basename, binary, target_platform)diff --git a/docs/utils.md b/docs/utils.md index 28607b6e8..a67ec59c9 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -15,6 +15,8 @@ out_label = utils.to_label(out_file) ## consistent_label_str+load("@aspect_bazel_lib//lib:utils.bzl", "consistent_label_str") + consistent_label_str(ctx, label)@@ -47,6 +49,8 @@ String representation of the label including the repository name if the label is ## default_timeout+load("@aspect_bazel_lib//lib:utils.bzl", "default_timeout") + default_timeout(size, timeout)@@ -89,6 +93,8 @@ This function can be used in a macro which wraps a testing rule. ## file_exists+load("@aspect_bazel_lib//lib:utils.bzl", "file_exists") + file_exists(path)@@ -111,7 +117,9 @@ This can only be called during the loading phase, not from a rule implementation ## glob_directories-glob_directories(include, kwargs) +load("@aspect_bazel_lib//lib:utils.bzl", "glob_directories") + +glob_directories(include, **kwargs)@@ -130,6 +138,8 @@ glob_directories(include, @@ -171,6 +181,8 @@ True if the Bazel version being used is greater than or equal to 6 (including pr ## is_bazel_7_or_greater+load("@aspect_bazel_lib//lib:utils.bzl", "is_bazel_7_or_greater") + is_bazel_7_or_greater()@@ -209,6 +221,8 @@ True if the Bazel version being used is greater than or equal to 7 (including pr ## is_bzlmod_enabled+load("@aspect_bazel_lib//lib:utils.bzl", "is_bzlmod_enabled") + is_bzlmod_enabled()@@ -221,6 +235,8 @@ Detect the value of the --enable_bzlmod flag ## is_external_label+load("@aspect_bazel_lib//lib:utils.bzl", "is_external_label") + is_external_label(param)@@ -243,7 +259,9 @@ a bool ## maybe_http_archive-maybe_http_archive(kwargs) +load("@aspect_bazel_lib//lib:utils.bzl", "maybe_http_archive") + +maybe_http_archive(**kwargs)Adapts a maybe(http_archive, ...) to look like an http_archive. @@ -292,6 +310,8 @@ maybe( ## path_to_workspace_root+load("@aspect_bazel_lib//lib:utils.bzl", "path_to_workspace_root") + path_to_workspace_root()@@ -308,6 +328,8 @@ Path to the workspace root ## propagate_common_binary_rule_attributes+load("@aspect_bazel_lib//lib:utils.bzl", "propagate_common_binary_rule_attributes") + propagate_common_binary_rule_attributes(attrs)@@ -335,6 +357,8 @@ The dict of parameters, containing only common binary attributes ## propagate_common_rule_attributes+load("@aspect_bazel_lib//lib:utils.bzl", "propagate_common_rule_attributes") + propagate_common_rule_attributes(attrs)@@ -361,6 +385,8 @@ The dict of parameters, containing only common attributes ## propagate_common_test_rule_attributes+load("@aspect_bazel_lib//lib:utils.bzl", "propagate_common_test_rule_attributes") + propagate_common_test_rule_attributes(attrs)@@ -388,6 +414,8 @@ The dict of parameters, containing only common test attributes ## propagate_well_known_tags+load("@aspect_bazel_lib//lib:utils.bzl", "propagate_well_known_tags") + propagate_well_known_tags(tags)@@ -415,6 +443,8 @@ List of tags that only contains the well known set ## to_label+load("@aspect_bazel_lib//lib:utils.bzl", "to_label") + to_label(param)@@ -437,6 +467,8 @@ a Label ## utils.consistent_label_str+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.consistent_label_str(ctx, label)@@ -469,6 +501,8 @@ String representation of the label including the repository name if the label is ## utils.default_timeout+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.default_timeout(size, timeout)@@ -511,6 +545,8 @@ This function can be used in a macro which wraps a testing rule. ## utils.file_exists+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.file_exists(path)@@ -533,7 +569,9 @@ This can only be called during the loading phase, not from a rule implementation ## utils.glob_directories-utils.glob_directories(include, kwargs) +load("@aspect_bazel_lib//lib:utils.bzl", "utils") + +utils.glob_directories(include, **kwargs)@@ -552,6 +590,8 @@ utils.glob_directories(include, +load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.is_bazel_6_or_greater()
+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.is_bazel_7_or_greater()@@ -631,6 +673,8 @@ True if the Bazel version being used is greater than or equal to 7 (including pr ## utils.is_bzlmod_enabled
+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.is_bzlmod_enabled()@@ -643,6 +687,8 @@ Detect the value of the --enable_bzlmod flag ## utils.is_external_label
+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.is_external_label(param)@@ -665,7 +711,9 @@ a bool ## utils.maybe_http_archive
-utils.maybe_http_archive(kwargs) +load("@aspect_bazel_lib//lib:utils.bzl", "utils") + +utils.maybe_http_archive(**kwargs)Adapts a maybe(http_archive, ...) to look like an http_archive. @@ -714,6 +762,8 @@ maybe( ## utils.path_to_workspace_root
+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.path_to_workspace_root()@@ -730,6 +780,8 @@ Path to the workspace root ## utils.propagate_common_binary_rule_attributes
+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.propagate_common_binary_rule_attributes(attrs)@@ -757,6 +809,8 @@ The dict of parameters, containing only common binary attributes ## utils.propagate_common_rule_attributes
+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.propagate_common_rule_attributes(attrs)@@ -783,6 +837,8 @@ The dict of parameters, containing only common attributes ## utils.propagate_common_test_rule_attributes
+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.propagate_common_test_rule_attributes(attrs)@@ -810,6 +866,8 @@ The dict of parameters, containing only common test attributes ## utils.propagate_well_known_tags
+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.propagate_well_known_tags(tags)@@ -837,6 +895,8 @@ List of tags that only contains the well known set ## utils.to_label
+load("@aspect_bazel_lib//lib:utils.bzl", "utils") + utils.to_label(param)diff --git a/docs/write_source_files.md b/docs/write_source_files.md index 74be7ddd7..44531d16e 100644 --- a/docs/write_source_files.md +++ b/docs/write_source_files.md @@ -86,6 +86,8 @@ NOTE: If you run formatters or linters on your codebase, it is advised that you ## WriteSourceFileInfo
+load("@aspect_bazel_lib//lib:write_source_files.bzl", "WriteSourceFileInfo") + WriteSourceFileInfo(executable)@@ -93,7 +95,6 @@ Provider for write_source_file targets **FIELDS** - | Name | Description | | :------------- | :------------- | | executable | Executable that updates the source files | @@ -104,8 +105,10 @@ Provider for write_source_file targets ## write_source_file
+load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_file") + write_source_file(name, in_file, out_file, executable, additional_update_targets, - suggested_update_target, diff_test, check_that_out_file_exists, kwargs) + suggested_update_target, diff_test, check_that_out_file_exists, **kwargs)Write a file or directory to the source tree. @@ -140,8 +143,10 @@ Name of the generated test target if requested, otherwise None. ## write_source_files
+load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") + write_source_files(name, files, executable, additional_update_targets, suggested_update_target, - diff_test, check_that_out_file_exists, kwargs) + diff_test, check_that_out_file_exists, **kwargs)Write one or more files and/or directories to the source tree. diff --git a/docs/yq.md b/docs/yq.md index a42fc1c04..8e09184c1 100644 --- a/docs/yq.md +++ b/docs/yq.md @@ -99,7 +99,9 @@ yq( ## yq
-yq(name, srcs, expression, args, outs, kwargs) +load("@aspect_bazel_lib//lib:yq.bzl", "yq") + +yq(name, srcs, expression, args, outs, **kwargs)Invoke yq with an expression on a set of input files. diff --git a/lib/expand_template.bzl b/lib/expand_template.bzl index a23c7598c..abeefd3bb 100644 --- a/lib/expand_template.bzl +++ b/lib/expand_template.bzl @@ -16,7 +16,7 @@ def expand_template(name, template, **kwargs): **kwargs: other named parameters to `expand_template_rule`. """ if types.is_list(template): - write_target = "_{}.tmpl".format(name) + write_target = "{}.tmpl".format(name) write_file( name = write_target, out = "{}.txt".format(write_target), diff --git a/lib/tar.bzl b/lib/tar.bzl index ee0e00eb8..988e82b01 100644 --- a/lib/tar.bzl +++ b/lib/tar.bzl @@ -102,7 +102,7 @@ def tar(name, mtree = "auto", stamp = 0, **kwargs): stamp: should mtree attribute be stamped **kwargs: additional named parameters to pass to `tar_rule` """ - mtree_target = "_{}.mtree".format(name) + mtree_target = "{}.mtree".format(name) if mtree == "auto": mtree_spec( name = mtree_target, diff --git a/lib/testing.bzl b/lib/testing.bzl index d50821881..9af979f8a 100644 --- a/lib/testing.bzl +++ b/lib/testing.bzl @@ -19,17 +19,17 @@ def assert_contains(name, actual, expected, size = "small", **kwargs): **kwargs: additional named arguments for the resulting sh_test """ - test_sh = "_{}_test.sh".format(name) - expected_file = "_{}_expected.txt".format(name) + test_sh = "{}_test.sh".format(name) + expected_file = "{}_expected.txt".format(name) write_file( - name = "_%s_expected" % name, + name = "{}_expected".format(name), out = expected_file, content = [expected], ) write_file( - name = "_" + name, + name = "{}_gen".format(name), out = test_sh, content = [ "#!/usr/bin/env bash", @@ -61,22 +61,22 @@ def assert_outputs(name, actual, expected, **kwargs): fail("expected should be a list of strings, not " + type(expected)) params_file( - name = "_actual_" + name, + name = name + "_actual", data = [actual], args = ["$(rootpaths {})".format(actual)], - out = "_{}_outputs.txt".format(name), + out = "{}_outputs.txt".format(name), ) write_file( - name = "_expected_ " + name, + name = name + "_expected", content = expected, - out = "_expected_{}.txt".format(name), + out = "{}_expected.txt".format(name), ) diff_test( name = name, - file1 = "_expected_ " + name, - file2 = "_actual_" + name, + file1 = name + "_expected", + file2 = name + "_actual", **kwargs ) @@ -97,8 +97,8 @@ def assert_json_matches(name, file1, file2, filter1 = ".", filter2 = ".", **kwar filter2: a jq filter to apply to file2 **kwargs: additional named arguments for the resulting diff_test """ - name1 = "_{}_jq1".format(name) - name2 = "_{}_jq2".format(name) + name1 = "{}_jq1".format(name) + name2 = "{}_jq2".format(name) jq( name = name1, srcs = [file1], @@ -154,8 +154,8 @@ def assert_archive_contains(name, archive, expected, type = None, **kwargs): # -v: only print lines which don't match grep = "grep -F -x -v -f $actual" - script_name = "_gen_assert_" + name - expected_name = "_expected_" + name + script_name = name + "_gen_assert" + expected_name = name + "_expected" if types.is_list(expected): write_file( @@ -207,8 +207,8 @@ def assert_directory_contains(name, directory, expected, **kwargs): # -v: only print lines which don't match grep = "grep -F -x -v -f $actual" - script_name = "_gen_assert_" + name - expected_name = "_expected_" + name + script_name = name + "_gen_assert" + expected_name = name + "_expected" if types.is_list(expected): write_file( diff --git a/lib/tests/tar/asserts.bzl b/lib/tests/tar/asserts.bzl index 2884e5fd0..4e8f49898 100644 --- a/lib/tests/tar/asserts.bzl +++ b/lib/tests/tar/asserts.bzl @@ -5,14 +5,14 @@ load("//lib:diff_test.bzl", "diff_test") # buildifier: disable=function-docstring def assert_tar_listing(name, actual, expected): - actual_listing = "_{}_listing".format(name) - expected_listing = "_{}_expected".format(name) + actual_listing = "{}_listing".format(name) + expected_listing = "{}_expected".format(name) native.genrule( name = actual_listing, srcs = [actual], testonly = True, - outs = ["_{}.listing".format(name)], + outs = ["{}.listing".format(name)], cmd = "$(BSDTAR_BIN) -tvf $(execpath {}) >$@".format(actual), toolchains = ["@bsd_tar_toolchains//:resolved_toolchain"], ) @@ -20,7 +20,7 @@ def assert_tar_listing(name, actual, expected): write_file( name = expected_listing, testonly = True, - out = "_{}.expected".format(name), + out = "{}.expected".format(name), content = expected + [""], newline = "unix", ) @@ -34,11 +34,11 @@ def assert_tar_listing(name, actual, expected): # buildifier: disable=function-docstring def assert_unused_listing(name, actual, expected): - actual_listing = native.package_relative_label("_{}_actual_listing".format(name)) - actual_shortnames = native.package_relative_label("_{}_actual_shortnames".format(name)) - actual_shortnames_file = native.package_relative_label("_{}.actual_shortnames".format(name)) - expected_listing = native.package_relative_label("_{}_expected".format(name)) - expected_listing_file = native.package_relative_label("_{}.expected".format(name)) + actual_listing = native.package_relative_label("{}_actual_listing".format(name)) + actual_shortnames = native.package_relative_label("{}_actual_shortnames".format(name)) + actual_shortnames_file = native.package_relative_label("{}.actual_shortnames".format(name)) + expected_listing = native.package_relative_label("{}_expected".format(name)) + expected_listing_file = native.package_relative_label("{}.expected".format(name)) native.filegroup( name = actual_listing.name,