diff --git a/WORKSPACE b/WORKSPACE index 16d78744c..3d5374de1 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -12,7 +12,7 @@ bazel_lib_internal_deps() load("//lib:repositories.bzl", "aspect_bazel_lib_dependencies") -aspect_bazel_lib_dependencies(override_local_config_platform = True) +aspect_bazel_lib_dependencies() # For running our own unit tests load("@bazel_skylib//lib:unittest.bzl", "register_unittest_toolchains") diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index da5c11b09..5a0e47963 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -1,5 +1,3 @@ -# These loads are in the docs/ package rather than anything users depend on -# so that the dependency on stardoc doesn't leak to them. load("//lib:docs.bzl", "stardoc_with_diff_test", "update_docs") stardoc_with_diff_test( diff --git a/docs/repositories.md b/docs/repositories.md index b854af039..bc7e64dde 100644 --- a/docs/repositories.md +++ b/docs/repositories.md @@ -7,17 +7,11 @@ Macros for loading dependencies and registering toolchains ## aspect_bazel_lib_dependencies
-aspect_bazel_lib_dependencies(override_local_config_platform)
+aspect_bazel_lib_dependencies()
 
Load dependencies required by aspect rules -**PARAMETERS** - - -| Name | Description | Default Value | -| :------------- | :------------- | :------------- | -| override_local_config_platform | override the @local_config_platform repository with one that adds stardoc support for loading constraints.bzl.

