From 8ab8fd1eddad52190bc6f095db59b5d40b92c0db Mon Sep 17 00:00:00 2001 From: Mike Bland Date: Fri, 6 Sep 2024 11:22:23 -0400 Subject: [PATCH] Add bzlmod/canonical-repo-names (#336) This is the example code for the upcoming EngFlow blog post "Migrating to Bazel Modules (a.k.a. Bzlmod) - Repo Names, Macros, and Variables." --- .bazelignore | 1 + MODULE.bazel.lock | 4 +- bzlmod/README.md | 4 + .../canonical-repo-name-injection/.gitignore | 1 + bzlmod/canonical-repo-name-injection/BUILD | 204 ++++ .../MODULE.bazel | 34 + .../MODULE.bazel.lock | 933 ++++++++++++++++++ .../canonical-repo-name-injection/README.md | 18 + .../repo-dir-check.mjs | 59 ++ .../repo-names.bzl | 136 +++ runfiles/engflow/MODULE.bazel.lock | 8 +- 11 files changed, 1396 insertions(+), 6 deletions(-) create mode 100644 bzlmod/README.md create mode 100644 bzlmod/canonical-repo-name-injection/.gitignore create mode 100644 bzlmod/canonical-repo-name-injection/BUILD create mode 100644 bzlmod/canonical-repo-name-injection/MODULE.bazel create mode 100644 bzlmod/canonical-repo-name-injection/MODULE.bazel.lock create mode 100644 bzlmod/canonical-repo-name-injection/README.md create mode 100644 bzlmod/canonical-repo-name-injection/repo-dir-check.mjs create mode 100644 bzlmod/canonical-repo-name-injection/repo-names.bzl diff --git a/.bazelignore b/.bazelignore index b39b3ef5..08ce76bb 100644 --- a/.bazelignore +++ b/.bazelignore @@ -4,3 +4,4 @@ # - https://github.com/bazelbuild/bazel/issues/22208 # - https://github.com/bazelbuild/bazel/issues/21515 runfiles/ +bzlmod/ diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 69e6d15e..2d5ec953 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -171,8 +171,8 @@ "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", "https://bcr.bazel.build/modules/zlib/1.2.13/MODULE.bazel": "aa6deb1b83c18ffecd940c4119aff9567cd0a671d7bba756741cb2ef043a29d5", - "https://bcr.bazel.build/modules/zlib/1.3/MODULE.bazel": "6a9c02f19a24dcedb05572b2381446e27c272cd383aed11d41d99da9e3167a72", - "https://bcr.bazel.build/modules/zlib/1.3/source.json": "b6b43d0737af846022636e6e255fd4a96fee0d34f08f3830e6e0bac51465c37c" + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d" }, "selectedYankedVersions": {}, "moduleExtensions": { diff --git a/bzlmod/README.md b/bzlmod/README.md new file mode 100644 index 00000000..2a5af0f8 --- /dev/null +++ b/bzlmod/README.md @@ -0,0 +1,4 @@ +# Bazel Modules (a.k.a. Bzlmod) Examples + +This directory contains sample projects demonstraing concepts specifically +related to [Bazel modules](https://bazel.build/external/overview#bzlmod). diff --git a/bzlmod/canonical-repo-name-injection/.gitignore b/bzlmod/canonical-repo-name-injection/.gitignore new file mode 100644 index 00000000..90214846 --- /dev/null +++ b/bzlmod/canonical-repo-name-injection/.gitignore @@ -0,0 +1 @@ +.aspect/ diff --git a/bzlmod/canonical-repo-name-injection/BUILD b/bzlmod/canonical-repo-name-injection/BUILD new file mode 100644 index 00000000..4f267caa --- /dev/null +++ b/bzlmod/canonical-repo-name-injection/BUILD @@ -0,0 +1,204 @@ +# Copyright 2024 EngFlow Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +load( + "//:repo-names.bzl", + "canonical_repo", + "workspace_root", + "repo_name_variable", + "repo_dir_variable", + "gen_js_constants", +) +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") +load("@rules_js//js:defs.bzl", "js_binary") + +# This value propagates through the rules below. +# Try it with other targets of your choosing! +repo_target = "@pnpm" + +# The following value inspired the `repo_name_variable` rule. +# - A macro executes during the loading phase and doesn't see resolved aliases. +# - A rule executes during the analysis phase, after aliases have resolved. +#repo_target = "@bison_v3.3.2//bin:bison" + +# Demonstrates the macro-based approach. +genrule( + name = "repo-macros", + outs = ["repo-macros.txt"], + cmd = "printf '%s\n canonical_name: %s\n workspace_root: %s\n' >$@" % ( + repo_target, canonical_repo(repo_target), workspace_root(repo_target) + ) +) + +# Demonstrates the custom Make variable-based approach. Depends on the +# ":repo-target" alias to show how the variables have access to the underlying +# target. +genrule( + name = "repo-vars", + outs = ["repo-vars.txt"], + cmd = r"""printf '%%s\n' \ + '%s' \ + ' repo-name: $(repo-name)' \ + ' repo-dir: $(repo-dir)' >$@""" % repo_target, + toolchains = [ + ":repo-name", + ":repo-dir", + ] +) + +# This alias demonstrates how the rules from `repo-names.bzl` work with resolved +# aliases during the analysis phase. Calling the `canonical_repo()` and +# `workspace_root()` macros with ":repo-target" in this file will return the +# empty string, since macros execute during the loading phase. +alias( + name = "repo-target", + actual = repo_target, +) + +# These rules create custom variables that other rules can use by adding +# ":repo-name" and ":repo-dir" to their `toolchains` attribute. +# - https://bazel.build/reference/be/make-variables#custom_variables +# - https://bazel.build/rules/lib/providers/TemplateVariableInfo +repo_name_variable( + name = "repo-name", + dep = ":repo-target", +) + +repo_dir_variable( + name = "repo-dir", + dep = ":repo-target", +) + +# Run this program via the following commands for different values of +# `repo_target` above. `node` must be installed for the invocations outside of +# `bazel run`. +# +# ```txt +# bazel run --//:constants=genrule //:repo-dir-check +# node bazel-bin/repo-dir-check.mjs +# +# bazel run --//:constants=custom //:repo-dir-check +# node bazel-bin/repo-dir-check.mjs +# ``` +# +# Note the differences between: +# - the macro-generated repo dir and the variable- or rule-generated repo dir +# - where the repo dir is found when running under `bazel run` vs `node` +js_binary( + name = "repo-dir-check", + entry_point = "repo-dir-check.mjs", + data = [ + ":constants-impl", + repo_target, + ], +) + +# Determines which rule generates the `constants.js` module used by +# `:repo-dir-check`, based on the value of the `--//:constants` flag. +genrule( + name = "constants-impl", + outs = ["constants.js"], + srcs = select({ + ":genrule": [":genrule-constants"], + ":custom-rule": [":custom-rule-constants"], + }), + cmd = "cp $< $@", +) + +# The `--//:constants` command line flag determines whether `:constants-impl` +# selects `:genrule-constants` or `:custom-rule-constants` as input. +string_flag( + name = "constants", + values = [ + "genrule", + "custom-rule", + ], + build_setting_default = "genrule", +) + +config_setting( + name = "genrule", + flag_values = {":constants": "genrule"}, +) + +config_setting( + name = "custom-rule", + flag_values = {":constants": "custom-rule"}, +) + +# A genrule producing a constants module illustrating how to incorporate: +# - the `BINDIR` predefined Make variable +# - the `rlocationpaths` predefined variable, called on the ":repo-target" alias +# - the `canonical_name()` and `workspace_root()` macros, called during the +# loading phase on a variable +# - the `repo_name_variable` and `repo_dir_variable` targets, evaluated during +# the analysis phase, which supplies a custom variable as a `toolchains` +# attribute target +# +# Replacing `repo_target` with the string ":repo-target" in the macros below +# will produce the empty string, since the macros won't see the resolved alias. +genrule( + name = "genrule-constants", + srcs = [":repo-target"], + outs = ["genrule-constants.js"], + cmd = r"""printf 'module.exports.%%s;\n' \ + 'ruleName = "genrule-constants"' \ + 'target = "%s"' \ + 'binDir = "$(BINDIR)"' \ + 'location = "$(rlocationpaths :repo-target)"' \ + 'macroName = "%s"' \ + 'macroDir = "%s"' \ + 'repoName = "$(repo-name)"' \ + 'repoDir = "$(repo-dir)"' >$@""" % ( + repo_target, + canonical_repo(repo_target), + workspace_root(repo_target) + ), + toolchains = [ + ":repo-name", + ":repo-dir", + ], +) + +# A custom rule producing a constants module from its `vars`, `repo_names`, and +# `repo_dirs` attributes. +# +# This rule illustrates how to use: +# - The `rlocationpaths` predefined variable, called on the ":repo-target" alias +# - The `canonical_name()` and `workspace_root()` macros, called during the +# loading phase on a variable +# - The `repo_names` and `repo_dirs` attributes of type +# `attr.label_keyed_string_dict`, whose keys are resolved Target values +# (including aliases) during the analysis phase +# +# Note that: +# - For the `vars` attribute, the keys become constant names, and the values +# become constant values. +# - For the `repo_names` and `repo_dirs` attributes, the keys become constant +# values, and the values become constant names. +# +# Replacing `repo_target` with the string ":repo-target" in the macros below +# will produce the empty string, since the macros won't see the resolved alias. +gen_js_constants( + name = "custom-rule-constants", + deps = [":repo-target"], + vars = { + "target": repo_target, + "location": "$(rlocationpaths :repo-target)", + "macroName": canonical_repo(repo_target), + "macroDir": workspace_root(repo_target), + }, + repo_names = {":repo-target": "repoName"}, + repo_dirs = {":repo-target": "repoDir"}, +) diff --git a/bzlmod/canonical-repo-name-injection/MODULE.bazel b/bzlmod/canonical-repo-name-injection/MODULE.bazel new file mode 100644 index 00000000..1c1544fc --- /dev/null +++ b/bzlmod/canonical-repo-name-injection/MODULE.bazel @@ -0,0 +1,34 @@ +# Copyright 2024 EngFlow Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +"""Example module for canonical repo name injection""" + +# Main module +module(name = "frobozz", version = "1.2.3") + +# aspect_rules_js +bazel_dep(name = "aspect_rules_js", version = "2.0.1", repo_name = "rules_js") + +pnpm = use_extension("@rules_js//npm:extensions.bzl", "pnpm") +use_repo(pnpm, "pnpm") + +# rules_bison +bazel_dep(name = "rules_bison", version = "0.2.2") + +bison = use_extension( + "@rules_bison//bison/extensions:bison_repository_ext.bzl", + "bison_repository_ext", +) +bison.repository(version = "3.3.2") +use_repo(bison, "bison_v3.3.2") diff --git a/bzlmod/canonical-repo-name-injection/MODULE.bazel.lock b/bzlmod/canonical-repo-name-injection/MODULE.bazel.lock new file mode 100644 index 00000000..65704485 --- /dev/null +++ b/bzlmod/canonical-repo-name-injection/MODULE.bazel.lock @@ -0,0 +1,933 @@ +{ + "lockFileVersion": 11, + "registryFileHashes": { + "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", + "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", + "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/MODULE.bazel": "70390338f7a5106231d20620712f7cccb659cd0e9d073d1991c038eb9fc57589", + "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/source.json": "7e3a9adf473e9af076ae485ed649d5641ad50ec5c11718103f34de03170d94ad", + "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", + "https://bcr.bazel.build/modules/apple_support/1.5.0/source.json": "eb98a7627c0bc486b57f598ad8da50f6625d974c8f723e9ea71bd39f709c9862", + "https://bcr.bazel.build/modules/aspect_bazel_lib/2.7.7/MODULE.bazel": "491f8681205e31bb57892d67442ce448cda4f472a8e6b3dc062865e29a64f89c", + "https://bcr.bazel.build/modules/aspect_bazel_lib/2.7.7/source.json": "87f12b449cd1d27d3e83840a59a6966d557e7c3c5f19e7b2e0361da5edc6b397", + "https://bcr.bazel.build/modules/aspect_rules_js/2.0.1/MODULE.bazel": "a09d32aa997ad899fcd88dc6e629188f03351994f0698bc32a9979c5bcfd5c31", + "https://bcr.bazel.build/modules/aspect_rules_js/2.0.1/source.json": "62bda0d34f3817af165d1903b890ecbf6e50d652492f8bb83682636e997b5619", + "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", + "https://bcr.bazel.build/modules/bazel_features/1.11.0/source.json": "c9320aa53cd1c441d24bd6b716da087ad7e4ff0d9742a9884587596edfe53015", + "https://bcr.bazel.build/modules/bazel_features/1.9.0/MODULE.bazel": "885151d58d90d8d9c811eb75e3288c11f850e1d6b481a8c9f766adee4712358b", + "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", + "https://bcr.bazel.build/modules/bazel_skylib/1.2.0/MODULE.bazel": "44fe84260e454ed94ad326352a698422dbe372b21a1ac9f3eab76eb531223686", + "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", + "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", + "https://bcr.bazel.build/modules/bazel_skylib/1.4.1/MODULE.bazel": "a0dcb779424be33100dcae821e9e27e4f2901d9dfd5333efe5ac6a8d7ab75e1d", + "https://bcr.bazel.build/modules/bazel_skylib/1.5.0/MODULE.bazel": "32880f5e2945ce6a03d1fbd588e9198c0a959bb42297b2cfaf1685b7bc32e138", + "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", + "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/source.json": "082ed5f9837901fada8c68c2f3ddc958bb22b6d654f71dd73f3df30d45d4b749", + "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", + "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", + "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", + "https://bcr.bazel.build/modules/googletest/1.11.0/source.json": "c73d9ef4268c91bd0c1cd88f1f9dfa08e814b1dbe89b5f594a9f08ba0244d206", + "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", + "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", + "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", + "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", + "https://bcr.bazel.build/modules/platforms/0.0.8/MODULE.bazel": "9f142c03e348f6d263719f5074b21ef3adf0b139ee4c5133e2aa35664da9eb2d", + "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", + "https://bcr.bazel.build/modules/platforms/0.0.9/source.json": "cd74d854bf16a9e002fb2ca7b1a421f4403cda29f824a765acd3a8c56f8d43e6", + "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", + "https://bcr.bazel.build/modules/protobuf/21.7/source.json": "bbe500720421e582ff2d18b0802464205138c06056f443184de39fbb8187b09b", + "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", + "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", + "https://bcr.bazel.build/modules/rules_bison/0.2.2/MODULE.bazel": "4326371dd66dda3c04765cd7f1c64c5dbc064c673555078ec1e4f758ba77d4ba", + "https://bcr.bazel.build/modules/rules_bison/0.2.2/source.json": "a11082c4935d0927c2e90d5d5abd44ceeca81a40b07d96b7a21bebf166f78f42", + "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", + "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", + "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", + "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", + "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", + "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", + "https://bcr.bazel.build/modules/rules_java/5.3.5/MODULE.bazel": "a4ec4f2db570171e3e5eb753276ee4b389bae16b96207e9d3230895c99644b86", + "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", + "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", + "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", + "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/source.json": "a075731e1b46bc8425098512d038d416e966ab19684a10a34f4741295642fc35", + "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", + "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", + "https://bcr.bazel.build/modules/rules_license/0.0.7/source.json": "355cc5737a0f294e560d52b1b7a6492d4fff2caf0bef1a315df5a298fca2d34a", + "https://bcr.bazel.build/modules/rules_m4/0.2.3/MODULE.bazel": "a201ad119823e1af5024240e1e1ef294425d9be73a698cb41c8450e6c8e107e3", + "https://bcr.bazel.build/modules/rules_m4/0.2.3/source.json": "d2fd4b91471317d0e6368ece3da2334884879ed6d6289591c7312944e50dea70", + "https://bcr.bazel.build/modules/rules_nodejs/6.2.0/MODULE.bazel": "ec27907f55eb34705adb4e8257952162a2d4c3ed0f0b3b4c3c1aad1fac7be35e", + "https://bcr.bazel.build/modules/rules_nodejs/6.2.0/source.json": "a77c307175a82982f0847fd6a8660db5b21440d8a9d073642cb4afa7a18612ff", + "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", + "https://bcr.bazel.build/modules/rules_pkg/0.7.0/source.json": "c2557066e0c0342223ba592510ad3d812d4963b9024831f7f66fd0584dd8c66c", + "https://bcr.bazel.build/modules/rules_proto/4.0.0/MODULE.bazel": "a7a7b6ce9bee418c1a760b3d84f83a299ad6952f9903c67f19e4edd964894e06", + "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/MODULE.bazel": "e8dff86b0971688790ae75528fe1813f71809b5afd57facb44dad9e8eca631b7", + "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/source.json": "d57902c052424dfda0e71646cb12668d39c4620ee0544294d9d941e7d12bc3a9", + "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", + "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel": "26114f0c0b5e93018c0c066d6673f1a2c3737c7e90af95eff30cfee38d0bbac7", + "https://bcr.bazel.build/modules/rules_python/0.22.1/source.json": "57226905e783bae7c37c2dd662be078728e48fa28ee4324a7eabcafb5a43d014", + "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", + "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", + "https://bcr.bazel.build/modules/stardoc/0.5.4/MODULE.bazel": "6569966df04610b8520957cb8e97cf2e9faac2c0309657c537ab51c16c18a2a4", + "https://bcr.bazel.build/modules/stardoc/0.5.4/source.json": "a961f58a71e735aa9dcb2d79b288e06b0a2d860ba730302c8f11be411b76631e", + "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", + "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/source.json": "f1ef7d3f9e0e26d4b23d1c39b5f5de71f584dd7d1b4ef83d9bbba6ec7a6a6459", + "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", + "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d" + }, + "selectedYankedVersions": {}, + "moduleExtensions": { + "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { + "general": { + "bzlTransitiveDigest": "PjIds3feoYE8SGbbIq2SFTZy3zmxeO2tQevJZNDo7iY=", + "usagesDigest": "aLmqbvowmHkkBPve05yyDNGN7oh7QE9kBADr3QIZTZs=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "local_config_apple_cc": { + "bzlFile": "@@apple_support~//crosstool:setup.bzl", + "ruleClassName": "_apple_cc_autoconf", + "attributes": {} + }, + "local_config_apple_cc_toolchains": { + "bzlFile": "@@apple_support~//crosstool:setup.bzl", + "ruleClassName": "_apple_cc_autoconf_toolchains", + "attributes": {} + } + }, + "recordedRepoMappingEntries": [ + [ + "apple_support~", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, + "@@aspect_bazel_lib~//lib:extensions.bzl%toolchains": { + "general": { + "bzlTransitiveDigest": "3KydN9M+cGcn8Huu/umxX7Vk08sXz5lJeUxg/b0Gxjc=", + "usagesDigest": "Cfe43UxnexwXh6eindVSVzskoYyQKVcN0d7Q5GURnP8=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "expand_template_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "windows_amd64" + } + }, + "copy_to_directory_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "windows_amd64" + } + }, + "jq_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", + "attributes": { + "platform": "darwin_amd64", + "version": "1.7" + } + }, + "copy_to_directory_freebsd_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "freebsd_amd64" + } + }, + "expand_template_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "linux_amd64" + } + }, + "jq_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", + "attributes": { + "platform": "linux_arm64", + "version": "1.7" + } + }, + "coreutils_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", + "attributes": { + "platform": "darwin_arm64", + "version": "0.0.26" + } + }, + "copy_to_directory_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "linux_arm64" + } + }, + "bsd_tar_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "bsdtar_binary_repo", + "attributes": { + "platform": "linux_arm64" + } + }, + "copy_directory_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "darwin_amd64" + } + }, + "coreutils_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", + "attributes": { + "platform": "darwin_amd64", + "version": "0.0.26" + } + }, + "coreutils_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", + "attributes": { + "platform": "linux_arm64", + "version": "0.0.26" + } + }, + "zstd_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:zstd_toolchain.bzl", + "ruleClassName": "zstd_binary_repo", + "attributes": { + "platform": "linux_arm64" + } + }, + "yq_linux_s390x": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "linux_s390x", + "version": "4.25.2" + } + }, + "yq": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_host_alias_repo", + "attributes": {} + }, + "expand_template_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "darwin_amd64" + } + }, + "copy_directory_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "linux_amd64" + } + }, + "jq_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", + "attributes": { + "platform": "darwin_arm64", + "version": "1.7" + } + }, + "yq_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "darwin_amd64", + "version": "4.25.2" + } + }, + "copy_directory_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "linux_arm64" + } + }, + "expand_template_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_toolchains_repo", + "attributes": { + "user_repository_name": "expand_template" + } + }, + "bats_assert": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "98ca3b685f8b8993e48ec057565e6e2abcc541034ed5b0e81f191505682037fd", + "urls": [ + "https://github.com/bats-core/bats-assert/archive/v2.1.0.tar.gz" + ], + "strip_prefix": "bats-assert-2.1.0", + "build_file_content": "load(\"@aspect_bazel_lib//lib:copy_to_directory.bzl\", \"copy_to_directory\")\n\ncopy_to_directory(\n name = \"assert\",\n hardlink = \"on\",\n srcs = glob([\n \"src/**\",\n \"load.bash\",\n ]),\n out = \"bats-assert\",\n visibility = [\"//visibility:public\"]\n)\n" + } + }, + "copy_to_directory_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "darwin_amd64" + } + }, + "zstd_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:zstd_toolchain.bzl", + "ruleClassName": "zstd_binary_repo", + "attributes": { + "platform": "darwin_arm64" + } + }, + "bsd_tar_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "bsdtar_binary_repo", + "attributes": { + "platform": "linux_amd64" + } + }, + "yq_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_toolchains_repo", + "attributes": { + "user_repository_name": "yq" + } + }, + "zstd_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:zstd_toolchain.bzl", + "ruleClassName": "zstd_binary_repo", + "attributes": { + "platform": "linux_amd64" + } + }, + "bats_support": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "7815237aafeb42ddcc1b8c698fc5808026d33317d8701d5ec2396e9634e2918f", + "urls": [ + "https://github.com/bats-core/bats-support/archive/v0.3.0.tar.gz" + ], + "strip_prefix": "bats-support-0.3.0", + "build_file_content": "load(\"@aspect_bazel_lib//lib:copy_to_directory.bzl\", \"copy_to_directory\")\n\ncopy_to_directory(\n name = \"support\",\n hardlink = \"on\",\n srcs = glob([\n \"src/**\",\n \"load.bash\",\n ]),\n out = \"bats-support\",\n visibility = [\"//visibility:public\"]\n)\n" + } + }, + "bsd_tar_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "bsdtar_binary_repo", + "attributes": { + "platform": "windows_amd64" + } + }, + "jq": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_host_alias_repo", + "attributes": {} + }, + "expand_template_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "darwin_arm64" + } + }, + "bsd_tar_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "bsdtar_binary_repo", + "attributes": { + "platform": "darwin_arm64" + } + }, + "copy_to_directory_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "linux_amd64" + } + }, + "coreutils_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", + "attributes": { + "platform": "linux_amd64", + "version": "0.0.26" + } + }, + "copy_directory_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_toolchains_repo", + "attributes": { + "user_repository_name": "copy_directory" + } + }, + "yq_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "linux_amd64", + "version": "4.25.2" + } + }, + "copy_to_directory_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "darwin_arm64" + } + }, + "coreutils_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_toolchains_repo", + "attributes": { + "user_repository_name": "coreutils" + } + }, + "copy_directory_freebsd_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "freebsd_amd64" + } + }, + "zstd_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:zstd_toolchain.bzl", + "ruleClassName": "zstd_binary_repo", + "attributes": { + "platform": "darwin_amd64" + } + }, + "zstd_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:zstd_toolchain.bzl", + "ruleClassName": "zstd_toolchains_repo", + "attributes": { + "user_repository_name": "zstd" + } + }, + "bats_file": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "9b69043241f3af1c2d251f89b4fcafa5df3f05e97b89db18d7c9bdf5731bb27a", + "urls": [ + "https://github.com/bats-core/bats-file/archive/v0.4.0.tar.gz" + ], + "strip_prefix": "bats-file-0.4.0", + "build_file_content": "load(\"@aspect_bazel_lib//lib:copy_to_directory.bzl\", \"copy_to_directory\")\n\ncopy_to_directory(\n name = \"file\",\n hardlink = \"on\",\n srcs = glob([\n \"src/**\",\n \"load.bash\",\n ]),\n out = \"bats-file\",\n visibility = [\"//visibility:public\"]\n)\n" + } + }, + "expand_template_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "linux_arm64" + } + }, + "jq_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", + "attributes": { + "platform": "linux_amd64", + "version": "1.7" + } + }, + "bsd_tar_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "bsdtar_binary_repo", + "attributes": { + "platform": "darwin_amd64" + } + }, + "bsd_tar_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "tar_toolchains_repo", + "attributes": { + "user_repository_name": "bsd_tar" + } + }, + "bats_toolchains": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "a1a9f7875aa4b6a9480ca384d5865f1ccf1b0b1faead6b47aa47d79709a5c5fd", + "urls": [ + "https://github.com/bats-core/bats-core/archive/v1.10.0.tar.gz" + ], + "strip_prefix": "bats-core-1.10.0", + "build_file_content": "load(\"@local_config_platform//:constraints.bzl\", \"HOST_CONSTRAINTS\")\nload(\"@aspect_bazel_lib//lib/private:bats_toolchain.bzl\", \"bats_toolchain\")\nload(\"@aspect_bazel_lib//lib:copy_to_directory.bzl\", \"copy_to_directory\")\n\ncopy_to_directory(\n name = \"core\",\n hardlink = \"on\",\n srcs = glob([\n \"lib/**\",\n \"libexec/**\"\n ]) + [\"bin/bats\"],\n out = \"bats-core\",\n)\n\nbats_toolchain(\n name = \"toolchain\",\n core = \":core\",\n libraries = [\"@bats_support//:support\", \"@bats_assert//:assert\", \"@bats_file//:file\"]\n)\n\ntoolchain(\n name = \"bats_toolchain\",\n exec_compatible_with = HOST_CONSTRAINTS,\n toolchain = \":toolchain\",\n toolchain_type = \"@aspect_bazel_lib//lib:bats_toolchain_type\",\n)\n" + } + }, + "yq_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "windows_amd64", + "version": "4.25.2" + } + }, + "jq_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", + "attributes": { + "platform": "windows_amd64", + "version": "1.7" + } + }, + "expand_template_freebsd_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "freebsd_amd64" + } + }, + "yq_linux_ppc64le": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "linux_ppc64le", + "version": "4.25.2" + } + }, + "copy_to_directory_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_toolchains_repo", + "attributes": { + "user_repository_name": "copy_to_directory" + } + }, + "jq_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_toolchains_repo", + "attributes": { + "user_repository_name": "jq" + } + }, + "copy_directory_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "darwin_arm64" + } + }, + "copy_directory_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "windows_amd64" + } + }, + "yq_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "darwin_arm64", + "version": "4.25.2" + } + }, + "coreutils_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", + "attributes": { + "platform": "windows_amd64", + "version": "0.0.26" + } + }, + "yq_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "linux_arm64", + "version": "4.25.2" + } + } + }, + "recordedRepoMappingEntries": [ + [ + "aspect_bazel_lib~", + "aspect_bazel_lib", + "aspect_bazel_lib~" + ], + [ + "aspect_bazel_lib~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "aspect_bazel_lib~", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, + "@@aspect_rules_js~//npm:extensions.bzl%pnpm": { + "general": { + "bzlTransitiveDigest": "N13ZfZ6wLGo0wuRf5ovh3O/4c65sIBLrcjjrNbt5M9o=", + "usagesDigest": "fyGbV2htiehfmRllpv0Q+N1sRzciZ0JD+aX2jecfQ2A=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "pnpm__links": { + "bzlFile": "@@aspect_rules_js~//npm/private:npm_import.bzl", + "ruleClassName": "npm_import_links", + "attributes": { + "package": "pnpm", + "version": "8.6.7", + "dev": false, + "root_package": "", + "link_packages": {}, + "deps": {}, + "transitive_closure": {}, + "lifecycle_build_target": false, + "lifecycle_hooks_env": [], + "lifecycle_hooks_execution_requirements": [ + "no-sandbox" + ], + "lifecycle_hooks_use_default_shell_env": false, + "bins": {}, + "package_visibility": [ + "//visibility:public" + ], + "replace_package": "" + } + }, + "pnpm": { + "bzlFile": "@@aspect_rules_js~//npm/private:npm_import.bzl", + "ruleClassName": "npm_import_rule", + "attributes": { + "package": "pnpm", + "version": "8.6.7", + "root_package": "", + "link_workspace": "", + "link_packages": {}, + "integrity": "sha512-vRIWpD/L4phf9Bk2o/O2TDR8fFoJnpYrp2TKqTIZF/qZ2/rgL3qKXzHofHgbXsinwMoSEigz28sqk3pQ+yMEQQ==", + "url": "", + "commit": "", + "patch_args": [ + "-p0" + ], + "patches": [], + "custom_postinstall": "", + "npm_auth": "", + "npm_auth_basic": "", + "npm_auth_username": "", + "npm_auth_password": "", + "lifecycle_hooks": [], + "extra_build_content": "load(\"@aspect_rules_js//js:defs.bzl\", \"js_binary\")\njs_binary(name = \"pnpm\", data = glob([\"package/**\"]), entry_point = \"package/dist/pnpm.cjs\", visibility = [\"//visibility:public\"])", + "generate_bzl_library_targets": false, + "extract_full_archive": true, + "system_tar": "auto" + } + } + }, + "recordedRepoMappingEntries": [ + [ + "aspect_bazel_lib~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "aspect_bazel_lib~", + "bazel_tools", + "bazel_tools" + ], + [ + "aspect_rules_js~", + "aspect_bazel_lib", + "aspect_bazel_lib~" + ], + [ + "aspect_rules_js~", + "bazel_features", + "bazel_features~" + ], + [ + "aspect_rules_js~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "aspect_rules_js~", + "bazel_tools", + "bazel_tools" + ], + [ + "bazel_features~", + "bazel_features_globals", + "bazel_features~~version_extension~bazel_features_globals" + ], + [ + "bazel_features~", + "bazel_features_version", + "bazel_features~~version_extension~bazel_features_version" + ] + ] + } + }, + "@@platforms//host:extension.bzl%host_platform": { + "general": { + "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", + "usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "host_platform": { + "bzlFile": "@@platforms//host:extension.bzl", + "ruleClassName": "host_platform_repo", + "attributes": {} + } + }, + "recordedRepoMappingEntries": [] + } + }, + "@@rules_bison~//bison/extensions:bison_repository_ext.bzl%bison_repository_ext": { + "general": { + "bzlTransitiveDigest": "A+3YMZenwhA/NwA7Bes9xuoVWQNCaBPxA05vtcFi8I4=", + "usagesDigest": "pg4ms5Q9MDybCOdUnh0ryjlnMfIBLNnZvGyBNb0Vhpk=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "bison_v3.3.2": { + "bzlFile": "@@rules_bison~//bison/rules:bison_toolchain_repository.bzl", + "ruleClassName": "bison_toolchain_repository", + "attributes": { + "bison_repository": "@bison_v3.3.2__cfg00000B62" + } + }, + "bison_v3.3.2__cfg00000B62": { + "bzlFile": "@@rules_bison~//bison/rules:bison_repository.bzl", + "ruleClassName": "bison_repository", + "attributes": { + "version": "3.3.2", + "extra_copts": [] + } + } + }, + "moduleExtensionMetadata": { + "explicitRootModuleDirectDeps": [ + "bison_v3.3.2" + ], + "explicitRootModuleDirectDevDeps": [], + "useAllRepos": "NO", + "reproducible": false + }, + "recordedRepoMappingEntries": [] + } + }, + "@@rules_bison~//bison/internal:default_toolchain_ext.bzl%default_toolchain_ext": { + "general": { + "bzlTransitiveDigest": "JVWcUny48LFS9D+xz4b9u/94awfBOIGXV5iu8iY/nRc=", + "usagesDigest": "d7Z3y2AZdN7Sc4BdRU4h9HDd4nZUFM+Ls3iQYb3mCOA=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "bison_v3.3.2": { + "bzlFile": "@@rules_bison~//bison/rules:bison_repository.bzl", + "ruleClassName": "bison_repository", + "attributes": { + "version": "3.3.2" + } + }, + "bison": { + "bzlFile": "@@rules_bison~//bison/rules:bison_toolchain_repository.bzl", + "ruleClassName": "bison_toolchain_repository", + "attributes": { + "bison_repository": "@bison_v3.3.2" + } + } + }, + "moduleExtensionMetadata": { + "explicitRootModuleDirectDeps": [ + "bison" + ], + "explicitRootModuleDirectDevDeps": [], + "useAllRepos": "NO", + "reproducible": false + }, + "recordedRepoMappingEntries": [] + } + }, + "@@rules_m4~//m4/internal:default_toolchain_ext.bzl%default_toolchain_ext": { + "general": { + "bzlTransitiveDigest": "rm6OAtIMR6n0t1X9wBVXucwCa6wqpIoqqh+kSzHNOg4=", + "usagesDigest": "UcxA/XigtmDpzRbmdFAY0WoatxHYiCgjCro6UZD+jvo=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "m4_v1.4.18": { + "bzlFile": "@@rules_m4~//m4/rules:m4_repository.bzl", + "ruleClassName": "m4_repository", + "attributes": { + "version": "1.4.18" + } + }, + "m4": { + "bzlFile": "@@rules_m4~//m4/rules:m4_toolchain_repository.bzl", + "ruleClassName": "m4_toolchain_repository", + "attributes": { + "m4_repository": "@m4_v1.4.18" + } + } + }, + "moduleExtensionMetadata": { + "explicitRootModuleDirectDeps": [ + "m4" + ], + "explicitRootModuleDirectDevDeps": [], + "useAllRepos": "NO", + "reproducible": false + }, + "recordedRepoMappingEntries": [] + } + }, + "@@rules_nodejs~//nodejs:extensions.bzl%node": { + "general": { + "bzlTransitiveDigest": "0IJr1Jg3Dns9QKY65MtauFLtHjjP3n1DgN0+ZAjFYXo=", + "usagesDigest": "QaaCjO0WbxbalX+3ei3mvAH3DxI2biGkZ5h5rxhaOwk=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "nodejs_host": { + "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_repo_host_os_alias.bzl", + "ruleClassName": "nodejs_repo_host_os_alias", + "attributes": { + "user_node_repository_name": "nodejs" + } + }, + "nodejs_linux_s390x": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "linux_s390x" + } + }, + "nodejs_windows_amd64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "windows_amd64" + } + }, + "nodejs_toolchains": { + "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_toolchains_repo.bzl", + "ruleClassName": "nodejs_toolchains_repo", + "attributes": { + "user_node_repository_name": "nodejs" + } + }, + "nodejs_linux_amd64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "linux_amd64" + } + }, + "nodejs_linux_ppc64le": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "linux_ppc64le" + } + }, + "nodejs_darwin_amd64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "darwin_amd64" + } + }, + "nodejs_linux_arm64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "linux_arm64" + } + }, + "nodejs": { + "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_repo_host_os_alias.bzl", + "ruleClassName": "nodejs_repo_host_os_alias", + "attributes": { + "user_node_repository_name": "nodejs" + } + }, + "nodejs_darwin_arm64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "darwin_arm64" + } + } + }, + "recordedRepoMappingEntries": [] + } + } + } +} diff --git a/bzlmod/canonical-repo-name-injection/README.md b/bzlmod/canonical-repo-name-injection/README.md new file mode 100644 index 00000000..45f22a69 --- /dev/null +++ b/bzlmod/canonical-repo-name-injection/README.md @@ -0,0 +1,18 @@ +# Canonical Repo Name Injection + +This is the example code for the upcoming EngFlow blog post "Migrating to +Bazel Modules (a.k.a. Bzlmod) - Repo Names, Macros, and Variables." + +To try it out: + +```sh +bazel build //:repo-macros && cat bazel-bin/repo-macros.txt +bazel build //:repo-vars && cat bazel-bin/repo-vars.txt +bazel run //:repo-dir-check +cat bazel-bin/genrule-constants.js +vimdiff bazel-bin/{genrule,}-constants.js +bazel run --//:constants=custom-rule //:repo-dir-check +cat bazel-bin/custom-rule-constants.js +vimdiff bazel-bin/{genrule,custom-rule}-constants.js +node bazel-bin/repo-dir-check.mjs +``` diff --git a/bzlmod/canonical-repo-name-injection/repo-dir-check.mjs b/bzlmod/canonical-repo-name-injection/repo-dir-check.mjs new file mode 100644 index 00000000..747e3b61 --- /dev/null +++ b/bzlmod/canonical-repo-name-injection/repo-dir-check.mjs @@ -0,0 +1,59 @@ +/* + * Copyright 2024 EngFlow Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +import { + ruleName, target, location, macroName, macroDir, repoName, repoDir, binDir, +} from './constants.js'; + +import * as path from 'node:path'; +import * as fs from 'node:fs/promises'; +import * as process from 'node:process'; + +console.log(`rule name: ${ruleName}\n`); + +console.log(`target: ${target}`); +console.log(`location: ${location}\n`); + +console.log(`macroName: ${macroName}`); +console.log(`macroDir: ${macroDir}\n`); + +console.log(`repoName: ${repoName}`); +console.log(`repoDir: ${repoDir}\n`); + +console.log(`runfiles: ${process.env.JS_BINARY__RUNFILES}`) +console.log(`PWD: ${path.resolve()}`); +console.log(`binDir: ${binDir}\n`); + +async function checkDir() { + const dirname = path.resolve(...arguments); + await fs.access(dirname, fs.constants.R_OK | fs.constants.X_OK); + return dirname; +} + +try { + const result = await Promise.any([ + checkDir(macroDir), + checkDir(repoDir), + checkDir(binDir, macroDir), + checkDir(binDir, repoDir), + ]) + console.log(`result: ${result}`); + +} catch (err) { + console.error('repo directory not found:') + console.error(err.errors ? err.errors.join('\n'): err); + process.exit(1); +} diff --git a/bzlmod/canonical-repo-name-injection/repo-names.bzl b/bzlmod/canonical-repo-name-injection/repo-names.bzl new file mode 100644 index 00000000..ad7b0c92 --- /dev/null +++ b/bzlmod/canonical-repo-name-injection/repo-names.bzl @@ -0,0 +1,136 @@ +# Copyright 2024 EngFlow Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +"""Macros and rules for accessing canonical repository names and paths""" + +load("@rules_js//js:providers.bzl", "JsInfo", _js_info_provider = "js_info") + +# These macros execute during the loading phase. For `alias` targets, they +# return the name of the repo containing the `alias`, not the repo of the +# target from its `actual` attribute. + +def canonical_repo(target_label): + """Return the canonical repository name corresponding to target_label.""" + return Label(target_label).repo_name + +def workspace_root(target_label): + """Return a target's repo workspace path relative to the execroot.""" + return Label(target_label).workspace_root + +# These rules will produce the repo name of the target of an `alias` rule, +# defined by its `actual` attribute. + +def _variable_info(ctx, value): + """Return a TemplateVariableInfo provider for Make variable rules.""" + return [platform_common.TemplateVariableInfo({ctx.attr.name: value})] + +repo_name_variable = rule( + implementation = lambda ctx: _variable_info( + ctx, ctx.attr.dep.label.repo_name + ), + doc = "Defines a custom variable for its dependency's repository name", + attrs = { + "dep": attr.label( + mandatory = True, + doc = "target for which to extract the repository name", + ), + }, +) + +repo_dir_variable = rule( + implementation = lambda ctx: _variable_info( + ctx, ctx.attr.dep.label.workspace_root + ), + doc = "Defines a custom variable for its dependency's repository dir", + attrs = { + "dep": attr.label( + mandatory = True, + doc = "target for which to extract the repository dir", + ), + }, +) + +# The following functions implement the `gen_js_constants` rule. + +def _js_info(label, sources, deps): + """Return a JsInfo provider for sources with transitive values from deps.""" + transitive_sources = [sources] + transitive_types = [] + npm_sources = [] + npm_package_store_infos = [] + + for i in [dep[JsInfo] for dep in deps if JsInfo in dep]: + transitive_sources.append(i.transitive_sources) + transitive_types.append(i.transitive_types) + npm_sources.append(i.npm_sources) + npm_package_store_infos.append(i.npm_package_store_infos) + + return _js_info_provider( + target = label, + sources = sources, + transitive_sources = depset(transitive = transitive_sources), + transitive_types = depset(transitive = transitive_types), + npm_sources = depset(transitive = npm_sources), + npm_package_store_infos = depset(transitive = npm_package_store_infos), + ) + +def _runfiles(ctx, sources, deps): + """Return a ctx.runfiles object with aggregate runfiles from deps.""" + deps_info = [dep[DefaultInfo] for dep in deps] + runfiles = ctx.runfiles( + files = sources.to_list(), + transitive_files = depset(transitive = [i.files for i in deps_info]), + ) + return runfiles.merge_all([i.default_runfiles for i in deps_info]) + +def _gen_js_constants_impl(ctx): + """Generate a JavaScript module exporting specified constants.""" + items = {"ruleName": ctx.attr.name, "binDir": ctx.bin_dir.path} + items |= {k: ctx.expand_location(v) for k, v in ctx.attr.vars.items()} + items |= {v: k.label.repo_name for k, v in ctx.attr.repo_names.items()} + items |= {v: k.label.workspace_root for k, v in ctx.attr.repo_dirs.items()} + declaration = "module.exports.{} = \"{}\";" + constants = [declaration.format(k, v) for k, v in items.items()] + + outfile = ctx.actions.declare_file(ctx.attr.name + ".js") + ctx.actions.write(outfile, "\n".join(constants) + "\n") + + sources = depset([outfile]) + deps = ctx.attr.deps + \ + ctx.attr.repo_names.keys() + \ + ctx.attr.repo_dirs.keys() + + return [ + _js_info(ctx.label, sources, deps), + DefaultInfo(files = sources, runfiles = _runfiles(ctx, sources, deps)), + ] + +gen_js_constants = rule( + implementation = _gen_js_constants_impl, + doc = "Generate a JavaScript module exporting specified constants.", + attrs = { + "deps": attr.label_list( + doc = "target labels for predefined source/output path variables", + ), + "vars": attr.string_dict( + doc = "mapping from constants to values or source/output vars", + ), + "repo_names": attr.label_keyed_string_dict( + doc = "mapping from target label to generated repo name constant", + ), + "repo_dirs": attr.label_keyed_string_dict( + doc = "mapping from target label to generated repo dir constant", + ), + }, +) diff --git a/runfiles/engflow/MODULE.bazel.lock b/runfiles/engflow/MODULE.bazel.lock index 564b56fd..7a0c3003 100644 --- a/runfiles/engflow/MODULE.bazel.lock +++ b/runfiles/engflow/MODULE.bazel.lock @@ -46,8 +46,8 @@ "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", "https://bcr.bazel.build/modules/rules_java/7.1.0/MODULE.bazel": "30d9135a2b6561c761bd67bd4990da591e6bdc128790ce3e7afd6a3558b2fb64", - "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", - "https://bcr.bazel.build/modules/rules_java/7.6.1/source.json": "8f3f3076554e1558e8e468b2232991c510ecbcbed9e6f8c06ac31c93bcf38362", + "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", + "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", "https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909", "https://bcr.bazel.build/modules/rules_jvm_external/5.1/source.json": "5abb45cc9beb27b77aec6a65a11855ef2b55d95dfdc358e9f312b78ae0ba32d5", @@ -73,8 +73,8 @@ "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/source.json": "b2150404947339e8b947c6b16baa39fa75657f4ddec5e37272c7b11c7ab533bc", "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", - "https://bcr.bazel.build/modules/zlib/1.3/MODULE.bazel": "6a9c02f19a24dcedb05572b2381446e27c272cd383aed11d41d99da9e3167a72", - "https://bcr.bazel.build/modules/zlib/1.3/source.json": "b6b43d0737af846022636e6e255fd4a96fee0d34f08f3830e6e0bac51465c37c" + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d" }, "selectedYankedVersions": {}, "moduleExtensions": {