Should be set in repositories that load @aspect_bazel_lib copy actions and also generate stardoc. | False | diff --git a/lib/BUILD.bazel b/lib/BUILD.bazel index a1e177ddf..0456649c0 100644 --- a/lib/BUILD.bazel +++ b/lib/BUILD.bazel @@ -59,19 +59,11 @@ toolchain_type( name = "tar_toolchain_type", ) -bzl_library( - name = "docs", - srcs = ["docs.bzl"], - deps = ["//lib/private/docs"], -) - bzl_library( name = "expand_make_vars", srcs = ["expand_make_vars.bzl"], deps = [ ":expand_template", - "//lib/private/docs:expand_locations", - "//lib/private/docs:expand_variables", ], ) @@ -79,9 +71,7 @@ bzl_library( name = "expand_template", srcs = ["expand_template.bzl"], deps = [ - "//lib/private/docs:expand_locations", - "//lib/private/docs:expand_template", - "//lib/private/docs:expand_variables", + "//lib/private:expand_template", "@bazel_skylib//lib:types", "@bazel_skylib//rules:write_file", ], @@ -90,26 +80,26 @@ bzl_library( bzl_library( name = "params_file", srcs = ["params_file.bzl"], - deps = ["//lib/private/docs:params_file"], + deps = ["//lib/private:params_file"], ) bzl_library( name = "paths", srcs = ["paths.bzl"], - deps = ["//lib/private/docs:paths"], + deps = ["//lib/private:paths"], ) bzl_library( name = "utils", srcs = ["utils.bzl"], - deps = ["//lib/private/docs:utils"], + deps = ["//lib/private:utils"], ) bzl_library( name = "tar", srcs = ["tar.bzl"], deps = [ - "//lib/private/docs:tar", + "//lib/private:tar", "@bazel_skylib//lib:types", "@bazel_skylib//rules:write_file", ], @@ -120,44 +110,51 @@ bzl_library( srcs = ["jq.bzl"], visibility = ["//visibility:public"], deps = [ - "//lib/private/docs:jq", + "//lib/private:jq", ], ) bzl_library( name = "directory_path", srcs = ["directory_path.bzl"], - deps = ["//lib/private/docs:directory_path"], + deps = ["//lib/private:directory_path"], ) bzl_library( name = "output_files", srcs = ["output_files.bzl"], - deps = ["//lib/private/docs:output_files"], + deps = ["//lib/private:output_files"], ) bzl_library( name = "copy_file", srcs = ["copy_file.bzl"], - deps = ["//lib/private/docs:copy_file"], + deps = ["//lib/private:copy_file"], ) bzl_library( name = "copy_directory", srcs = ["copy_directory.bzl"], - deps = ["//lib/private/docs:copy_directory"], + deps = ["//lib/private:copy_directory"], ) bzl_library( name = "copy_to_directory", srcs = ["copy_to_directory.bzl"], - deps = ["//lib/private/docs:copy_to_directory"], + deps = ["//lib/private:copy_to_directory"], ) bzl_library( name = "copy_to_bin", srcs = ["copy_to_bin.bzl"], - deps = ["//lib/private/docs:copy_to_bin"], + deps = ["//lib/private:copy_to_bin"], +) + +#keep +bzl_library( + name = "diff_test", + srcs = ["diff_test.bzl"], + deps = ["//lib/private:diff_test"], ) bzl_library( @@ -166,49 +163,43 @@ bzl_library( deps = [ ":diff_test", ":utils", - "//lib/private/docs:fail_with_message_test", - "//lib/private/docs:write_source_file", + # "//lib/private:fail_with_message_test", + "//lib/private:write_source_file", ], ) -bzl_library( - name = "diff_test", - srcs = ["diff_test.bzl"], - deps = ["//lib/private/docs:diff_test"], -) - bzl_library( name = "run_binary", srcs = ["run_binary.bzl"], - deps = ["//lib/private/docs:run_binary"], + deps = ["//lib/private:run_binary"], ) bzl_library( name = "repo_utils", srcs = ["repo_utils.bzl"], deps = [ - "//lib/private/docs:patch", - "//lib/private/docs:repo_utils", + "//lib/private:patch", + "//lib/private:repo_utils", ], ) bzl_library( name = "yq", srcs = ["yq.bzl"], - deps = ["//lib/private/docs:yq"], + deps = ["//lib/private:yq"], ) bzl_library( name = "glob_match", srcs = ["glob_match.bzl"], - deps = ["//lib/private/docs:glob_match"], + deps = ["//lib/private:glob_match"], ) bzl_library( name = "host_repo", srcs = ["host_repo.bzl"], deps = [ - "//lib/private/docs:host_repo", + "//lib/private:host_repo", "@bazel_skylib//lib:versions", ], ) @@ -216,7 +207,7 @@ bzl_library( bzl_library( name = "stamping", srcs = ["stamping.bzl"], - deps = ["//lib/private/docs:stamping"], + deps = ["//lib/private:stamping"], ) bzl_library( @@ -243,15 +234,14 @@ bzl_library( srcs = ["repositories.bzl"], deps = [ ":utils", - "//lib/private/docs:copy_directory_toolchain", - "//lib/private/docs:copy_to_directory_toolchain", - "//lib/private/docs:coreutils_toolchain", - "//lib/private/docs:expand_template_toolchain", - "//lib/private/docs:jq_toolchain", - "//lib/private/docs:local_config_platform", - "//lib/private/docs:source_toolchains_repo", - "//lib/private/docs:tar_toolchain", - "//lib/private/docs:yq_toolchain", + "//lib/private:copy_directory_toolchain", + "//lib/private:copy_to_directory_toolchain", + "//lib/private:coreutils_toolchain", + "//lib/private:expand_template_toolchain", + "//lib/private:jq_toolchain", + "//lib/private:source_toolchains_repo", + "//lib/private:tar_toolchain", + "//lib/private:yq_toolchain", ], ) @@ -266,13 +256,13 @@ bzl_library( bzl_library( name = "platform_utils", srcs = ["platform_utils.bzl"], - deps = ["//lib/private/docs:platform_utils"], + deps = ["//lib/private:platform_utils"], ) bzl_library( name = "base64", srcs = ["base64.bzl"], - deps = ["//lib/private/docs:base64"], + deps = ["//lib/private:base64"], ) bzl_library( @@ -284,13 +274,19 @@ bzl_library( bzl_library( name = "strings", srcs = ["strings.bzl"], - deps = ["//lib/private/docs:strings"], + deps = ["//lib/private:strings"], ) bzl_library( name = "lists", srcs = ["lists.bzl"], - deps = ["//lib/private/docs:lists"], + deps = ["//lib/private:lists"], +) + +bzl_library( + name = "docs", + srcs = ["docs.bzl"], + deps = ["//lib/private:docs"], ) bzl_library( diff --git a/lib/private/BUILD.bazel b/lib/private/BUILD.bazel index 9a9278c65..115aea46b 100644 --- a/lib/private/BUILD.bazel +++ b/lib/private/BUILD.bazel @@ -1,3 +1,5 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + exports_files( [ "diff_test_tmpl.sh", @@ -12,3 +14,315 @@ exports_files( glob(["*.bzl"]), visibility = ["//lib/private/docs:__pkg__"], ) + +bzl_library( + name = "base64", + srcs = ["base64.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [":strings"], +) + +bzl_library( + name = "copy_directory", + srcs = ["copy_directory.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + ":copy_common", + ":platform_utils", + ], +) + +bzl_library( + name = "copy_directory_toolchain", + srcs = ["copy_directory_toolchain.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + "//tools:integrity", + "//tools:version", + ], +) + +bzl_library( + name = "copy_file", + srcs = ["copy_file.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + ":copy_common", + ":directory_path", + ":platform_utils", + ], +) + +bzl_library( + name = "copy_to_bin", + srcs = ["copy_to_bin.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + ":copy_file", + "@bazel_skylib//lib:paths", + ], +) + +bzl_library( + name = "copy_to_directory", + srcs = ["copy_to_directory.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + ":copy_common", + ":directory_path", + ":glob_match", + ":paths", + ":platform_utils", + "@bazel_skylib//lib:paths", + ], +) + +bzl_library( + name = "copy_to_directory_toolchain", + srcs = ["copy_to_directory_toolchain.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + "//tools:integrity", + "//tools:version", + ], +) + +bzl_library( + name = "directory_path", + srcs = ["directory_path.bzl"], + visibility = ["//lib:__subpackages__"], + deps = ["//lib:utils"], +) + +#keep +bzl_library( + name = "diff_test", + srcs = ["diff_test.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + ":directory_path", + "//lib:utils", + ], +) + +bzl_library( + name = "docs", + srcs = ["docs.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + "//lib:write_source_files", + "@io_bazel_stardoc//stardoc:stardoc_lib", #keep + ], +) + +bzl_library( + name = "expand_template", + srcs = ["expand_template.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + ":expand_locations", + ":expand_variables", + "//lib:stamping", + "@bazel_skylib//lib:dicts", + ], +) + +bzl_library( + name = "expand_template_toolchain", + srcs = ["expand_template_toolchain.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + "//tools:integrity", + "//tools:version", + ], +) + +bzl_library( + name = "expand_variables", + srcs = ["expand_variables.bzl"], + visibility = ["//lib:__subpackages__"], + deps = ["@bazel_skylib//lib:paths"], +) + +bzl_library( + name = "host_repo", + srcs = ["host_repo.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + ":repo_utils", + "@bazel_skylib//lib:versions", + ], +) + +bzl_library( + name = "jq", + srcs = ["jq.bzl"], + visibility = ["//lib:__subpackages__"], + deps = ["//lib:stamping"], +) + +bzl_library( + name = "jq_toolchain", + srcs = ["jq_toolchain.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [":repo_utils"], +) + +bzl_library( + name = "output_files", + srcs = ["output_files.bzl"], + visibility = ["//lib:__subpackages__"], + deps = ["//lib:utils"], +) + +bzl_library( + name = "params_file", + srcs = ["params_file.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [":expand_locations"], +) + +bzl_library( + name = "patch", + srcs = ["patch.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [":repo_utils"], +) + +bzl_library( + name = "paths", + srcs = ["paths.bzl"], + visibility = ["//lib:__subpackages__"], + deps = ["@bazel_skylib//lib:paths"], +) + +bzl_library( + name = "run_binary", + srcs = ["run_binary.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + ":expand_locations", + ":expand_variables", + "//lib:stamping", + "@bazel_skylib//lib:dicts", + ], +) + +bzl_library( + name = "utils", + srcs = ["utils.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + "@bazel_tools//tools/build_defs/repo:http.bzl", + "@bazel_tools//tools/build_defs/repo:utils.bzl", + ], +) + +# keep +bzl_library( + name = "fail_with_message_test", + srcs = ["fail_with_message_test.bzl"], +) + +bzl_library( + name = "write_source_file", + srcs = ["write_source_file.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [ + ":diff_test", + ":directory_path", + ":fail_with_message_test", + ":utils", + ], +) + +bzl_library( + name = "yq", + srcs = ["yq.bzl"], + visibility = ["//lib:__subpackages__"], + deps = ["//lib:stamping"], +) + +bzl_library( + name = "yq_toolchain", + srcs = ["yq_toolchain.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [":repo_utils"], +) + +bzl_library( + name = "platform_utils", + srcs = [ + "platform_utils.bzl", + "@local_config_platform//:constraints.bzl", # keep + ], + visibility = ["//lib:__subpackages__"], + deps = [], # keep +) + +bzl_library( + name = "tar_toolchain", + srcs = ["tar_toolchain.bzl"], + visibility = ["//lib:__subpackages__"], + deps = [":repo_utils"], +) + +bzl_library( + name = "copy_common", + srcs = ["copy_common.bzl"], + visibility = ["//lib:__subpackages__"], +) + +bzl_library( + name = "coreutils_toolchain", + srcs = ["coreutils_toolchain.bzl"], + visibility = ["//lib:__subpackages__"], +) + +bzl_library( + name = "expand_locations", + srcs = ["expand_locations.bzl"], + visibility = ["//lib:__subpackages__"], +) + +bzl_library( + name = "glob_match", + srcs = ["glob_match.bzl"], + visibility = ["//lib:__subpackages__"], +) + +bzl_library( + name = "lists", + srcs = ["lists.bzl"], + visibility = ["//lib:__subpackages__"], +) + +bzl_library( + name = "repo_utils", + srcs = ["repo_utils.bzl"], + visibility = ["//lib:__subpackages__"], +) + +bzl_library( + name = "source_toolchains_repo", + srcs = ["source_toolchains_repo.bzl"], + visibility = ["//lib:__subpackages__"], +) + +bzl_library( + name = "stamping", + srcs = ["stamping.bzl"], + visibility = ["//lib:__subpackages__"], +) + +bzl_library( + name = "strings", + srcs = ["strings.bzl"], + visibility = ["//lib:__subpackages__"], +) + +bzl_library( + name = "tar", + srcs = ["tar.bzl"], + visibility = ["//lib:__subpackages__"], +) diff --git a/lib/private/docs/BUILD.bazel b/lib/private/docs/BUILD.bazel deleted file mode 100644 index dfa64f475..000000000 --- a/lib/private/docs/BUILD.bazel +++ /dev/null @@ -1,297 +0,0 @@ -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") - -# `bzl_library` targets for `//lib/private:*.bzl` are in this package so that `:platform_utils` dep on -# `@local_config_platform//:constraints` doesn't leak unless downstream consumer is generating docs. -# That dep requires the downstream WORKSPACE to set `override_local_config_platform = True` in -# `aspect_bazel_lib_dependencies`. - -package(default_visibility = ["//lib:__pkg__"]) - -bzl_library( - name = "local_config_platform_constraints", - srcs = ["@local_config_platform//:constraints.bzl"], - visibility = ["//visibility:public"], -) - -bzl_library( - name = "copy_common", - srcs = ["//lib/private:copy_common.bzl"], -) - -bzl_library( - name = "platform_utils", - srcs = ["//lib/private:platform_utils.bzl"], - deps = [":local_config_platform_constraints"], -) - -bzl_library( - name = "copy_file", - srcs = ["//lib/private:copy_file.bzl"], - deps = [ - ":copy_common", - ":directory_path", - ":platform_utils", - ], -) - -bzl_library( - name = "copy_directory", - srcs = ["//lib/private:copy_directory.bzl"], - deps = [ - ":copy_common", - ":paths", - ":platform_utils", - ], -) - -bzl_library( - name = "copy_to_directory", - srcs = ["//lib/private:copy_to_directory.bzl"], - deps = [ - ":copy_common", - ":directory_path", - ":glob_match", - ":output_files", - ":paths", - ":platform_utils", - "@bazel_skylib//lib:paths", - ], -) - -bzl_library( - name = "copy_to_bin", - srcs = ["//lib/private:copy_to_bin.bzl"], - deps = [ - ":copy_file", - "@bazel_skylib//lib:paths", - ], -) - -bzl_library( - name = "params_file", - srcs = ["//lib/private:params_file.bzl"], - deps = [":expand_locations"], -) - -bzl_library( - name = "paths", - srcs = ["//lib/private:paths.bzl"], - deps = ["@bazel_skylib//lib:paths"], -) - -bzl_library( - name = "docs", - srcs = ["//lib/private:docs.bzl"], - deps = [ - "//lib:write_source_files", - "@io_bazel_stardoc//stardoc:stardoc_lib", - ], -) - -bzl_library( - name = "expand_locations", - srcs = ["//lib/private:expand_locations.bzl"], - deps = [ - "@bazel_skylib//lib:paths", - ], -) - -bzl_library( - name = "expand_template", - srcs = ["//lib/private:expand_template.bzl"], - deps = [ - ":expand_locations", - "//lib:stamping", - "@bazel_skylib//lib:dicts", - ], -) - -bzl_library( - name = "expand_variables", - srcs = ["//lib/private:expand_variables.bzl"], - deps = [ - "@bazel_skylib//lib:paths", - ], -) - -bzl_library( - name = "lists", - srcs = [ - "//lib/private:lists.bzl", - ], -) - -bzl_library( - name = "tar", - srcs = [ - "//lib/private:tar.bzl", - ], -) - -bzl_library( - name = "utils", - srcs = [ - "//lib/private:utils.bzl", - "@bazel_tools//tools/build_defs/repo:http.bzl", - "@bazel_tools//tools/build_defs/repo:utils.bzl", - ], -) - -bzl_library( - name = "jq", - srcs = ["//lib/private:jq.bzl"], - deps = ["//lib:stamping"], -) - -bzl_library( - name = "local_config_platform", - srcs = ["//lib/private:local_config_platform.bzl"], -) - -bzl_library( - name = "write_source_file", - srcs = ["//lib/private:write_source_file.bzl"], - deps = [ - ":directory_path", - ":output_files", - "//lib:utils", - ], -) - -bzl_library( - name = "fail_with_message_test", - srcs = ["//lib/private:fail_with_message_test.bzl"], -) - -bzl_library( - name = "glob_match", - srcs = ["//lib/private:glob_match.bzl"], -) - -bzl_library( - name = "directory_path", - srcs = ["//lib/private:directory_path.bzl"], - deps = ["//lib:utils"], -) - -bzl_library( - name = "output_files", - srcs = ["//lib/private:output_files.bzl"], - deps = ["//lib:utils"], -) - -bzl_library( - name = "diff_test", - srcs = [ - "//lib:utils", - "//lib/private:diff_test.bzl", - "//lib/private:directory_path.bzl", - ], -) - -bzl_library( - name = "run_binary", - srcs = ["//lib/private:run_binary.bzl"], - deps = [ - ":expand_locations", - ":expand_variables", - "//lib:stamping", - "@bazel_skylib//lib:dicts", - ], -) - -bzl_library( - name = "patch", - srcs = ["//lib/private:patch.bzl"], - deps = [":repo_utils"], -) - -bzl_library( - name = "host_repo", - srcs = ["//lib/private:host_repo.bzl"], - deps = [":repo_utils"], -) - -bzl_library( - name = "jq_toolchain", - srcs = ["//lib/private:jq_toolchain.bzl"], - deps = [":repo_utils"], -) - -bzl_library( - name = "tar_toolchain", - srcs = ["//lib/private:tar_toolchain.bzl"], - deps = [":repo_utils"], -) - -bzl_library( - name = "repo_utils", - srcs = ["//lib/private:repo_utils.bzl"], -) - -bzl_library( - name = "stamping", - srcs = ["//lib/private:stamping.bzl"], -) - -bzl_library( - name = "yq", - srcs = ["//lib/private:yq.bzl"], - deps = ["//lib:stamping"], -) - -bzl_library( - name = "yq_toolchain", - srcs = ["//lib/private:yq_toolchain.bzl"], - deps = [":repo_utils"], -) - -bzl_library( - name = "base64", - srcs = ["//lib/private:base64.bzl"], - deps = [ - ":strings", - ], -) - -bzl_library( - name = "copy_directory_toolchain", - srcs = ["//lib/private:copy_directory_toolchain.bzl"], - deps = [ - "//tools:sri", - "//tools:version", - ], -) - -bzl_library( - name = "copy_to_directory_toolchain", - srcs = ["//lib/private:copy_to_directory_toolchain.bzl"], - deps = [ - "//tools:sri", - "//tools:version", - ], -) - -bzl_library( - name = "source_toolchains_repo", - srcs = ["//lib/private:source_toolchains_repo.bzl"], -) - -bzl_library( - name = "coreutils_toolchain", - srcs = ["//lib/private:coreutils_toolchain.bzl"], -) - -bzl_library( - name = "expand_template_toolchain", - srcs = ["//lib/private:expand_template_toolchain.bzl"], - deps = [ - "//lib:stamping", - "//tools:sri", - ], -) - -bzl_library( - name = "strings", - srcs = ["//lib/private:strings.bzl"], -) diff --git a/lib/private/local_config_platform.bzl b/lib/private/local_config_platform.bzl deleted file mode 100644 index 1e755d486..000000000 --- a/lib/private/local_config_platform.bzl +++ /dev/null @@ -1,39 +0,0 @@ -"""local_config_platform repository rule -""" - -load(":repo_utils.bzl", "repo_utils") - -def _impl(rctx): - rctx.file("BUILD.bazel", """load(':constraints.bzl', 'HOST_CONSTRAINTS') - -package(default_visibility = ['//visibility:public']) - -platform(name = 'host', - # Auto-detected host platform constraints. - constraint_values = HOST_CONSTRAINTS, -) - -exports_files([ - # Export constraints.bzl for use in downstream bzl_library targets. - 'constraints.bzl', -]) -""") - - [os, cpu] = repo_utils.platform(rctx).split("_") - cpu_constraint = "@platforms//cpu:{0}".format("x86_64" if cpu == "amd64" else cpu) - os_constraint = "@platforms//os:{0}".format("osx" if os == "darwin" else os) - - rctx.file("constraints.bzl", content = """HOST_CONSTRAINTS = [ - '{0}', - '{1}', -] -""".format(cpu_constraint, os_constraint)) - -local_config_platform = repository_rule( - implementation = _impl, - doc = """Generates a repository in the same shape as the auto-generated @local_config_platform repository with an added bzl_library. - - This is useful for rules that want to load `HOST_CONSTRAINTS` from `@local_config_platform//:constraints.bzl` and - also want to use stardoc for generating documentation. - """, -) diff --git a/lib/repositories.bzl b/lib/repositories.bzl index 83e4cf35d..af3dbb3aa 100644 --- a/lib/repositories.bzl +++ b/lib/repositories.bzl @@ -1,27 +1,19 @@ "Macros for loading dependencies and registering toolchains" -load("//lib:utils.bzl", "is_bazel_6_or_greater", http_archive = "maybe_http_archive") +load("//lib:utils.bzl", http_archive = "maybe_http_archive") load("//lib/private:copy_directory_toolchain.bzl", "COPY_DIRECTORY_PLATFORMS", "copy_directory_platform_repo", "copy_directory_toolchains_repo") load("//lib/private:copy_to_directory_toolchain.bzl", "COPY_TO_DIRECTORY_PLATFORMS", "copy_to_directory_platform_repo", "copy_to_directory_toolchains_repo") load("//lib/private:coreutils_toolchain.bzl", "COREUTILS_PLATFORMS", "coreutils_platform_repo", "coreutils_toolchains_repo", _DEFAULT_COREUTILS_VERSION = "DEFAULT_COREUTILS_VERSION") load("//lib/private:expand_template_toolchain.bzl", "EXPAND_TEMPLATE_PLATFORMS", "expand_template_platform_repo", "expand_template_toolchains_repo") load("//lib/private:jq_toolchain.bzl", "JQ_PLATFORMS", "jq_host_alias_repo", "jq_platform_repo", "jq_toolchains_repo", _DEFAULT_JQ_VERSION = "DEFAULT_JQ_VERSION") -load("//lib/private:local_config_platform.bzl", "local_config_platform") load("//lib/private:source_toolchains_repo.bzl", "source_toolchains_repo") load("//lib/private:tar_toolchain.bzl", "BSDTAR_PLATFORMS", "bsdtar_binary_repo", "tar_toolchains_repo") load("//lib/private:yq_toolchain.bzl", "YQ_PLATFORMS", "yq_host_alias_repo", "yq_platform_repo", "yq_toolchains_repo", _DEFAULT_YQ_VERSION = "DEFAULT_YQ_VERSION") load("//tools:version.bzl", "VERSION") # buildifier: disable=unnamed-macro -def aspect_bazel_lib_dependencies(override_local_config_platform = False): - """Load dependencies required by aspect rules - - Args: - override_local_config_platform: override the @local_config_platform repository with one that adds stardoc - support for loading constraints.bzl. - - Should be set in repositories that load @aspect_bazel_lib copy actions and also generate stardoc. - """ +def aspect_bazel_lib_dependencies(): + "Load dependencies required by aspect rules" http_archive( name = "bazel_skylib", sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa", @@ -31,14 +23,6 @@ def aspect_bazel_lib_dependencies(override_local_config_platform = False): ], ) - # Bazel 6 now has the exports that our custom local_config_platform rule made - # so it should never be needed when running Bazel 6 or newer - # TODO(2.0): remove the override_local_config_platform attribute entirely - if not is_bazel_6_or_greater() and override_local_config_platform: - local_config_platform( - name = "local_config_platform", - ) - # Always register the copy_to_directory toolchain register_copy_directory_toolchains() register_copy_to_directory_toolchains() diff --git a/lib/testing.bzl b/lib/testing.bzl index 2f7d36cf1..c12565ff9 100644 --- a/lib/testing.bzl +++ b/lib/testing.bzl @@ -61,7 +61,7 @@ def assert_outputs(name, actual, expected, **kwargs): """ if not types.is_list(expected): - fail("expected should be a list of strings") + fail("expected should be a list of strings, not " + type(expected)) params_file( name = "_actual_" + name, diff --git a/lib/tests/tar/BUILD.bazel b/lib/tests/tar/BUILD.bazel index 3dd3da855..0a3ecab31 100644 --- a/lib/tests/tar/BUILD.bazel +++ b/lib/tests/tar/BUILD.bazel @@ -1,5 +1,6 @@ load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar") load("@aspect_bazel_lib//lib:testing.bzl", "assert_archive_contains") +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@bazel_skylib//rules:write_file.bzl", "write_file") load(":asserts.bzl", "assert_tar_listing") @@ -141,3 +142,13 @@ assert_tar_listing( "-rwxr-xr-x 0 0 0 21 Jan 1 2023 src_file", ], ) + +bzl_library( + name = "asserts", + srcs = ["asserts.bzl"], + visibility = ["//visibility:public"], + deps = [ + "@bazel_skylib//rules:diff_test", + "@bazel_skylib//rules:write_file", + ], +) diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel index 6f86f0a15..e67cc1099 100644 --- a/tools/BUILD.bazel +++ b/tools/BUILD.bazel @@ -8,24 +8,6 @@ exports_files([ "create_version.sh", ]) -bzl_library( - name = "sri", - srcs = [":integrity.bzl"], - visibility = ["//lib/private/docs:__pkg__"], -) - -bzl_library( - name = "version", - srcs = [":version.bzl"], - visibility = ["//lib/private/docs:__pkg__"], -) - -bzl_library( - name = "hashes", - srcs = ["hashes.bzl"], - visibility = ["//visibility:public"], -) - multi_platform_go_binaries( name = "copy_to_directory", embed = ["//tools/copy_to_directory:copy_to_directory_lib"], @@ -65,3 +47,21 @@ write_source_files( }, tags = (["manual"] if not is_bazel_6_or_greater() else []), ) + +bzl_library( + name = "hashes", + srcs = ["hashes.bzl"], + visibility = ["//visibility:public"], +) + +bzl_library( + name = "integrity", + srcs = ["integrity.bzl"], + visibility = ["//visibility:public"], +) + +bzl_library( + name = "version", + srcs = ["version.bzl"], + visibility = ["//visibility:public"], +) diff --git a/tools/expand_template/BUILD.bazel b/tools/expand_template/BUILD.bazel index 009ea0ab1..8041f61d8 100644 --- a/tools/expand_template/BUILD.bazel +++ b/tools/expand_template/BUILD.bazel @@ -5,10 +5,7 @@ go_library( srcs = ["main.go"], importpath = "github.com/aspect-build/bazel-lib/tools/expand_template", visibility = ["//visibility:public"], - deps = [ - "//tools/common", - "@org_golang_x_exp//maps", - ], + deps = ["@org_golang_x_exp//maps"], ) go_binary(