From 0e06ebf49407962722ff3c32428af2344adedd36 Mon Sep 17 00:00:00 2001 From: Alexander Khabarov Date: Tue, 14 Nov 2023 20:00:35 +0000 Subject: [PATCH 01/55] chore: add template files --- .bazelignore | 1 + .bazelrc | 14 + .bazelrc.ci | 36 ++ .bazelversion | 2 + .gitignore | 6 + .gitlab-ci.yml | 17 + MODULE.bazel | 7 + MODULE.bazel.lock | 624 ++++++++++++++++++++++++++++++++ README.md | 92 +---- WORKSPACE | 0 e2e/.bazelrc | 14 + e2e/.bazelrc.ci | 36 ++ e2e/.bazelversion | 2 + e2e/.gitignore | 6 + e2e/BUILD.bazel | 6 + e2e/MODULE.bazel | 12 + e2e/MODULE.bazel.lock | 639 +++++++++++++++++++++++++++++++++ e2e/WORKSPACE | 0 placeholder/BUILD.bazel | 6 + placeholder/defs.bzl | 5 + placeholder/fixture.txt | 1 + placeholder/test/BUILD.bazel | 1 + placeholder/test/posix.tmpl.sh | 11 + placeholder/test/rule.bzl | 41 +++ 24 files changed, 1493 insertions(+), 86 deletions(-) create mode 100644 .bazelignore create mode 100644 .bazelrc create mode 100644 .bazelrc.ci create mode 100644 .bazelversion create mode 100644 .gitignore create mode 100644 .gitlab-ci.yml create mode 100644 MODULE.bazel create mode 100644 MODULE.bazel.lock create mode 100644 WORKSPACE create mode 100644 e2e/.bazelrc create mode 100644 e2e/.bazelrc.ci create mode 100644 e2e/.bazelversion create mode 100644 e2e/.gitignore create mode 100644 e2e/BUILD.bazel create mode 100644 e2e/MODULE.bazel create mode 100644 e2e/MODULE.bazel.lock create mode 100644 e2e/WORKSPACE create mode 100644 placeholder/BUILD.bazel create mode 100644 placeholder/defs.bzl create mode 100644 placeholder/fixture.txt create mode 100644 placeholder/test/BUILD.bazel create mode 100644 placeholder/test/posix.tmpl.sh create mode 100644 placeholder/test/rule.bzl diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 0000000..c7ca8d0 --- /dev/null +++ b/.bazelignore @@ -0,0 +1 @@ +e2e diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..9931842 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,14 @@ +# Enable `bzlmod` +common --enable_bzlmod + +# Build cache +build --experimental_guard_against_concurrent_changes + +# Prevent `PATH` and `LD_LIBRARY_PATH` leaking into action enviroment +build --incompatible_strict_action_env + +# Prevent symlink forest under `.runfiles/wsname/external/repo` +build --nolegacy_external_runfiles + +# User-specific .bazelrc +try-import %workspace%/.bazelrc.user diff --git a/.bazelrc.ci b/.bazelrc.ci new file mode 100644 index 0000000..5af25a1 --- /dev/null +++ b/.bazelrc.ci @@ -0,0 +1,36 @@ +# Declare all run commands that are loaded +common --announce_rc + +# Use relative paths where possible for concise CI output +common --attempt_to_print_relative_paths + +# Prevent progress bars or similar +common --curses=no + +# CI "terminals" support colour +common --color=yes + +# Output timestamps for each command to aid debugging of CI runtime +common --show_timestamps + +# Do not wrap any output +common --terminal_columns=0 + +# Print relative paths where possible to reduce noise +common --attempt_to_print_relative_paths + +# Output as much information in the CI log about failures as possible +build --verbose_failures + +# Avoid building all targets when testing +test --build_tests_only + +# Noisy logs but allows debugging CI run failures +test --test_output=errors + +# Output as much information when a test exceeds a timeout +test --test_verbose_timeout_warnings + +# These locations are cached on the CI +build --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk +build --repository_cache=${CI_PROJECT_DIR}/.cache/bazel/repo diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000..6543a03 --- /dev/null +++ b/.bazelversion @@ -0,0 +1,2 @@ +last_rc +# TODO: relax this once we have `use_rule_repo` diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..78c9d9f --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/.cache +/bazel-bin +/bazel-testlogs +/bazel-rules_placeholder +/bazel-out +/.bazelrc.user diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..048eff7 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,17 @@ +include: + - component: "${CI_SERVER_HOST}/ci/component/bazelisk@016de670d2db1297c14478a61ef1efa3531619f5" + inputs: + tag: "016de670d2db1297c14478a61ef1efa3531619f5" + +default: + tags: + - arm64 + +test: + extends: .bazelisk + parallel: + matrix: + - ROOT: + - . + - e2e + diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..c56a26e --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,7 @@ +module( + name = "rules_placeholder", + version = "0.0.0", + bazel_compatibility = [ + ">=6.4.0", + ], +) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock new file mode 100644 index 0000000..dc46c5d --- /dev/null +++ b/MODULE.bazel.lock @@ -0,0 +1,624 @@ +{ + "lockFileVersion": 3, + "moduleFileHash": "bfe34180a91f3ff908710075c27bf5597532ff414e99589309e1cb2b4ab201e7", + "flags": { + "cmdRegistries": [ + "https://bcr.bazel.build/" + ], + "cmdModuleOverrides": {}, + "allowedYankedVersions": [], + "envVarAllowedYankedVersions": "", + "ignoreDevDependency": false, + "directDependenciesMode": "WARNING", + "compatibilityMode": "ERROR" + }, + "localOverrideHashes": { + "bazel_tools": "922ea6752dc9105de5af957f7a99a6933c0a6a712d23df6aad16a9c399f7e787" + }, + "moduleDepGraph": { + "": { + "name": "rules_placeholder", + "version": "0.0.0", + "key": "", + "repoName": "rules_placeholder", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + } + }, + "bazel_tools@_": { + "name": "bazel_tools", + "version": "", + "key": "bazel_tools@_", + "repoName": "bazel_tools", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "@local_config_cc_toolchains//:all", + "@local_config_sh//:local_sh_toolchain" + ], + "extensionUsages": [ + { + "extensionBzlFile": "@bazel_tools//tools/cpp:cc_configure.bzl", + "extensionName": "cc_configure_extension", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 17, + "column": 29 + }, + "imports": { + "local_config_cc": "local_config_cc", + "local_config_cc_toolchains": "local_config_cc_toolchains" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + }, + { + "extensionBzlFile": "@bazel_tools//tools/osx:xcode_configure.bzl", + "extensionName": "xcode_configure_extension", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 21, + "column": 32 + }, + "imports": { + "local_config_xcode": "local_config_xcode" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + }, + { + "extensionBzlFile": "@rules_java//java:extensions.bzl", + "extensionName": "toolchains", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 24, + "column": 32 + }, + "imports": { + "local_jdk": "local_jdk", + "remote_java_tools": "remote_java_tools", + "remote_java_tools_linux": "remote_java_tools_linux", + "remote_java_tools_windows": "remote_java_tools_windows", + "remote_java_tools_darwin_x86_64": "remote_java_tools_darwin_x86_64", + "remote_java_tools_darwin_arm64": "remote_java_tools_darwin_arm64" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + }, + { + "extensionBzlFile": "@bazel_tools//tools/sh:sh_configure.bzl", + "extensionName": "sh_configure_extension", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 35, + "column": 39 + }, + "imports": { + "local_config_sh": "local_config_sh" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + }, + { + "extensionBzlFile": "@bazel_tools//tools/test:extensions.bzl", + "extensionName": "remote_coverage_tools_extension", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 39, + "column": 48 + }, + "imports": { + "remote_coverage_tools": "remote_coverage_tools" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + }, + { + "extensionBzlFile": "@bazel_tools//tools/android:android_extensions.bzl", + "extensionName": "remote_android_tools_extensions", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 42, + "column": 42 + }, + "imports": { + "android_gmaven_r8": "android_gmaven_r8", + "android_tools": "android_tools" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], + "deps": { + "rules_cc": "rules_cc@0.0.9", + "rules_java": "rules_java@7.1.0", + "rules_license": "rules_license@0.0.7", + "rules_proto": "rules_proto@4.0.0", + "rules_python": "rules_python@0.4.0", + "platforms": "platforms@0.0.7", + "com_google_protobuf": "protobuf@3.19.6", + "zlib": "zlib@1.3", + "build_bazel_apple_support": "apple_support@1.5.0", + "local_config_platform": "local_config_platform@_" + } + }, + "local_config_platform@_": { + "name": "local_config_platform", + "version": "", + "key": "local_config_platform@_", + "repoName": "local_config_platform", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "platforms": "platforms@0.0.7", + "bazel_tools": "bazel_tools@_" + } + }, + "rules_cc@0.0.9": { + "name": "rules_cc", + "version": "0.0.9", + "key": "rules_cc@0.0.9", + "repoName": "rules_cc", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "@local_config_cc_toolchains//:all" + ], + "extensionUsages": [ + { + "extensionBzlFile": "@bazel_tools//tools/cpp:cc_configure.bzl", + "extensionName": "cc_configure_extension", + "usingModule": "rules_cc@0.0.9", + "location": { + "file": "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel", + "line": 9, + "column": 29 + }, + "imports": { + "local_config_cc_toolchains": "local_config_cc_toolchains" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], + "deps": { + "platforms": "platforms@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_cc~0.0.9", + "urls": [ + "https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz" + ], + "integrity": "sha256-IDeHW5pEVtzkp50RKorohbvEqtlo5lh9ym5k86CQDN8=", + "strip_prefix": "rules_cc-0.0.9", + "remote_patches": { + "https://bcr.bazel.build/modules/rules_cc/0.0.9/patches/module_dot_bazel_version.patch": "sha256-mM+qzOI0SgAdaJBlWOSMwMPKpaA9b7R37Hj/tp5bb4g=" + }, + "remote_patch_strip": 0 + } + } + }, + "rules_java@7.1.0": { + "name": "rules_java", + "version": "7.1.0", + "key": "rules_java@7.1.0", + "repoName": "rules_java", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "//toolchains:all", + "@local_jdk//:runtime_toolchain_definition", + "@local_jdk//:bootstrap_runtime_toolchain_definition", + "@remotejdk11_linux_toolchain_config_repo//:all", + "@remotejdk11_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk11_linux_ppc64le_toolchain_config_repo//:all", + "@remotejdk11_linux_s390x_toolchain_config_repo//:all", + "@remotejdk11_macos_toolchain_config_repo//:all", + "@remotejdk11_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk11_win_toolchain_config_repo//:all", + "@remotejdk11_win_arm64_toolchain_config_repo//:all", + "@remotejdk17_linux_toolchain_config_repo//:all", + "@remotejdk17_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk17_linux_ppc64le_toolchain_config_repo//:all", + "@remotejdk17_linux_s390x_toolchain_config_repo//:all", + "@remotejdk17_macos_toolchain_config_repo//:all", + "@remotejdk17_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk17_win_toolchain_config_repo//:all", + "@remotejdk17_win_arm64_toolchain_config_repo//:all", + "@remotejdk21_linux_toolchain_config_repo//:all", + "@remotejdk21_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk21_macos_toolchain_config_repo//:all", + "@remotejdk21_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk21_win_toolchain_config_repo//:all" + ], + "extensionUsages": [ + { + "extensionBzlFile": "@rules_java//java:extensions.bzl", + "extensionName": "toolchains", + "usingModule": "rules_java@7.1.0", + "location": { + "file": "https://bcr.bazel.build/modules/rules_java/7.1.0/MODULE.bazel", + "line": 19, + "column": 27 + }, + "imports": { + "remote_java_tools": "remote_java_tools", + "remote_java_tools_linux": "remote_java_tools_linux", + "remote_java_tools_windows": "remote_java_tools_windows", + "remote_java_tools_darwin_x86_64": "remote_java_tools_darwin_x86_64", + "remote_java_tools_darwin_arm64": "remote_java_tools_darwin_arm64", + "local_jdk": "local_jdk", + "remotejdk11_linux_toolchain_config_repo": "remotejdk11_linux_toolchain_config_repo", + "remotejdk11_linux_aarch64_toolchain_config_repo": "remotejdk11_linux_aarch64_toolchain_config_repo", + "remotejdk11_linux_ppc64le_toolchain_config_repo": "remotejdk11_linux_ppc64le_toolchain_config_repo", + "remotejdk11_linux_s390x_toolchain_config_repo": "remotejdk11_linux_s390x_toolchain_config_repo", + "remotejdk11_macos_toolchain_config_repo": "remotejdk11_macos_toolchain_config_repo", + "remotejdk11_macos_aarch64_toolchain_config_repo": "remotejdk11_macos_aarch64_toolchain_config_repo", + "remotejdk11_win_toolchain_config_repo": "remotejdk11_win_toolchain_config_repo", + "remotejdk11_win_arm64_toolchain_config_repo": "remotejdk11_win_arm64_toolchain_config_repo", + "remotejdk17_linux_toolchain_config_repo": "remotejdk17_linux_toolchain_config_repo", + "remotejdk17_linux_aarch64_toolchain_config_repo": "remotejdk17_linux_aarch64_toolchain_config_repo", + "remotejdk17_linux_ppc64le_toolchain_config_repo": "remotejdk17_linux_ppc64le_toolchain_config_repo", + "remotejdk17_linux_s390x_toolchain_config_repo": "remotejdk17_linux_s390x_toolchain_config_repo", + "remotejdk17_macos_toolchain_config_repo": "remotejdk17_macos_toolchain_config_repo", + "remotejdk17_macos_aarch64_toolchain_config_repo": "remotejdk17_macos_aarch64_toolchain_config_repo", + "remotejdk17_win_toolchain_config_repo": "remotejdk17_win_toolchain_config_repo", + "remotejdk17_win_arm64_toolchain_config_repo": "remotejdk17_win_arm64_toolchain_config_repo", + "remotejdk21_linux_toolchain_config_repo": "remotejdk21_linux_toolchain_config_repo", + "remotejdk21_linux_aarch64_toolchain_config_repo": "remotejdk21_linux_aarch64_toolchain_config_repo", + "remotejdk21_macos_toolchain_config_repo": "remotejdk21_macos_toolchain_config_repo", + "remotejdk21_macos_aarch64_toolchain_config_repo": "remotejdk21_macos_aarch64_toolchain_config_repo", + "remotejdk21_win_toolchain_config_repo": "remotejdk21_win_toolchain_config_repo" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], + "deps": { + "platforms": "platforms@0.0.7", + "rules_cc": "rules_cc@0.0.9", + "bazel_skylib": "bazel_skylib@1.3.0", + "rules_proto": "rules_proto@4.0.0", + "rules_license": "rules_license@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0", + "urls": [ + "https://github.com/bazelbuild/rules_java/releases/download/7.1.0/rules_java-7.1.0.tar.gz" + ], + "integrity": "sha256-o3pOX2OrgnFuXdau75iO2EYcegC46TYnImKJn1h81OE=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, + "rules_license@0.0.7": { + "name": "rules_license", + "version": "0.0.7", + "key": "rules_license@0.0.7", + "repoName": "rules_license", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_license~0.0.7", + "urls": [ + "https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz" + ], + "integrity": "sha256-RTHezLkTY5ww5cdRKgVNXYdWmNrrddjPkPKEN1/nw2A=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, + "rules_proto@4.0.0": { + "name": "rules_proto", + "version": "4.0.0", + "key": "rules_proto@4.0.0", + "repoName": "rules_proto", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "bazel_skylib": "bazel_skylib@1.3.0", + "rules_cc": "rules_cc@0.0.9", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_proto~4.0.0", + "urls": [ + "https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.zip" + ], + "integrity": "sha256-Lr5z6xyuRA19pNtRYMGjKaynwQpck4H/lwYyVjyhoq4=", + "strip_prefix": "rules_proto-4.0.0", + "remote_patches": { + "https://bcr.bazel.build/modules/rules_proto/4.0.0/patches/module_dot_bazel.patch": "sha256-MclJO7tIAM2ElDAmscNId9pKTpOuDGHgVlW/9VBOIp0=" + }, + "remote_patch_strip": 0 + } + } + }, + "rules_python@0.4.0": { + "name": "rules_python", + "version": "0.4.0", + "key": "rules_python@0.4.0", + "repoName": "rules_python", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "@bazel_tools//tools/python:autodetecting_toolchain" + ], + "extensionUsages": [ + { + "extensionBzlFile": "@rules_python//bzlmod:extensions.bzl", + "extensionName": "pip_install", + "usingModule": "rules_python@0.4.0", + "location": { + "file": "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel", + "line": 7, + "column": 28 + }, + "imports": { + "pypi__click": "pypi__click", + "pypi__pip": "pypi__pip", + "pypi__pip_tools": "pypi__pip_tools", + "pypi__pkginfo": "pypi__pkginfo", + "pypi__setuptools": "pypi__setuptools", + "pypi__wheel": "pypi__wheel" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], + "deps": { + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_python~0.4.0", + "urls": [ + "https://github.com/bazelbuild/rules_python/releases/download/0.4.0/rules_python-0.4.0.tar.gz" + ], + "integrity": "sha256-lUqom0kb5KCDMEosuDgBnIuMNyCnq7nEy4GseiQjDOo=", + "strip_prefix": "", + "remote_patches": { + "https://bcr.bazel.build/modules/rules_python/0.4.0/patches/propagate_pip_install_dependencies.patch": "sha256-v7S/dem/mixg63MF4KoRGDA4KEol9ab/tIVp+6Xq0D0=", + "https://bcr.bazel.build/modules/rules_python/0.4.0/patches/module_dot_bazel.patch": "sha256-kG4VIfWxQazzTuh50mvsx6pmyoRVA4lfH5rkto/Oq+Y=" + }, + "remote_patch_strip": 1 + } + } + }, + "platforms@0.0.7": { + "name": "platforms", + "version": "0.0.7", + "key": "platforms@0.0.7", + "repoName": "platforms", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "rules_license": "rules_license@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "platforms", + "urls": [ + "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz" + ], + "integrity": "sha256-OlYcmee9vpFzqmU/1Xn+hJ8djWc5V4CrR3Cx84FDHVE=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, + "protobuf@3.19.6": { + "name": "protobuf", + "version": "3.19.6", + "key": "protobuf@3.19.6", + "repoName": "protobuf", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "bazel_skylib": "bazel_skylib@1.3.0", + "zlib": "zlib@1.3", + "rules_python": "rules_python@0.4.0", + "rules_cc": "rules_cc@0.0.9", + "rules_proto": "rules_proto@4.0.0", + "rules_java": "rules_java@7.1.0", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "protobuf~3.19.6", + "urls": [ + "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.19.6.zip" + ], + "integrity": "sha256-OH4sVZuyx8G8N5jE5s/wFTgaebJ1hpavy/johzC0c4k=", + "strip_prefix": "protobuf-3.19.6", + "remote_patches": { + "https://bcr.bazel.build/modules/protobuf/3.19.6/patches/relative_repo_names.patch": "sha256-w/5gw/zGv8NFId+669hcdw1Uus2lxgYpulATHIwIByI=", + "https://bcr.bazel.build/modules/protobuf/3.19.6/patches/remove_dependency_on_rules_jvm_external.patch": "sha256-THUTnVgEBmjA0W7fKzIyZOVG58DnW9HQTkr4D2zKUUc=", + "https://bcr.bazel.build/modules/protobuf/3.19.6/patches/add_module_dot_bazel_for_examples.patch": "sha256-s/b1gi3baK3LsXefI2rQilhmkb2R5jVJdnT6zEcdfHY=", + "https://bcr.bazel.build/modules/protobuf/3.19.6/patches/module_dot_bazel.patch": "sha256-S0DEni8zgx7rHscW3z/rCEubQnYec0XhNet640cw0h4=" + }, + "remote_patch_strip": 1 + } + } + }, + "zlib@1.3": { + "name": "zlib", + "version": "1.3", + "key": "zlib@1.3", + "repoName": "zlib", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "platforms": "platforms@0.0.7", + "rules_cc": "rules_cc@0.0.9", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "zlib~1.3", + "urls": [ + "https://github.com/madler/zlib/releases/download/v1.3/zlib-1.3.tar.gz" + ], + "integrity": "sha256-/wukwpIBPbwnUws6geH5qBPNOd4Byl4Pi/NVcC76WT4=", + "strip_prefix": "zlib-1.3", + "remote_patches": { + "https://bcr.bazel.build/modules/zlib/1.3/patches/add_build_file.patch": "sha256-Ei+FYaaOo7A3jTKunMEodTI0Uw5NXQyZEcboMC8JskY=", + "https://bcr.bazel.build/modules/zlib/1.3/patches/module_dot_bazel.patch": "sha256-fPWLM+2xaF/kuy+kZc1YTfW6hNjrkG400Ho7gckuyJk=" + }, + "remote_patch_strip": 0 + } + } + }, + "apple_support@1.5.0": { + "name": "apple_support", + "version": "1.5.0", + "key": "apple_support@1.5.0", + "repoName": "build_bazel_apple_support", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "@local_config_apple_cc_toolchains//:all" + ], + "extensionUsages": [ + { + "extensionBzlFile": "@build_bazel_apple_support//crosstool:setup.bzl", + "extensionName": "apple_cc_configure_extension", + "usingModule": "apple_support@1.5.0", + "location": { + "file": "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel", + "line": 17, + "column": 35 + }, + "imports": { + "local_config_apple_cc": "local_config_apple_cc", + "local_config_apple_cc_toolchains": "local_config_apple_cc_toolchains" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], + "deps": { + "bazel_skylib": "bazel_skylib@1.3.0", + "platforms": "platforms@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "apple_support~1.5.0", + "urls": [ + "https://github.com/bazelbuild/apple_support/releases/download/1.5.0/apple_support.1.5.0.tar.gz" + ], + "integrity": "sha256-miM41vja0yRPgj8txghKA+TQ+7J8qJLclw5okNW0gYQ=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, + "bazel_skylib@1.3.0": { + "name": "bazel_skylib", + "version": "1.3.0", + "key": "bazel_skylib@1.3.0", + "repoName": "bazel_skylib", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "//toolchains/unittest:cmd_toolchain", + "//toolchains/unittest:bash_toolchain" + ], + "extensionUsages": [], + "deps": { + "platforms": "platforms@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "bazel_skylib~1.3.0", + "urls": [ + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz" + ], + "integrity": "sha256-dNVE2W9KW7Yw1GXKi7z+Ix41lOWq5X4e2/F6brPKJQY=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + } + }, + "moduleExtensions": {} +} diff --git a/README.md b/README.md index 663c614..d1e8127 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,12 @@ -# semantic-release Plugin +# `rules_placeholder` +> A Bazel ruleset for placeholder. +## Getting Started -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: +Add the following to `MODULE.bazel`: +```py +bazel_dep(name="rules_placeholder", version="0.0.0") ``` -cd existing_repo -git remote add origin https://git.gitlab.arm.com/semantic-release/template/plugin.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.arm.com/semantic-release/template/plugin/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..e69de29 diff --git a/e2e/.bazelrc b/e2e/.bazelrc new file mode 100644 index 0000000..9931842 --- /dev/null +++ b/e2e/.bazelrc @@ -0,0 +1,14 @@ +# Enable `bzlmod` +common --enable_bzlmod + +# Build cache +build --experimental_guard_against_concurrent_changes + +# Prevent `PATH` and `LD_LIBRARY_PATH` leaking into action enviroment +build --incompatible_strict_action_env + +# Prevent symlink forest under `.runfiles/wsname/external/repo` +build --nolegacy_external_runfiles + +# User-specific .bazelrc +try-import %workspace%/.bazelrc.user diff --git a/e2e/.bazelrc.ci b/e2e/.bazelrc.ci new file mode 100644 index 0000000..5af25a1 --- /dev/null +++ b/e2e/.bazelrc.ci @@ -0,0 +1,36 @@ +# Declare all run commands that are loaded +common --announce_rc + +# Use relative paths where possible for concise CI output +common --attempt_to_print_relative_paths + +# Prevent progress bars or similar +common --curses=no + +# CI "terminals" support colour +common --color=yes + +# Output timestamps for each command to aid debugging of CI runtime +common --show_timestamps + +# Do not wrap any output +common --terminal_columns=0 + +# Print relative paths where possible to reduce noise +common --attempt_to_print_relative_paths + +# Output as much information in the CI log about failures as possible +build --verbose_failures + +# Avoid building all targets when testing +test --build_tests_only + +# Noisy logs but allows debugging CI run failures +test --test_output=errors + +# Output as much information when a test exceeds a timeout +test --test_verbose_timeout_warnings + +# These locations are cached on the CI +build --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk +build --repository_cache=${CI_PROJECT_DIR}/.cache/bazel/repo diff --git a/e2e/.bazelversion b/e2e/.bazelversion new file mode 100644 index 0000000..6543a03 --- /dev/null +++ b/e2e/.bazelversion @@ -0,0 +1,2 @@ +last_rc +# TODO: relax this once we have `use_rule_repo` diff --git a/e2e/.gitignore b/e2e/.gitignore new file mode 100644 index 0000000..5ebc57e --- /dev/null +++ b/e2e/.gitignore @@ -0,0 +1,6 @@ +/.cache +/bazel-bin +/bazel-testlogs +/bazel-e2e +/bazel-out +/.bazelrc.user diff --git a/e2e/BUILD.bazel b/e2e/BUILD.bazel new file mode 100644 index 0000000..d1bc255 --- /dev/null +++ b/e2e/BUILD.bazel @@ -0,0 +1,6 @@ +load("@rules_placeholder//placeholder:defs.bzl", "placeholder_test") + +placeholder_test( + name = "test", + size = "small", +) diff --git a/e2e/MODULE.bazel b/e2e/MODULE.bazel new file mode 100644 index 0000000..f090525 --- /dev/null +++ b/e2e/MODULE.bazel @@ -0,0 +1,12 @@ +module( + name = "e2e", + bazel_compatibility = [ + ">=6.4.0", + ], +) + +bazel_dep(name = "rules_placeholder", version = "0.0.0") +local_path_override( + module_name = "rules_placeholder", + path = "..", +) diff --git a/e2e/MODULE.bazel.lock b/e2e/MODULE.bazel.lock new file mode 100644 index 0000000..51c002d --- /dev/null +++ b/e2e/MODULE.bazel.lock @@ -0,0 +1,639 @@ +{ + "lockFileVersion": 3, + "moduleFileHash": "0ae7ae7e1528f93aef4bfb44931525ab435a24fd4f480fc0b28f19c1c9a7f66f", + "flags": { + "cmdRegistries": [ + "https://bcr.bazel.build/" + ], + "cmdModuleOverrides": {}, + "allowedYankedVersions": [], + "envVarAllowedYankedVersions": "", + "ignoreDevDependency": false, + "directDependenciesMode": "WARNING", + "compatibilityMode": "ERROR" + }, + "localOverrideHashes": { + "bazel_tools": "922ea6752dc9105de5af957f7a99a6933c0a6a712d23df6aad16a9c399f7e787", + "rules_placeholder": "bfe34180a91f3ff908710075c27bf5597532ff414e99589309e1cb2b4ab201e7" + }, + "moduleDepGraph": { + "": { + "name": "e2e", + "version": "", + "key": "", + "repoName": "e2e", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "rules_placeholder": "rules_placeholder@_", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + } + }, + "rules_placeholder@_": { + "name": "rules_placeholder", + "version": "0.0.0", + "key": "rules_placeholder@_", + "repoName": "rules_placeholder", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + } + }, + "bazel_tools@_": { + "name": "bazel_tools", + "version": "", + "key": "bazel_tools@_", + "repoName": "bazel_tools", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "@local_config_cc_toolchains//:all", + "@local_config_sh//:local_sh_toolchain" + ], + "extensionUsages": [ + { + "extensionBzlFile": "@bazel_tools//tools/cpp:cc_configure.bzl", + "extensionName": "cc_configure_extension", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 17, + "column": 29 + }, + "imports": { + "local_config_cc": "local_config_cc", + "local_config_cc_toolchains": "local_config_cc_toolchains" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + }, + { + "extensionBzlFile": "@bazel_tools//tools/osx:xcode_configure.bzl", + "extensionName": "xcode_configure_extension", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 21, + "column": 32 + }, + "imports": { + "local_config_xcode": "local_config_xcode" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + }, + { + "extensionBzlFile": "@rules_java//java:extensions.bzl", + "extensionName": "toolchains", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 24, + "column": 32 + }, + "imports": { + "local_jdk": "local_jdk", + "remote_java_tools": "remote_java_tools", + "remote_java_tools_linux": "remote_java_tools_linux", + "remote_java_tools_windows": "remote_java_tools_windows", + "remote_java_tools_darwin_x86_64": "remote_java_tools_darwin_x86_64", + "remote_java_tools_darwin_arm64": "remote_java_tools_darwin_arm64" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + }, + { + "extensionBzlFile": "@bazel_tools//tools/sh:sh_configure.bzl", + "extensionName": "sh_configure_extension", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 35, + "column": 39 + }, + "imports": { + "local_config_sh": "local_config_sh" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + }, + { + "extensionBzlFile": "@bazel_tools//tools/test:extensions.bzl", + "extensionName": "remote_coverage_tools_extension", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 39, + "column": 48 + }, + "imports": { + "remote_coverage_tools": "remote_coverage_tools" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + }, + { + "extensionBzlFile": "@bazel_tools//tools/android:android_extensions.bzl", + "extensionName": "remote_android_tools_extensions", + "usingModule": "bazel_tools@_", + "location": { + "file": "@@bazel_tools//:MODULE.bazel", + "line": 42, + "column": 42 + }, + "imports": { + "android_gmaven_r8": "android_gmaven_r8", + "android_tools": "android_tools" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], + "deps": { + "rules_cc": "rules_cc@0.0.9", + "rules_java": "rules_java@7.1.0", + "rules_license": "rules_license@0.0.7", + "rules_proto": "rules_proto@4.0.0", + "rules_python": "rules_python@0.4.0", + "platforms": "platforms@0.0.7", + "com_google_protobuf": "protobuf@3.19.6", + "zlib": "zlib@1.3", + "build_bazel_apple_support": "apple_support@1.5.0", + "local_config_platform": "local_config_platform@_" + } + }, + "local_config_platform@_": { + "name": "local_config_platform", + "version": "", + "key": "local_config_platform@_", + "repoName": "local_config_platform", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "platforms": "platforms@0.0.7", + "bazel_tools": "bazel_tools@_" + } + }, + "rules_cc@0.0.9": { + "name": "rules_cc", + "version": "0.0.9", + "key": "rules_cc@0.0.9", + "repoName": "rules_cc", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "@local_config_cc_toolchains//:all" + ], + "extensionUsages": [ + { + "extensionBzlFile": "@bazel_tools//tools/cpp:cc_configure.bzl", + "extensionName": "cc_configure_extension", + "usingModule": "rules_cc@0.0.9", + "location": { + "file": "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel", + "line": 9, + "column": 29 + }, + "imports": { + "local_config_cc_toolchains": "local_config_cc_toolchains" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], + "deps": { + "platforms": "platforms@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_cc~0.0.9", + "urls": [ + "https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz" + ], + "integrity": "sha256-IDeHW5pEVtzkp50RKorohbvEqtlo5lh9ym5k86CQDN8=", + "strip_prefix": "rules_cc-0.0.9", + "remote_patches": { + "https://bcr.bazel.build/modules/rules_cc/0.0.9/patches/module_dot_bazel_version.patch": "sha256-mM+qzOI0SgAdaJBlWOSMwMPKpaA9b7R37Hj/tp5bb4g=" + }, + "remote_patch_strip": 0 + } + } + }, + "rules_java@7.1.0": { + "name": "rules_java", + "version": "7.1.0", + "key": "rules_java@7.1.0", + "repoName": "rules_java", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "//toolchains:all", + "@local_jdk//:runtime_toolchain_definition", + "@local_jdk//:bootstrap_runtime_toolchain_definition", + "@remotejdk11_linux_toolchain_config_repo//:all", + "@remotejdk11_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk11_linux_ppc64le_toolchain_config_repo//:all", + "@remotejdk11_linux_s390x_toolchain_config_repo//:all", + "@remotejdk11_macos_toolchain_config_repo//:all", + "@remotejdk11_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk11_win_toolchain_config_repo//:all", + "@remotejdk11_win_arm64_toolchain_config_repo//:all", + "@remotejdk17_linux_toolchain_config_repo//:all", + "@remotejdk17_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk17_linux_ppc64le_toolchain_config_repo//:all", + "@remotejdk17_linux_s390x_toolchain_config_repo//:all", + "@remotejdk17_macos_toolchain_config_repo//:all", + "@remotejdk17_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk17_win_toolchain_config_repo//:all", + "@remotejdk17_win_arm64_toolchain_config_repo//:all", + "@remotejdk21_linux_toolchain_config_repo//:all", + "@remotejdk21_linux_aarch64_toolchain_config_repo//:all", + "@remotejdk21_macos_toolchain_config_repo//:all", + "@remotejdk21_macos_aarch64_toolchain_config_repo//:all", + "@remotejdk21_win_toolchain_config_repo//:all" + ], + "extensionUsages": [ + { + "extensionBzlFile": "@rules_java//java:extensions.bzl", + "extensionName": "toolchains", + "usingModule": "rules_java@7.1.0", + "location": { + "file": "https://bcr.bazel.build/modules/rules_java/7.1.0/MODULE.bazel", + "line": 19, + "column": 27 + }, + "imports": { + "remote_java_tools": "remote_java_tools", + "remote_java_tools_linux": "remote_java_tools_linux", + "remote_java_tools_windows": "remote_java_tools_windows", + "remote_java_tools_darwin_x86_64": "remote_java_tools_darwin_x86_64", + "remote_java_tools_darwin_arm64": "remote_java_tools_darwin_arm64", + "local_jdk": "local_jdk", + "remotejdk11_linux_toolchain_config_repo": "remotejdk11_linux_toolchain_config_repo", + "remotejdk11_linux_aarch64_toolchain_config_repo": "remotejdk11_linux_aarch64_toolchain_config_repo", + "remotejdk11_linux_ppc64le_toolchain_config_repo": "remotejdk11_linux_ppc64le_toolchain_config_repo", + "remotejdk11_linux_s390x_toolchain_config_repo": "remotejdk11_linux_s390x_toolchain_config_repo", + "remotejdk11_macos_toolchain_config_repo": "remotejdk11_macos_toolchain_config_repo", + "remotejdk11_macos_aarch64_toolchain_config_repo": "remotejdk11_macos_aarch64_toolchain_config_repo", + "remotejdk11_win_toolchain_config_repo": "remotejdk11_win_toolchain_config_repo", + "remotejdk11_win_arm64_toolchain_config_repo": "remotejdk11_win_arm64_toolchain_config_repo", + "remotejdk17_linux_toolchain_config_repo": "remotejdk17_linux_toolchain_config_repo", + "remotejdk17_linux_aarch64_toolchain_config_repo": "remotejdk17_linux_aarch64_toolchain_config_repo", + "remotejdk17_linux_ppc64le_toolchain_config_repo": "remotejdk17_linux_ppc64le_toolchain_config_repo", + "remotejdk17_linux_s390x_toolchain_config_repo": "remotejdk17_linux_s390x_toolchain_config_repo", + "remotejdk17_macos_toolchain_config_repo": "remotejdk17_macos_toolchain_config_repo", + "remotejdk17_macos_aarch64_toolchain_config_repo": "remotejdk17_macos_aarch64_toolchain_config_repo", + "remotejdk17_win_toolchain_config_repo": "remotejdk17_win_toolchain_config_repo", + "remotejdk17_win_arm64_toolchain_config_repo": "remotejdk17_win_arm64_toolchain_config_repo", + "remotejdk21_linux_toolchain_config_repo": "remotejdk21_linux_toolchain_config_repo", + "remotejdk21_linux_aarch64_toolchain_config_repo": "remotejdk21_linux_aarch64_toolchain_config_repo", + "remotejdk21_macos_toolchain_config_repo": "remotejdk21_macos_toolchain_config_repo", + "remotejdk21_macos_aarch64_toolchain_config_repo": "remotejdk21_macos_aarch64_toolchain_config_repo", + "remotejdk21_win_toolchain_config_repo": "remotejdk21_win_toolchain_config_repo" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], + "deps": { + "platforms": "platforms@0.0.7", + "rules_cc": "rules_cc@0.0.9", + "bazel_skylib": "bazel_skylib@1.3.0", + "rules_proto": "rules_proto@4.0.0", + "rules_license": "rules_license@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0", + "urls": [ + "https://github.com/bazelbuild/rules_java/releases/download/7.1.0/rules_java-7.1.0.tar.gz" + ], + "integrity": "sha256-o3pOX2OrgnFuXdau75iO2EYcegC46TYnImKJn1h81OE=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, + "rules_license@0.0.7": { + "name": "rules_license", + "version": "0.0.7", + "key": "rules_license@0.0.7", + "repoName": "rules_license", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_license~0.0.7", + "urls": [ + "https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz" + ], + "integrity": "sha256-RTHezLkTY5ww5cdRKgVNXYdWmNrrddjPkPKEN1/nw2A=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, + "rules_proto@4.0.0": { + "name": "rules_proto", + "version": "4.0.0", + "key": "rules_proto@4.0.0", + "repoName": "rules_proto", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "bazel_skylib": "bazel_skylib@1.3.0", + "rules_cc": "rules_cc@0.0.9", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_proto~4.0.0", + "urls": [ + "https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.zip" + ], + "integrity": "sha256-Lr5z6xyuRA19pNtRYMGjKaynwQpck4H/lwYyVjyhoq4=", + "strip_prefix": "rules_proto-4.0.0", + "remote_patches": { + "https://bcr.bazel.build/modules/rules_proto/4.0.0/patches/module_dot_bazel.patch": "sha256-MclJO7tIAM2ElDAmscNId9pKTpOuDGHgVlW/9VBOIp0=" + }, + "remote_patch_strip": 0 + } + } + }, + "rules_python@0.4.0": { + "name": "rules_python", + "version": "0.4.0", + "key": "rules_python@0.4.0", + "repoName": "rules_python", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "@bazel_tools//tools/python:autodetecting_toolchain" + ], + "extensionUsages": [ + { + "extensionBzlFile": "@rules_python//bzlmod:extensions.bzl", + "extensionName": "pip_install", + "usingModule": "rules_python@0.4.0", + "location": { + "file": "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel", + "line": 7, + "column": 28 + }, + "imports": { + "pypi__click": "pypi__click", + "pypi__pip": "pypi__pip", + "pypi__pip_tools": "pypi__pip_tools", + "pypi__pkginfo": "pypi__pkginfo", + "pypi__setuptools": "pypi__setuptools", + "pypi__wheel": "pypi__wheel" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], + "deps": { + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_python~0.4.0", + "urls": [ + "https://github.com/bazelbuild/rules_python/releases/download/0.4.0/rules_python-0.4.0.tar.gz" + ], + "integrity": "sha256-lUqom0kb5KCDMEosuDgBnIuMNyCnq7nEy4GseiQjDOo=", + "strip_prefix": "", + "remote_patches": { + "https://bcr.bazel.build/modules/rules_python/0.4.0/patches/propagate_pip_install_dependencies.patch": "sha256-v7S/dem/mixg63MF4KoRGDA4KEol9ab/tIVp+6Xq0D0=", + "https://bcr.bazel.build/modules/rules_python/0.4.0/patches/module_dot_bazel.patch": "sha256-kG4VIfWxQazzTuh50mvsx6pmyoRVA4lfH5rkto/Oq+Y=" + }, + "remote_patch_strip": 1 + } + } + }, + "platforms@0.0.7": { + "name": "platforms", + "version": "0.0.7", + "key": "platforms@0.0.7", + "repoName": "platforms", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "rules_license": "rules_license@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "platforms", + "urls": [ + "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz" + ], + "integrity": "sha256-OlYcmee9vpFzqmU/1Xn+hJ8djWc5V4CrR3Cx84FDHVE=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, + "protobuf@3.19.6": { + "name": "protobuf", + "version": "3.19.6", + "key": "protobuf@3.19.6", + "repoName": "protobuf", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "bazel_skylib": "bazel_skylib@1.3.0", + "zlib": "zlib@1.3", + "rules_python": "rules_python@0.4.0", + "rules_cc": "rules_cc@0.0.9", + "rules_proto": "rules_proto@4.0.0", + "rules_java": "rules_java@7.1.0", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "protobuf~3.19.6", + "urls": [ + "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.19.6.zip" + ], + "integrity": "sha256-OH4sVZuyx8G8N5jE5s/wFTgaebJ1hpavy/johzC0c4k=", + "strip_prefix": "protobuf-3.19.6", + "remote_patches": { + "https://bcr.bazel.build/modules/protobuf/3.19.6/patches/relative_repo_names.patch": "sha256-w/5gw/zGv8NFId+669hcdw1Uus2lxgYpulATHIwIByI=", + "https://bcr.bazel.build/modules/protobuf/3.19.6/patches/remove_dependency_on_rules_jvm_external.patch": "sha256-THUTnVgEBmjA0W7fKzIyZOVG58DnW9HQTkr4D2zKUUc=", + "https://bcr.bazel.build/modules/protobuf/3.19.6/patches/add_module_dot_bazel_for_examples.patch": "sha256-s/b1gi3baK3LsXefI2rQilhmkb2R5jVJdnT6zEcdfHY=", + "https://bcr.bazel.build/modules/protobuf/3.19.6/patches/module_dot_bazel.patch": "sha256-S0DEni8zgx7rHscW3z/rCEubQnYec0XhNet640cw0h4=" + }, + "remote_patch_strip": 1 + } + } + }, + "zlib@1.3": { + "name": "zlib", + "version": "1.3", + "key": "zlib@1.3", + "repoName": "zlib", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "platforms": "platforms@0.0.7", + "rules_cc": "rules_cc@0.0.9", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "zlib~1.3", + "urls": [ + "https://github.com/madler/zlib/releases/download/v1.3/zlib-1.3.tar.gz" + ], + "integrity": "sha256-/wukwpIBPbwnUws6geH5qBPNOd4Byl4Pi/NVcC76WT4=", + "strip_prefix": "zlib-1.3", + "remote_patches": { + "https://bcr.bazel.build/modules/zlib/1.3/patches/add_build_file.patch": "sha256-Ei+FYaaOo7A3jTKunMEodTI0Uw5NXQyZEcboMC8JskY=", + "https://bcr.bazel.build/modules/zlib/1.3/patches/module_dot_bazel.patch": "sha256-fPWLM+2xaF/kuy+kZc1YTfW6hNjrkG400Ho7gckuyJk=" + }, + "remote_patch_strip": 0 + } + } + }, + "apple_support@1.5.0": { + "name": "apple_support", + "version": "1.5.0", + "key": "apple_support@1.5.0", + "repoName": "build_bazel_apple_support", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "@local_config_apple_cc_toolchains//:all" + ], + "extensionUsages": [ + { + "extensionBzlFile": "@build_bazel_apple_support//crosstool:setup.bzl", + "extensionName": "apple_cc_configure_extension", + "usingModule": "apple_support@1.5.0", + "location": { + "file": "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel", + "line": 17, + "column": 35 + }, + "imports": { + "local_config_apple_cc": "local_config_apple_cc", + "local_config_apple_cc_toolchains": "local_config_apple_cc_toolchains" + }, + "devImports": [], + "tags": [], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], + "deps": { + "bazel_skylib": "bazel_skylib@1.3.0", + "platforms": "platforms@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "apple_support~1.5.0", + "urls": [ + "https://github.com/bazelbuild/apple_support/releases/download/1.5.0/apple_support.1.5.0.tar.gz" + ], + "integrity": "sha256-miM41vja0yRPgj8txghKA+TQ+7J8qJLclw5okNW0gYQ=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, + "bazel_skylib@1.3.0": { + "name": "bazel_skylib", + "version": "1.3.0", + "key": "bazel_skylib@1.3.0", + "repoName": "bazel_skylib", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "//toolchains/unittest:cmd_toolchain", + "//toolchains/unittest:bash_toolchain" + ], + "extensionUsages": [], + "deps": { + "platforms": "platforms@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "bazel_skylib~1.3.0", + "urls": [ + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz" + ], + "integrity": "sha256-dNVE2W9KW7Yw1GXKi7z+Ix41lOWq5X4e2/F6brPKJQY=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + } + }, + "moduleExtensions": {} +} diff --git a/e2e/WORKSPACE b/e2e/WORKSPACE new file mode 100644 index 0000000..e69de29 diff --git a/placeholder/BUILD.bazel b/placeholder/BUILD.bazel new file mode 100644 index 0000000..b0ff7af --- /dev/null +++ b/placeholder/BUILD.bazel @@ -0,0 +1,6 @@ +load("//placeholder/test:rule.bzl", "placeholder_test") + +placeholder_test( + name = "placeholder", + size = "small", +) diff --git a/placeholder/defs.bzl b/placeholder/defs.bzl new file mode 100644 index 0000000..8cce2fa --- /dev/null +++ b/placeholder/defs.bzl @@ -0,0 +1,5 @@ +load("//placeholder/test:rule.bzl", _test = "test") + +visibility("public") + +placeholder_test = _test diff --git a/placeholder/fixture.txt b/placeholder/fixture.txt new file mode 100644 index 0000000..af5626b --- /dev/null +++ b/placeholder/fixture.txt @@ -0,0 +1 @@ +Hello, world! diff --git a/placeholder/test/BUILD.bazel b/placeholder/test/BUILD.bazel new file mode 100644 index 0000000..53004d8 --- /dev/null +++ b/placeholder/test/BUILD.bazel @@ -0,0 +1 @@ +exports_files(["posix.tmpl.sh"]) diff --git a/placeholder/test/posix.tmpl.sh b/placeholder/test/posix.tmpl.sh new file mode 100644 index 0000000..9d7eec9 --- /dev/null +++ b/placeholder/test/posix.tmpl.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +# Strict shell +set -o errexit -o nounset + +# Bazel substitutions +CODE="{{code}}" +readonly CODE + +# Simple! +exit "${CODE}" diff --git a/placeholder/test/rule.bzl b/placeholder/test/rule.bzl new file mode 100644 index 0000000..c614430 --- /dev/null +++ b/placeholder/test/rule.bzl @@ -0,0 +1,41 @@ +visibility("//...") + +ATTRS = { + "code": attr.int( + doc = "The exit code for the test.", + default = 0, + ), + "template": attr.label( + doc = "The template script to expand.", + allow_single_file = True, + default = ":posix.tmpl.sh", + ), +} + +DOC = "A simple placeholder test rule." + +def implementation(ctx): + executable = ctx.actions.declare_file(ctx.label.name) + + ctx.actions.expand_template( + output = executable, + template = ctx.file.template, + substitutions = { + "{{code}}": str(ctx.attr.code), + }, + ) + + return DefaultInfo( + executable = executable, + files = depset([executable]), + runfiles = ctx.runfiles([executable]), + ) + +placeholder_test = rule( + attrs = ATTRS, + doc = DOC, + implementation = implementation, + test = True, +) + +test = placeholder_test -- GitLab From 1cf9296f56c162c46bfb65be1b04a80e296bd645 Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 14 Nov 2023 20:57:49 +0000 Subject: [PATCH 02/55] chore: rename `placeholder` to `toolchain` --- MODULE.bazel | 2 +- MODULE.bazel.lock | 6 +++--- README.md | 6 +++--- e2e/BUILD.bazel | 4 ++-- e2e/MODULE.bazel | 4 ++-- e2e/MODULE.bazel.lock | 16 ++++++++-------- placeholder/BUILD.bazel | 6 ------ placeholder/defs.bzl | 5 ----- toolchain/BUILD.bazel | 6 ++++++ toolchain/defs.bzl | 5 +++++ {placeholder => toolchain}/fixture.txt | 0 {placeholder => toolchain}/test/BUILD.bazel | 0 {placeholder => toolchain}/test/posix.tmpl.sh | 0 {placeholder => toolchain}/test/rule.bzl | 4 ++-- 14 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 placeholder/BUILD.bazel delete mode 100644 placeholder/defs.bzl create mode 100644 toolchain/BUILD.bazel create mode 100644 toolchain/defs.bzl rename {placeholder => toolchain}/fixture.txt (100%) rename {placeholder => toolchain}/test/BUILD.bazel (100%) rename {placeholder => toolchain}/test/posix.tmpl.sh (100%) rename {placeholder => toolchain}/test/rule.bzl (94%) diff --git a/MODULE.bazel b/MODULE.bazel index c56a26e..c4bf564 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,5 +1,5 @@ module( - name = "rules_placeholder", + name = "rules_toolchain", version = "0.0.0", bazel_compatibility = [ ">=6.4.0", diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index dc46c5d..ebe20f5 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,6 +1,6 @@ { "lockFileVersion": 3, - "moduleFileHash": "bfe34180a91f3ff908710075c27bf5597532ff414e99589309e1cb2b4ab201e7", + "moduleFileHash": "00739f08c18e0704210a078643d314b473139c28fd054989fe83997c8453025f", "flags": { "cmdRegistries": [ "https://bcr.bazel.build/" @@ -17,10 +17,10 @@ }, "moduleDepGraph": { "": { - "name": "rules_placeholder", + "name": "rules_toolchain", "version": "0.0.0", "key": "", - "repoName": "rules_placeholder", + "repoName": "rules_toolchain", "executionPlatformsToRegister": [], "toolchainsToRegister": [], "extensionUsages": [], diff --git a/README.md b/README.md index d1e8127..dfd2c73 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# `rules_placeholder` +# `rules_toolchain` -> A Bazel ruleset for placeholder. +> A Bazel ruleset to enable concise toolchain registration. ## Getting Started Add the following to `MODULE.bazel`: ```py -bazel_dep(name="rules_placeholder", version="0.0.0") +bazel_dep(name="rules_toolchain", version="0.0.0") ``` diff --git a/e2e/BUILD.bazel b/e2e/BUILD.bazel index d1bc255..02eecce 100644 --- a/e2e/BUILD.bazel +++ b/e2e/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_placeholder//placeholder:defs.bzl", "placeholder_test") +load("@rules_toolchain//toolchain:defs.bzl", "toolchain_test") -placeholder_test( +toolchain_test( name = "test", size = "small", ) diff --git a/e2e/MODULE.bazel b/e2e/MODULE.bazel index f090525..7825f84 100644 --- a/e2e/MODULE.bazel +++ b/e2e/MODULE.bazel @@ -5,8 +5,8 @@ module( ], ) -bazel_dep(name = "rules_placeholder", version = "0.0.0") +bazel_dep(name = "rules_toolchain", version = "0.0.0") local_path_override( - module_name = "rules_placeholder", + module_name = "rules_toolchain", path = "..", ) diff --git a/e2e/MODULE.bazel.lock b/e2e/MODULE.bazel.lock index 51c002d..0afb99c 100644 --- a/e2e/MODULE.bazel.lock +++ b/e2e/MODULE.bazel.lock @@ -1,6 +1,6 @@ { "lockFileVersion": 3, - "moduleFileHash": "0ae7ae7e1528f93aef4bfb44931525ab435a24fd4f480fc0b28f19c1c9a7f66f", + "moduleFileHash": "5994db4b0cb0b6d41c15302e14e389188de639595869b573fcd2879139985020", "flags": { "cmdRegistries": [ "https://bcr.bazel.build/" @@ -13,8 +13,8 @@ "compatibilityMode": "ERROR" }, "localOverrideHashes": { - "bazel_tools": "922ea6752dc9105de5af957f7a99a6933c0a6a712d23df6aad16a9c399f7e787", - "rules_placeholder": "bfe34180a91f3ff908710075c27bf5597532ff414e99589309e1cb2b4ab201e7" + "rules_toolchain": "00739f08c18e0704210a078643d314b473139c28fd054989fe83997c8453025f", + "bazel_tools": "922ea6752dc9105de5af957f7a99a6933c0a6a712d23df6aad16a9c399f7e787" }, "moduleDepGraph": { "": { @@ -26,16 +26,16 @@ "toolchainsToRegister": [], "extensionUsages": [], "deps": { - "rules_placeholder": "rules_placeholder@_", + "rules_toolchain": "rules_toolchain@_", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" } }, - "rules_placeholder@_": { - "name": "rules_placeholder", + "rules_toolchain@_": { + "name": "rules_toolchain", "version": "0.0.0", - "key": "rules_placeholder@_", - "repoName": "rules_placeholder", + "key": "rules_toolchain@_", + "repoName": "rules_toolchain", "executionPlatformsToRegister": [], "toolchainsToRegister": [], "extensionUsages": [], diff --git a/placeholder/BUILD.bazel b/placeholder/BUILD.bazel deleted file mode 100644 index b0ff7af..0000000 --- a/placeholder/BUILD.bazel +++ /dev/null @@ -1,6 +0,0 @@ -load("//placeholder/test:rule.bzl", "placeholder_test") - -placeholder_test( - name = "placeholder", - size = "small", -) diff --git a/placeholder/defs.bzl b/placeholder/defs.bzl deleted file mode 100644 index 8cce2fa..0000000 --- a/placeholder/defs.bzl +++ /dev/null @@ -1,5 +0,0 @@ -load("//placeholder/test:rule.bzl", _test = "test") - -visibility("public") - -placeholder_test = _test diff --git a/toolchain/BUILD.bazel b/toolchain/BUILD.bazel new file mode 100644 index 0000000..07fef9e --- /dev/null +++ b/toolchain/BUILD.bazel @@ -0,0 +1,6 @@ +load("//toolchain/test:rule.bzl", "toolchain_test") + +toolchain_test( + name = "toolchain", + size = "small", +) diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl new file mode 100644 index 0000000..7de4ec9 --- /dev/null +++ b/toolchain/defs.bzl @@ -0,0 +1,5 @@ +load("//toolchain/test:rule.bzl", _test = "test") + +visibility("public") + +toolchain_test = _test diff --git a/placeholder/fixture.txt b/toolchain/fixture.txt similarity index 100% rename from placeholder/fixture.txt rename to toolchain/fixture.txt diff --git a/placeholder/test/BUILD.bazel b/toolchain/test/BUILD.bazel similarity index 100% rename from placeholder/test/BUILD.bazel rename to toolchain/test/BUILD.bazel diff --git a/placeholder/test/posix.tmpl.sh b/toolchain/test/posix.tmpl.sh similarity index 100% rename from placeholder/test/posix.tmpl.sh rename to toolchain/test/posix.tmpl.sh diff --git a/placeholder/test/rule.bzl b/toolchain/test/rule.bzl similarity index 94% rename from placeholder/test/rule.bzl rename to toolchain/test/rule.bzl index c614430..17e4c11 100644 --- a/placeholder/test/rule.bzl +++ b/toolchain/test/rule.bzl @@ -31,11 +31,11 @@ def implementation(ctx): runfiles = ctx.runfiles([executable]), ) -placeholder_test = rule( +toolchain_test = rule( attrs = ATTRS, doc = DOC, implementation = implementation, test = True, ) -test = placeholder_test +test = toolchain_test -- GitLab From af9d07ef69e15ba9cdc0982cf466a700b8aba2f0 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Fri, 15 Sep 2023 10:44:20 +0100 Subject: [PATCH 03/55] feat(rules_toolchain): add extension for finding local binaries --- rules_toolchain/.bazelrc | 12 +++++ rules_toolchain/.gitignore | 5 ++ rules_toolchain/MODULE.bazel | 9 ++++ rules_toolchain/WORKSPACE | 0 rules_toolchain/toolchain/BUILD.bazel | 0 rules_toolchain/toolchain/extensions.bzl | 3 ++ rules_toolchain/toolchain/local/BUILD.bazel | 0 .../toolchain/local/binary/BUILD.bazel | 1 + .../toolchain/local/binary/BinaryInfo.bzl | 35 ++++++++++++ .../toolchain/local/binary/posix.sh.in | 18 +++++++ .../toolchain/local/binary/rule.bzl | 53 +++++++++++++++++++ rules_toolchain/toolchain/local/defs.bzl | 5 ++ rules_toolchain/toolchain/local/extension.bzl | 17 ++++++ .../toolchain/local/which/BUILD.bazel | 0 .../toolchain/local/which/BUILD.bazel.in | 10 ++++ .../toolchain/local/which/repository.bzl | 40 ++++++++++++++ 16 files changed, 208 insertions(+) create mode 100644 rules_toolchain/.bazelrc create mode 100644 rules_toolchain/.gitignore create mode 100644 rules_toolchain/MODULE.bazel create mode 100644 rules_toolchain/WORKSPACE create mode 100644 rules_toolchain/toolchain/BUILD.bazel create mode 100644 rules_toolchain/toolchain/extensions.bzl create mode 100644 rules_toolchain/toolchain/local/BUILD.bazel create mode 100644 rules_toolchain/toolchain/local/binary/BUILD.bazel create mode 100644 rules_toolchain/toolchain/local/binary/BinaryInfo.bzl create mode 100755 rules_toolchain/toolchain/local/binary/posix.sh.in create mode 100644 rules_toolchain/toolchain/local/binary/rule.bzl create mode 100644 rules_toolchain/toolchain/local/defs.bzl create mode 100644 rules_toolchain/toolchain/local/extension.bzl create mode 100644 rules_toolchain/toolchain/local/which/BUILD.bazel create mode 100644 rules_toolchain/toolchain/local/which/BUILD.bazel.in create mode 100644 rules_toolchain/toolchain/local/which/repository.bzl diff --git a/rules_toolchain/.bazelrc b/rules_toolchain/.bazelrc new file mode 100644 index 0000000..82569eb --- /dev/null +++ b/rules_toolchain/.bazelrc @@ -0,0 +1,12 @@ +# Enable `bzlmod` +common --enable_bzlmod +common --registry https://bcr.bazel.build + +# Build cache +build --experimental_guard_against_concurrent_changes + +# Use modern toolchain resolution +build --incompatible_enable_cc_toolchain_resolution + +# User-specific .bazelrc +try-import user.bazelrc diff --git a/rules_toolchain/.gitignore b/rules_toolchain/.gitignore new file mode 100644 index 0000000..beb652d --- /dev/null +++ b/rules_toolchain/.gitignore @@ -0,0 +1,5 @@ +/.cache +/bazel-bin +/bazel-testlogs +/bazel-rules_toolchain +/bazel-out diff --git a/rules_toolchain/MODULE.bazel b/rules_toolchain/MODULE.bazel new file mode 100644 index 0000000..f2b99c7 --- /dev/null +++ b/rules_toolchain/MODULE.bazel @@ -0,0 +1,9 @@ +module( + name = "rules_toolchain", +) + +bazel_dep(name = "bazel_skylib", version = "1.4.2", dev_dependency = True) + +local = use_extension("//toolchain:extensions.bzl", "local") +local.which(name = "echo") +use_repo(local, "echo") diff --git a/rules_toolchain/WORKSPACE b/rules_toolchain/WORKSPACE new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/BUILD.bazel b/rules_toolchain/toolchain/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/extensions.bzl b/rules_toolchain/toolchain/extensions.bzl new file mode 100644 index 0000000..7427385 --- /dev/null +++ b/rules_toolchain/toolchain/extensions.bzl @@ -0,0 +1,3 @@ +load("//toolchain/local:extension.bzl", _local = "local") + +local = _local diff --git a/rules_toolchain/toolchain/local/BUILD.bazel b/rules_toolchain/toolchain/local/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/local/binary/BUILD.bazel b/rules_toolchain/toolchain/local/binary/BUILD.bazel new file mode 100644 index 0000000..d51daaa --- /dev/null +++ b/rules_toolchain/toolchain/local/binary/BUILD.bazel @@ -0,0 +1 @@ +exports_files(["posix.sh.in"]) diff --git a/rules_toolchain/toolchain/local/binary/BinaryInfo.bzl b/rules_toolchain/toolchain/local/binary/BinaryInfo.bzl new file mode 100644 index 0000000..c365dd7 --- /dev/null +++ b/rules_toolchain/toolchain/local/binary/BinaryInfo.bzl @@ -0,0 +1,35 @@ +def check_envvar(name, value): + if not value[0].isalpha(): + fail("`{}` must start with a letter: {}".format(name, value)) + + if not value.isupper(): + fail("`{}` must be uppercase: {}".format(name, value)) + + if not value.replace("_", "A").isalnum(): + fail("`{}` must be underscore separated and alphanumeric: {}".format(name, value)) + + return value + +def init(program, path, variable): + """ + Initialises a `BinaryInfo` instance. + + Args: + program: The executable name. + path: The local path to the binary. + variable: The variable name to use for Make or the execution environment. + + Returns: + A mapping of keywords for the `binary_info` raw constructor. + """ + return { + "program": program, + "path": path, + "variable": check_envvar("BinaryInfo.variable", variable).upper(), + } + +BinaryInfo, binary_info = provider( + "Information about a locally wrapped binary", + fields = ["program", "path", "variable"], + init = init, +) diff --git a/rules_toolchain/toolchain/local/binary/posix.sh.in b/rules_toolchain/toolchain/local/binary/posix.sh.in new file mode 100755 index 0000000..19e5ec8 --- /dev/null +++ b/rules_toolchain/toolchain/local/binary/posix.sh.in @@ -0,0 +1,18 @@ +#!/bin/sh + +# e: quit on command errors +# u: quit on undefined variables +set -eu + +# Bazel substitutions +EXECUTABLE="{{path}}" +readonly EXECUTABLE + +# Validate the executable is...executable +if ! test -x "${EXECUTABLE}"; then + echo >&2 "Not executable: ${EXECUTABLE}" + exit 69 +fi + +# Pass on the argument to the actual executable +"${EXECUTABLE}" "${@}" diff --git a/rules_toolchain/toolchain/local/binary/rule.bzl b/rules_toolchain/toolchain/local/binary/rule.bzl new file mode 100644 index 0000000..72cb902 --- /dev/null +++ b/rules_toolchain/toolchain/local/binary/rule.bzl @@ -0,0 +1,53 @@ +load(":BinaryInfo.bzl", "BinaryInfo") + +ATTRS = { + "path": attr.string( + doc = "The path to the local binary.", + mandatory = True, + ), + "program": attr.string( + doc = "The name of the binary to found on PATH.", + ), + "variable": attr.string( + doc = "The variable name for Make or the execution environment.", + ), + "template": attr.label( + doc = "The template that is expanded into the binary.", + default = Label(":posix.sh.in"), + allow_single_file = True, + ), +} + +def implementation(ctx): + program = ctx.attr.program or ctx.label.name + info = BinaryInfo( + program = program, + path = ctx.attr.path, + variable = ctx.attr.variable or program.upper(), + ) + + output = ctx.actions.declare_file(info.program) + ctx.actions.expand_template( + template = ctx.file.template, + output = output, + substitutions = { + "{{path}}": info.path, + }, + is_executable = True, + ) + + default = DefaultInfo( + executable = output, + files = depset([output]), + runfiles = ctx.runfiles([output]), + ) + + return [info, default] + +binary = rule( + doc = "Creates a executable binary target file around a local binary path", + attrs = ATTRS, + implementation = implementation, + provides = [BinaryInfo], + executable = True, +) diff --git a/rules_toolchain/toolchain/local/defs.bzl b/rules_toolchain/toolchain/local/defs.bzl new file mode 100644 index 0000000..8be1870 --- /dev/null +++ b/rules_toolchain/toolchain/local/defs.bzl @@ -0,0 +1,5 @@ +load("//toolchain/local/binary:BinaryInfo.bzl", _BinaryInfo = "BinaryInfo") +load("//toolchain/local/binary:rule.bzl", _binary = "binary") + +BinaryInfo = _BinaryInfo +binary = _binary diff --git a/rules_toolchain/toolchain/local/extension.bzl b/rules_toolchain/toolchain/local/extension.bzl new file mode 100644 index 0000000..30a9234 --- /dev/null +++ b/rules_toolchain/toolchain/local/extension.bzl @@ -0,0 +1,17 @@ +load("//toolchain/local/which:repository.bzl", _WHICH = "ATTRS", _which = "which") + +which = tag_class(attrs = { + "name": attr.string(doc = "Name of the generated repository.", mandatory = True), +} | _WHICH) + +def implementation(mctx): + for mod in mctx.modules: + for d in mod.tags.which: + _which(name = d.name, **{a: getattr(d, a) for a in _WHICH}) + +local = module_extension( + implementation = implementation, + tag_classes = { + "which": which, + }, +) diff --git a/rules_toolchain/toolchain/local/which/BUILD.bazel b/rules_toolchain/toolchain/local/which/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/local/which/BUILD.bazel.in b/rules_toolchain/toolchain/local/which/BUILD.bazel.in new file mode 100644 index 0000000..107580a --- /dev/null +++ b/rules_toolchain/toolchain/local/which/BUILD.bazel.in @@ -0,0 +1,10 @@ +load("@rules_toolchain//toolchain/local:defs.bzl", "binary") + +package(default_visibility = ["//visibility:public"]) + +binary( + name = "{{name}}", + program = "{{program}}", + path = "{{path}}", + variable = "{{variable}}", +) diff --git a/rules_toolchain/toolchain/local/which/repository.bzl b/rules_toolchain/toolchain/local/which/repository.bzl new file mode 100644 index 0000000..236dbe9 --- /dev/null +++ b/rules_toolchain/toolchain/local/which/repository.bzl @@ -0,0 +1,40 @@ +ATTRS = { + "program": attr.string( + doc = "The name of the binary to find on `PATH`.", + ), + "target": attr.string( + doc = "The name of the Bazel target to expose around the binary.", + ), + "variable": attr.string( + doc = "The variable name for Make or the execution environment.", + ), + "template": attr.label( + doc = "The template that is expanded into the `BUILD.bazel`.", + default = Label("//toolchain/local/which:BUILD.bazel.in"), + allow_single_file = True, + ), +} + +def implementation(rctx): + program = rctx.attr.program or rctx.attr.name.rsplit("~", 1)[1] + + path = rctx.which(program) + if not path: + fail("Cannot find `{}` on `PATH`".format(program)) + + rctx.template("BUILD.bazel", rctx.attr.template, { + "{{name}}": program or rctx.attr.target, + "{{program}}": program, + "{{path}}": str(path.realpath), + "{{variable}}": rctx.attr.variable or program.upper(), + }) + +which = repository_rule( + doc = "Creates a repository that provides a binary target wrapping a local binary found on `PATH`.", + implementation = implementation, + attrs = ATTRS, + configure = True, + environ = [ + "PATH", + ], +) -- GitLab From 05fb31540aee9615255e02e6bd6e4d85fe09d128 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Fri, 15 Sep 2023 12:40:01 +0100 Subject: [PATCH 04/55] feat(rules_toolchain): add local toolchain information rule --- rules_toolchain/toolchain/info/BUILD.bazel | 0 rules_toolchain/toolchain/info/DataInfo.bzl | 21 +++++++++++ .../toolchain/local/info/BUILD.bazel | 12 ++++++ rules_toolchain/toolchain/local/info/rule.bzl | 37 +++++++++++++++++++ rules_toolchain/toolchain/local/info/test.bzl | 12 ++++++ 5 files changed, 82 insertions(+) create mode 100644 rules_toolchain/toolchain/info/BUILD.bazel create mode 100644 rules_toolchain/toolchain/info/DataInfo.bzl create mode 100644 rules_toolchain/toolchain/local/info/BUILD.bazel create mode 100644 rules_toolchain/toolchain/local/info/rule.bzl create mode 100644 rules_toolchain/toolchain/local/info/test.bzl diff --git a/rules_toolchain/toolchain/info/BUILD.bazel b/rules_toolchain/toolchain/info/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/info/DataInfo.bzl b/rules_toolchain/toolchain/info/DataInfo.bzl new file mode 100644 index 0000000..eeb308f --- /dev/null +++ b/rules_toolchain/toolchain/info/DataInfo.bzl @@ -0,0 +1,21 @@ +def init(target, env): + """ + Initialises a `DataInfo` instance. + + Args: + target: The Bazel target that to be used as the toolchain + env: Environment variables to be exposed + + Returns: + A mapping of keywords for the `data_info` raw constructor. + """ + return { + "target": target, + "env": env, + } + +DataInfo, data_info = provider( + "Data that is contained in a `platform_common.ToolchainInfo`", + fields = ["target", "env"], + init = init, +) diff --git a/rules_toolchain/toolchain/local/info/BUILD.bazel b/rules_toolchain/toolchain/local/info/BUILD.bazel new file mode 100644 index 0000000..2619364 --- /dev/null +++ b/rules_toolchain/toolchain/local/info/BUILD.bazel @@ -0,0 +1,12 @@ +load(":rule.bzl", "info") +load(":test.bzl", "test") + +info( + name = "echo", + binary = "@echo//:echo", +) + +test( + name = "test", + target_under_test = ":echo", +) diff --git a/rules_toolchain/toolchain/local/info/rule.bzl b/rules_toolchain/toolchain/local/info/rule.bzl new file mode 100644 index 0000000..a598e22 --- /dev/null +++ b/rules_toolchain/toolchain/local/info/rule.bzl @@ -0,0 +1,37 @@ +load("//toolchain/local/binary:BinaryInfo.bzl", "BinaryInfo") +load("//toolchain/info:DataInfo.bzl", "DataInfo") + +ATTRS = { + "binary": attr.label( + doc = "The binary target to provide toolchain information for.", + allow_single_file = True, + mandatory = True, + cfg = "exec", + providers = [BinaryInfo], + ), +} + +def implementation(ctx): + binary = ctx.attr.binary[BinaryInfo] + data = DataInfo( + target = ctx.attr.binary, + env = { + binary.variable: str(ctx.file.binary.path), + }, + ) + return [ + platform_common.ToolchainInfo(data = data), + data, + binary, + ] + +info = rule( + doc = "Provides toolchain information for a local binary target.", + implementation = implementation, + attrs = ATTRS, + provides = [ + platform_common.ToolchainInfo, + DataInfo, + BinaryInfo, + ], +) diff --git a/rules_toolchain/toolchain/local/info/test.bzl b/rules_toolchain/toolchain/local/info/test.bzl new file mode 100644 index 0000000..4dc7e40 --- /dev/null +++ b/rules_toolchain/toolchain/local/info/test.bzl @@ -0,0 +1,12 @@ +load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") + +def implementation(ctx): + env = analysistest.begin(ctx) + target = analysistest.target_under_test(env) + info = target[platform_common.ToolchainInfo] + asserts.true(env, "ECHO" in info.data.env) + return analysistest.end(env) + +info_test = analysistest.make(implementation) + +test = info_test -- GitLab From 45309bf68d0bcec0d9d6d67b7bcedfd492f4ea26 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Fri, 15 Sep 2023 14:56:00 +0100 Subject: [PATCH 05/55] feat(rules_toolchain): add `echo` toolchain end-to-end test --- rules_toolchain/.bazelignore | 1 + rules_toolchain/MODULE.bazel | 4 -- rules_toolchain/e2e/.bazelrc | 8 ++++ rules_toolchain/e2e/.gitignore | 5 +++ rules_toolchain/e2e/MODULE.bazel | 15 +++++++ rules_toolchain/e2e/WORKSPACE | 0 .../e2e/toolchain/echo/BUILD.bazel | 40 +++++++++++++++++++ rules_toolchain/e2e/toolchain/echo/content.sh | 31 ++++++++++++++ .../e2e/toolchain/echo/info/BUILD.bazel | 6 +++ .../e2e/toolchain/echo/variable.bzl | 14 +++++++ rules_toolchain/toolchain/local/defs.bzl | 2 + .../toolchain/local/info/BUILD.bazel | 11 +++-- .../toolchain/local/info/binary.bzl | 34 ++++++++++++++++ rules_toolchain/toolchain/local/info/test.bzl | 2 +- rules_toolchain/toolchain/variable.bzl | 29 ++++++++++++++ 15 files changed, 194 insertions(+), 8 deletions(-) create mode 100644 rules_toolchain/.bazelignore create mode 100644 rules_toolchain/e2e/.bazelrc create mode 100644 rules_toolchain/e2e/.gitignore create mode 100644 rules_toolchain/e2e/MODULE.bazel create mode 100644 rules_toolchain/e2e/WORKSPACE create mode 100644 rules_toolchain/e2e/toolchain/echo/BUILD.bazel create mode 100755 rules_toolchain/e2e/toolchain/echo/content.sh create mode 100644 rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel create mode 100644 rules_toolchain/e2e/toolchain/echo/variable.bzl create mode 100644 rules_toolchain/toolchain/local/info/binary.bzl create mode 100644 rules_toolchain/toolchain/variable.bzl diff --git a/rules_toolchain/.bazelignore b/rules_toolchain/.bazelignore new file mode 100644 index 0000000..c7ca8d0 --- /dev/null +++ b/rules_toolchain/.bazelignore @@ -0,0 +1 @@ +e2e diff --git a/rules_toolchain/MODULE.bazel b/rules_toolchain/MODULE.bazel index f2b99c7..031ee05 100644 --- a/rules_toolchain/MODULE.bazel +++ b/rules_toolchain/MODULE.bazel @@ -3,7 +3,3 @@ module( ) bazel_dep(name = "bazel_skylib", version = "1.4.2", dev_dependency = True) - -local = use_extension("//toolchain:extensions.bzl", "local") -local.which(name = "echo") -use_repo(local, "echo") diff --git a/rules_toolchain/e2e/.bazelrc b/rules_toolchain/e2e/.bazelrc new file mode 100644 index 0000000..f01df94 --- /dev/null +++ b/rules_toolchain/e2e/.bazelrc @@ -0,0 +1,8 @@ +# Enable `bzlmod` +common --enable_bzlmod + +# Disable built-in toolchain detection +build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 + +# User-specific .bazelrc +try-import user.bazelrc diff --git a/rules_toolchain/e2e/.gitignore b/rules_toolchain/e2e/.gitignore new file mode 100644 index 0000000..3ec2cc3 --- /dev/null +++ b/rules_toolchain/e2e/.gitignore @@ -0,0 +1,5 @@ +/.cache +/bazel-bin +/bazel-testlogs +/bazel-e2e +/bazel-out diff --git a/rules_toolchain/e2e/MODULE.bazel b/rules_toolchain/e2e/MODULE.bazel new file mode 100644 index 0000000..3530e36 --- /dev/null +++ b/rules_toolchain/e2e/MODULE.bazel @@ -0,0 +1,15 @@ +module( + name = "e2e", +) + +bazel_dep(name = "rules_toolchain", version = "0.0.0") +local_path_override( + module_name = "rules_toolchain", + path = "..", +) + +local = use_extension("@rules_toolchain//toolchain:extensions.bzl", "local") +local.which(name = "echo") +use_repo(local, "echo") + +register_toolchains("//toolchain/echo:all") diff --git a/rules_toolchain/e2e/WORKSPACE b/rules_toolchain/e2e/WORKSPACE new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/e2e/toolchain/echo/BUILD.bazel b/rules_toolchain/e2e/toolchain/echo/BUILD.bazel new file mode 100644 index 0000000..827ad43 --- /dev/null +++ b/rules_toolchain/e2e/toolchain/echo/BUILD.bazel @@ -0,0 +1,40 @@ +load(":variable.bzl", "variable") + +toolchain_type( + name = "type", +) + +toolchain( + name = "local", + toolchain = "//toolchain/echo/info:local", + toolchain_type = ":type", +) + +alias( + name = "echo", + actual = "local", +) + +variable( + name = "variable", + toolchain = ":type", +) + +genrule( + name = "data", + testonly = True, + outs = ["hello-world.txt"], + cmd = "$(ECHO) 'Hello, world!' > $@", + toolchains = [":variable"], +) + +sh_test( + name = "sh", + size = "small", + srcs = ["content.sh"], + args = [ + "hello-world.txt", + "'Hello, world!'", + ], + data = [":data"], +) diff --git a/rules_toolchain/e2e/toolchain/echo/content.sh b/rules_toolchain/e2e/toolchain/echo/content.sh new file mode 100755 index 0000000..d3770ab --- /dev/null +++ b/rules_toolchain/e2e/toolchain/echo/content.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# e: quit on command errors +# u: quit on undefined variables +set -eu + +# Test setup +TEST_SCRIPT="${TEST_BINARY?TEST_BINARY is unset}" +TEST_FOLDER="${TEST_SCRIPT%/*}" +TEST_DATA="${TEST_FOLDER}/${1}" +TEST_EXPECTED="${2}" +readonly TEST_FOLDER TEST_DATA TEST_EXPECTED + +# Validate the test data +if ! test -f "${TEST_DATA}"; then + echo >&2 "Missing test DATA: ${TEST_DATA}" + exit 2 +elif ! test -r "${TEST_DATA}"; then + echo >&2 "Unreadable test DATA: ${TEST_DATA}" + exit 2 +fi + +# Validate the test content +while IFS= read -r LINE; do + if test "${LINE}" != "${TEST_EXPECTED}"; then + echo >&2 "Invalid data content:" + echo >&2 " - actual : ${LINE}" + echo >&2 " - expected: ${TEST_EXPECTED}" + exit 1 + fi +done <"${TEST_DATA}" diff --git a/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel b/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel new file mode 100644 index 0000000..02b5ee9 --- /dev/null +++ b/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel @@ -0,0 +1,6 @@ +load("@rules_toolchain//toolchain/local:defs.bzl", "info") + +info( + name = "local", + binary = "@echo//:echo", +) diff --git a/rules_toolchain/e2e/toolchain/echo/variable.bzl b/rules_toolchain/e2e/toolchain/echo/variable.bzl new file mode 100644 index 0000000..567e499 --- /dev/null +++ b/rules_toolchain/e2e/toolchain/echo/variable.bzl @@ -0,0 +1,14 @@ +load("@rules_toolchain//toolchain:variable.bzl", _ATTRS = "ATTRS", _implementation = "implementation") + +ATTRS = _ATTRS + +implementation = _implementation + +variable = rule( + doc = "Provides template variable information for the toolchain.", + attrs = ATTRS, + implementation = implementation, + incompatible_use_toolchain_transition = True, + provides = [platform_common.TemplateVariableInfo], + toolchains = ["//toolchain/echo:type"], +) diff --git a/rules_toolchain/toolchain/local/defs.bzl b/rules_toolchain/toolchain/local/defs.bzl index 8be1870..37c5d70 100644 --- a/rules_toolchain/toolchain/local/defs.bzl +++ b/rules_toolchain/toolchain/local/defs.bzl @@ -1,5 +1,7 @@ load("//toolchain/local/binary:BinaryInfo.bzl", _BinaryInfo = "BinaryInfo") load("//toolchain/local/binary:rule.bzl", _binary = "binary") +load("//toolchain/local/info:rule.bzl", _info = "info") BinaryInfo = _BinaryInfo binary = _binary +info = _info diff --git a/rules_toolchain/toolchain/local/info/BUILD.bazel b/rules_toolchain/toolchain/local/info/BUILD.bazel index 2619364..c39fd79 100644 --- a/rules_toolchain/toolchain/local/info/BUILD.bazel +++ b/rules_toolchain/toolchain/local/info/BUILD.bazel @@ -1,12 +1,17 @@ +load(":binary.bzl", "binary") load(":rule.bzl", "info") load(":test.bzl", "test") +binary( + name = "binary", +) + info( - name = "echo", - binary = "@echo//:echo", + name = "info", + binary = ":binary", ) test( name = "test", - target_under_test = ":echo", + target_under_test = ":info", ) diff --git a/rules_toolchain/toolchain/local/info/binary.bzl b/rules_toolchain/toolchain/local/info/binary.bzl new file mode 100644 index 0000000..9bf1313 --- /dev/null +++ b/rules_toolchain/toolchain/local/info/binary.bzl @@ -0,0 +1,34 @@ +load("//toolchain/local:defs.bzl", "BinaryInfo") + +ATTRS = {} + +def implementation(ctx): + output = ctx.actions.declare_file(ctx.label.name) + + info = BinaryInfo( + program = output.basename, + path = output.path, + variable = output.basename.upper(), + ) + + ctx.actions.write( + output = output, + content = "#!/bin/sh", + is_executable = True, + ) + + default = DefaultInfo( + executable = output, + files = depset([output]), + runfiles = ctx.runfiles([output]), + ) + + return [info, default] + +binary = rule( + doc = "Creates a executable binary target file around a local binary path", + attrs = ATTRS, + implementation = implementation, + provides = [BinaryInfo], + executable = True, +) diff --git a/rules_toolchain/toolchain/local/info/test.bzl b/rules_toolchain/toolchain/local/info/test.bzl index 4dc7e40..2fa3013 100644 --- a/rules_toolchain/toolchain/local/info/test.bzl +++ b/rules_toolchain/toolchain/local/info/test.bzl @@ -4,7 +4,7 @@ def implementation(ctx): env = analysistest.begin(ctx) target = analysistest.target_under_test(env) info = target[platform_common.ToolchainInfo] - asserts.true(env, "ECHO" in info.data.env) + asserts.true(env, "BINARY" in info.data.env) return analysistest.end(env) info_test = analysistest.make(implementation) diff --git a/rules_toolchain/toolchain/variable.bzl b/rules_toolchain/toolchain/variable.bzl new file mode 100644 index 0000000..28fc1cb --- /dev/null +++ b/rules_toolchain/toolchain/variable.bzl @@ -0,0 +1,29 @@ +ATTRS = { + "toolchain": attr.label( + doc = "The toolchain type to gather the template variable information for.", + mandatory = True, + ), +} + +def implementation(ctx): + toolchain = ctx.toolchains[ctx.attr.toolchain.label] + return [ + toolchain, + platform_common.TemplateVariableInfo(toolchain.data.env), + DefaultInfo( + files = toolchain.data.target.files, + runfiles = toolchain.data.target.default_runfiles, + ), + ] + +# This rule is useless by itself as the specific toolchain type needs to be defined +# Derive a toolchain specific rule and specify the correct toolchain +# The `ATTRS` and `implementation` can be reused +variable = rule( + doc = "Provides template variable information for a toolchain.", + attrs = ATTRS, + implementation = implementation, + incompatible_use_toolchain_transition = True, + provides = [platform_common.TemplateVariableInfo], + # toolchains = ["//your/toolchain/type"], +) -- GitLab From 0bce1ce726ff0f4fec393c000b35052fcb0a33b5 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Mon, 18 Sep 2023 16:25:53 +0100 Subject: [PATCH 06/55] fix(rules_toolchain): simplify Bazel run commands --- rules_toolchain/.bazelrc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/rules_toolchain/.bazelrc b/rules_toolchain/.bazelrc index 82569eb..025f832 100644 --- a/rules_toolchain/.bazelrc +++ b/rules_toolchain/.bazelrc @@ -1,12 +1,5 @@ # Enable `bzlmod` common --enable_bzlmod -common --registry https://bcr.bazel.build - -# Build cache -build --experimental_guard_against_concurrent_changes - -# Use modern toolchain resolution -build --incompatible_enable_cc_toolchain_resolution # User-specific .bazelrc try-import user.bazelrc -- GitLab From c609b07f39d96e51f79de96a0dd27f6c11d19609 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 19 Sep 2023 10:22:30 +0100 Subject: [PATCH 07/55] feat(rules_toolchain): add `DataInfo.executable` --- rules_toolchain/toolchain/info/DataInfo.bzl | 10 ++++++---- rules_toolchain/toolchain/local/info/rule.bzl | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/rules_toolchain/toolchain/info/DataInfo.bzl b/rules_toolchain/toolchain/info/DataInfo.bzl index eeb308f..76228ad 100644 --- a/rules_toolchain/toolchain/info/DataInfo.bzl +++ b/rules_toolchain/toolchain/info/DataInfo.bzl @@ -1,21 +1,23 @@ -def init(target, env): +def init(target, executable, env): """ Initialises a `DataInfo` instance. Args: - target: The Bazel target that to be used as the toolchain - env: Environment variables to be exposed + target: The Bazel target that to be used as the toolchain. + executable: The executable file to be used with actions. + env: Environment variables to be exposed. Returns: A mapping of keywords for the `data_info` raw constructor. """ return { "target": target, + "executable": executable, "env": env, } DataInfo, data_info = provider( "Data that is contained in a `platform_common.ToolchainInfo`", - fields = ["target", "env"], + fields = ["target", "executable", "env"], init = init, ) diff --git a/rules_toolchain/toolchain/local/info/rule.bzl b/rules_toolchain/toolchain/local/info/rule.bzl index a598e22..6c8749b 100644 --- a/rules_toolchain/toolchain/local/info/rule.bzl +++ b/rules_toolchain/toolchain/local/info/rule.bzl @@ -15,6 +15,7 @@ def implementation(ctx): binary = ctx.attr.binary[BinaryInfo] data = DataInfo( target = ctx.attr.binary, + executable = ctx.file.binary, env = { binary.variable: str(ctx.file.binary.path), }, -- GitLab From 19d77d2491c508939d7b395de5b30ac82da69217 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Fri, 22 Sep 2023 09:39:03 +0100 Subject: [PATCH 08/55] refactor(rules_toolchain): rename template files to `*.tmpl.*` We get syntax highlighting and `pre-commit`. --- rules_toolchain/toolchain/local/binary/BUILD.bazel | 2 +- .../toolchain/local/binary/{posix.sh.in => posix.tmpl.sh} | 0 rules_toolchain/toolchain/local/binary/rule.bzl | 2 +- .../toolchain/local/which/{BUILD.bazel.in => BUILD.tmpl.bazel} | 2 +- rules_toolchain/toolchain/local/which/repository.bzl | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename rules_toolchain/toolchain/local/binary/{posix.sh.in => posix.tmpl.sh} (100%) rename rules_toolchain/toolchain/local/which/{BUILD.bazel.in => BUILD.tmpl.bazel} (100%) diff --git a/rules_toolchain/toolchain/local/binary/BUILD.bazel b/rules_toolchain/toolchain/local/binary/BUILD.bazel index d51daaa..53004d8 100644 --- a/rules_toolchain/toolchain/local/binary/BUILD.bazel +++ b/rules_toolchain/toolchain/local/binary/BUILD.bazel @@ -1 +1 @@ -exports_files(["posix.sh.in"]) +exports_files(["posix.tmpl.sh"]) diff --git a/rules_toolchain/toolchain/local/binary/posix.sh.in b/rules_toolchain/toolchain/local/binary/posix.tmpl.sh similarity index 100% rename from rules_toolchain/toolchain/local/binary/posix.sh.in rename to rules_toolchain/toolchain/local/binary/posix.tmpl.sh diff --git a/rules_toolchain/toolchain/local/binary/rule.bzl b/rules_toolchain/toolchain/local/binary/rule.bzl index 72cb902..a82c0c1 100644 --- a/rules_toolchain/toolchain/local/binary/rule.bzl +++ b/rules_toolchain/toolchain/local/binary/rule.bzl @@ -13,7 +13,7 @@ ATTRS = { ), "template": attr.label( doc = "The template that is expanded into the binary.", - default = Label(":posix.sh.in"), + default = Label(":posix.tmpl.sh"), allow_single_file = True, ), } diff --git a/rules_toolchain/toolchain/local/which/BUILD.bazel.in b/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel similarity index 100% rename from rules_toolchain/toolchain/local/which/BUILD.bazel.in rename to rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel index 107580a..74e2851 100644 --- a/rules_toolchain/toolchain/local/which/BUILD.bazel.in +++ b/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel @@ -4,7 +4,7 @@ package(default_visibility = ["//visibility:public"]) binary( name = "{{name}}", - program = "{{program}}", path = "{{path}}", + program = "{{program}}", variable = "{{variable}}", ) diff --git a/rules_toolchain/toolchain/local/which/repository.bzl b/rules_toolchain/toolchain/local/which/repository.bzl index 236dbe9..2cf4f2d 100644 --- a/rules_toolchain/toolchain/local/which/repository.bzl +++ b/rules_toolchain/toolchain/local/which/repository.bzl @@ -10,7 +10,7 @@ ATTRS = { ), "template": attr.label( doc = "The template that is expanded into the `BUILD.bazel`.", - default = Label("//toolchain/local/which:BUILD.bazel.in"), + default = Label(":BUILD.tmpl.bazel"), allow_single_file = True, ), } -- GitLab From 21ee13fca2a51d7512ccfed38784e2a40566a2c7 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 27 Sep 2023 09:57:45 +0100 Subject: [PATCH 09/55] fix(rules_toolchain): respect `target` attribute The `or` condition is simply the wrong way around, the `target` attribute should be honoured before the program name. --- rules_toolchain/toolchain/local/which/repository.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules_toolchain/toolchain/local/which/repository.bzl b/rules_toolchain/toolchain/local/which/repository.bzl index 2cf4f2d..d4d815f 100644 --- a/rules_toolchain/toolchain/local/which/repository.bzl +++ b/rules_toolchain/toolchain/local/which/repository.bzl @@ -23,7 +23,7 @@ def implementation(rctx): fail("Cannot find `{}` on `PATH`".format(program)) rctx.template("BUILD.bazel", rctx.attr.template, { - "{{name}}": program or rctx.attr.target, + "{{name}}": rctx.attr.target or program, "{{program}}": program, "{{path}}": str(path.realpath), "{{variable}}": rctx.attr.variable or program.upper(), -- GitLab From f4167341452e44f0380e9aef6be101b7a36de762 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 3 Oct 2023 10:13:58 +0100 Subject: [PATCH 10/55] refactor(rules_toolchain): make `info` rule common The exposing of toolchain information on a target does not have to be unique to local toolchains. This switches to a generic `TargetInfo` that provides the necessary toolchain information. --- rules_toolchain/MODULE.bazel | 2 +- .../e2e/toolchain/echo/info/BUILD.bazel | 2 +- rules_toolchain/toolchain/defs.bzl | 3 +++ rules_toolchain/toolchain/info/BUILD.bazel | 17 +++++++++++++++ rules_toolchain/toolchain/info/TargetInfo.bzl | 19 +++++++++++++++++ .../toolchain/{local => }/info/binary.bzl | 18 ++++++++-------- rules_toolchain/toolchain/info/defs.bzl | 7 +++++++ .../toolchain/{local => }/info/rule.bzl | 16 +++++++------- .../toolchain/{local => }/info/test.bzl | 0 .../toolchain/local/binary/rule.bzl | 21 ++++++++++++++----- rules_toolchain/toolchain/local/defs.bzl | 2 -- .../toolchain/local/info/BUILD.bazel | 17 --------------- 12 files changed, 80 insertions(+), 44 deletions(-) create mode 100644 rules_toolchain/toolchain/defs.bzl create mode 100644 rules_toolchain/toolchain/info/TargetInfo.bzl rename rules_toolchain/toolchain/{local => }/info/binary.bzl (62%) create mode 100644 rules_toolchain/toolchain/info/defs.bzl rename rules_toolchain/toolchain/{local => }/info/rule.bzl (67%) rename rules_toolchain/toolchain/{local => }/info/test.bzl (100%) delete mode 100644 rules_toolchain/toolchain/local/info/BUILD.bazel diff --git a/rules_toolchain/MODULE.bazel b/rules_toolchain/MODULE.bazel index 031ee05..89367aa 100644 --- a/rules_toolchain/MODULE.bazel +++ b/rules_toolchain/MODULE.bazel @@ -2,4 +2,4 @@ module( name = "rules_toolchain", ) -bazel_dep(name = "bazel_skylib", version = "1.4.2", dev_dependency = True) +bazel_dep(name = "bazel_skylib", version = "1.4.2") diff --git a/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel b/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel index 02b5ee9..7cec474 100644 --- a/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel +++ b/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel @@ -1,4 +1,4 @@ -load("@rules_toolchain//toolchain/local:defs.bzl", "info") +load("@rules_toolchain//toolchain:defs.bzl", "info") info( name = "local", diff --git a/rules_toolchain/toolchain/defs.bzl b/rules_toolchain/toolchain/defs.bzl new file mode 100644 index 0000000..84ca8b0 --- /dev/null +++ b/rules_toolchain/toolchain/defs.bzl @@ -0,0 +1,3 @@ +load("//toolchain/info:defs.bzl", _info = "info") + +info = _info diff --git a/rules_toolchain/toolchain/info/BUILD.bazel b/rules_toolchain/toolchain/info/BUILD.bazel index e69de29..c39fd79 100644 --- a/rules_toolchain/toolchain/info/BUILD.bazel +++ b/rules_toolchain/toolchain/info/BUILD.bazel @@ -0,0 +1,17 @@ +load(":binary.bzl", "binary") +load(":rule.bzl", "info") +load(":test.bzl", "test") + +binary( + name = "binary", +) + +info( + name = "info", + binary = ":binary", +) + +test( + name = "test", + target_under_test = ":info", +) diff --git a/rules_toolchain/toolchain/info/TargetInfo.bzl b/rules_toolchain/toolchain/info/TargetInfo.bzl new file mode 100644 index 0000000..250c4ca --- /dev/null +++ b/rules_toolchain/toolchain/info/TargetInfo.bzl @@ -0,0 +1,19 @@ +def init(env): + """ + Initialises a `TargetInfo` instance. + + Args: + env: Environment variables to be exposed. + + Returns: + A mapping of keywords for the `target_info` raw constructor. + """ + return { + "env": env, + } + +TargetInfo, target_info = provider( + "Information about a toolchain target that is used to construct a `DataInfo`", + fields = ["env"], + init = init, +) diff --git a/rules_toolchain/toolchain/local/info/binary.bzl b/rules_toolchain/toolchain/info/binary.bzl similarity index 62% rename from rules_toolchain/toolchain/local/info/binary.bzl rename to rules_toolchain/toolchain/info/binary.bzl index 9bf1313..87f8e3e 100644 --- a/rules_toolchain/toolchain/local/info/binary.bzl +++ b/rules_toolchain/toolchain/info/binary.bzl @@ -1,22 +1,22 @@ -load("//toolchain/local:defs.bzl", "BinaryInfo") +load(":TargetInfo.bzl", "TargetInfo") ATTRS = {} def implementation(ctx): output = ctx.actions.declare_file(ctx.label.name) - info = BinaryInfo( - program = output.basename, - path = output.path, - variable = output.basename.upper(), - ) - ctx.actions.write( output = output, content = "#!/bin/sh", is_executable = True, ) + info = TargetInfo( + env = { + output.basename.upper(): output.path, + }, + ) + default = DefaultInfo( executable = output, files = depset([output]), @@ -26,9 +26,9 @@ def implementation(ctx): return [info, default] binary = rule( - doc = "Creates a executable binary target file around a local binary path", + doc = "Creates a stub executable binary target.", attrs = ATTRS, implementation = implementation, - provides = [BinaryInfo], + provides = [TargetInfo], executable = True, ) diff --git a/rules_toolchain/toolchain/info/defs.bzl b/rules_toolchain/toolchain/info/defs.bzl new file mode 100644 index 0000000..32b2199 --- /dev/null +++ b/rules_toolchain/toolchain/info/defs.bzl @@ -0,0 +1,7 @@ +load("//toolchain/info:DataInfo.bzl", _DataInfo = "DataInfo") +load("//toolchain/info:TargetInfo.bzl", _TargetInfo = "TargetInfo") +load("//toolchain/info:rule.bzl", _info = "info") + +DataInfo = _DataInfo +TargetInfo = _TargetInfo +info = _info diff --git a/rules_toolchain/toolchain/local/info/rule.bzl b/rules_toolchain/toolchain/info/rule.bzl similarity index 67% rename from rules_toolchain/toolchain/local/info/rule.bzl rename to rules_toolchain/toolchain/info/rule.bzl index 6c8749b..077b129 100644 --- a/rules_toolchain/toolchain/local/info/rule.bzl +++ b/rules_toolchain/toolchain/info/rule.bzl @@ -1,5 +1,6 @@ -load("//toolchain/local/binary:BinaryInfo.bzl", "BinaryInfo") -load("//toolchain/info:DataInfo.bzl", "DataInfo") +load("@bazel_skylib//lib:structs.bzl", "structs") +load(":TargetInfo.bzl", "TargetInfo") +load(":DataInfo.bzl", "DataInfo") ATTRS = { "binary": attr.label( @@ -7,23 +8,21 @@ ATTRS = { allow_single_file = True, mandatory = True, cfg = "exec", - providers = [BinaryInfo], + providers = [TargetInfo], + executable = True, ), } def implementation(ctx): - binary = ctx.attr.binary[BinaryInfo] + target = ctx.attr.binary[TargetInfo] data = DataInfo( target = ctx.attr.binary, executable = ctx.file.binary, - env = { - binary.variable: str(ctx.file.binary.path), - }, + **{k: v for k, v in structs.to_dict(target).items()} ) return [ platform_common.ToolchainInfo(data = data), data, - binary, ] info = rule( @@ -33,6 +32,5 @@ info = rule( provides = [ platform_common.ToolchainInfo, DataInfo, - BinaryInfo, ], ) diff --git a/rules_toolchain/toolchain/local/info/test.bzl b/rules_toolchain/toolchain/info/test.bzl similarity index 100% rename from rules_toolchain/toolchain/local/info/test.bzl rename to rules_toolchain/toolchain/info/test.bzl diff --git a/rules_toolchain/toolchain/local/binary/rule.bzl b/rules_toolchain/toolchain/local/binary/rule.bzl index a82c0c1..82cfa37 100644 --- a/rules_toolchain/toolchain/local/binary/rule.bzl +++ b/rules_toolchain/toolchain/local/binary/rule.bzl @@ -1,4 +1,5 @@ load(":BinaryInfo.bzl", "BinaryInfo") +load("//toolchain/info:TargetInfo.bzl", "TargetInfo") ATTRS = { "path": attr.string( @@ -20,34 +21,44 @@ ATTRS = { def implementation(ctx): program = ctx.attr.program or ctx.label.name - info = BinaryInfo( + binary = BinaryInfo( program = program, path = ctx.attr.path, variable = ctx.attr.variable or program.upper(), ) - output = ctx.actions.declare_file(info.program) + output = ctx.actions.declare_file(binary.program) ctx.actions.expand_template( template = ctx.file.template, output = output, substitutions = { - "{{path}}": info.path, + "{{path}}": binary.path, }, is_executable = True, ) + target = TargetInfo( + env = { + binary.variable: output.path, + }, + ) + default = DefaultInfo( executable = output, files = depset([output]), runfiles = ctx.runfiles([output]), ) - return [info, default] + return [binary, target, default] binary = rule( doc = "Creates a executable binary target file around a local binary path", attrs = ATTRS, implementation = implementation, - provides = [BinaryInfo], + provides = [ + BinaryInfo, + TargetInfo, + DefaultInfo, + ], executable = True, ) diff --git a/rules_toolchain/toolchain/local/defs.bzl b/rules_toolchain/toolchain/local/defs.bzl index 37c5d70..8be1870 100644 --- a/rules_toolchain/toolchain/local/defs.bzl +++ b/rules_toolchain/toolchain/local/defs.bzl @@ -1,7 +1,5 @@ load("//toolchain/local/binary:BinaryInfo.bzl", _BinaryInfo = "BinaryInfo") load("//toolchain/local/binary:rule.bzl", _binary = "binary") -load("//toolchain/local/info:rule.bzl", _info = "info") BinaryInfo = _BinaryInfo binary = _binary -info = _info diff --git a/rules_toolchain/toolchain/local/info/BUILD.bazel b/rules_toolchain/toolchain/local/info/BUILD.bazel deleted file mode 100644 index c39fd79..0000000 --- a/rules_toolchain/toolchain/local/info/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load(":binary.bzl", "binary") -load(":rule.bzl", "info") -load(":test.bzl", "test") - -binary( - name = "binary", -) - -info( - name = "info", - binary = ":binary", -) - -test( - name = "test", - target_under_test = ":info", -) -- GitLab From 7de77146b9cc2f078775a417960026b6dbc02680 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 3 Oct 2023 12:27:17 +0100 Subject: [PATCH 11/55] feat(rules_toolchain): add triplet targets and information --- rules_toolchain/MODULE.bazel | 1 + .../toolchain/constraint/cpu/BUILD.bazel | 13 +++ .../toolchain/constraint/libc/BUILD.bazel | 8 ++ .../toolchain/constraint/libc/gnu/BUILD.bazel | 87 +++++++++++++++++++ .../toolchain/constraint/os/BUILD.bazel | 12 +++ .../toolchain/constraint/os/linux/BUILD.bazel | 17 ++++ rules_toolchain/toolchain/triplet/BUILD.bazel | 17 ++++ .../toolchain/triplet/TripletInfo.bzl | 55 ++++++++++++ .../toolchain/triplet/VersionInfo.bzl | 50 +++++++++++ .../toolchain/triplet/VersionedInfo.bzl | 36 ++++++++ rules_toolchain/toolchain/triplet/common.bzl | 6 ++ rules_toolchain/toolchain/triplet/rule.bzl | 43 +++++++++ rules_toolchain/toolchain/triplet/split.bzl | 27 ++++++ rules_toolchain/toolchain/triplet/test.bzl | 25 ++++++ .../toolchain/triplet/unversioned.bzl | 19 ++++ 15 files changed, 416 insertions(+) create mode 100644 rules_toolchain/toolchain/constraint/cpu/BUILD.bazel create mode 100644 rules_toolchain/toolchain/constraint/libc/BUILD.bazel create mode 100644 rules_toolchain/toolchain/constraint/libc/gnu/BUILD.bazel create mode 100644 rules_toolchain/toolchain/constraint/os/BUILD.bazel create mode 100644 rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel create mode 100644 rules_toolchain/toolchain/triplet/BUILD.bazel create mode 100644 rules_toolchain/toolchain/triplet/TripletInfo.bzl create mode 100644 rules_toolchain/toolchain/triplet/VersionInfo.bzl create mode 100644 rules_toolchain/toolchain/triplet/VersionedInfo.bzl create mode 100644 rules_toolchain/toolchain/triplet/common.bzl create mode 100644 rules_toolchain/toolchain/triplet/rule.bzl create mode 100644 rules_toolchain/toolchain/triplet/split.bzl create mode 100644 rules_toolchain/toolchain/triplet/test.bzl create mode 100644 rules_toolchain/toolchain/triplet/unversioned.bzl diff --git a/rules_toolchain/MODULE.bazel b/rules_toolchain/MODULE.bazel index 89367aa..ff57681 100644 --- a/rules_toolchain/MODULE.bazel +++ b/rules_toolchain/MODULE.bazel @@ -3,3 +3,4 @@ module( ) bazel_dep(name = "bazel_skylib", version = "1.4.2") +bazel_dep(name = "platforms", version = "0.0.7") diff --git a/rules_toolchain/toolchain/constraint/cpu/BUILD.bazel b/rules_toolchain/toolchain/constraint/cpu/BUILD.bazel new file mode 100644 index 0000000..7f3bbf0 --- /dev/null +++ b/rules_toolchain/toolchain/constraint/cpu/BUILD.bazel @@ -0,0 +1,13 @@ +package(default_visibility = ["//visibility:public"]) + +# TODO: add more CPU aliases when we are ready to support them. +[ + alias( + name = v, + actual = "@platforms//cpu:{}".format(v), + ) + for v in ( + "aarch64", + "x86_64", + ) +] diff --git a/rules_toolchain/toolchain/constraint/libc/BUILD.bazel b/rules_toolchain/toolchain/constraint/libc/BUILD.bazel new file mode 100644 index 0000000..bddb17a --- /dev/null +++ b/rules_toolchain/toolchain/constraint/libc/BUILD.bazel @@ -0,0 +1,8 @@ +package(default_visibility = ["//visibility:public"]) + +constraint_setting(name = "libc") + +constraint_value( + name = "gnu", + constraint_setting = ":libc", +) diff --git a/rules_toolchain/toolchain/constraint/libc/gnu/BUILD.bazel b/rules_toolchain/toolchain/constraint/libc/gnu/BUILD.bazel new file mode 100644 index 0000000..1b73c64 --- /dev/null +++ b/rules_toolchain/toolchain/constraint/libc/gnu/BUILD.bazel @@ -0,0 +1,87 @@ +package(default_visibility = ["//visibility:public"]) + +constraint_setting(name = "gnu") + +# git ls-remote --tags https://sourceware.org/git/glibc.git | +# awk '{print $2}' | +# grep -oe 'glibc-2\.[0-9]\+\(\.[0-9]\+\)\?$' | +# grep -ve '\.\(9[0-9]\|1[0-1][0-9]\|9000\)$' | +# sort -V | +# uniq | +# sed 's|glibc-\(.\+\)| "\1",|g' +VERSIONS = ( + "2.0.2", + "2.0.4", + "2.0.5", + "2.0.6", + "2.1", + "2.1.1", + "2.1.2", + "2.2", + "2.2.1", + "2.2.2", + "2.2.3", + "2.2.4", + "2.2.5", + "2.3", + "2.3.1", + "2.3.2", + "2.3.3", + "2.3.4", + "2.3.5", + "2.3.6", + "2.4", + "2.5", + "2.5.1", + "2.6", + "2.6.1", + "2.7", + "2.8", + "2.9", + "2.10", + "2.10.1", + "2.10.2", + "2.11", + "2.11.1", + "2.11.2", + "2.11.3", + "2.12", + "2.12.1", + "2.12.2", + "2.13", + "2.14", + "2.14.1", + "2.15", + "2.16", + "2.16.0", + "2.17", + "2.18", + "2.19", + "2.20", + "2.21", + "2.22", + "2.23", + "2.24", + "2.25", + "2.26", + "2.27", + "2.28", + "2.29", + "2.30", + "2.31", + "2.32", + "2.33", + "2.34", + "2.35", + "2.36", + "2.37", + "2.38", +) + +[ + constraint_value( + name = version, + constraint_setting = ":gnu", + ) + for version in VERSIONS +] diff --git a/rules_toolchain/toolchain/constraint/os/BUILD.bazel b/rules_toolchain/toolchain/constraint/os/BUILD.bazel new file mode 100644 index 0000000..642cd8e --- /dev/null +++ b/rules_toolchain/toolchain/constraint/os/BUILD.bazel @@ -0,0 +1,12 @@ +package(default_visibility = ["//visibility:public"]) + +# TODO: add more OS aliases when we are ready to support them. +[ + alias( + name = v, + actual = "@platforms//os:{}".format(v), + ) + for v in ( + "linux", + ) +] diff --git a/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel b/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel new file mode 100644 index 0000000..2f56aae --- /dev/null +++ b/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel @@ -0,0 +1,17 @@ +package(default_visibility = ["//visibility:public"]) + +constraint_setting(name = "linux") + +# TODO: figure out a way to generate these +VERSIONS = ( + "3.11.13", + "6.3.0", +) + +[ + constraint_value( + name = version, + constraint_setting = ":linux", + ) + for version in VERSIONS +] diff --git a/rules_toolchain/toolchain/triplet/BUILD.bazel b/rules_toolchain/toolchain/triplet/BUILD.bazel new file mode 100644 index 0000000..0249abf --- /dev/null +++ b/rules_toolchain/toolchain/triplet/BUILD.bazel @@ -0,0 +1,17 @@ +load("@bazel_skylib//lib:sets.bzl", "sets") +load(":common.bzl", "TRIPLETS") +load(":rule.bzl", "triplet") +load(":test.bzl", "test") + +[ + triplet( + name = value, + visibility = ["//visibility:public"], + ) + for value in sets.to_list(TRIPLETS) +] + +test( + name = "test", + target_under_test = ":amd64-linux-gnu", +) diff --git a/rules_toolchain/toolchain/triplet/TripletInfo.bzl b/rules_toolchain/toolchain/triplet/TripletInfo.bzl new file mode 100644 index 0000000..58095aa --- /dev/null +++ b/rules_toolchain/toolchain/triplet/TripletInfo.bzl @@ -0,0 +1,55 @@ +load("@bazel_skylib//lib:types.bzl", "types") +load(":VersionedInfo.bzl", "VersionedInfo") +load(":split.bzl", "split") + +def init(value): + """ + Initializes a `TripletInfo` provider. + + Processes `value` into the constituent parts. + + Args: + value: A machine triplet which can be kebab-separated such as `aarch64-linux-gnu.2.19` + + Returns: + A mapping of keywords for the `triplet_info` raw constructor. + """ + if not types.is_string(value): + fail("`TripletInfo.value` must be a `str`: {}".format(value)) + + cpu, vendor, os, libc = split(value, "-", { + 3: lambda c, o, l: (c, None, o, l), + 4: lambda c, v, o, l: (c, v, o, l), + }) + + os = VersionedInfo(os) + libc = VersionedInfo(libc) + + constraints = [ + "cpu:{}".format(cpu), + "os:{}".format(os.kind), + "libc:{}".format(libc.kind), + ] + + if os.version: + constraints.append("os/{}:{}".format(os.kind, os.version.value)) + if libc.version: + constraints.append("libc/{}:{}".format(libc.kind, libc.version.value)) + + return { + "value": value, + "cpu": cpu, + "vendor": vendor, + "os": os, + "libc": libc, + "constraints": tuple([ + Label("//toolchain/constraint/{}".format(c)) + for c in constraints + ]), + } + +TripletInfo, triplet_info = provider( + "A machine triplet. Has the associated compatible Bazel constraints.", + fields = ("value", "cpu", "vendor", "os", "libc", "constraints"), + init = init, +) diff --git a/rules_toolchain/toolchain/triplet/VersionInfo.bzl b/rules_toolchain/toolchain/triplet/VersionInfo.bzl new file mode 100644 index 0000000..66365b3 --- /dev/null +++ b/rules_toolchain/toolchain/triplet/VersionInfo.bzl @@ -0,0 +1,50 @@ +load("@bazel_skylib//lib:types.bzl", "types") +load(":split.bzl", "split") + +def init(value): + """ + Initializes a `VersionInfo` provider. + + Processes `value` into a semantic version[1] + + [1]: semver.org + + Args: + value: A semantic version such as `1.2.3`, `0.1.0-beta.1` or `1.0.0+aefc24ef`. + + Returns: + A mapping of keywords for the `version_info` raw constructor. + """ + if not types.is_string(value): + fail("`VersionInfo.value` must be a `str`: {}".format(value)) + + prefix, build = split(value, "+", { + 1: lambda a: (a, None), + 2: lambda a, b: (a, b), + }) + + prefix, pre = split(prefix, "-", { + 1: lambda a: (a, None), + 2: lambda a, b: (a, b), + }) + + major, minor, patch = split(prefix, ".", { + 1: lambda a: (a, 0, 0), + 2: lambda a, b: (a, b, 0), + 3: lambda a, b, c: (a, b, c), + }) + + return { + "value": value, + "major": int(major), + "minor": int(minor), + "patch": int(patch), + "pre": pre, + "build": build, + } + +VersionInfo, version_info = provider( + "A semantic version.", + fields = ["value", "major", "minor", "patch", "pre", "build"], + init = init, +) diff --git a/rules_toolchain/toolchain/triplet/VersionedInfo.bzl b/rules_toolchain/toolchain/triplet/VersionedInfo.bzl new file mode 100644 index 0000000..85b2d81 --- /dev/null +++ b/rules_toolchain/toolchain/triplet/VersionedInfo.bzl @@ -0,0 +1,36 @@ +load("@bazel_skylib//lib:types.bzl", "types") +load(":VersionInfo.bzl", "VersionInfo") + +def init(value): + """ + Initializes a `VersionedInfo` provider. + + Processes `value` into a `kind` and semantic version. + + Args: + value: A part of a full triplet which can be dot-separated such as `gnu.2.19` + + Returns: + A mapping of keywords for the `versioned_info` raw constructor. + """ + if not types.is_string(value): + fail("`VersionedInfo.value` must be a `str`: {}".format(value)) + + parts = value.split(".") + kind = parts[0] + version = ".".join(parts[1:]) or None + + if version: + version = VersionInfo(version) + + return { + "value": value, + "kind": kind, + "version": version, + } + +VersionedInfo, versioned_info = provider( + "A versioned triplet part.", + fields = ["value", "kind", "version"], + init = init, +) diff --git a/rules_toolchain/toolchain/triplet/common.bzl b/rules_toolchain/toolchain/triplet/common.bzl new file mode 100644 index 0000000..fe79222 --- /dev/null +++ b/rules_toolchain/toolchain/triplet/common.bzl @@ -0,0 +1,6 @@ +load("@bazel_skylib//lib:sets.bzl", "sets") + +TRIPLETS = sets.make(( + "arm64-linux-gnu", + "amd64-linux-gnu", +)) diff --git a/rules_toolchain/toolchain/triplet/rule.bzl b/rules_toolchain/toolchain/triplet/rule.bzl new file mode 100644 index 0000000..3f40268 --- /dev/null +++ b/rules_toolchain/toolchain/triplet/rule.bzl @@ -0,0 +1,43 @@ +load(":TripletInfo.bzl", "TripletInfo") + +ATTRS = { + "value": attr.string( + doc = "A triplet value that overrides `name`.", + ), +} + +def implementation(ctx): + value = ctx.attr.value or ctx.label.name + triplet = TripletInfo(value) + + output = ctx.actions.declare_file("{}.txt".format(value)) + ctx.actions.write( + output = output, + content = value, + ) + + executable = ctx.actions.declare_file("{}.sh".format(value)) + ctx.actions.write( + output = executable, + content = "#!/bin/sh\nprintf '%s\n' {}".format(value), + is_executable = True, + ) + + default = DefaultInfo( + executable = executable, + files = depset([output]), + runfiles = ctx.runfiles([output]), + ) + + return [triplet, default] + +triplet = rule( + doc = "Provies a machine triplet", + attrs = ATTRS, + implementation = implementation, + provides = [ + DefaultInfo, + TripletInfo, + ], + executable = True, +) diff --git a/rules_toolchain/toolchain/triplet/split.bzl b/rules_toolchain/toolchain/triplet/split.bzl new file mode 100644 index 0000000..c85dd80 --- /dev/null +++ b/rules_toolchain/toolchain/triplet/split.bzl @@ -0,0 +1,27 @@ +def split(value, delimiter, map): + """ + Splits a value and invokes a callback based on the number of split elements. + + ``` + a, b = split("a.b", ".", { + 1: lambda a: (major, None), + 2: lambda a, b: (major, minor), + }) + + ``` + + Args: + value: The value to invoke `.split` on, often a `str`. + delimiter: The argument to pass to `.split` which delimits the split parts. + map: A `Mapping[int, callable]` that processes the split parts. + + Returns: + The result of the matching callable + """ + parts = value.split(delimiter) + length = len(parts) + + def _fail(*_): + fail("No callable specified for a split length of `{}` with `{}` on `{}`".format(length, delimiter, value)) + + return map.get(length, _fail)(*parts) diff --git a/rules_toolchain/toolchain/triplet/test.bzl b/rules_toolchain/toolchain/triplet/test.bzl new file mode 100644 index 0000000..1790eb7 --- /dev/null +++ b/rules_toolchain/toolchain/triplet/test.bzl @@ -0,0 +1,25 @@ +load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") +load(":TripletInfo.bzl", "TripletInfo") +load(":unversioned.bzl", "unversioned") + +def implementation(ctx): + env = analysistest.begin(ctx) + target = analysistest.target_under_test(env) + info = target[TripletInfo] + asserts.equals(env, "amd64-linux-gnu", info.value) + asserts.equals(env, "amd64", info.cpu) + asserts.equals(env, "linux", info.os.kind) + asserts.equals(env, None, info.os.version) + asserts.equals(env, "gnu", info.libc.kind) + asserts.equals(env, None, info.libc.version) + asserts.equals(env, info.constraints, ( + Label("//toolchain/constraint/cpu:amd64"), + Label("//toolchain/constraint/os:linux"), + Label("//toolchain/constraint/libc:gnu"), + )) + asserts.equals(env, unversioned(info).value, "amd64-linux-gnu") + return analysistest.end(env) + +triplet_test = analysistest.make(implementation) + +test = triplet_test diff --git a/rules_toolchain/toolchain/triplet/unversioned.bzl b/rules_toolchain/toolchain/triplet/unversioned.bzl new file mode 100644 index 0000000..a76780d --- /dev/null +++ b/rules_toolchain/toolchain/triplet/unversioned.bzl @@ -0,0 +1,19 @@ +load(":TripletInfo.bzl", "TripletInfo") + +def unversioned(triplet): + """ + Converts a `TripletInfo` into an unversioned one. + + Args: + triplet: the `TripletInfo` to remove version numbers from. + + Returns: + An unversioned `TripletInfo` + """ + parts = ( + triplet.cpu, + triplet.vendor, + triplet.os.kind, + triplet.libc.kind, + ) + return TripletInfo("-".join([p for p in parts if p != None])) -- GitLab From 445ce43b43795f16ed2d660138f89367b94ce095 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 3 Oct 2023 14:13:10 +0100 Subject: [PATCH 12/55] feat(rules_toolchain): add host triplet detection To see the detected host triplet: ``` bazelisk run @rules_toolchain//toolchain/triplet:host ``` --- rules_toolchain/MODULE.bazel | 6 ++ rules_toolchain/e2e/host/BUILD.bazel | 14 ++++ rules_toolchain/e2e/host/non-empty.sh | 40 +++++++++++ rules_toolchain/toolchain/defs.bzl | 2 + rules_toolchain/toolchain/host/BUILD.bazel | 8 +++ rules_toolchain/toolchain/host/extension.bzl | 17 +++++ .../toolchain/host/triplet/BUILD.bazel | 0 .../toolchain/host/triplet/cpu.bzl | 14 ++++ .../toolchain/host/triplet/detect.bzl | 11 +++ .../toolchain/host/triplet/libc.bzl | 72 +++++++++++++++++++ rules_toolchain/toolchain/host/triplet/os.bzl | 66 +++++++++++++++++ .../toolchain/host/triplet/repository.bzl | 23 ++++++ .../toolchain/host/triplet/triplet.tmpl.bzl | 3 + rules_toolchain/toolchain/triplet/BUILD.bazel | 6 ++ 14 files changed, 282 insertions(+) create mode 100644 rules_toolchain/e2e/host/BUILD.bazel create mode 100755 rules_toolchain/e2e/host/non-empty.sh create mode 100644 rules_toolchain/toolchain/host/BUILD.bazel create mode 100644 rules_toolchain/toolchain/host/extension.bzl create mode 100644 rules_toolchain/toolchain/host/triplet/BUILD.bazel create mode 100644 rules_toolchain/toolchain/host/triplet/cpu.bzl create mode 100644 rules_toolchain/toolchain/host/triplet/detect.bzl create mode 100644 rules_toolchain/toolchain/host/triplet/libc.bzl create mode 100644 rules_toolchain/toolchain/host/triplet/os.bzl create mode 100644 rules_toolchain/toolchain/host/triplet/repository.bzl create mode 100644 rules_toolchain/toolchain/host/triplet/triplet.tmpl.bzl diff --git a/rules_toolchain/MODULE.bazel b/rules_toolchain/MODULE.bazel index ff57681..aba81b6 100644 --- a/rules_toolchain/MODULE.bazel +++ b/rules_toolchain/MODULE.bazel @@ -4,3 +4,9 @@ module( bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "platforms", version = "0.0.7") + +host = use_extension("//toolchain/host:extension.bzl", "host") +host.triplet( + name = "host", +) +use_repo(host, "host") diff --git a/rules_toolchain/e2e/host/BUILD.bazel b/rules_toolchain/e2e/host/BUILD.bazel new file mode 100644 index 0000000..d3c16e5 --- /dev/null +++ b/rules_toolchain/e2e/host/BUILD.bazel @@ -0,0 +1,14 @@ +genrule( + name = "data", + testonly = True, + srcs = ["@rules_toolchain//toolchain/triplet:host"], + outs = ["triplet.txt"], + cmd = "cp $< $@", +) + +sh_test( + name = "test", + srcs = ["non-empty.sh"], + args = ["triplet.txt"], + data = [":data"], +) diff --git a/rules_toolchain/e2e/host/non-empty.sh b/rules_toolchain/e2e/host/non-empty.sh new file mode 100755 index 0000000..4be205c --- /dev/null +++ b/rules_toolchain/e2e/host/non-empty.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# e: quit on command errors +# u: quit on undefined variables +set -eu + +# Test setup +TEST_SCRIPT="${TEST_BINARY?TEST_BINARY is unset}" +TEST_FOLDER="${TEST_SCRIPT%/*}" +TEST_DATA="${TEST_FOLDER}/${1}" +readonly TEST_FOLDER TEST_DATA + +# Validate the test data +if ! test -f "${TEST_DATA}"; then + echo >&2 "Missing test DATA: ${TEST_DATA}" + tree + exit 2 +elif ! test -r "${TEST_DATA}"; then + echo >&2 "Unreadable test DATA: ${TEST_DATA}" + exit 2 +fi + +# Check no extra lines +while IFS="-" read -r CPU ARCH LIBC; do + echo >&2 "Unexpected line: ${CPU}-${ARCH}-${LIBC}" + exit 1 +done <"${TEST_DATA}" + +if test -z "${CPU}"; then + echo >&2 "Empty CPU" + exit 1 +fi +if test -z "${ARCH}"; then + echo >&2 "Empty ARCH" + exit 1 +fi +if test -z "${LIBC}"; then + echo >&2 "Empty LIBC" + exit 1 +fi diff --git a/rules_toolchain/toolchain/defs.bzl b/rules_toolchain/toolchain/defs.bzl index 84ca8b0..143d3b8 100644 --- a/rules_toolchain/toolchain/defs.bzl +++ b/rules_toolchain/toolchain/defs.bzl @@ -1,3 +1,5 @@ +load("//toolchain/triplet:TripletInfo.bzl", _TripletInfo = "TripletInfo") load("//toolchain/info:defs.bzl", _info = "info") +ToolchainTripletInfo = _TripletInfo info = _info diff --git a/rules_toolchain/toolchain/host/BUILD.bazel b/rules_toolchain/toolchain/host/BUILD.bazel new file mode 100644 index 0000000..767c4f3 --- /dev/null +++ b/rules_toolchain/toolchain/host/BUILD.bazel @@ -0,0 +1,8 @@ +load("@host//:triplet.bzl", "TRIPLET") +load("//toolchain/triplet:rule.bzl", "triplet") + +triplet( + name = "triplet", + value = TRIPLET.value, + visibility = ["//visibility:public"], +) diff --git a/rules_toolchain/toolchain/host/extension.bzl b/rules_toolchain/toolchain/host/extension.bzl new file mode 100644 index 0000000..c984daa --- /dev/null +++ b/rules_toolchain/toolchain/host/extension.bzl @@ -0,0 +1,17 @@ +load("//toolchain/host/triplet:repository.bzl", _TRIPLET = "ATTRS", _triplet = "triplet") + +triplet = tag_class(attrs = { + "name": attr.string(doc = "Name of the generated repository.", mandatory = True), +} | _TRIPLET) + +def implementation(mctx): + for mod in mctx.modules: + for d in mod.tags.triplet: + _triplet(name = d.name, **{a: getattr(d, a) for a in _TRIPLET}) + +host = module_extension( + implementation = implementation, + tag_classes = { + "triplet": triplet, + }, +) diff --git a/rules_toolchain/toolchain/host/triplet/BUILD.bazel b/rules_toolchain/toolchain/host/triplet/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/host/triplet/cpu.bzl b/rules_toolchain/toolchain/host/triplet/cpu.bzl new file mode 100644 index 0000000..90b996d --- /dev/null +++ b/rules_toolchain/toolchain/host/triplet/cpu.bzl @@ -0,0 +1,14 @@ +def cpu(rctx): + """ + Detects the host CPU. + + Args: + rctx: the repository context to use for detection. + + Return: + A CPU string. + """ + return { + "amd64": "amd64", + "arm64": "arm64", + }[rctx.os.arch] diff --git a/rules_toolchain/toolchain/host/triplet/detect.bzl b/rules_toolchain/toolchain/host/triplet/detect.bzl new file mode 100644 index 0000000..29b0af0 --- /dev/null +++ b/rules_toolchain/toolchain/host/triplet/detect.bzl @@ -0,0 +1,11 @@ +load("//toolchain/triplet:TripletInfo.bzl", "TripletInfo") +load(":cpu.bzl", "cpu") +load(":os.bzl", "os") +load(":libc.bzl", "libc") + +def detect(rctx): + return TripletInfo("{}-{}-{}".format( + cpu(rctx), + os(rctx).value, + libc(rctx).value, + )) diff --git a/rules_toolchain/toolchain/host/triplet/libc.bzl b/rules_toolchain/toolchain/host/triplet/libc.bzl new file mode 100644 index 0000000..9f32aad --- /dev/null +++ b/rules_toolchain/toolchain/host/triplet/libc.bzl @@ -0,0 +1,72 @@ +load("//toolchain/triplet:VersionedInfo.bzl", "VersionedInfo") +load("//toolchain/triplet:split.bzl", "split") + +def _unquote(value): + if value[0] == '"' and value[-1] == '"': + return value[1:-1] + return value + +def _release(rctx, path): + data = struct(**{ + k.lower(): _unquote(v) + for line in rctx.read(path).splitlines() + if "=" in line + for k, v in line.split("=", 1) + }) + + if data.id in ("arch", "debian", "fedora"): + return VersionedInfo("gnu") + + if data.id in ("alpine",): + return VersionedInfo("musl") + + if data.id_like in ("debian",): + return VersionedInfo("gnu") + + fail("Failed to determine host C library from `{}`".format(path)) + +def _ldd(rctx, path): + result = rctx.execute([path, "--version"]) + if result.return_code != 0: + fail("Failed to retrieve `ldd` version output:\n{}".format(result.stderr)) + + first, second = result.stdout.strip().splitlines()[:2] + + if first.startswith("musl lib"): + version = split(second, " ", { + 2: lambda _, v: v, + }) + return VersionedInfo("musl.{}".format(version)) + + if first.startswith("ldd") and "Free Software Foundation" in second: + _, _, description = first.partition(" (") + description, _, version = description.rpartition(") ") + version = version + + if description == "GNU libc": + return VersionedInfo("gnu.{}".format(version)) + + if description.startswith("Debian GLIBC"): + return VersionedInfo("gnu.{}".format(version)) + + fail("Failed to detect `{}` version:\n{}".format(path, result.stdout)) + +def libc(rctx): + """ + Detects the host C library. + + Args: + rctx: the repository context to use for detection. + + Return: + A `VersionedInfo` operating system triplet part. + """ + path = rctx.which("ldd") + if path: + return _ldd(rctx, path) + + path = rctx.path("/etc/os-release") + if path.exists: + return _release(rctx, path) + + fail("Failed to detect host C library") diff --git a/rules_toolchain/toolchain/host/triplet/os.bzl b/rules_toolchain/toolchain/host/triplet/os.bzl new file mode 100644 index 0000000..85c1541 --- /dev/null +++ b/rules_toolchain/toolchain/host/triplet/os.bzl @@ -0,0 +1,66 @@ +load("//toolchain/triplet:VersionedInfo.bzl", "VersionedInfo") + +def _header(rctx, path): + """ + Reads the Linux version header to determine the correct Linux version. + + Args: + rctx: The repository context that can execute commands on the host machine. + path: the path to the Linux version header to read. + + Returns: + The dot-separated version string. + """ + data = rctx.read(path).strip() + + def _split(line): + if not line.startswith("#define"): + return (None, None) + + _, name, value = line.split(" ", 2) + + if "(" in name: + return (None, None) + + name = name.removeprefix("LINUX_VERSION_").lower() + + return (name, value) + + pairs = [_split(line) for line in data.splitlines()] + map = {k: v for k, v in pairs if k and v} + + major = map.get("major", None) + minor = map.get("patchlevel", None) + patch = map.get("sublevel", None) + + if major and minor and patch: + return VersionedInfo("linux.{}.{}.{}".format(int(major), int(minor), int(patch))) + + if "code" not in map: + fail("Failed to find a `LINUX_VERSION_CODE` in {}".format(path)) + + code = int(map["code"]) + + major = (code >> 16) & 0xFF + minor = (code >> 8) & 0xFF + patch = (code >> 0) & 0xFF + + return VersionedInfo("linux.{}.{}.{}".format(major, minor, patch)) + +def os(rctx): + """ + Detects the host operating system. + + Args: + rctx: the repository context to use for detection. + + Return: + A `VersionedInfo` operating system triplet part. + """ + path = rctx.path("/usr/include/linux/version.h") + if path.exists: + return _header(rctx, path) + + return VersionedInfo({ + "linux": "linux", + }[rctx.os.name]) diff --git a/rules_toolchain/toolchain/host/triplet/repository.bzl b/rules_toolchain/toolchain/host/triplet/repository.bzl new file mode 100644 index 0000000..3984a32 --- /dev/null +++ b/rules_toolchain/toolchain/host/triplet/repository.bzl @@ -0,0 +1,23 @@ +load(":detect.bzl", "detect") + +ATTRS = { + "template": attr.label( + doc = "The template that is expanded into the `triplet.bzl`.", + default = Label(":triplet.tmpl.bzl"), + allow_single_file = True, + ), +} + +def implementation(rctx): + triplet = detect(rctx) + rctx.template("triplet.bzl", rctx.attr.template, { + "{{value}}": triplet.value, + }) + rctx.file("BUILD.bazel", "") + +triplet = repository_rule( + doc = "Detects the host triplet.", + implementation = implementation, + attrs = ATTRS, + local = True, +) diff --git a/rules_toolchain/toolchain/host/triplet/triplet.tmpl.bzl b/rules_toolchain/toolchain/host/triplet/triplet.tmpl.bzl new file mode 100644 index 0000000..33decde --- /dev/null +++ b/rules_toolchain/toolchain/host/triplet/triplet.tmpl.bzl @@ -0,0 +1,3 @@ +load("@rules_toolchain//toolchain:defs.bzl", "TripletInfo") + +TRIPLET = TripletInfo("{{value}}") diff --git a/rules_toolchain/toolchain/triplet/BUILD.bazel b/rules_toolchain/toolchain/triplet/BUILD.bazel index 0249abf..fb7dafc 100644 --- a/rules_toolchain/toolchain/triplet/BUILD.bazel +++ b/rules_toolchain/toolchain/triplet/BUILD.bazel @@ -11,6 +11,12 @@ load(":test.bzl", "test") for value in sets.to_list(TRIPLETS) ] +alias( + name = "host", + actual = "//toolchain/host:triplet", + visibility = ["//visibility:public"], +) + test( name = "test", target_under_test = ":amd64-linux-gnu", -- GitLab From 09e2490f77e733481152049f0c4f475a9dcb3a77 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 3 Oct 2023 14:16:27 +0100 Subject: [PATCH 13/55] refactor(rules_toolchain): add correct prefix to rule --- rules_toolchain/toolchain/defs.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules_toolchain/toolchain/defs.bzl b/rules_toolchain/toolchain/defs.bzl index 143d3b8..939ff85 100644 --- a/rules_toolchain/toolchain/defs.bzl +++ b/rules_toolchain/toolchain/defs.bzl @@ -2,4 +2,4 @@ load("//toolchain/triplet:TripletInfo.bzl", _TripletInfo = "TripletInfo") load("//toolchain/info:defs.bzl", _info = "info") ToolchainTripletInfo = _TripletInfo -info = _info +toolchain_info = _info -- GitLab From 8c22fdbaef91b26ba227a59e73693147b3022a1f Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 3 Oct 2023 14:22:31 +0100 Subject: [PATCH 14/55] refactor(rules_toolchain): standardise on one `defs.bzl` --- rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel | 4 ++-- rules_toolchain/toolchain/defs.bzl | 4 +++- rules_toolchain/toolchain/host/triplet/triplet.tmpl.bzl | 4 ++-- rules_toolchain/toolchain/info/defs.bzl | 7 ------- rules_toolchain/toolchain/local/defs.bzl | 5 ----- rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel | 4 ++-- 6 files changed, 9 insertions(+), 19 deletions(-) delete mode 100644 rules_toolchain/toolchain/info/defs.bzl delete mode 100644 rules_toolchain/toolchain/local/defs.bzl diff --git a/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel b/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel index 7cec474..a36f031 100644 --- a/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel +++ b/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel @@ -1,6 +1,6 @@ -load("@rules_toolchain//toolchain:defs.bzl", "info") +load("@rules_toolchain//toolchain:defs.bzl", "toolchain_info") -info( +toolchain_info( name = "local", binary = "@echo//:echo", ) diff --git a/rules_toolchain/toolchain/defs.bzl b/rules_toolchain/toolchain/defs.bzl index 939ff85..501a342 100644 --- a/rules_toolchain/toolchain/defs.bzl +++ b/rules_toolchain/toolchain/defs.bzl @@ -1,5 +1,7 @@ load("//toolchain/triplet:TripletInfo.bzl", _TripletInfo = "TripletInfo") -load("//toolchain/info:defs.bzl", _info = "info") +load("//toolchain/local/binary:rule.bzl", _local_binary = "binary") +load("//toolchain/info:rule.bzl", _info = "info") ToolchainTripletInfo = _TripletInfo +toolchain_local_binary = _local_binary toolchain_info = _info diff --git a/rules_toolchain/toolchain/host/triplet/triplet.tmpl.bzl b/rules_toolchain/toolchain/host/triplet/triplet.tmpl.bzl index 33decde..da36686 100644 --- a/rules_toolchain/toolchain/host/triplet/triplet.tmpl.bzl +++ b/rules_toolchain/toolchain/host/triplet/triplet.tmpl.bzl @@ -1,3 +1,3 @@ -load("@rules_toolchain//toolchain:defs.bzl", "TripletInfo") +load("@rules_toolchain//toolchain:defs.bzl", "ToolchainTripletInfo") -TRIPLET = TripletInfo("{{value}}") +TRIPLET = ToolchainTripletInfo("{{value}}") diff --git a/rules_toolchain/toolchain/info/defs.bzl b/rules_toolchain/toolchain/info/defs.bzl deleted file mode 100644 index 32b2199..0000000 --- a/rules_toolchain/toolchain/info/defs.bzl +++ /dev/null @@ -1,7 +0,0 @@ -load("//toolchain/info:DataInfo.bzl", _DataInfo = "DataInfo") -load("//toolchain/info:TargetInfo.bzl", _TargetInfo = "TargetInfo") -load("//toolchain/info:rule.bzl", _info = "info") - -DataInfo = _DataInfo -TargetInfo = _TargetInfo -info = _info diff --git a/rules_toolchain/toolchain/local/defs.bzl b/rules_toolchain/toolchain/local/defs.bzl deleted file mode 100644 index 8be1870..0000000 --- a/rules_toolchain/toolchain/local/defs.bzl +++ /dev/null @@ -1,5 +0,0 @@ -load("//toolchain/local/binary:BinaryInfo.bzl", _BinaryInfo = "BinaryInfo") -load("//toolchain/local/binary:rule.bzl", _binary = "binary") - -BinaryInfo = _BinaryInfo -binary = _binary diff --git a/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel b/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel index 74e2851..e5ff632 100644 --- a/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel +++ b/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel @@ -1,8 +1,8 @@ -load("@rules_toolchain//toolchain/local:defs.bzl", "binary") +load("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_binary") package(default_visibility = ["//visibility:public"]) -binary( +toolchain_local_binary( name = "{{name}}", path = "{{path}}", program = "{{program}}", -- GitLab From 5f62a3a6091eb3f9bbe5e995626a6de6372b2cb6 Mon Sep 17 00:00:00 2001 From: Sebastian Birunt Date: Thu, 5 Oct 2023 09:47:42 +0200 Subject: [PATCH 15/55] fix(rules_toolchain): correct GNU libc check Do not narrow `libc` check to Debian system. --- rules_toolchain/toolchain/host/triplet/libc.bzl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rules_toolchain/toolchain/host/triplet/libc.bzl b/rules_toolchain/toolchain/host/triplet/libc.bzl index 9f32aad..593ca32 100644 --- a/rules_toolchain/toolchain/host/triplet/libc.bzl +++ b/rules_toolchain/toolchain/host/triplet/libc.bzl @@ -43,10 +43,7 @@ def _ldd(rctx, path): description, _, version = description.rpartition(") ") version = version - if description == "GNU libc": - return VersionedInfo("gnu.{}".format(version)) - - if description.startswith("Debian GLIBC"): + if description == "GNU libc" or "GLIBC" in description: return VersionedInfo("gnu.{}".format(version)) fail("Failed to detect `{}` version:\n{}".format(path, result.stdout)) -- GitLab From c81ce7f4bfa9a49e575be6036b15627812b537c7 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Mon, 9 Oct 2023 15:54:08 +0100 Subject: [PATCH 16/55] fix(rules_toolchain): local binary not found error --- rules_toolchain/toolchain/local/binary/posix.tmpl.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rules_toolchain/toolchain/local/binary/posix.tmpl.sh b/rules_toolchain/toolchain/local/binary/posix.tmpl.sh index 19e5ec8..94f11ed 100755 --- a/rules_toolchain/toolchain/local/binary/posix.tmpl.sh +++ b/rules_toolchain/toolchain/local/binary/posix.tmpl.sh @@ -9,9 +9,12 @@ EXECUTABLE="{{path}}" readonly EXECUTABLE # Validate the executable is...executable -if ! test -x "${EXECUTABLE}"; then - echo >&2 "Not executable: ${EXECUTABLE}" +if ! test -f "${EXECUTABLE}"; then + echo >&2 "Not found: ${EXECUTABLE}" exit 69 +elif ! test -x "${EXECUTABLE}"; then + echo >&2 "Not executable: ${EXECUTABLE}" + exit 123 fi # Pass on the argument to the actual executable -- GitLab From 757610d7c9208bad687013bcf03842a31df05596 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Mon, 9 Oct 2023 16:39:18 +0100 Subject: [PATCH 17/55] refactor(rules_toolchain): simplify toolchain providers This patch removes an extra layer of indirection in toolchains. The `toolchain/local/binary` rule sets up the `TemplateVariableInfo`, `ToolchainInfo` and `DefaultInfo`. The newly renamed `resolved` rule just forwards on the created providers after the toolchain resolution has happened. This removed the need to create an extra `info` rule to describe the toolchain --- rules_toolchain/e2e/MODULE.bazel | 1 + .../e2e/toolchain/echo/BUILD.bazel | 24 ++++----- rules_toolchain/e2e/toolchain/echo/content.sh | 31 ------------ .../e2e/toolchain/echo/hello-world.txt | 1 + .../e2e/toolchain/echo/info/BUILD.bazel | 6 --- .../e2e/toolchain/echo/resolved.bzl | 17 +++++++ .../e2e/toolchain/echo/variable.bzl | 14 ------ rules_toolchain/toolchain/defs.bzl | 2 - rules_toolchain/toolchain/info/BUILD.bazel | 17 ------- rules_toolchain/toolchain/info/DataInfo.bzl | 23 --------- rules_toolchain/toolchain/info/TargetInfo.bzl | 19 ------- rules_toolchain/toolchain/info/binary.bzl | 34 ------------- rules_toolchain/toolchain/info/rule.bzl | 36 -------------- rules_toolchain/toolchain/info/test.bzl | 12 ----- .../toolchain/local/binary/rule.bzl | 45 ++++++++--------- rules_toolchain/toolchain/resolved.bzl | 49 +++++++++++++++++++ rules_toolchain/toolchain/variable.bzl | 29 ----------- 17 files changed, 101 insertions(+), 259 deletions(-) delete mode 100755 rules_toolchain/e2e/toolchain/echo/content.sh create mode 100644 rules_toolchain/e2e/toolchain/echo/hello-world.txt delete mode 100644 rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel create mode 100644 rules_toolchain/e2e/toolchain/echo/resolved.bzl delete mode 100644 rules_toolchain/e2e/toolchain/echo/variable.bzl delete mode 100644 rules_toolchain/toolchain/info/BUILD.bazel delete mode 100644 rules_toolchain/toolchain/info/DataInfo.bzl delete mode 100644 rules_toolchain/toolchain/info/TargetInfo.bzl delete mode 100644 rules_toolchain/toolchain/info/binary.bzl delete mode 100644 rules_toolchain/toolchain/info/rule.bzl delete mode 100644 rules_toolchain/toolchain/info/test.bzl create mode 100644 rules_toolchain/toolchain/resolved.bzl delete mode 100644 rules_toolchain/toolchain/variable.bzl diff --git a/rules_toolchain/e2e/MODULE.bazel b/rules_toolchain/e2e/MODULE.bazel index 3530e36..8c49d27 100644 --- a/rules_toolchain/e2e/MODULE.bazel +++ b/rules_toolchain/e2e/MODULE.bazel @@ -2,6 +2,7 @@ module( name = "e2e", ) +bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "rules_toolchain", version = "0.0.0") local_path_override( module_name = "rules_toolchain", diff --git a/rules_toolchain/e2e/toolchain/echo/BUILD.bazel b/rules_toolchain/e2e/toolchain/echo/BUILD.bazel index 827ad43..be406ed 100644 --- a/rules_toolchain/e2e/toolchain/echo/BUILD.bazel +++ b/rules_toolchain/e2e/toolchain/echo/BUILD.bazel @@ -1,4 +1,5 @@ -load(":variable.bzl", "variable") +load("@bazel_skylib//rules:diff_test.bzl", "diff_test") +load(":resolved.bzl", "resolved") toolchain_type( name = "type", @@ -6,7 +7,7 @@ toolchain_type( toolchain( name = "local", - toolchain = "//toolchain/echo/info:local", + toolchain = "@echo//:echo", toolchain_type = ":type", ) @@ -15,8 +16,8 @@ alias( actual = "local", ) -variable( - name = "variable", +resolved( + name = "resolved", toolchain = ":type", ) @@ -25,16 +26,11 @@ genrule( testonly = True, outs = ["hello-world.txt"], cmd = "$(ECHO) 'Hello, world!' > $@", - toolchains = [":variable"], + toolchains = [":resolved"], ) -sh_test( - name = "sh", - size = "small", - srcs = ["content.sh"], - args = [ - "hello-world.txt", - "'Hello, world!'", - ], - data = [":data"], +diff_test( + name = "diff", + file1 = ":data", + file2 = ":hello-world.txt", ) diff --git a/rules_toolchain/e2e/toolchain/echo/content.sh b/rules_toolchain/e2e/toolchain/echo/content.sh deleted file mode 100755 index d3770ab..0000000 --- a/rules_toolchain/e2e/toolchain/echo/content.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -# e: quit on command errors -# u: quit on undefined variables -set -eu - -# Test setup -TEST_SCRIPT="${TEST_BINARY?TEST_BINARY is unset}" -TEST_FOLDER="${TEST_SCRIPT%/*}" -TEST_DATA="${TEST_FOLDER}/${1}" -TEST_EXPECTED="${2}" -readonly TEST_FOLDER TEST_DATA TEST_EXPECTED - -# Validate the test data -if ! test -f "${TEST_DATA}"; then - echo >&2 "Missing test DATA: ${TEST_DATA}" - exit 2 -elif ! test -r "${TEST_DATA}"; then - echo >&2 "Unreadable test DATA: ${TEST_DATA}" - exit 2 -fi - -# Validate the test content -while IFS= read -r LINE; do - if test "${LINE}" != "${TEST_EXPECTED}"; then - echo >&2 "Invalid data content:" - echo >&2 " - actual : ${LINE}" - echo >&2 " - expected: ${TEST_EXPECTED}" - exit 1 - fi -done <"${TEST_DATA}" diff --git a/rules_toolchain/e2e/toolchain/echo/hello-world.txt b/rules_toolchain/e2e/toolchain/echo/hello-world.txt new file mode 100644 index 0000000..af5626b --- /dev/null +++ b/rules_toolchain/e2e/toolchain/echo/hello-world.txt @@ -0,0 +1 @@ +Hello, world! diff --git a/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel b/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel deleted file mode 100644 index a36f031..0000000 --- a/rules_toolchain/e2e/toolchain/echo/info/BUILD.bazel +++ /dev/null @@ -1,6 +0,0 @@ -load("@rules_toolchain//toolchain:defs.bzl", "toolchain_info") - -toolchain_info( - name = "local", - binary = "@echo//:echo", -) diff --git a/rules_toolchain/e2e/toolchain/echo/resolved.bzl b/rules_toolchain/e2e/toolchain/echo/resolved.bzl new file mode 100644 index 0000000..21d8f3e --- /dev/null +++ b/rules_toolchain/e2e/toolchain/echo/resolved.bzl @@ -0,0 +1,17 @@ +load("@rules_toolchain//toolchain:resolved.bzl", _ATTRS = "ATTRS", _implementation = "implementation") + +ATTRS = _ATTRS + +implementation = _implementation + +resolved = rule( + doc = "Provides resolved toolchain information.", + attrs = ATTRS, + implementation = implementation, + provides = [ + platform_common.TemplateVariableInfo, + platform_common.ToolchainInfo, + DefaultInfo, + ], + toolchains = ["//toolchain/echo:type"], +) diff --git a/rules_toolchain/e2e/toolchain/echo/variable.bzl b/rules_toolchain/e2e/toolchain/echo/variable.bzl deleted file mode 100644 index 567e499..0000000 --- a/rules_toolchain/e2e/toolchain/echo/variable.bzl +++ /dev/null @@ -1,14 +0,0 @@ -load("@rules_toolchain//toolchain:variable.bzl", _ATTRS = "ATTRS", _implementation = "implementation") - -ATTRS = _ATTRS - -implementation = _implementation - -variable = rule( - doc = "Provides template variable information for the toolchain.", - attrs = ATTRS, - implementation = implementation, - incompatible_use_toolchain_transition = True, - provides = [platform_common.TemplateVariableInfo], - toolchains = ["//toolchain/echo:type"], -) diff --git a/rules_toolchain/toolchain/defs.bzl b/rules_toolchain/toolchain/defs.bzl index 501a342..b30f5d1 100644 --- a/rules_toolchain/toolchain/defs.bzl +++ b/rules_toolchain/toolchain/defs.bzl @@ -1,7 +1,5 @@ load("//toolchain/triplet:TripletInfo.bzl", _TripletInfo = "TripletInfo") load("//toolchain/local/binary:rule.bzl", _local_binary = "binary") -load("//toolchain/info:rule.bzl", _info = "info") ToolchainTripletInfo = _TripletInfo toolchain_local_binary = _local_binary -toolchain_info = _info diff --git a/rules_toolchain/toolchain/info/BUILD.bazel b/rules_toolchain/toolchain/info/BUILD.bazel deleted file mode 100644 index c39fd79..0000000 --- a/rules_toolchain/toolchain/info/BUILD.bazel +++ /dev/null @@ -1,17 +0,0 @@ -load(":binary.bzl", "binary") -load(":rule.bzl", "info") -load(":test.bzl", "test") - -binary( - name = "binary", -) - -info( - name = "info", - binary = ":binary", -) - -test( - name = "test", - target_under_test = ":info", -) diff --git a/rules_toolchain/toolchain/info/DataInfo.bzl b/rules_toolchain/toolchain/info/DataInfo.bzl deleted file mode 100644 index 76228ad..0000000 --- a/rules_toolchain/toolchain/info/DataInfo.bzl +++ /dev/null @@ -1,23 +0,0 @@ -def init(target, executable, env): - """ - Initialises a `DataInfo` instance. - - Args: - target: The Bazel target that to be used as the toolchain. - executable: The executable file to be used with actions. - env: Environment variables to be exposed. - - Returns: - A mapping of keywords for the `data_info` raw constructor. - """ - return { - "target": target, - "executable": executable, - "env": env, - } - -DataInfo, data_info = provider( - "Data that is contained in a `platform_common.ToolchainInfo`", - fields = ["target", "executable", "env"], - init = init, -) diff --git a/rules_toolchain/toolchain/info/TargetInfo.bzl b/rules_toolchain/toolchain/info/TargetInfo.bzl deleted file mode 100644 index 250c4ca..0000000 --- a/rules_toolchain/toolchain/info/TargetInfo.bzl +++ /dev/null @@ -1,19 +0,0 @@ -def init(env): - """ - Initialises a `TargetInfo` instance. - - Args: - env: Environment variables to be exposed. - - Returns: - A mapping of keywords for the `target_info` raw constructor. - """ - return { - "env": env, - } - -TargetInfo, target_info = provider( - "Information about a toolchain target that is used to construct a `DataInfo`", - fields = ["env"], - init = init, -) diff --git a/rules_toolchain/toolchain/info/binary.bzl b/rules_toolchain/toolchain/info/binary.bzl deleted file mode 100644 index 87f8e3e..0000000 --- a/rules_toolchain/toolchain/info/binary.bzl +++ /dev/null @@ -1,34 +0,0 @@ -load(":TargetInfo.bzl", "TargetInfo") - -ATTRS = {} - -def implementation(ctx): - output = ctx.actions.declare_file(ctx.label.name) - - ctx.actions.write( - output = output, - content = "#!/bin/sh", - is_executable = True, - ) - - info = TargetInfo( - env = { - output.basename.upper(): output.path, - }, - ) - - default = DefaultInfo( - executable = output, - files = depset([output]), - runfiles = ctx.runfiles([output]), - ) - - return [info, default] - -binary = rule( - doc = "Creates a stub executable binary target.", - attrs = ATTRS, - implementation = implementation, - provides = [TargetInfo], - executable = True, -) diff --git a/rules_toolchain/toolchain/info/rule.bzl b/rules_toolchain/toolchain/info/rule.bzl deleted file mode 100644 index 077b129..0000000 --- a/rules_toolchain/toolchain/info/rule.bzl +++ /dev/null @@ -1,36 +0,0 @@ -load("@bazel_skylib//lib:structs.bzl", "structs") -load(":TargetInfo.bzl", "TargetInfo") -load(":DataInfo.bzl", "DataInfo") - -ATTRS = { - "binary": attr.label( - doc = "The binary target to provide toolchain information for.", - allow_single_file = True, - mandatory = True, - cfg = "exec", - providers = [TargetInfo], - executable = True, - ), -} - -def implementation(ctx): - target = ctx.attr.binary[TargetInfo] - data = DataInfo( - target = ctx.attr.binary, - executable = ctx.file.binary, - **{k: v for k, v in structs.to_dict(target).items()} - ) - return [ - platform_common.ToolchainInfo(data = data), - data, - ] - -info = rule( - doc = "Provides toolchain information for a local binary target.", - implementation = implementation, - attrs = ATTRS, - provides = [ - platform_common.ToolchainInfo, - DataInfo, - ], -) diff --git a/rules_toolchain/toolchain/info/test.bzl b/rules_toolchain/toolchain/info/test.bzl deleted file mode 100644 index 2fa3013..0000000 --- a/rules_toolchain/toolchain/info/test.bzl +++ /dev/null @@ -1,12 +0,0 @@ -load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") - -def implementation(ctx): - env = analysistest.begin(ctx) - target = analysistest.target_under_test(env) - info = target[platform_common.ToolchainInfo] - asserts.true(env, "BINARY" in info.data.env) - return analysistest.end(env) - -info_test = analysistest.make(implementation) - -test = info_test diff --git a/rules_toolchain/toolchain/local/binary/rule.bzl b/rules_toolchain/toolchain/local/binary/rule.bzl index 82cfa37..f05bdd0 100644 --- a/rules_toolchain/toolchain/local/binary/rule.bzl +++ b/rules_toolchain/toolchain/local/binary/rule.bzl @@ -1,6 +1,3 @@ -load(":BinaryInfo.bzl", "BinaryInfo") -load("//toolchain/info:TargetInfo.bzl", "TargetInfo") - ATTRS = { "path": attr.string( doc = "The path to the local binary.", @@ -17,47 +14,51 @@ ATTRS = { default = Label(":posix.tmpl.sh"), allow_single_file = True, ), + "data": attr.label_list( + doc = "Extra files that are needed at runtime.", + allow_files = True, + ), } def implementation(ctx): program = ctx.attr.program or ctx.label.name - binary = BinaryInfo( - program = program, - path = ctx.attr.path, - variable = ctx.attr.variable or program.upper(), - ) + variable = ctx.attr.variable or program.upper() - output = ctx.actions.declare_file(binary.program) + executable = ctx.actions.declare_file("{}.sh".format(program)) ctx.actions.expand_template( template = ctx.file.template, - output = output, + output = executable, substitutions = { - "{{path}}": binary.path, + "{{path}}": ctx.attr.path, }, is_executable = True, ) - target = TargetInfo( - env = { - binary.variable: output.path, - }, - ) + variables = platform_common.TemplateVariableInfo({ + ctx.attr.variable or program.upper(): executable.path, + }) default = DefaultInfo( - executable = output, - files = depset([output]), - runfiles = ctx.runfiles([output]), + executable = executable, + files = depset([executable]), + runfiles = ctx.runfiles(ctx.attr.data + [executable]), + ) + + toolchain = platform_common.ToolchainInfo( + variables = variables, + default = default, + executable = executable, ) - return [binary, target, default] + return [variables, toolchain, default] binary = rule( doc = "Creates a executable binary target file around a local binary path", attrs = ATTRS, implementation = implementation, provides = [ - BinaryInfo, - TargetInfo, + platform_common.TemplateVariableInfo, + platform_common.ToolchainInfo, DefaultInfo, ], executable = True, diff --git a/rules_toolchain/toolchain/resolved.bzl b/rules_toolchain/toolchain/resolved.bzl new file mode 100644 index 0000000..a3c4682 --- /dev/null +++ b/rules_toolchain/toolchain/resolved.bzl @@ -0,0 +1,49 @@ +ATTRS = { + "toolchain": attr.label( + doc = "The toolchain type to resolve and forward on providers.", + mandatory = True, + ), +} + +def implementation(ctx): + toolchain = ctx.toolchains[ctx.attr.toolchain.label] + + executable = ctx.actions.declare_file("toolchain-resolved-{}".format(ctx.label.name)) + ctx.actions.symlink( + output = executable, + target_file = toolchain.executable, + is_executable = True, + ) + + files = depset([executable], transitive = [toolchain.default.files]) + runfiles = ctx.runfiles() + runfiles = runfiles.merge(toolchain.default.default_runfiles) + + default = DefaultInfo( + executable = executable, + files = files, + runfiles = runfiles, + ) + + return [ + toolchain, + toolchain.variables, + default, + ] + +# This rule is useless by itself +# A toolchain type to resolve needs to be declared +# The `ATTRS` and `implementation` can be reused +# It is needed to work around the toolchain resolution step of Bazel[1] +# https://github.com/bazelbuild/bazel/issues/14009 +resolved = rule( + doc = "Provides template variable information for a toolchain.", + attrs = ATTRS, + implementation = implementation, + provides = [ + platform_common.TemplateVariableInfo, + platform_common.ToolchainInfo, + DefaultInfo, + ], + # toolchains = ["//your/toolchain/type"], +) diff --git a/rules_toolchain/toolchain/variable.bzl b/rules_toolchain/toolchain/variable.bzl deleted file mode 100644 index 28fc1cb..0000000 --- a/rules_toolchain/toolchain/variable.bzl +++ /dev/null @@ -1,29 +0,0 @@ -ATTRS = { - "toolchain": attr.label( - doc = "The toolchain type to gather the template variable information for.", - mandatory = True, - ), -} - -def implementation(ctx): - toolchain = ctx.toolchains[ctx.attr.toolchain.label] - return [ - toolchain, - platform_common.TemplateVariableInfo(toolchain.data.env), - DefaultInfo( - files = toolchain.data.target.files, - runfiles = toolchain.data.target.default_runfiles, - ), - ] - -# This rule is useless by itself as the specific toolchain type needs to be defined -# Derive a toolchain specific rule and specify the correct toolchain -# The `ATTRS` and `implementation` can be reused -variable = rule( - doc = "Provides template variable information for a toolchain.", - attrs = ATTRS, - implementation = implementation, - incompatible_use_toolchain_transition = True, - provides = [platform_common.TemplateVariableInfo], - # toolchains = ["//your/toolchain/type"], -) -- GitLab From fee116e89f590442e8eec7f4e9694c1c9fa8f916 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 10 Oct 2023 10:55:05 +0100 Subject: [PATCH 18/55] feat(rules_toolchain): add `toolchain_symlink_target` rule This can be used to create hermetic toolchains --- .../e2e/toolchain/echo/BUILD.bazel | 8 ++- rules_toolchain/e2e/toolchain/echo/echo.sh | 5 ++ rules_toolchain/toolchain/defs.bzl | 2 + .../toolchain/symlink/target/BUILD.bazel | 0 .../toolchain/symlink/target/rule.bzl | 56 +++++++++++++++++++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100755 rules_toolchain/e2e/toolchain/echo/echo.sh create mode 100644 rules_toolchain/toolchain/symlink/target/BUILD.bazel create mode 100644 rules_toolchain/toolchain/symlink/target/rule.bzl diff --git a/rules_toolchain/e2e/toolchain/echo/BUILD.bazel b/rules_toolchain/e2e/toolchain/echo/BUILD.bazel index be406ed..5fec74f 100644 --- a/rules_toolchain/e2e/toolchain/echo/BUILD.bazel +++ b/rules_toolchain/e2e/toolchain/echo/BUILD.bazel @@ -1,10 +1,16 @@ load("@bazel_skylib//rules:diff_test.bzl", "diff_test") load(":resolved.bzl", "resolved") +load("@rules_toolchain//toolchain:defs.bzl", "toolchain_symlink_target") toolchain_type( name = "type", ) +toolchain_symlink_target( + name = "hermetic", + target = ":echo.sh", +) + toolchain( name = "local", toolchain = "@echo//:echo", @@ -13,7 +19,7 @@ toolchain( alias( name = "echo", - actual = "local", + actual = "hermetic", ) resolved( diff --git a/rules_toolchain/e2e/toolchain/echo/echo.sh b/rules_toolchain/e2e/toolchain/echo/echo.sh new file mode 100755 index 0000000..d749aa3 --- /dev/null +++ b/rules_toolchain/e2e/toolchain/echo/echo.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +set -eu + +PATH="" echo "${@}" diff --git a/rules_toolchain/toolchain/defs.bzl b/rules_toolchain/toolchain/defs.bzl index b30f5d1..2b80d68 100644 --- a/rules_toolchain/toolchain/defs.bzl +++ b/rules_toolchain/toolchain/defs.bzl @@ -1,5 +1,7 @@ load("//toolchain/triplet:TripletInfo.bzl", _TripletInfo = "TripletInfo") load("//toolchain/local/binary:rule.bzl", _local_binary = "binary") +load("//toolchain/symlink/target:rule.bzl", _symlink_target = "target") ToolchainTripletInfo = _TripletInfo toolchain_local_binary = _local_binary +toolchain_symlink_target = _symlink_target diff --git a/rules_toolchain/toolchain/symlink/target/BUILD.bazel b/rules_toolchain/toolchain/symlink/target/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/symlink/target/rule.bzl b/rules_toolchain/toolchain/symlink/target/rule.bzl new file mode 100644 index 0000000..f76bf13 --- /dev/null +++ b/rules_toolchain/toolchain/symlink/target/rule.bzl @@ -0,0 +1,56 @@ +ATTRS = { + "target": attr.label( + doc = "The binary file to symlink.", + mandatory = True, + allow_single_file = True, + executable = True, + cfg = "exec", + ), + "variable": attr.string( + doc = "The variable name for Make or the execution environment.", + ), + "data": attr.label_list( + doc = "Extra files that are needed at runtime.", + allow_files = True, + ), +} + +def implementation(ctx): + variable = ctx.attr.variable or ctx.file.target.basename + + executable = ctx.actions.declare_file(ctx.label.name) + ctx.actions.symlink( + output = executable, + target_file = ctx.file.target, + is_executable = True, + ) + + variables = platform_common.TemplateVariableInfo({ + variable: executable.path, + }) + + default = DefaultInfo( + executable = executable, + files = depset([executable]), + runfiles = ctx.runfiles(ctx.attr.data + [executable]), + ) + + toolchain = platform_common.ToolchainInfo( + variables = variables, + default = default, + executable = executable, + ) + + return [variables, toolchain, default] + +target = rule( + doc = "Creates a executable symlink to a binary target file.", + attrs = ATTRS, + implementation = implementation, + provides = [ + platform_common.TemplateVariableInfo, + platform_common.ToolchainInfo, + DefaultInfo, + ], + executable = True, +) -- GitLab From 1ad702a424286ef99f5db6f1e21aaf88c636d7f7 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 10 Oct 2023 11:01:46 +0100 Subject: [PATCH 19/55] feat(rules_toolchain): add `toolchain_symlink_path` rule A simple implementation of `toolchain_local_binary`. --- rules_toolchain/toolchain/defs.bzl | 4 +-- .../toolchain/local/binary/BUILD.bazel | 1 - .../toolchain/local/binary/BinaryInfo.bzl | 35 ------------------- .../toolchain/local/binary/posix.tmpl.sh | 21 ----------- .../toolchain/local/which/BUILD.tmpl.bazel | 5 ++- .../toolchain/symlink/path/BUILD.bazel | 0 .../{local/binary => symlink/path}/rule.bzl | 29 +++++---------- 7 files changed, 12 insertions(+), 83 deletions(-) delete mode 100644 rules_toolchain/toolchain/local/binary/BUILD.bazel delete mode 100644 rules_toolchain/toolchain/local/binary/BinaryInfo.bzl delete mode 100755 rules_toolchain/toolchain/local/binary/posix.tmpl.sh create mode 100644 rules_toolchain/toolchain/symlink/path/BUILD.bazel rename rules_toolchain/toolchain/{local/binary => symlink/path}/rule.bzl (54%) diff --git a/rules_toolchain/toolchain/defs.bzl b/rules_toolchain/toolchain/defs.bzl index 2b80d68..794858d 100644 --- a/rules_toolchain/toolchain/defs.bzl +++ b/rules_toolchain/toolchain/defs.bzl @@ -1,7 +1,7 @@ load("//toolchain/triplet:TripletInfo.bzl", _TripletInfo = "TripletInfo") -load("//toolchain/local/binary:rule.bzl", _local_binary = "binary") +load("//toolchain/symlink/path:rule.bzl", _symlink_path = "path") load("//toolchain/symlink/target:rule.bzl", _symlink_target = "target") ToolchainTripletInfo = _TripletInfo -toolchain_local_binary = _local_binary +toolchain_symlink_path = _symlink_path toolchain_symlink_target = _symlink_target diff --git a/rules_toolchain/toolchain/local/binary/BUILD.bazel b/rules_toolchain/toolchain/local/binary/BUILD.bazel deleted file mode 100644 index 53004d8..0000000 --- a/rules_toolchain/toolchain/local/binary/BUILD.bazel +++ /dev/null @@ -1 +0,0 @@ -exports_files(["posix.tmpl.sh"]) diff --git a/rules_toolchain/toolchain/local/binary/BinaryInfo.bzl b/rules_toolchain/toolchain/local/binary/BinaryInfo.bzl deleted file mode 100644 index c365dd7..0000000 --- a/rules_toolchain/toolchain/local/binary/BinaryInfo.bzl +++ /dev/null @@ -1,35 +0,0 @@ -def check_envvar(name, value): - if not value[0].isalpha(): - fail("`{}` must start with a letter: {}".format(name, value)) - - if not value.isupper(): - fail("`{}` must be uppercase: {}".format(name, value)) - - if not value.replace("_", "A").isalnum(): - fail("`{}` must be underscore separated and alphanumeric: {}".format(name, value)) - - return value - -def init(program, path, variable): - """ - Initialises a `BinaryInfo` instance. - - Args: - program: The executable name. - path: The local path to the binary. - variable: The variable name to use for Make or the execution environment. - - Returns: - A mapping of keywords for the `binary_info` raw constructor. - """ - return { - "program": program, - "path": path, - "variable": check_envvar("BinaryInfo.variable", variable).upper(), - } - -BinaryInfo, binary_info = provider( - "Information about a locally wrapped binary", - fields = ["program", "path", "variable"], - init = init, -) diff --git a/rules_toolchain/toolchain/local/binary/posix.tmpl.sh b/rules_toolchain/toolchain/local/binary/posix.tmpl.sh deleted file mode 100755 index 94f11ed..0000000 --- a/rules_toolchain/toolchain/local/binary/posix.tmpl.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -# e: quit on command errors -# u: quit on undefined variables -set -eu - -# Bazel substitutions -EXECUTABLE="{{path}}" -readonly EXECUTABLE - -# Validate the executable is...executable -if ! test -f "${EXECUTABLE}"; then - echo >&2 "Not found: ${EXECUTABLE}" - exit 69 -elif ! test -x "${EXECUTABLE}"; then - echo >&2 "Not executable: ${EXECUTABLE}" - exit 123 -fi - -# Pass on the argument to the actual executable -"${EXECUTABLE}" "${@}" diff --git a/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel b/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel index e5ff632..6a51efa 100644 --- a/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel +++ b/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel @@ -1,10 +1,9 @@ -load("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_binary") +load("@rules_toolchain//toolchain:defs.bzl", "toolchain_symlink_path") package(default_visibility = ["//visibility:public"]) -toolchain_local_binary( +toolchain_symlink_path( name = "{{name}}", path = "{{path}}", - program = "{{program}}", variable = "{{variable}}", ) diff --git a/rules_toolchain/toolchain/symlink/path/BUILD.bazel b/rules_toolchain/toolchain/symlink/path/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/local/binary/rule.bzl b/rules_toolchain/toolchain/symlink/path/rule.bzl similarity index 54% rename from rules_toolchain/toolchain/local/binary/rule.bzl rename to rules_toolchain/toolchain/symlink/path/rule.bzl index f05bdd0..06699d3 100644 --- a/rules_toolchain/toolchain/local/binary/rule.bzl +++ b/rules_toolchain/toolchain/symlink/path/rule.bzl @@ -1,19 +1,11 @@ ATTRS = { "path": attr.string( - doc = "The path to the local binary.", + doc = "The path to a binary to symlink.", mandatory = True, ), - "program": attr.string( - doc = "The name of the binary to found on PATH.", - ), "variable": attr.string( doc = "The variable name for Make or the execution environment.", ), - "template": attr.label( - doc = "The template that is expanded into the binary.", - default = Label(":posix.tmpl.sh"), - allow_single_file = True, - ), "data": attr.label_list( doc = "Extra files that are needed at runtime.", allow_files = True, @@ -21,21 +13,16 @@ ATTRS = { } def implementation(ctx): - program = ctx.attr.program or ctx.label.name - variable = ctx.attr.variable or program.upper() + variable = ctx.attr.variable or ctx.file.target.basename - executable = ctx.actions.declare_file("{}.sh".format(program)) - ctx.actions.expand_template( - template = ctx.file.template, + executable = ctx.actions.declare_symlink(ctx.label.name) + ctx.actions.symlink( output = executable, - substitutions = { - "{{path}}": ctx.attr.path, - }, - is_executable = True, + target_path = ctx.attr.path, ) variables = platform_common.TemplateVariableInfo({ - ctx.attr.variable or program.upper(): executable.path, + variable: executable.path, }) default = DefaultInfo( @@ -52,8 +39,8 @@ def implementation(ctx): return [variables, toolchain, default] -binary = rule( - doc = "Creates a executable binary target file around a local binary path", +path = rule( + doc = "Creates a executable symlink to a binary path.", attrs = ATTRS, implementation = implementation, provides = [ -- GitLab From 61d38821184d3f65f0323ea2bc1cd8892fa65bc8 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 10 Oct 2023 22:27:24 +0100 Subject: [PATCH 20/55] refactor(rules_toolchain): make `TRIPLETS` real `TripletInfo` --- rules_toolchain/toolchain/triplet/BUILD.bazel | 5 ++--- rules_toolchain/toolchain/triplet/common.bzl | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/rules_toolchain/toolchain/triplet/BUILD.bazel b/rules_toolchain/toolchain/triplet/BUILD.bazel index fb7dafc..b977536 100644 --- a/rules_toolchain/toolchain/triplet/BUILD.bazel +++ b/rules_toolchain/toolchain/triplet/BUILD.bazel @@ -1,14 +1,13 @@ -load("@bazel_skylib//lib:sets.bzl", "sets") load(":common.bzl", "TRIPLETS") load(":rule.bzl", "triplet") load(":test.bzl", "test") [ triplet( - name = value, + name = t.value, visibility = ["//visibility:public"], ) - for value in sets.to_list(TRIPLETS) + for t in TRIPLETS ] alias( diff --git a/rules_toolchain/toolchain/triplet/common.bzl b/rules_toolchain/toolchain/triplet/common.bzl index fe79222..64e2058 100644 --- a/rules_toolchain/toolchain/triplet/common.bzl +++ b/rules_toolchain/toolchain/triplet/common.bzl @@ -1,6 +1,6 @@ -load("@bazel_skylib//lib:sets.bzl", "sets") +load(":TripletInfo.bzl", "TripletInfo") -TRIPLETS = sets.make(( - "arm64-linux-gnu", - "amd64-linux-gnu", -)) +TRIPLETS = ( + TripletInfo("arm64-linux-gnu"), + TripletInfo("amd64-linux-gnu"), +) -- GitLab From a9299e40da74ec9fec1567ea7dccff6b2d962be6 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 10 Oct 2023 22:28:01 +0100 Subject: [PATCH 21/55] fix(rules_toolchain): add `amd64`/`arm64` aliases --- rules_toolchain/toolchain/constraint/cpu/BUILD.bazel | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rules_toolchain/toolchain/constraint/cpu/BUILD.bazel b/rules_toolchain/toolchain/constraint/cpu/BUILD.bazel index 7f3bbf0..68516e1 100644 --- a/rules_toolchain/toolchain/constraint/cpu/BUILD.bazel +++ b/rules_toolchain/toolchain/constraint/cpu/BUILD.bazel @@ -11,3 +11,14 @@ package(default_visibility = ["//visibility:public"]) "x86_64", ) ] + +[ + alias( + name = name, + actual = actual, + ) + for name, actual in ( + ("arm64", "aarch64"), + ("amd64", "x86_64"), + ) +] -- GitLab From 8f642fc56bdbf53747e494d2e3a7460340771c7b Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 10 Oct 2023 22:29:02 +0100 Subject: [PATCH 22/55] feat(rules_toolchain): add `host` platform and constraint The "constraint" is actually a `config_settings` that combines all of the host constraints but can be used in a `select`. --- rules_toolchain/toolchain/host/BUILD.bazel | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rules_toolchain/toolchain/host/BUILD.bazel b/rules_toolchain/toolchain/host/BUILD.bazel index 767c4f3..066c7a3 100644 --- a/rules_toolchain/toolchain/host/BUILD.bazel +++ b/rules_toolchain/toolchain/host/BUILD.bazel @@ -6,3 +6,15 @@ triplet( value = TRIPLET.value, visibility = ["//visibility:public"], ) + +config_setting( + name = "constraint", + constraint_values = TRIPLET.constraints, + visibility = ["//visibility:public"], +) + +platform( + name = "platform", + constraint_values = TRIPLET.constraints, + visibility = ["//visibility:public"], +) -- GitLab From 387398bd1f138ac0be691b5e8a6795c4b8e5f6ce Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 10 Oct 2023 22:30:13 +0100 Subject: [PATCH 23/55] feat(rules_toolchain): add triplet constraints They are not _real_ constraints but `config_settings` which can be used in a `select` to switch on the triplet. --- rules_toolchain/toolchain/constraint/BUILD.bazel | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 rules_toolchain/toolchain/constraint/BUILD.bazel diff --git a/rules_toolchain/toolchain/constraint/BUILD.bazel b/rules_toolchain/toolchain/constraint/BUILD.bazel new file mode 100644 index 0000000..dd10484 --- /dev/null +++ b/rules_toolchain/toolchain/constraint/BUILD.bazel @@ -0,0 +1,16 @@ +load("//toolchain/triplet:common.bzl", "TRIPLETS") + +[ + config_setting( + name = t.value, + constraint_values = t.constraints, + visibility = ["//visibility:public"], + ) + for t in TRIPLETS +] + +alias( + name = "host", + actual = "//toolchain/host:constraint", + visibility = ["//visibility:public"], +) -- GitLab From cf5347c1e720654c70d872e9d911f862d458345c Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 10 Oct 2023 22:31:19 +0100 Subject: [PATCH 24/55] feat(rules_toolchain): add triplet platforms Allows usage of `--host_platform=@rules_toolchain//toolchain/platform:host` to get `libc` aware host constraints. --- rules_toolchain/toolchain/platform/BUILD.bazel | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 rules_toolchain/toolchain/platform/BUILD.bazel diff --git a/rules_toolchain/toolchain/platform/BUILD.bazel b/rules_toolchain/toolchain/platform/BUILD.bazel new file mode 100644 index 0000000..d26aef3 --- /dev/null +++ b/rules_toolchain/toolchain/platform/BUILD.bazel @@ -0,0 +1,16 @@ +load("//toolchain/triplet:common.bzl", "TRIPLETS") + +[ + platform( + name = t.value, + constraint_values = t.constraints, + visibility = ["//visibility:public"], + ) + for t in TRIPLETS +] + +alias( + name = "host", + actual = "//toolchain/host:platform", + visibility = ["//visibility:public"], +) -- GitLab From 9561366b8971e9b990d9d5215309c1fae2261aa7 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 11 Oct 2023 09:51:03 +0100 Subject: [PATCH 25/55] docs(rules_toolchain): example for `resolved` Importantly, includes the `executable = True` keyword. --- rules_toolchain/toolchain/resolved.bzl | 51 +++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/rules_toolchain/toolchain/resolved.bzl b/rules_toolchain/toolchain/resolved.bzl index a3c4682..9bedfbf 100644 --- a/rules_toolchain/toolchain/resolved.bzl +++ b/rules_toolchain/toolchain/resolved.bzl @@ -15,7 +15,7 @@ def implementation(ctx): is_executable = True, ) - files = depset([executable], transitive = [toolchain.default.files]) + files = depset([executable]) runfiles = ctx.runfiles() runfiles = runfiles.merge(toolchain.default.default_runfiles) @@ -37,7 +37,53 @@ def implementation(ctx): # It is needed to work around the toolchain resolution step of Bazel[1] # https://github.com/bazelbuild/bazel/issues/14009 resolved = rule( - doc = "Provides template variable information for a toolchain.", + doc = """Provides template variable information for a toolchain. + +This rule is useless by itself and is a workaround for Bazel toolchain resolution[1]. + +When creating a toolchain, to provide the resolved toolchain create a `resolved.bzl` file: + + + load( + "@rules_toolchain//toolchain:resolved.bzl", + _ATTRS = "ATTRS", + _implementation = "implementation" + ) + + ATTRS = _ATTRS + + implementation = _implementation + + resolved = rule( + doc = "Resolved toolchain information for a `xxx` toolchain.", + attrs = ATTRS, + implementation = implementation, + provides = [ + platform_common.TemplateVariableInfo, + platform_common.ToolchainInfo, + DefaultInfo, + ], + toolchains = ["//yyy/toolchain/xxx:type"], + executable = True, + ) + +This rule can then be used to provide the resolved toolchain: + + load(":resolved.bzl", "resolved") + + toolchain_type( + name = ":type", + ) + + # Some `toolchain` rules + + resolved( + name = "resolved", + toolchain = ":type", + ) + +[1]: https://github.com/bazelbuild/bazel/issues/14009 +""", attrs = ATTRS, implementation = implementation, provides = [ @@ -45,5 +91,6 @@ resolved = rule( platform_common.ToolchainInfo, DefaultInfo, ], + executable = True, # toolchains = ["//your/toolchain/type"], ) -- GitLab From d7a5f13cb90db60de8457aafeb6c8b01b3a3d780 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 11 Oct 2023 10:25:26 +0100 Subject: [PATCH 26/55] refactor(rules_toolchain): make `resolved` re-usable with a macro --- .../e2e/toolchain/echo/resolved.bzl | 14 +-- rules_toolchain/toolchain/resolved.bzl | 99 +++++++++---------- 2 files changed, 51 insertions(+), 62 deletions(-) diff --git a/rules_toolchain/e2e/toolchain/echo/resolved.bzl b/rules_toolchain/e2e/toolchain/echo/resolved.bzl index 21d8f3e..8cd2f3c 100644 --- a/rules_toolchain/e2e/toolchain/echo/resolved.bzl +++ b/rules_toolchain/e2e/toolchain/echo/resolved.bzl @@ -1,17 +1,9 @@ -load("@rules_toolchain//toolchain:resolved.bzl", _ATTRS = "ATTRS", _implementation = "implementation") +load("@rules_toolchain//toolchain:resolved.bzl", _ATTRS = "ATTRS", _implementation = "implementation", _rule = "macro") ATTRS = _ATTRS implementation = _implementation -resolved = rule( - doc = "Provides resolved toolchain information.", - attrs = ATTRS, - implementation = implementation, - provides = [ - platform_common.TemplateVariableInfo, - platform_common.ToolchainInfo, - DefaultInfo, - ], - toolchains = ["//toolchain/echo:type"], +resolved = _rule( + toolchain = Label("//toolchain/echo:type"), ) diff --git a/rules_toolchain/toolchain/resolved.bzl b/rules_toolchain/toolchain/resolved.bzl index 9bedfbf..fca63fa 100644 --- a/rules_toolchain/toolchain/resolved.bzl +++ b/rules_toolchain/toolchain/resolved.bzl @@ -1,3 +1,9 @@ +PROVIDES = ( + platform_common.TemplateVariableInfo, + platform_common.ToolchainInfo, + DefaultInfo, +) + ATTRS = { "toolchain": attr.label( doc = "The toolchain type to resolve and forward on providers.", @@ -15,7 +21,7 @@ def implementation(ctx): is_executable = True, ) - files = depset([executable]) + files = depset([executable], transitive = [toolchain.default.files]) runfiles = ctx.runfiles() runfiles = runfiles.merge(toolchain.default.default_runfiles) @@ -31,66 +37,57 @@ def implementation(ctx): default, ] -# This rule is useless by itself -# A toolchain type to resolve needs to be declared -# The `ATTRS` and `implementation` can be reused -# It is needed to work around the toolchain resolution step of Bazel[1] -# https://github.com/bazelbuild/bazel/issues/14009 -resolved = rule( - doc = """Provides template variable information for a toolchain. +def macro(*, toolchain): + """ + Provides template variable information for a toolchain. -This rule is useless by itself and is a workaround for Bazel toolchain resolution[1]. + When creating a toolchain, to provide the resolved toolchain create a `resolved.bzl` file: -When creating a toolchain, to provide the resolved toolchain create a `resolved.bzl` file: + load( + "@rules_toolchain//toolchain:resolved.bzl", + _ATTRS = "ATTRS", + _implementation = "implementation" + _rule = "macro", + ) - load( - "@rules_toolchain//toolchain:resolved.bzl", - _ATTRS = "ATTRS", - _implementation = "implementation" - ) + ATTRS = _ATTRS - ATTRS = _ATTRS + implementation = _implementation - implementation = _implementation + resolved = _rule( + toolchain = Label("//coreutils/toolchain/cp:type"), + ) - resolved = rule( - doc = "Resolved toolchain information for a `xxx` toolchain.", - attrs = ATTRS, - implementation = implementation, - provides = [ - platform_common.TemplateVariableInfo, - platform_common.ToolchainInfo, - DefaultInfo, - ], - toolchains = ["//yyy/toolchain/xxx:type"], - executable = True, - ) + This rule can then be used to provide the resolved toolchain: -This rule can then be used to provide the resolved toolchain: + load(":resolved.bzl", "resolved") - load(":resolved.bzl", "resolved") + toolchain_type( + name = ":type", + ) - toolchain_type( - name = ":type", - ) + # Some `toolchain` rules that are registered - # Some `toolchain` rules + resolved( + name = "resolved", + toolchain = ":type", + ) - resolved( - name = "resolved", - toolchain = ":type", - ) + The resolved target is runnable with `bazelisk run`. -[1]: https://github.com/bazelbuild/bazel/issues/14009 -""", - attrs = ATTRS, - implementation = implementation, - provides = [ - platform_common.TemplateVariableInfo, - platform_common.ToolchainInfo, - DefaultInfo, - ], - executable = True, - # toolchains = ["//your/toolchain/type"], -) + [1]: https://github.com/bazelbuild/bazel/issues/14009 + """ + return rule( + doc = """Resolved toolchain information for the `{toolchain}` toolchain. + +This target is runnable via: + + bazelisk run -- {toolchain} +""".format(toolchain = toolchain), + attrs = ATTRS, + implementation = implementation, + provides = PROVIDES, + toolchains = [toolchain], + executable = True, + ) -- GitLab From 6253453a4b7f07b10bce03493e799ef74d560730 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 11 Oct 2023 10:27:31 +0100 Subject: [PATCH 27/55] fix(rules_toolchain): all multiple files to `symlink` This allows rules that need to propagate multiple files. `sh_binary` is one example of this. _Technically_, this should be possible by propagating runfiles but the toolchains are needed at build time, not runtime. --- rules_toolchain/toolchain/symlink/target/rule.bzl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rules_toolchain/toolchain/symlink/target/rule.bzl b/rules_toolchain/toolchain/symlink/target/rule.bzl index f76bf13..ea38172 100644 --- a/rules_toolchain/toolchain/symlink/target/rule.bzl +++ b/rules_toolchain/toolchain/symlink/target/rule.bzl @@ -2,7 +2,7 @@ ATTRS = { "target": attr.label( doc = "The binary file to symlink.", mandatory = True, - allow_single_file = True, + allow_files = True, executable = True, cfg = "exec", ), @@ -16,12 +16,13 @@ ATTRS = { } def implementation(ctx): - variable = ctx.attr.variable or ctx.file.target.basename + target = ctx.files.target[0] + variable = ctx.attr.variable or target.basename.upper() executable = ctx.actions.declare_file(ctx.label.name) ctx.actions.symlink( output = executable, - target_file = ctx.file.target, + target_file = target, is_executable = True, ) -- GitLab From 81f08c6fb5396568a62564ac74be8801e07de729 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 11 Oct 2023 10:29:04 +0100 Subject: [PATCH 28/55] feat(rules_toolchain): add customising the basename for symlink rules --- rules_toolchain/toolchain/resolved.bzl | 6 +++++- rules_toolchain/toolchain/symlink/path/rule.bzl | 8 ++++++-- rules_toolchain/toolchain/symlink/target/rule.bzl | 11 +++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/rules_toolchain/toolchain/resolved.bzl b/rules_toolchain/toolchain/resolved.bzl index fca63fa..37079c1 100644 --- a/rules_toolchain/toolchain/resolved.bzl +++ b/rules_toolchain/toolchain/resolved.bzl @@ -5,6 +5,9 @@ PROVIDES = ( ) ATTRS = { + "basename": attr.string( + doc = "The basename for the symlink, which defaults to `name`", + ), "toolchain": attr.label( doc = "The toolchain type to resolve and forward on providers.", mandatory = True, @@ -12,9 +15,10 @@ ATTRS = { } def implementation(ctx): + basename = ctx.attr.basename or ctx.label.name toolchain = ctx.toolchains[ctx.attr.toolchain.label] - executable = ctx.actions.declare_file("toolchain-resolved-{}".format(ctx.label.name)) + executable = ctx.actions.declare_file(basename) ctx.actions.symlink( output = executable, target_file = toolchain.executable, diff --git a/rules_toolchain/toolchain/symlink/path/rule.bzl b/rules_toolchain/toolchain/symlink/path/rule.bzl index 06699d3..40a591f 100644 --- a/rules_toolchain/toolchain/symlink/path/rule.bzl +++ b/rules_toolchain/toolchain/symlink/path/rule.bzl @@ -3,6 +3,9 @@ ATTRS = { doc = "The path to a binary to symlink.", mandatory = True, ), + "basename": attr.string( + doc = "The basename for the symlink, which defaults to `name`", + ), "variable": attr.string( doc = "The variable name for Make or the execution environment.", ), @@ -13,9 +16,10 @@ ATTRS = { } def implementation(ctx): - variable = ctx.attr.variable or ctx.file.target.basename + basename = ctx.attr.basename or ctx.label.name + variable = ctx.attr.variable or basename.upper() - executable = ctx.actions.declare_symlink(ctx.label.name) + executable = ctx.actions.declare_symlink(basename) ctx.actions.symlink( output = executable, target_path = ctx.attr.path, diff --git a/rules_toolchain/toolchain/symlink/target/rule.bzl b/rules_toolchain/toolchain/symlink/target/rule.bzl index ea38172..431b59c 100644 --- a/rules_toolchain/toolchain/symlink/target/rule.bzl +++ b/rules_toolchain/toolchain/symlink/target/rule.bzl @@ -6,6 +6,9 @@ ATTRS = { executable = True, cfg = "exec", ), + "basename": attr.string( + doc = "The basename for the symlink, which defaults to `name`", + ), "variable": attr.string( doc = "The variable name for Make or the execution environment.", ), @@ -16,13 +19,13 @@ ATTRS = { } def implementation(ctx): - target = ctx.files.target[0] - variable = ctx.attr.variable or target.basename.upper() + basename = ctx.attr.basename or ctx.label.name + variable = ctx.attr.variable or basename.upper() - executable = ctx.actions.declare_file(ctx.label.name) + executable = ctx.actions.declare_file(basename) ctx.actions.symlink( output = executable, - target_file = target, + target_file = ctx.files.target[0], is_executable = True, ) -- GitLab From ed2ade3c7e3c3388e71f3cc6adffeeea166be5ed Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 11 Oct 2023 19:38:43 +0100 Subject: [PATCH 29/55] feat(rules_toolchain): add `toolchain_test` rule Allows easy testing of a toolchain binary. --- .../e2e/toolchain/echo/BUILD.bazel | 18 +-- rules_toolchain/toolchain/defs.bzl | 2 + rules_toolchain/toolchain/test/BUILD.bazel | 9 ++ rules_toolchain/toolchain/test/empty | 0 rules_toolchain/toolchain/test/non-empty | 0 rules_toolchain/toolchain/test/posix.tmpl.sh | 134 ++++++++++++++++++ rules_toolchain/toolchain/test/rule.bzl | 84 +++++++++++ 7 files changed, 234 insertions(+), 13 deletions(-) create mode 100644 rules_toolchain/toolchain/test/BUILD.bazel create mode 100644 rules_toolchain/toolchain/test/empty create mode 100644 rules_toolchain/toolchain/test/non-empty create mode 100755 rules_toolchain/toolchain/test/posix.tmpl.sh create mode 100644 rules_toolchain/toolchain/test/rule.bzl diff --git a/rules_toolchain/e2e/toolchain/echo/BUILD.bazel b/rules_toolchain/e2e/toolchain/echo/BUILD.bazel index 5fec74f..bd8e13b 100644 --- a/rules_toolchain/e2e/toolchain/echo/BUILD.bazel +++ b/rules_toolchain/e2e/toolchain/echo/BUILD.bazel @@ -1,6 +1,5 @@ -load("@bazel_skylib//rules:diff_test.bzl", "diff_test") load(":resolved.bzl", "resolved") -load("@rules_toolchain//toolchain:defs.bzl", "toolchain_symlink_target") +load("@rules_toolchain//toolchain:defs.bzl", "toolchain_symlink_target", "toolchain_test") toolchain_type( name = "type", @@ -27,16 +26,9 @@ resolved( toolchain = ":type", ) -genrule( - name = "data", - testonly = True, - outs = ["hello-world.txt"], - cmd = "$(ECHO) 'Hello, world!' > $@", +toolchain_test( + name = "test", + args = ["Hello, world!"], + stdout = ":hello-world.txt", toolchains = [":resolved"], ) - -diff_test( - name = "diff", - file1 = ":data", - file2 = ":hello-world.txt", -) diff --git a/rules_toolchain/toolchain/defs.bzl b/rules_toolchain/toolchain/defs.bzl index 794858d..e9d8be7 100644 --- a/rules_toolchain/toolchain/defs.bzl +++ b/rules_toolchain/toolchain/defs.bzl @@ -1,7 +1,9 @@ load("//toolchain/triplet:TripletInfo.bzl", _TripletInfo = "TripletInfo") load("//toolchain/symlink/path:rule.bzl", _symlink_path = "path") load("//toolchain/symlink/target:rule.bzl", _symlink_target = "target") +load("//toolchain/test:rule.bzl", _test = "test") ToolchainTripletInfo = _TripletInfo toolchain_symlink_path = _symlink_path toolchain_symlink_target = _symlink_target +toolchain_test = _test diff --git a/rules_toolchain/toolchain/test/BUILD.bazel b/rules_toolchain/toolchain/test/BUILD.bazel new file mode 100644 index 0000000..322e8db --- /dev/null +++ b/rules_toolchain/toolchain/test/BUILD.bazel @@ -0,0 +1,9 @@ +exports_files(["posix.tmpl.sh"]) + +exports_files( + [ + "non-empty", + "empty", + ], + visibility = ["//visibility:public"], +) diff --git a/rules_toolchain/toolchain/test/empty b/rules_toolchain/toolchain/test/empty new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/test/non-empty b/rules_toolchain/toolchain/test/non-empty new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/test/posix.tmpl.sh b/rules_toolchain/toolchain/test/posix.tmpl.sh new file mode 100755 index 0000000..0c6547c --- /dev/null +++ b/rules_toolchain/toolchain/test/posix.tmpl.sh @@ -0,0 +1,134 @@ +#! /bin/sh + +# e: quit on command errors +# u: quit on undefined variables +set -eu + +# Bazel substitutions +EXECUTABLE="{{executable}}" +STDOUT="{{stdout}}" +STDERR="{{stderr}}" +readonly EXECUTABLE STDOUT STDERR + +# Test environment +JUNIT="${XML_OUTPUT_FILE-junit.xml}" +readonly JUNIT + +# Run the toolchain executable and validate the output +"${EXECUTABLE}" "${@}" >stdout.txt 2>stderr.txt + +non_empty() ( + FILEPATH="${1}" + readonly FILEPATH + if ! test -s "${FILEPATH}"; then + printf ' \n' "${FILEPATH}" + printf ' %s contained no content\n' "${FILEPATH}" + printf ' \n' + else + printf ' \n' "${FILEPATH}" + fi +) + +empty() ( + FILEPATH="${1}" + if test -s "${FILEPATH}"; then + printf ' \n' "${FILEPATH}" + printf ' %s contained unexpected content:\n' "${FILEPATH}" + while IFS= read -r LINE; do + printf '%s\n' "${LINE}" + done + printf '%s\n' "${LINE}" + printf ' \n' + else + printf ' \n' "${FILEPATH}" + fi +) + +diff() ( + FILEPATH="${1}" + EXPECTED="${2}" + while true; do + FAILS=0 + IFS= read -r A <&3 || FAILS=$((FAILS + 1)) + IFS= read -r B <&4 || FAILS=$((FAILS + 1)) + if test "${FAILS}" -eq 1; then + printf ' \n' "${FILEPATH}" + printf ' %s contained different line counts:\n' "${FILEPATH}" + printf '%s %s\n' '---' "${FILEPATH}" + printf '%s %s\n' '+++' "${EXPECTED}" + printf '@@ -1 +1 @@\n' + printf '%s%s\n' '-' "${A-}" + printf '%s%s\n' '+' "${B-}" + printf '\n' + printf ' \n' + exit + elif test "${FAILS}" -eq 2; then + exit + elif test "${A}" != "${B}"; then + printf ' \n' "${FILEPATH}" + printf ' %s contained different content:\n' "${FILEPATH}" + printf '%s %s\n' '---' "${FILEPATH}" + printf '%s %s\n' '+++' "${EXPECTED}" + printf '@@ -1 +1 @@\n' + printf '%s%s\n' '-' "${A}" + printf '%s%s\n' '+' "${B}" + printf '\n' + printf ' \n' + exit + fi + done 3<"${FILEPATH}" 4<"${EXPECTED}" + + printf ' \n' "${FILEPATH}" +) + +validate() ( + FILEPATH="${1}" + EXPECTED="${2}" + + if ! test -f "${FILEPATH}"; then + printf ' \n' "${FILEPATH}" + printf ' %s was not found\n' "${FILEPATH}" + printf ' \n' + exit + elif ! test -f "${EXPECTED}"; then + printf ' \n' "${FILEPATH}" + printf ' %s was not found\n' "${EXPECTED}" + printf ' \n' + exit + fi + + case "${EXPECTED}" in + *"/toolchain/test/non-empty") + non_empty "${FILEPATH}" "${JUNIT}" + ;; + *"/toolchain/test/empty") + empty "${FILEPATH}" "${JUNIT}" + ;; + *) + diff "${FILEPATH}" "${EXPECTED}" "${JUNIT}" + ;; + esac +) + +junit() ( + COUNT="${#}" + printf '\n' $((COUNT / 2)) + while ! test -z ${2+x}; do + FILEPATH="${1}" + EXPECTED="${2}" + shift 2 + validate "${FILEPATH}" "${EXPECTED}" + done + printf '\n' +) + +junit \ + stdout.txt "${STDOUT}" \ + stderr.txt "${STDERR}" \ + >"${JUNIT}" + +while IFS= read -r LINE; do + if test -z "${LINE#**}"; then + exit 1 + fi +done <"${JUNIT}" diff --git a/rules_toolchain/toolchain/test/rule.bzl b/rules_toolchain/toolchain/test/rule.bzl new file mode 100644 index 0000000..88b5cc7 --- /dev/null +++ b/rules_toolchain/toolchain/test/rule.bzl @@ -0,0 +1,84 @@ +ATTRS = { + "stdout": attr.label( + doc = """The expected standard output. + +Can be set to the following values for special handling: + +- `@rules_toolchain//toolchain/test:non-empty`: accept any non-empty output +- `@rules_toolchain//toolchain/test:empty`: require empty output +""", + default = ":non-empty", + allow_single_file = True, + ), + "stderr": attr.label( + doc = """The expected standard error. + +Can be set to the following values for special handling: + +- `@rules_toolchain//toolchain/test:non-empty`: accept any non-empty output +- `@rules_toolchain//toolchain/test:empty`: require empty output +""", + default = ":empty", + allow_single_file = True, + ), + "template": attr.label( + doc = """The template that is expanded into the binary. + +Can be overridden to a custom script that receives the following replacements: + +- `{{executable}}`: the toolchain executable path +- `{{stdout}}`: the expected standard output +- `{{stderr}}`: the expected standard error +""", + default = ":posix.tmpl.sh", + allow_single_file = True, + ), +} + +def implementation(ctx): + if len(ctx.attr.toolchains) != 1: + fail("Only one toolchain can be provided") + toolchain = ctx.attr.toolchains[0][platform_common.ToolchainInfo] + + executable = ctx.actions.declare_file("{}.executable".format(ctx.label.name)) + ctx.actions.expand_template( + template = ctx.file.template, + output = executable, + substitutions = { + "{{executable}}": str(toolchain.executable.short_path), + "{{stdout}}": str(ctx.file.stdout.path), + "{{stderr}}": str(ctx.file.stderr.path), + }, + is_executable = True, + ) + + return DefaultInfo( + executable = executable, + files = depset([executable]), + runfiles = ctx.runfiles([toolchain.executable, ctx.file.stdout, ctx.file.stderr]), + ) + +toolchain_test = rule( + doc = """Performs a simple test that a toolchain resolved to an executable. + +- Resolves the provided toolchain binary +- Executes with the provided arguments +- Captures `stdout` and `stderr` +- Can do optional `diff` checking of the output + +A common use case is to check that a toolchain can output some help text: + +``` +toolchain_test( + name = "test", + args = ["--help"], + toolchains = [":resolved"], +) +``` +""", + attrs = ATTRS, + implementation = implementation, + test = True, +) + +test = toolchain_test -- GitLab From 4f24b65d1251d0137014b795e394422e621c3215 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 11 Oct 2023 21:16:42 +0100 Subject: [PATCH 30/55] docs(rules_toolchain): provide docstrings --- rules_toolchain/toolchain/host/extension.bzl | 5 +-- .../toolchain/host/triplet/repository.bzl | 5 ++- rules_toolchain/toolchain/local/extension.bzl | 12 ++++--- .../toolchain/local/which/repository.bzl | 19 +++++++++- .../toolchain/symlink/path/rule.bzl | 28 ++++++++++++++- .../toolchain/symlink/target/rule.bzl | 36 ++++++++++++++++++- rules_toolchain/toolchain/triplet/rule.bzl | 11 +++++- 7 files changed, 105 insertions(+), 11 deletions(-) diff --git a/rules_toolchain/toolchain/host/extension.bzl b/rules_toolchain/toolchain/host/extension.bzl index c984daa..acaf999 100644 --- a/rules_toolchain/toolchain/host/extension.bzl +++ b/rules_toolchain/toolchain/host/extension.bzl @@ -1,6 +1,6 @@ -load("//toolchain/host/triplet:repository.bzl", _TRIPLET = "ATTRS", _triplet = "triplet") +load("//toolchain/host/triplet:repository.bzl", _DOC = "DOC", _TRIPLET = "ATTRS", _triplet = "triplet") -triplet = tag_class(attrs = { +triplet = tag_class(doc = _DOC, attrs = { "name": attr.string(doc = "Name of the generated repository.", mandatory = True), } | _TRIPLET) @@ -10,6 +10,7 @@ def implementation(mctx): _triplet(name = d.name, **{a: getattr(d, a) for a in _TRIPLET}) host = module_extension( + doc = "An extension for performing `host` inspection.", implementation = implementation, tag_classes = { "triplet": triplet, diff --git a/rules_toolchain/toolchain/host/triplet/repository.bzl b/rules_toolchain/toolchain/host/triplet/repository.bzl index 3984a32..d7dc1c3 100644 --- a/rules_toolchain/toolchain/host/triplet/repository.bzl +++ b/rules_toolchain/toolchain/host/triplet/repository.bzl @@ -1,5 +1,8 @@ load(":detect.bzl", "detect") +DOC = """Detects the host triplet. +""" + ATTRS = { "template": attr.label( doc = "The template that is expanded into the `triplet.bzl`.", @@ -16,7 +19,7 @@ def implementation(rctx): rctx.file("BUILD.bazel", "") triplet = repository_rule( - doc = "Detects the host triplet.", + doc = DOC, implementation = implementation, attrs = ATTRS, local = True, diff --git a/rules_toolchain/toolchain/local/extension.bzl b/rules_toolchain/toolchain/local/extension.bzl index 30a9234..ec29ca5 100644 --- a/rules_toolchain/toolchain/local/extension.bzl +++ b/rules_toolchain/toolchain/local/extension.bzl @@ -1,8 +1,11 @@ -load("//toolchain/local/which:repository.bzl", _WHICH = "ATTRS", _which = "which") +load("//toolchain/local/which:repository.bzl", _DOC = "DOC", _WHICH = "ATTRS", _which = "which") -which = tag_class(attrs = { - "name": attr.string(doc = "Name of the generated repository.", mandatory = True), -} | _WHICH) +which = tag_class( + doc = _DOC, + attrs = { + "name": attr.string(doc = "Name of the generated repository.", mandatory = True), + } | _WHICH, +) def implementation(mctx): for mod in mctx.modules: @@ -10,6 +13,7 @@ def implementation(mctx): _which(name = d.name, **{a: getattr(d, a) for a in _WHICH}) local = module_extension( + doc = "An extension for working with the local (i.e. host) system.", implementation = implementation, tag_classes = { "which": which, diff --git a/rules_toolchain/toolchain/local/which/repository.bzl b/rules_toolchain/toolchain/local/which/repository.bzl index d4d815f..77e1a93 100644 --- a/rules_toolchain/toolchain/local/which/repository.bzl +++ b/rules_toolchain/toolchain/local/which/repository.bzl @@ -1,3 +1,20 @@ +DOC = """Creates a repository that provides a binary target wrapping a local binary found on `PATH`. + +The resulting repository has a `toolchain_symlink_path` target which can be used with the native `toolchain` rule to expose the local binary as a toolchain. + +Assuming a repository created as `name = "echo"`, by default the `echo` binary will be search for an the nested target will be named `:echo`. + +Consuming this target as a toolchain is trivial: + +```py +toolchain( + name = "local", + toolchain = "@echo", + toolchain_type = ":type", +) +``` +""" + ATTRS = { "program": attr.string( doc = "The name of the binary to find on `PATH`.", @@ -30,7 +47,7 @@ def implementation(rctx): }) which = repository_rule( - doc = "Creates a repository that provides a binary target wrapping a local binary found on `PATH`.", + doc = DOC, implementation = implementation, attrs = ATTRS, configure = True, diff --git a/rules_toolchain/toolchain/symlink/path/rule.bzl b/rules_toolchain/toolchain/symlink/path/rule.bzl index 40a591f..4d58250 100644 --- a/rules_toolchain/toolchain/symlink/path/rule.bzl +++ b/rules_toolchain/toolchain/symlink/path/rule.bzl @@ -44,7 +44,33 @@ def implementation(ctx): return [variables, toolchain, default] path = rule( - doc = "Creates a executable symlink to a binary path.", + doc = """Creates a executable symlink to a binary path. + +This rule can be used to symlink a executable file outside of the workspace. + +The external executable become part of the Bazel target graph. + +It exports the necessary providers for the target to be easily ingested by the native `toolchain` rule. + +``` +toolchain_type( + name = "type", +) + +toolchain_symlink_path( + name = "gcc-local", + path = "/usr/bin/gcc", +) + +toolchain( + name = "local", + toolchain = ":gcc-local", + toolchain_type = ":type", +) +``` + +_Commonly_, this target is not used directly and the `local.which` extension is used that looks up a binary on a path. +""", attrs = ATTRS, implementation = implementation, provides = [ diff --git a/rules_toolchain/toolchain/symlink/target/rule.bzl b/rules_toolchain/toolchain/symlink/target/rule.bzl index 431b59c..329ff6a 100644 --- a/rules_toolchain/toolchain/symlink/target/rule.bzl +++ b/rules_toolchain/toolchain/symlink/target/rule.bzl @@ -48,7 +48,41 @@ def implementation(ctx): return [variables, toolchain, default] target = rule( - doc = "Creates a executable symlink to a binary target file.", + doc = """Creates a executable symlink to a binary target file. + +This rule can be used to symlink a executable target and export the necessary toolchain providers. + +Often used with downloaded binary targets: + +```py +load("@rules_toolchain//toolchain:defs.bzl", "ToolchainTripletInfo") + +toolchain_type( + name = "type", +) + +# Setup a toolchain for each downloaded binary +[ + ( + toolchain_symlink_target( + name = "something-{}".format(triplet.value), + target = "@downloaded-{}//:something".format(triplet), + ), + toolchain( + name = triplet.value, + toolchain = ":something-{}".format(triplet.value), + exec_compatible_with = triplet.constraints, + ) + ) + for triplet in ( + ToolchainTripletInfo("arm64-linux-gnu"), + ToolchainTripletInfo("arm64-linux-musl"), + ) +] +``` + +`rules_download` has a `download.archive` and `download.file` extension that can help with retrieving remote binaries. +""", attrs = ATTRS, implementation = implementation, provides = [ diff --git a/rules_toolchain/toolchain/triplet/rule.bzl b/rules_toolchain/toolchain/triplet/rule.bzl index 3f40268..ba7270b 100644 --- a/rules_toolchain/toolchain/triplet/rule.bzl +++ b/rules_toolchain/toolchain/triplet/rule.bzl @@ -32,7 +32,16 @@ def implementation(ctx): return [triplet, default] triplet = rule( - doc = "Provies a machine triplet", + doc = """Provides a machine triplet. + +A simple rule that provides a `ToolchainTripletInfo` provider. + +The resulting provider can be used in other rules to understand triplet values. + +Running the target with `bazel run` will result in the triplet being printed. + +The triplet runnable output is particularly useful for the resolved host triplet at `@rules_toolchain//toolchain/triplet:host` +""", attrs = ATTRS, implementation = implementation, provides = [ -- GitLab From b27ab76999a0abaf11801e61a4022af5632f027d Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Wed, 11 Oct 2023 21:29:55 +0100 Subject: [PATCH 31/55] refactor(rules_toolchain): align on "local" being the "host" machine Bazel has conflicting nomenclature here. They use host machine, in particular `--host_platform` but they also use local machine when refering to remote execution. It makes sense to align on one, local seems sensible as that works in both non-remote-execution and remote-execution conversations. --- rules_toolchain/MODULE.bazel | 8 ++++---- .../e2e/{host => local}/BUILD.bazel | 2 +- .../e2e/{host => local}/non-empty.sh | 0 .../toolchain/constraint/BUILD.bazel | 4 ++-- rules_toolchain/toolchain/host/BUILD.bazel | 20 ------------------- rules_toolchain/toolchain/host/extension.bzl | 18 ----------------- rules_toolchain/toolchain/local/BUILD.bazel | 20 +++++++++++++++++++ rules_toolchain/toolchain/local/extension.bzl | 19 ++++++++++++++---- .../{host => local}/triplet/BUILD.bazel | 0 .../toolchain/{host => local}/triplet/cpu.bzl | 0 .../{host => local}/triplet/detect.bzl | 0 .../{host => local}/triplet/libc.bzl | 0 .../toolchain/{host => local}/triplet/os.bzl | 0 .../{host => local}/triplet/repository.bzl | 6 ++++++ .../{host => local}/triplet/triplet.tmpl.bzl | 0 .../toolchain/local/which/repository.bzl | 6 ++++++ .../toolchain/platform/BUILD.bazel | 4 ++-- rules_toolchain/toolchain/triplet/BUILD.bazel | 4 ++-- 18 files changed, 58 insertions(+), 53 deletions(-) rename rules_toolchain/e2e/{host => local}/BUILD.bazel (78%) rename rules_toolchain/e2e/{host => local}/non-empty.sh (100%) delete mode 100644 rules_toolchain/toolchain/host/BUILD.bazel delete mode 100644 rules_toolchain/toolchain/host/extension.bzl rename rules_toolchain/toolchain/{host => local}/triplet/BUILD.bazel (100%) rename rules_toolchain/toolchain/{host => local}/triplet/cpu.bzl (100%) rename rules_toolchain/toolchain/{host => local}/triplet/detect.bzl (100%) rename rules_toolchain/toolchain/{host => local}/triplet/libc.bzl (100%) rename rules_toolchain/toolchain/{host => local}/triplet/os.bzl (100%) rename rules_toolchain/toolchain/{host => local}/triplet/repository.bzl (88%) rename rules_toolchain/toolchain/{host => local}/triplet/triplet.tmpl.bzl (100%) diff --git a/rules_toolchain/MODULE.bazel b/rules_toolchain/MODULE.bazel index aba81b6..7e93c3d 100644 --- a/rules_toolchain/MODULE.bazel +++ b/rules_toolchain/MODULE.bazel @@ -5,8 +5,8 @@ module( bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "platforms", version = "0.0.7") -host = use_extension("//toolchain/host:extension.bzl", "host") -host.triplet( - name = "host", +local = use_extension("//toolchain:extensions.bzl", "local") +local.triplet( + name = "local", ) -use_repo(host, "host") +use_repo(local, "local") diff --git a/rules_toolchain/e2e/host/BUILD.bazel b/rules_toolchain/e2e/local/BUILD.bazel similarity index 78% rename from rules_toolchain/e2e/host/BUILD.bazel rename to rules_toolchain/e2e/local/BUILD.bazel index d3c16e5..f2b7c32 100644 --- a/rules_toolchain/e2e/host/BUILD.bazel +++ b/rules_toolchain/e2e/local/BUILD.bazel @@ -1,7 +1,7 @@ genrule( name = "data", testonly = True, - srcs = ["@rules_toolchain//toolchain/triplet:host"], + srcs = ["@rules_toolchain//toolchain/triplet:local"], outs = ["triplet.txt"], cmd = "cp $< $@", ) diff --git a/rules_toolchain/e2e/host/non-empty.sh b/rules_toolchain/e2e/local/non-empty.sh similarity index 100% rename from rules_toolchain/e2e/host/non-empty.sh rename to rules_toolchain/e2e/local/non-empty.sh diff --git a/rules_toolchain/toolchain/constraint/BUILD.bazel b/rules_toolchain/toolchain/constraint/BUILD.bazel index dd10484..36a30b1 100644 --- a/rules_toolchain/toolchain/constraint/BUILD.bazel +++ b/rules_toolchain/toolchain/constraint/BUILD.bazel @@ -10,7 +10,7 @@ load("//toolchain/triplet:common.bzl", "TRIPLETS") ] alias( - name = "host", - actual = "//toolchain/host:constraint", + name = "local", + actual = "//toolchain/local:constraint", visibility = ["//visibility:public"], ) diff --git a/rules_toolchain/toolchain/host/BUILD.bazel b/rules_toolchain/toolchain/host/BUILD.bazel deleted file mode 100644 index 066c7a3..0000000 --- a/rules_toolchain/toolchain/host/BUILD.bazel +++ /dev/null @@ -1,20 +0,0 @@ -load("@host//:triplet.bzl", "TRIPLET") -load("//toolchain/triplet:rule.bzl", "triplet") - -triplet( - name = "triplet", - value = TRIPLET.value, - visibility = ["//visibility:public"], -) - -config_setting( - name = "constraint", - constraint_values = TRIPLET.constraints, - visibility = ["//visibility:public"], -) - -platform( - name = "platform", - constraint_values = TRIPLET.constraints, - visibility = ["//visibility:public"], -) diff --git a/rules_toolchain/toolchain/host/extension.bzl b/rules_toolchain/toolchain/host/extension.bzl deleted file mode 100644 index acaf999..0000000 --- a/rules_toolchain/toolchain/host/extension.bzl +++ /dev/null @@ -1,18 +0,0 @@ -load("//toolchain/host/triplet:repository.bzl", _DOC = "DOC", _TRIPLET = "ATTRS", _triplet = "triplet") - -triplet = tag_class(doc = _DOC, attrs = { - "name": attr.string(doc = "Name of the generated repository.", mandatory = True), -} | _TRIPLET) - -def implementation(mctx): - for mod in mctx.modules: - for d in mod.tags.triplet: - _triplet(name = d.name, **{a: getattr(d, a) for a in _TRIPLET}) - -host = module_extension( - doc = "An extension for performing `host` inspection.", - implementation = implementation, - tag_classes = { - "triplet": triplet, - }, -) diff --git a/rules_toolchain/toolchain/local/BUILD.bazel b/rules_toolchain/toolchain/local/BUILD.bazel index e69de29..033e576 100644 --- a/rules_toolchain/toolchain/local/BUILD.bazel +++ b/rules_toolchain/toolchain/local/BUILD.bazel @@ -0,0 +1,20 @@ +load("@local//:triplet.bzl", "TRIPLET") +load("//toolchain/triplet:rule.bzl", "triplet") + +triplet( + name = "triplet", + value = TRIPLET.value, + visibility = ["//visibility:public"], +) + +config_setting( + name = "constraint", + constraint_values = TRIPLET.constraints, + visibility = ["//visibility:public"], +) + +platform( + name = "platform", + constraint_values = TRIPLET.constraints, + visibility = ["//visibility:public"], +) diff --git a/rules_toolchain/toolchain/local/extension.bzl b/rules_toolchain/toolchain/local/extension.bzl index ec29ca5..984789c 100644 --- a/rules_toolchain/toolchain/local/extension.bzl +++ b/rules_toolchain/toolchain/local/extension.bzl @@ -1,21 +1,32 @@ -load("//toolchain/local/which:repository.bzl", _DOC = "DOC", _WHICH = "ATTRS", _which = "which") +load("//toolchain/local/which:repository.bzl", _which = "export") +load("//toolchain/local/triplet:repository.bzl", _triplet = "export") which = tag_class( - doc = _DOC, + doc = _which.doc, attrs = { "name": attr.string(doc = "Name of the generated repository.", mandatory = True), - } | _WHICH, + } | _which.attrs, +) + +triplet = tag_class( + doc = _triplet.doc, + attrs = { + "name": attr.string(doc = "Name of the generated repository.", mandatory = True), + } | _triplet.attrs, ) def implementation(mctx): for mod in mctx.modules: for d in mod.tags.which: - _which(name = d.name, **{a: getattr(d, a) for a in _WHICH}) + _which.rule(name = d.name, **{a: getattr(d, a) for a in _which.attrs}) + for d in mod.tags.triplet: + _triplet.rule(name = d.name, **{a: getattr(d, a) for a in _triplet.attrs}) local = module_extension( doc = "An extension for working with the local (i.e. host) system.", implementation = implementation, tag_classes = { "which": which, + "triplet": triplet, }, ) diff --git a/rules_toolchain/toolchain/host/triplet/BUILD.bazel b/rules_toolchain/toolchain/local/triplet/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/host/triplet/BUILD.bazel rename to rules_toolchain/toolchain/local/triplet/BUILD.bazel diff --git a/rules_toolchain/toolchain/host/triplet/cpu.bzl b/rules_toolchain/toolchain/local/triplet/cpu.bzl similarity index 100% rename from rules_toolchain/toolchain/host/triplet/cpu.bzl rename to rules_toolchain/toolchain/local/triplet/cpu.bzl diff --git a/rules_toolchain/toolchain/host/triplet/detect.bzl b/rules_toolchain/toolchain/local/triplet/detect.bzl similarity index 100% rename from rules_toolchain/toolchain/host/triplet/detect.bzl rename to rules_toolchain/toolchain/local/triplet/detect.bzl diff --git a/rules_toolchain/toolchain/host/triplet/libc.bzl b/rules_toolchain/toolchain/local/triplet/libc.bzl similarity index 100% rename from rules_toolchain/toolchain/host/triplet/libc.bzl rename to rules_toolchain/toolchain/local/triplet/libc.bzl diff --git a/rules_toolchain/toolchain/host/triplet/os.bzl b/rules_toolchain/toolchain/local/triplet/os.bzl similarity index 100% rename from rules_toolchain/toolchain/host/triplet/os.bzl rename to rules_toolchain/toolchain/local/triplet/os.bzl diff --git a/rules_toolchain/toolchain/host/triplet/repository.bzl b/rules_toolchain/toolchain/local/triplet/repository.bzl similarity index 88% rename from rules_toolchain/toolchain/host/triplet/repository.bzl rename to rules_toolchain/toolchain/local/triplet/repository.bzl index d7dc1c3..85b8968 100644 --- a/rules_toolchain/toolchain/host/triplet/repository.bzl +++ b/rules_toolchain/toolchain/local/triplet/repository.bzl @@ -24,3 +24,9 @@ triplet = repository_rule( attrs = ATTRS, local = True, ) + +export = struct( + doc = DOC, + attrs = ATTRS, + rule = triplet, +) diff --git a/rules_toolchain/toolchain/host/triplet/triplet.tmpl.bzl b/rules_toolchain/toolchain/local/triplet/triplet.tmpl.bzl similarity index 100% rename from rules_toolchain/toolchain/host/triplet/triplet.tmpl.bzl rename to rules_toolchain/toolchain/local/triplet/triplet.tmpl.bzl diff --git a/rules_toolchain/toolchain/local/which/repository.bzl b/rules_toolchain/toolchain/local/which/repository.bzl index 77e1a93..e513636 100644 --- a/rules_toolchain/toolchain/local/which/repository.bzl +++ b/rules_toolchain/toolchain/local/which/repository.bzl @@ -55,3 +55,9 @@ which = repository_rule( "PATH", ], ) + +export = struct( + doc = DOC, + attrs = ATTRS, + rule = which, +) diff --git a/rules_toolchain/toolchain/platform/BUILD.bazel b/rules_toolchain/toolchain/platform/BUILD.bazel index d26aef3..3771c5b 100644 --- a/rules_toolchain/toolchain/platform/BUILD.bazel +++ b/rules_toolchain/toolchain/platform/BUILD.bazel @@ -10,7 +10,7 @@ load("//toolchain/triplet:common.bzl", "TRIPLETS") ] alias( - name = "host", - actual = "//toolchain/host:platform", + name = "local", + actual = "//toolchain/local:platform", visibility = ["//visibility:public"], ) diff --git a/rules_toolchain/toolchain/triplet/BUILD.bazel b/rules_toolchain/toolchain/triplet/BUILD.bazel index b977536..cab6ea5 100644 --- a/rules_toolchain/toolchain/triplet/BUILD.bazel +++ b/rules_toolchain/toolchain/triplet/BUILD.bazel @@ -11,8 +11,8 @@ load(":test.bzl", "test") ] alias( - name = "host", - actual = "//toolchain/host:triplet", + name = "local", + actual = "//toolchain/local:triplet", visibility = ["//visibility:public"], ) -- GitLab From 628a9fbd40ff760d5b6c0560112aa314fbe0bf10 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 12 Oct 2023 10:08:46 +0100 Subject: [PATCH 32/55] docs(rules_toolchain): readme --- rules_toolchain/README.md | 130 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 rules_toolchain/README.md diff --git a/rules_toolchain/README.md b/rules_toolchain/README.md new file mode 100644 index 0000000..9a55a13 --- /dev/null +++ b/rules_toolchain/README.md @@ -0,0 +1,130 @@ +# `rules_toolchain` + +> A Bazel ruleset to enable concise toolchain registration. + +## Getting Started + +### Local Tool + +Add the following to `MODULE.bazel`: + +```py +local = use_extension("@rules_toolchain//toolchain:extensions.bzl", "local") +local.which("echo") +use_repo(local, "echo") +``` + +The `echo` tool will be found on the `PATH`. + +A repository with the `@echo//:echo` target will be created. + +### Downloaded Tool + +Use `rules_download` to provide a hermetic, pre-built binary in `MODULE.bazel` + +```py +download = use_extension("@rules_download//download:extensions.bzl", "download") +download = use_extension("@rules_download//download:extensions.bzl", "download") +download.archive( + name = "coreutils-arm64-linux-gnu", + srcs = ["coreutils"], + integrity = "sha256-mlmkbeabyu4+5+cFiUSL6Ki4KFNqWu48gTjFc3NS43g=", + strip_prefix = "coreutils-0.0.21-aarch64-unknown-linux-gnu", + urls = ["https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-aarch64-unknown-linux-gnu.tar.gz"], +) +use_repo(download, "coreutils-arm64-linux-gnu") +``` + +A repository with the `@coreutils-arm64-linux-gnu//:coreutils` target will be created. + +### Toolchains + +Create a `toolchain/echo/BUILD.bazel` with the following: + +```py +load("@rules_toolchain//toolchain:defs.bzl", "toolchain_symlink_target", "toolchain_test") + +# Custom rule, described in the next section +load(":resolved.bzl", "resolved") + +# The `toolchain/echo:type` for registration +toolchain_type( + name = "type", +) + +# Register the `local` binary as a toolchain +# No `exec_compatible_with` constraints are needed as a local binary is always compatible with the execution platform +toolchain( + name = "local", + toolchain = "@echo", + toolchain_type = ":type", +) + +# Create a toolchain binary from the downloaded `coreutils` +toolchain_symlink_target( + name = "coreutils-arm64-linux-gnu", + target = "@coreutils-arm64-linux-gnu//:coreutils", +) + +# Create a symlink to the multi-call binary +toolchain_symlink_target( + name = "echo-arm64-linux-gnu", + basename = "echo", + target = ":coreutils-arm64-linux-gnu", +) + +# Register the hermetic toolchain +# Use constraints to signify what host machines the toolchain is compatible with +toolchain( + name = "arm64-linux", + toolchain = ":echo-arm64-linux-gnu", + toolchain_type = ":type", + exec_compatible_with = [ + "@rules_toolchain//toolchain/constraint/cpu:arm64", + "@rules_toolchain//toolchain/constraint/os:linux", + # Bazel _assumes_ `glibc` for Linux + # "@rules_toolchain//toolchain/constraint/libc:gnu", + ], +) + +# Provide a resolved toolchain target +resolved( + name = "resolved", + toolchain_type = ":type", +) +``` + +#### Resolved + +To work around a [quirk in Bazel][resolved], the resolution of the toolchain must be defined in a separate rule. + +`@rules_toolchain` provides the necessary building blocks for this rule. + +Create `toolchain/echo/resolved.bzl` to provide the `resolved` rule that is used above: + +```py +load("@rules_toolchain//toolchain:resolved.bzl", _resolved = "export") + +DOC = _resolved.doc + +ATTRS = _resolved.attrs + +implementation = _resolve.implementation + +resolved = _resolved.rule( + toolchain = Label("//toolchain/echo:type"), +) +``` + +### Run + +The `resolved` target allows toolchain that is compatible with the current machine to be executed: + +```py +bazelisk run -- //toolchain/echo:resolved "Hello, world!" +``` + +If the machine is compatible with the downloaded toolchain constraints, that will be used. Otherwise, it will fallback +to finding the toolchain on the local `PATH`. + +[resolved]: https://github.com/bazelbuild/bazel/issues/14009 -- GitLab From 524eca092f230231db32e89dc0e02f99bb270bef Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 12 Oct 2023 10:30:57 +0100 Subject: [PATCH 33/55] refactor(rules_toolchain): simplify `resolved` rule (again) --- .../e2e/toolchain/echo/resolved.bzl | 12 +-- rules_toolchain/toolchain/resolved.bzl | 77 +++++++++++-------- 2 files changed, 50 insertions(+), 39 deletions(-) diff --git a/rules_toolchain/e2e/toolchain/echo/resolved.bzl b/rules_toolchain/e2e/toolchain/echo/resolved.bzl index 8cd2f3c..7aefaa9 100644 --- a/rules_toolchain/e2e/toolchain/echo/resolved.bzl +++ b/rules_toolchain/e2e/toolchain/echo/resolved.bzl @@ -1,9 +1,11 @@ -load("@rules_toolchain//toolchain:resolved.bzl", _ATTRS = "ATTRS", _implementation = "implementation", _rule = "macro") +load("@rules_toolchain//toolchain:resolved.bzl", _resolved = "export") -ATTRS = _ATTRS +DOC = _resolved.doc.format(toolchain = "echo") -implementation = _implementation +ATTRS = _resolved.attrs -resolved = _rule( - toolchain = Label("//toolchain/echo:type"), +implementation = _resolved.implementation + +resolved = _resolved.rule( + toolchain_type = Label("//toolchain/echo:type"), ) diff --git a/rules_toolchain/toolchain/resolved.bzl b/rules_toolchain/toolchain/resolved.bzl index 37079c1..2814016 100644 --- a/rules_toolchain/toolchain/resolved.bzl +++ b/rules_toolchain/toolchain/resolved.bzl @@ -1,3 +1,10 @@ +DOC = """Resolved toolchain information for the `{toolchain}` toolchain. + +This target is runnable via: + + bazelisk run -- {toolchain} +""" + PROVIDES = ( platform_common.TemplateVariableInfo, platform_common.ToolchainInfo, @@ -41,57 +48,59 @@ def implementation(ctx): default, ] -def macro(*, toolchain): - """ - Provides template variable information for a toolchain. +def macro(*, toolchain_type): + """Provides a executable `rule` to resolve a toolchain. - When creating a toolchain, to provide the resolved toolchain create a `resolved.bzl` file: + To provide the resolved toolchain create a `resolved.bzl` file: + ```py + load("@rules_toolchain//toolchain:resolved.bzl", _resolved = "export") - load( - "@rules_toolchain//toolchain:resolved.bzl", - _ATTRS = "ATTRS", - _implementation = "implementation" - _rule = "macro", - ) + DOC = _resolved.doc.format(toolchain="cp") - ATTRS = _ATTRS + ATTRS = _resolve.attrs - implementation = _implementation + implementation = _resolved.implementation - resolved = _rule( - toolchain = Label("//coreutils/toolchain/cp:type"), - ) + resolved = _resolved.rule( + toolchain_type = Label("//coreutils/toolchain/cp:type"), + ) + ``` This rule can then be used to provide the resolved toolchain: - load(":resolved.bzl", "resolved") + ```py + load(":resolved.bzl", "resolved") - toolchain_type( - name = ":type", - ) - - # Some `toolchain` rules that are registered + toolchain_type( + name = ":type", + ) - resolved( - name = "resolved", - toolchain = ":type", - ) + # Some `toolchain` rules that are registered - The resolved target is runnable with `bazelisk run`. + resolved( + name = "resolved", + toolchain = ":type", + ) + ``` - [1]: https://github.com/bazelbuild/bazel/issues/14009 + The resulting `resolved` target is runnable via `bazelisk run`. """ - return rule( - doc = """Resolved toolchain information for the `{toolchain}` toolchain. - -This target is runnable via: + if type(toolchain_type) != type(Label("//:all")): + fail("`toolchain_type` must be passed as a `Label`: {}".format(type(toolchain_type))) - bazelisk run -- {toolchain} -""".format(toolchain = toolchain), + return rule( + doc = DOC.format(toolchain = toolchain_type), attrs = ATTRS, implementation = implementation, provides = PROVIDES, - toolchains = [toolchain], + toolchains = [toolchain_type], executable = True, ) + +export = struct( + doc = DOC, + attrs = ATTRS, + implementation = implementation, + rule = macro, +) -- GitLab From 18e01d3cac25e9b7a88adfb1dff0160f2fb1f764 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 12 Oct 2023 11:34:40 +0100 Subject: [PATCH 34/55] feat(rules_toolchain): test anything protocol for testing --- rules_toolchain/toolchain/test/BUILD.bazel | 1 + rules_toolchain/toolchain/test/any | 0 rules_toolchain/toolchain/test/posix.tmpl.sh | 72 ++++++++++++++++---- 3 files changed, 58 insertions(+), 15 deletions(-) create mode 100644 rules_toolchain/toolchain/test/any diff --git a/rules_toolchain/toolchain/test/BUILD.bazel b/rules_toolchain/toolchain/test/BUILD.bazel index 322e8db..5a9399a 100644 --- a/rules_toolchain/toolchain/test/BUILD.bazel +++ b/rules_toolchain/toolchain/test/BUILD.bazel @@ -2,6 +2,7 @@ exports_files(["posix.tmpl.sh"]) exports_files( [ + "any", "non-empty", "empty", ], diff --git a/rules_toolchain/toolchain/test/any b/rules_toolchain/toolchain/test/any new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/test/posix.tmpl.sh b/rules_toolchain/toolchain/test/posix.tmpl.sh index 0c6547c..0005c08 100755 --- a/rules_toolchain/toolchain/test/posix.tmpl.sh +++ b/rules_toolchain/toolchain/test/posix.tmpl.sh @@ -15,43 +15,72 @@ JUNIT="${XML_OUTPUT_FILE-junit.xml}" readonly JUNIT # Run the toolchain executable and validate the output -"${EXECUTABLE}" "${@}" >stdout.txt 2>stderr.txt +if ! "${EXECUTABLE}" "${@}" >stdout.txt 2>stderr.txt; then + echo >&2 "Failed to run: ${EXECUTABLE} ${*}" + echo >&2 "stdout:" + while IFS= read -r LINE; do + echo >&2 "${LINE}" + done &2 "stderr:" + while IFS= read -r LINE; do + echo >&2 "${LINE}" + done &2 'ok %i - %s contained any content\n' "${INDEX}" "${FILEPATH}" + printf ' \n' "${FILEPATH}" +) non_empty() ( - FILEPATH="${1}" - readonly FILEPATH + INDEX="${1}" + FILEPATH="${2}" + if ! test -s "${FILEPATH}"; then + printf >&2 'not ok %i - %s was an empty file when content was expected\n' "${INDEX}" "${FILEPATH}" printf ' \n' "${FILEPATH}" - printf ' %s contained no content\n' "${FILEPATH}" + printf ' %s was an empty file when content was expected\n' "${FILEPATH}" printf ' \n' else + printf >&2 'ok %i - %s was an empty file\n' "${INDEX}" "${FILEPATH}" printf ' \n' "${FILEPATH}" fi ) empty() ( - FILEPATH="${1}" + INDEX="${1}" + FILEPATH="${2}" + if test -s "${FILEPATH}"; then + printf >&2 'not ok %i - %s contained content when an empty file was expected\n' "${INDEX}" "${FILEPATH}" printf ' \n' "${FILEPATH}" printf ' %s contained unexpected content:\n' "${FILEPATH}" while IFS= read -r LINE; do printf '%s\n' "${LINE}" - done + done <"${FILEPATH}" printf '%s\n' "${LINE}" printf ' \n' else + printf >&2 'ok %i - %s was a non-empty file\n' "${INDEX}" "${FILEPATH}" printf ' \n' "${FILEPATH}" fi ) diff() ( - FILEPATH="${1}" - EXPECTED="${2}" + INDEX="${1}" + FILEPATH="${2}" + EXPECTED="${3}" + while true; do FAILS=0 IFS= read -r A <&3 || FAILS=$((FAILS + 1)) IFS= read -r B <&4 || FAILS=$((FAILS + 1)) if test "${FAILS}" -eq 1; then + printf >&2 'not ok %i - %s had a different number of lines to %s\n' "${INDEX}" "${FILEPATH}" "${EXPECTED}" printf ' \n' "${FILEPATH}" printf ' %s contained different line counts:\n' "${FILEPATH}" printf '%s %s\n' '---' "${FILEPATH}" @@ -65,6 +94,7 @@ diff() ( elif test "${FAILS}" -eq 2; then exit elif test "${A}" != "${B}"; then + printf >&2 'not ok %i: %s had different content to %s\n' "${INDEX}" "${FILEPATH}" "${EXPECTED}" printf ' \n' "${FILEPATH}" printf ' %s contained different content:\n' "${FILEPATH}" printf '%s %s\n' '---' "${FILEPATH}" @@ -78,19 +108,23 @@ diff() ( fi done 3<"${FILEPATH}" 4<"${EXPECTED}" + printf >&2 'ok %s - %s was a non-empty file\n' "${INDEX}" "${FILEPATH}" printf ' \n' "${FILEPATH}" ) validate() ( - FILEPATH="${1}" - EXPECTED="${2}" + INDEX="${1}" + FILEPATH="${2}" + EXPECTED="${3}" if ! test -f "${FILEPATH}"; then + printf >&2 'not ok %i - %s not found\n' "${INDEX}" "${FILEPATH}" printf ' \n' "${FILEPATH}" printf ' %s was not found\n' "${FILEPATH}" printf ' \n' exit elif ! test -f "${EXPECTED}"; then + printf >&2 'not ok %i - %s not found\n' "${INDEX}" "${EXPECTED}" printf ' \n' "${FILEPATH}" printf ' %s was not found\n' "${EXPECTED}" printf ' \n' @@ -98,26 +132,34 @@ validate() ( fi case "${EXPECTED}" in + *"/toolchain/test/any") + any "${INDEX}" "${FILEPATH}" + ;; *"/toolchain/test/non-empty") - non_empty "${FILEPATH}" "${JUNIT}" + non_empty "${INDEX}" "${FILEPATH}" ;; *"/toolchain/test/empty") - empty "${FILEPATH}" "${JUNIT}" + empty "${INDEX}" "${FILEPATH}" ;; *) - diff "${FILEPATH}" "${EXPECTED}" "${JUNIT}" + diff "${INDEX}" "${FILEPATH}" "${EXPECTED}" ;; esac ) junit() ( COUNT="${#}" - printf '\n' $((COUNT / 2)) + TESTS=$((COUNT / 2)) + readonly COUNT TESTS + printf '\n' "${TESTS}" + printf >&2 '1..%i\n' $((TESTS)) + INDEX=1 while ! test -z ${2+x}; do FILEPATH="${1}" EXPECTED="${2}" shift 2 - validate "${FILEPATH}" "${EXPECTED}" + validate "${INDEX}" "${FILEPATH}" "${EXPECTED}" + INDEX=$((INDEX + 1)) done printf '\n' ) -- GitLab From 18daf60ec9184a4e2ba6e90b4c26b2b3c31f09de Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 12 Oct 2023 14:50:14 +0100 Subject: [PATCH 35/55] fix(rules_toolchain): add `no-remote` to local binary symlinks It is almost impossible to correctly transfer all the local files necessary for a local binary to the remote service. For safety, constraint all local toolchains to run on the local client until we have more time to validate that local toolchains work remotely. This is certainly possible: C/C++ toolchain define all the local files needed for remote execution. We will need to expose the `data` attribute through so that arbitary files can be globbed and sent along with the binary. --- rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel b/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel index 6a51efa..84f9d92 100644 --- a/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel +++ b/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel @@ -5,5 +5,6 @@ package(default_visibility = ["//visibility:public"]) toolchain_symlink_path( name = "{{name}}", path = "{{path}}", + tags = ["no-remote"], variable = "{{variable}}", ) -- GitLab From ffad3b5b81862de4e7db9d6db9512a67e11b981d Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 12 Oct 2023 16:13:27 +0100 Subject: [PATCH 36/55] feat(rules_toolchain): add `uname` release detection --- .../toolchain/local/triplet/os.bzl | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/rules_toolchain/toolchain/local/triplet/os.bzl b/rules_toolchain/toolchain/local/triplet/os.bzl index 85c1541..b7810b1 100644 --- a/rules_toolchain/toolchain/local/triplet/os.bzl +++ b/rules_toolchain/toolchain/local/triplet/os.bzl @@ -1,3 +1,4 @@ +load("//toolchain/triplet:split.bzl", "split") load("//toolchain/triplet:VersionedInfo.bzl", "VersionedInfo") def _header(rctx, path): @@ -9,7 +10,7 @@ def _header(rctx, path): path: the path to the Linux version header to read. Returns: - The dot-separated version string. + The `VersionedInfo` provider """ data = rctx.read(path).strip() @@ -47,6 +48,34 @@ def _header(rctx, path): return VersionedInfo("linux.{}.{}.{}".format(major, minor, patch)) +def _uname(rctx, path): + """ + Determines the operating system version from `uname` + + Args: + rctx: The repository context that can execute commands on the host machine. + path: the path to the `uname` executable. + + Returns: + The `VersionedInfo` provider + """ + result = rctx.execute((path, "-r")) + if result.return_code != 0: + fail("Failed to get `uname` release: {}".format(result.stderr)) + + version, _ = result.stdout.split("-", 1) + + major, minor, patch = split(version, ".", { + 1: lambda x: (x, None, None), + 2: lambda x, y: (x, y, None), + 3: lambda x, y, z: (x, y, z), + }) + + if rctx.path("/.dockerenv").exists: + print("`uname` release is the host kernel inside a container.") + + return VersionedInfo("linux.{}.{}.{}".format(int(major), int(minor), int(patch))) + def os(rctx): """ Detects the host operating system. @@ -61,6 +90,10 @@ def os(rctx): if path.exists: return _header(rctx, path) + path = rctx.which("uname") + if path.exists: + return _uname(rctx, path) + return VersionedInfo({ "linux": "linux", }[rctx.os.name]) -- GitLab From c434993005c85658e478901809cccaf5dbefda2f Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 12 Oct 2023 14:57:29 +0100 Subject: [PATCH 37/55] fix(rules_toolchain): add locally detect OS version to constraints --- rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel b/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel index 2f56aae..67cc3e3 100644 --- a/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel +++ b/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel @@ -1,12 +1,12 @@ +load("@local//:triplet.bzl", "TRIPLET") +load("@bazel_skylib//lib:sets.bzl", "sets") + package(default_visibility = ["//visibility:public"]) constraint_setting(name = "linux") # TODO: figure out a way to generate these -VERSIONS = ( - "3.11.13", - "6.3.0", -) +VERSIONS = sets.to_list(sets.make(() + (TRIPLET.os.version.value,) if TRIPLET.os.version else ())) [ constraint_value( -- GitLab From 940c38c52e018b5835aa896a4e32d70a553f0362 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Fri, 13 Oct 2023 09:01:35 +0100 Subject: [PATCH 38/55] feat(rules_toolchain): generate LTS version variants --- .../toolchain/constraint/os/linux/BUILD.bazel | 6 +--- .../constraint/os/linux/versions.bzl | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 rules_toolchain/toolchain/constraint/os/linux/versions.bzl diff --git a/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel b/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel index 67cc3e3..b0fbd86 100644 --- a/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel +++ b/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel @@ -1,13 +1,9 @@ -load("@local//:triplet.bzl", "TRIPLET") -load("@bazel_skylib//lib:sets.bzl", "sets") +load(":versions.bzl", "VERSIONS") package(default_visibility = ["//visibility:public"]) constraint_setting(name = "linux") -# TODO: figure out a way to generate these -VERSIONS = sets.to_list(sets.make(() + (TRIPLET.os.version.value,) if TRIPLET.os.version else ())) - [ constraint_value( name = version, diff --git a/rules_toolchain/toolchain/constraint/os/linux/versions.bzl b/rules_toolchain/toolchain/constraint/os/linux/versions.bzl new file mode 100644 index 0000000..23e107a --- /dev/null +++ b/rules_toolchain/toolchain/constraint/os/linux/versions.bzl @@ -0,0 +1,28 @@ +load("@local//:triplet.bzl", "TRIPLET") +load("@bazel_skylib//lib:sets.bzl", "sets") + +LOCAL = TRIPLET.os.version and TRIPLET.os.version.value + +# TODO: figure out a way to generate Linux versions +# Manually updating from https://en.wikipedia.org/wiki/Linux_kernel_version_history +# Only need the _latest_ patch version for each +LTS = ( + "4.4.302", + "4.14.325", + "4.19.294", + "5.4.256", + "5.10.194", + "5.15.131", +) + +def _versions(value): + major, minor, patch = value.split(".") + return ["{}.{}.{}".format(major, minor, p) for p in range(int(patch))] + +VERSIONS = tuple(sets.to_list(sets.make([ + v + for v in list(LTS) + + [x for v in LTS for x in _versions(v)] + + [LOCAL] + if v != None +]))) -- GitLab From f76f836bc35248783eab41d687b7537db6d89f7f Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Fri, 13 Oct 2023 09:03:26 +0100 Subject: [PATCH 39/55] refactor(rules_toolchain): rename `common.bzl` to `triplets.bzl` --- rules_toolchain/toolchain/constraint/BUILD.bazel | 2 +- rules_toolchain/toolchain/platform/BUILD.bazel | 2 +- rules_toolchain/toolchain/triplet/BUILD.bazel | 2 +- rules_toolchain/toolchain/triplet/{common.bzl => triplets.bzl} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename rules_toolchain/toolchain/triplet/{common.bzl => triplets.bzl} (100%) diff --git a/rules_toolchain/toolchain/constraint/BUILD.bazel b/rules_toolchain/toolchain/constraint/BUILD.bazel index 36a30b1..a35ed05 100644 --- a/rules_toolchain/toolchain/constraint/BUILD.bazel +++ b/rules_toolchain/toolchain/constraint/BUILD.bazel @@ -1,4 +1,4 @@ -load("//toolchain/triplet:common.bzl", "TRIPLETS") +load("//toolchain/triplet:triplets.bzl", "TRIPLETS") [ config_setting( diff --git a/rules_toolchain/toolchain/platform/BUILD.bazel b/rules_toolchain/toolchain/platform/BUILD.bazel index 3771c5b..2cda2f7 100644 --- a/rules_toolchain/toolchain/platform/BUILD.bazel +++ b/rules_toolchain/toolchain/platform/BUILD.bazel @@ -1,4 +1,4 @@ -load("//toolchain/triplet:common.bzl", "TRIPLETS") +load("//toolchain/triplet:triplets.bzl", "TRIPLETS") [ platform( diff --git a/rules_toolchain/toolchain/triplet/BUILD.bazel b/rules_toolchain/toolchain/triplet/BUILD.bazel index cab6ea5..7a7903f 100644 --- a/rules_toolchain/toolchain/triplet/BUILD.bazel +++ b/rules_toolchain/toolchain/triplet/BUILD.bazel @@ -1,4 +1,4 @@ -load(":common.bzl", "TRIPLETS") +load(":triplets.bzl", "TRIPLETS") load(":rule.bzl", "triplet") load(":test.bzl", "test") diff --git a/rules_toolchain/toolchain/triplet/common.bzl b/rules_toolchain/toolchain/triplet/triplets.bzl similarity index 100% rename from rules_toolchain/toolchain/triplet/common.bzl rename to rules_toolchain/toolchain/triplet/triplets.bzl -- GitLab From d30c060218d25edb49be6f4b0a45d6f4b4e4add0 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Fri, 13 Oct 2023 09:06:16 +0100 Subject: [PATCH 40/55] feat(rules_toolchain): expose `glibc` `VERSIONS` collection --- .../toolchain/constraint/libc/gnu/BUILD.bazel | 78 +------------------ .../constraint/libc/gnu/versions.bzl | 75 ++++++++++++++++++ 2 files changed, 77 insertions(+), 76 deletions(-) create mode 100644 rules_toolchain/toolchain/constraint/libc/gnu/versions.bzl diff --git a/rules_toolchain/toolchain/constraint/libc/gnu/BUILD.bazel b/rules_toolchain/toolchain/constraint/libc/gnu/BUILD.bazel index 1b73c64..16f3174 100644 --- a/rules_toolchain/toolchain/constraint/libc/gnu/BUILD.bazel +++ b/rules_toolchain/toolchain/constraint/libc/gnu/BUILD.bazel @@ -1,83 +1,9 @@ +load(":versions.bzl", "VERSIONS") + package(default_visibility = ["//visibility:public"]) constraint_setting(name = "gnu") -# git ls-remote --tags https://sourceware.org/git/glibc.git | -# awk '{print $2}' | -# grep -oe 'glibc-2\.[0-9]\+\(\.[0-9]\+\)\?$' | -# grep -ve '\.\(9[0-9]\|1[0-1][0-9]\|9000\)$' | -# sort -V | -# uniq | -# sed 's|glibc-\(.\+\)| "\1",|g' -VERSIONS = ( - "2.0.2", - "2.0.4", - "2.0.5", - "2.0.6", - "2.1", - "2.1.1", - "2.1.2", - "2.2", - "2.2.1", - "2.2.2", - "2.2.3", - "2.2.4", - "2.2.5", - "2.3", - "2.3.1", - "2.3.2", - "2.3.3", - "2.3.4", - "2.3.5", - "2.3.6", - "2.4", - "2.5", - "2.5.1", - "2.6", - "2.6.1", - "2.7", - "2.8", - "2.9", - "2.10", - "2.10.1", - "2.10.2", - "2.11", - "2.11.1", - "2.11.2", - "2.11.3", - "2.12", - "2.12.1", - "2.12.2", - "2.13", - "2.14", - "2.14.1", - "2.15", - "2.16", - "2.16.0", - "2.17", - "2.18", - "2.19", - "2.20", - "2.21", - "2.22", - "2.23", - "2.24", - "2.25", - "2.26", - "2.27", - "2.28", - "2.29", - "2.30", - "2.31", - "2.32", - "2.33", - "2.34", - "2.35", - "2.36", - "2.37", - "2.38", -) - [ constraint_value( name = version, diff --git a/rules_toolchain/toolchain/constraint/libc/gnu/versions.bzl b/rules_toolchain/toolchain/constraint/libc/gnu/versions.bzl new file mode 100644 index 0000000..9cd4d7d --- /dev/null +++ b/rules_toolchain/toolchain/constraint/libc/gnu/versions.bzl @@ -0,0 +1,75 @@ +# git ls-remote --tags https://sourceware.org/git/glibc.git | +# awk '{print $2}' | +# grep -oe 'glibc-2\.[0-9]\+\(\.[0-9]\+\)\?$' | +# grep -ve '\.\(9[0-9]\|1[0-1][0-9]\|9000\)$' | +# sort -V | +# uniq | +# sed 's|glibc-\(.\+\)| "\1",|g' +VERSIONS = ( + "2.0.2", + "2.0.4", + "2.0.5", + "2.0.6", + "2.1", + "2.1.1", + "2.1.2", + "2.2", + "2.2.1", + "2.2.2", + "2.2.3", + "2.2.4", + "2.2.5", + "2.3", + "2.3.1", + "2.3.2", + "2.3.3", + "2.3.4", + "2.3.5", + "2.3.6", + "2.4", + "2.5", + "2.5.1", + "2.6", + "2.6.1", + "2.7", + "2.8", + "2.9", + "2.10", + "2.10.1", + "2.10.2", + "2.11", + "2.11.1", + "2.11.2", + "2.11.3", + "2.12", + "2.12.1", + "2.12.2", + "2.13", + "2.14", + "2.14.1", + "2.15", + "2.16", + "2.16.0", + "2.17", + "2.18", + "2.19", + "2.20", + "2.21", + "2.22", + "2.23", + "2.24", + "2.25", + "2.26", + "2.27", + "2.28", + "2.29", + "2.30", + "2.31", + "2.32", + "2.33", + "2.34", + "2.35", + "2.36", + "2.37", + "2.38", +) -- GitLab From 2d30d944f3c57c10d613392e5d8f3107131f77f9 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Fri, 13 Oct 2023 09:17:36 +0100 Subject: [PATCH 41/55] feat(rules_toolchain): generate versioned triplets --- rules_toolchain/toolchain/triplet/triplets.bzl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rules_toolchain/toolchain/triplet/triplets.bzl b/rules_toolchain/toolchain/triplet/triplets.bzl index 64e2058..1b78a1a 100644 --- a/rules_toolchain/toolchain/triplet/triplets.bzl +++ b/rules_toolchain/toolchain/triplet/triplets.bzl @@ -1,6 +1,17 @@ +load("@rules_toolchain//toolchain/constraint/os/linux:versions.bzl", _LINUX = "VERSIONS") +load("@rules_toolchain//toolchain/constraint/libc/gnu:versions.bzl", _GNU = "VERSIONS") load(":TripletInfo.bzl", "TripletInfo") -TRIPLETS = ( +UNVERSIONED = ( TripletInfo("arm64-linux-gnu"), TripletInfo("amd64-linux-gnu"), ) + +LINUX_GNU = tuple([ + TripletInfo("{}-{}-{}".format(cpu, os, libc)) + for cpu in ("arm64", "amd64") + for os in ["linux.{}".format(v) for v in _LINUX] + for libc in ["gnu.{}".format(v) for v in _GNU] +]) + +TRIPLETS = UNVERSIONED + LINUX_GNU -- GitLab From de9a56a772af392e116157585a4abe95e610db59 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Fri, 13 Oct 2023 09:54:11 +0100 Subject: [PATCH 42/55] fix(rules_toolchain): only expose unversioned triplets For some reason, the `triplet:test` target creates all the Posix shell scripts for each triplet. We need a more efficient `triplet` rule implementation. We also need to figure out why every single triplet is getting resolved. --- rules_toolchain/toolchain/triplet/BUILD.bazel | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules_toolchain/toolchain/triplet/BUILD.bazel b/rules_toolchain/toolchain/triplet/BUILD.bazel index 7a7903f..5a13be9 100644 --- a/rules_toolchain/toolchain/triplet/BUILD.bazel +++ b/rules_toolchain/toolchain/triplet/BUILD.bazel @@ -1,4 +1,4 @@ -load(":triplets.bzl", "TRIPLETS") +load(":triplets.bzl", "UNVERSIONED") load(":rule.bzl", "triplet") load(":test.bzl", "test") @@ -7,7 +7,7 @@ load(":test.bzl", "test") name = t.value, visibility = ["//visibility:public"], ) - for t in TRIPLETS + for t in UNVERSIONED ] alias( -- GitLab From 3d77b595e9e2c5376f997c2daf3e387cc6fa8849 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Fri, 13 Oct 2023 13:38:57 +0100 Subject: [PATCH 43/55] docs(rules_toolchain): remove duplicated line --- rules_toolchain/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/rules_toolchain/README.md b/rules_toolchain/README.md index 9a55a13..57d2a25 100644 --- a/rules_toolchain/README.md +++ b/rules_toolchain/README.md @@ -24,7 +24,6 @@ Use `rules_download` to provide a hermetic, pre-built binary in `MODULE.bazel` ```py download = use_extension("@rules_download//download:extensions.bzl", "download") -download = use_extension("@rules_download//download:extensions.bzl", "download") download.archive( name = "coreutils-arm64-linux-gnu", srcs = ["coreutils"], -- GitLab From ef539a741ae495760e3796c140381e6f62314fe8 Mon Sep 17 00:00:00 2001 From: Sebastian Birunt Date: Thu, 5 Oct 2023 18:44:26 +0200 Subject: [PATCH 44/55] feat(rules_toolchain): add `local.select` extension Adds an tag class that can select a repository based on the current local machine triplet. --- rules_toolchain/e2e/MODULE.bazel | 22 ++++++ rules_toolchain/e2e/local/select/BUILD.bazel | 8 ++ rules_toolchain/e2e/test/BUILD.bazel | 0 rules_toolchain/e2e/test/extension.bzl | 21 ++++++ rules_toolchain/e2e/test/fixture/BUILD.bazel | 4 + .../e2e/test/fixture/BUILD.tmpl.bazel | 4 + .../e2e/test/fixture/hello-world.txt | 1 + .../e2e/test/fixture/repository.bzl | 36 +++++++++ rules_toolchain/toolchain/local/extension.bzl | 75 +++++++++++++++++++ .../toolchain/local/symlink/BUILD.bazel | 0 .../toolchain/local/symlink/repository.bzl | 34 +++++++++ 11 files changed, 205 insertions(+) create mode 100644 rules_toolchain/e2e/local/select/BUILD.bazel create mode 100644 rules_toolchain/e2e/test/BUILD.bazel create mode 100644 rules_toolchain/e2e/test/extension.bzl create mode 100644 rules_toolchain/e2e/test/fixture/BUILD.bazel create mode 100644 rules_toolchain/e2e/test/fixture/BUILD.tmpl.bazel create mode 100644 rules_toolchain/e2e/test/fixture/hello-world.txt create mode 100644 rules_toolchain/e2e/test/fixture/repository.bzl create mode 100644 rules_toolchain/toolchain/local/symlink/BUILD.bazel create mode 100644 rules_toolchain/toolchain/local/symlink/repository.bzl diff --git a/rules_toolchain/e2e/MODULE.bazel b/rules_toolchain/e2e/MODULE.bazel index 8c49d27..f009e5e 100644 --- a/rules_toolchain/e2e/MODULE.bazel +++ b/rules_toolchain/e2e/MODULE.bazel @@ -14,3 +14,25 @@ local.which(name = "echo") use_repo(local, "echo") register_toolchains("//toolchain/echo:all") + +test = use_extension("//test:extension.bzl", "test") +test.fixture( + name = "fixture-amd64-linux-gnu", +) +test.fixture( + name = "fixture-arm64-linux-gnu", +) +test.fixture( + name = "fixture-arm-linux-musl", +) +use_repo(test, "fixture-amd64-linux-gnu", "fixture-arm-linux-musl", "fixture-arm64-linux-gnu") + +local.select( + name = "fixture", + map = { + "@fixture-amd64-linux-gnu": "amd64-linux-gnu", + "@fixture-arm64-linux-gnu": "arm64-linux-gnu", + "@fixture-arm-linux-musl": "arm-linux-musl", + }, +) +use_repo(local, "fixture") diff --git a/rules_toolchain/e2e/local/select/BUILD.bazel b/rules_toolchain/e2e/local/select/BUILD.bazel new file mode 100644 index 0000000..179fa93 --- /dev/null +++ b/rules_toolchain/e2e/local/select/BUILD.bazel @@ -0,0 +1,8 @@ +load("@bazel_skylib//rules:diff_test.bzl", "diff_test") + +diff_test( + name = "hello-world", + size = "small", + file1 = "@fixture//:test/fixture/hello-world.txt", + file2 = "//test/fixture:hello-world.txt", +) diff --git a/rules_toolchain/e2e/test/BUILD.bazel b/rules_toolchain/e2e/test/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/e2e/test/extension.bzl b/rules_toolchain/e2e/test/extension.bzl new file mode 100644 index 0000000..e0c25f4 --- /dev/null +++ b/rules_toolchain/e2e/test/extension.bzl @@ -0,0 +1,21 @@ +load("//test/fixture:repository.bzl", _fixture = "export") + +fixture = tag_class( + doc = _fixture.doc, + attrs = { + "name": attr.string(doc = "Name of the generated repository.", mandatory = True), + } | _fixture.attrs, +) + +def implementation(mctx): + for mod in mctx.modules: + for d in mod.tags.fixture: + _fixture.rule(name = d.name, **{a: getattr(d, a) for a in _fixture.attrs}) + +test = module_extension( + doc = "An extension for creating test fixtures.", + implementation = implementation, + tag_classes = { + "fixture": fixture, + }, +) diff --git a/rules_toolchain/e2e/test/fixture/BUILD.bazel b/rules_toolchain/e2e/test/fixture/BUILD.bazel new file mode 100644 index 0000000..fb55e49 --- /dev/null +++ b/rules_toolchain/e2e/test/fixture/BUILD.bazel @@ -0,0 +1,4 @@ +exports_files( + ["hello-world.txt"], + visibility = ["//:__subpackages__"], +) diff --git a/rules_toolchain/e2e/test/fixture/BUILD.tmpl.bazel b/rules_toolchain/e2e/test/fixture/BUILD.tmpl.bazel new file mode 100644 index 0000000..a645646 --- /dev/null +++ b/rules_toolchain/e2e/test/fixture/BUILD.tmpl.bazel @@ -0,0 +1,4 @@ +exports_files( + glob({{srcs}}), + visibility = ["//visibility:public"], +) diff --git a/rules_toolchain/e2e/test/fixture/hello-world.txt b/rules_toolchain/e2e/test/fixture/hello-world.txt new file mode 100644 index 0000000..af5626b --- /dev/null +++ b/rules_toolchain/e2e/test/fixture/hello-world.txt @@ -0,0 +1 @@ +Hello, world! diff --git a/rules_toolchain/e2e/test/fixture/repository.bzl b/rules_toolchain/e2e/test/fixture/repository.bzl new file mode 100644 index 0000000..c700795 --- /dev/null +++ b/rules_toolchain/e2e/test/fixture/repository.bzl @@ -0,0 +1,36 @@ +DOC = "Creates a test fixture repository." + +ATTRS = { + "srcs": attr.label_list( + doc = "Files that should be put into the repository.", + default = [":hello-world.txt"], + ), + "template": attr.label( + doc = "The template that is expanded into the `BUILD.bazel`.", + default = ":BUILD.tmpl.bazel", + allow_single_file = True, + ), +} + +def implementation(rctx): + map = {l: "{}/{}".format(l.package, l.name) for l in rctx.attr.srcs} + + for label, path in map.items(): + rctx.file(path, content = rctx.read(label)) + + rctx.template("BUILD.bazel", rctx.attr.template, { + "{{srcs}}": repr(map.values()), + }, executable = False) + +fixture = repository_rule( + doc = DOC, + implementation = implementation, + attrs = ATTRS, + configure = True, +) + +export = struct( + doc = DOC, + attrs = ATTRS, + rule = fixture, +) diff --git a/rules_toolchain/toolchain/local/extension.bzl b/rules_toolchain/toolchain/local/extension.bzl index 984789c..07efbd3 100644 --- a/rules_toolchain/toolchain/local/extension.bzl +++ b/rules_toolchain/toolchain/local/extension.bzl @@ -1,5 +1,7 @@ load("//toolchain/local/which:repository.bzl", _which = "export") +load("//toolchain/local/triplet:detect.bzl", "detect") load("//toolchain/local/triplet:repository.bzl", _triplet = "export") +load("//toolchain/local/symlink:repository.bzl", _symlink = "export") which = tag_class( doc = _which.doc, @@ -15,12 +17,84 @@ triplet = tag_class( } | _triplet.attrs, ) +select = tag_class( + doc = """Select a repository based on the current local triplet. + +```py +local.select( + name = "coreutils", + map = { + "@coreutils-arm64-linux-gnu": "arm64-linux-gnu", + "@coreutils-amd64-linux-gnu": "amd64-linux-gnu", + } +) +``` +""", + attrs = { + "name": attr.string(doc = "Name of the generated repository.", mandatory = True), + "map": attr.label_keyed_string_dict( + doc = """Label to repositories that will be selected based on the triplet value. + +The values can use reduced precision triplets to do a generic select: + +```py +local.select( + name = "abc", + map = { + "@xzy": "amd64-linux.5.3.1-gnu.2.31", + "@foo": "amd64-linux-gnu", + "@rrr": "amd64-linux.6.3.0", + "@bar": "amd64-linux", + "@baz": "amd64", + "@def": "//conditions:default", + } +) +``` +""", + allow_empty = False, + ), + "no_match_error": attr.string( + doc = """Error message to raise when no match is found in map. + + Can use the `{triplet}` replacement to show the resolved local triplet.""", + default = "No repository match found for `{triplet}`", + ), + }, +) + def implementation(mctx): for mod in mctx.modules: for d in mod.tags.which: _which.rule(name = d.name, **{a: getattr(d, a) for a in _which.attrs}) for d in mod.tags.triplet: _triplet.rule(name = d.name, **{a: getattr(d, a) for a in _triplet.attrs}) + for d in mod.tags.select: + _symlink.rule(name = d.name, target = match(mctx, d)) + +def match(mctx, tag): + local = detect(mctx) + + map = {} + for label, triplet in tag.map.items(): + if triplet in map: + fail("Cannot have duplicate triplet values: {}".format(triplet)) + + map[triplet] = label + + selects = ( + "{}-{}-{}".format(local.cpu, local.os.value, local.libc.value), + "{}-{}-{}".format(local.cpu, local.os.kind, local.libc.kind), + "{}-{}".format(local.cpu, local.os.value), + "{}-{}".format(local.cpu, local.os.kind), + "{}".format(local.cpu), + "//conditions:default", + ) + + for key in selects: + if key in map: + return map[key] + + fail(tag.no_match_error.format(triplet = local.value)) local = module_extension( doc = "An extension for working with the local (i.e. host) system.", @@ -28,5 +102,6 @@ local = module_extension( tag_classes = { "which": which, "triplet": triplet, + "select": select, }, ) diff --git a/rules_toolchain/toolchain/local/symlink/BUILD.bazel b/rules_toolchain/toolchain/local/symlink/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/rules_toolchain/toolchain/local/symlink/repository.bzl b/rules_toolchain/toolchain/local/symlink/repository.bzl new file mode 100644 index 0000000..681c1cd --- /dev/null +++ b/rules_toolchain/toolchain/local/symlink/repository.bzl @@ -0,0 +1,34 @@ +DOC = "Creates a symlink repository." + +ATTRS = { + "target": attr.label( + doc = "Target repository.", + allow_single_file = True, + mandatory = True, + ), +} + +def implementation(rctx): + workspace = rctx.attr.target.workspace_name + label = Label("@@{}//:WORKSPACE".format(workspace)) + path = rctx.path(label) + + if not path.exists: + fail("Failed to resolve local respository workspace: {}".format(label)) + + rctx.delete(".") + rctx.symlink(path.dirname, ".") + +symlink = repository_rule( + doc = DOC, + implementation = implementation, + attrs = ATTRS, + local = True, + configure = True, +) + +export = struct( + doc = DOC, + attrs = ATTRS, + rule = symlink, +) -- GitLab From 3e935d69a8039937506ae3643fc0f3176d0d5b7e Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Fri, 13 Oct 2023 15:03:00 +0100 Subject: [PATCH 45/55] test(rules_toolchain): remove `non-empty.sh` --- rules_toolchain/e2e/MODULE.bazel | 1 + rules_toolchain/e2e/local/BUILD.bazel | 14 ------- rules_toolchain/e2e/local/non-empty.sh | 40 ------------------- rules_toolchain/e2e/local/triplet/BUILD.bazel | 15 +++++++ 4 files changed, 16 insertions(+), 54 deletions(-) delete mode 100644 rules_toolchain/e2e/local/BUILD.bazel delete mode 100755 rules_toolchain/e2e/local/non-empty.sh create mode 100644 rules_toolchain/e2e/local/triplet/BUILD.bazel diff --git a/rules_toolchain/e2e/MODULE.bazel b/rules_toolchain/e2e/MODULE.bazel index f009e5e..60d9960 100644 --- a/rules_toolchain/e2e/MODULE.bazel +++ b/rules_toolchain/e2e/MODULE.bazel @@ -10,6 +10,7 @@ local_path_override( ) local = use_extension("@rules_toolchain//toolchain:extensions.bzl", "local") +use_repo(local, "local") local.which(name = "echo") use_repo(local, "echo") diff --git a/rules_toolchain/e2e/local/BUILD.bazel b/rules_toolchain/e2e/local/BUILD.bazel deleted file mode 100644 index f2b7c32..0000000 --- a/rules_toolchain/e2e/local/BUILD.bazel +++ /dev/null @@ -1,14 +0,0 @@ -genrule( - name = "data", - testonly = True, - srcs = ["@rules_toolchain//toolchain/triplet:local"], - outs = ["triplet.txt"], - cmd = "cp $< $@", -) - -sh_test( - name = "test", - srcs = ["non-empty.sh"], - args = ["triplet.txt"], - data = [":data"], -) diff --git a/rules_toolchain/e2e/local/non-empty.sh b/rules_toolchain/e2e/local/non-empty.sh deleted file mode 100755 index 4be205c..0000000 --- a/rules_toolchain/e2e/local/non-empty.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -# e: quit on command errors -# u: quit on undefined variables -set -eu - -# Test setup -TEST_SCRIPT="${TEST_BINARY?TEST_BINARY is unset}" -TEST_FOLDER="${TEST_SCRIPT%/*}" -TEST_DATA="${TEST_FOLDER}/${1}" -readonly TEST_FOLDER TEST_DATA - -# Validate the test data -if ! test -f "${TEST_DATA}"; then - echo >&2 "Missing test DATA: ${TEST_DATA}" - tree - exit 2 -elif ! test -r "${TEST_DATA}"; then - echo >&2 "Unreadable test DATA: ${TEST_DATA}" - exit 2 -fi - -# Check no extra lines -while IFS="-" read -r CPU ARCH LIBC; do - echo >&2 "Unexpected line: ${CPU}-${ARCH}-${LIBC}" - exit 1 -done <"${TEST_DATA}" - -if test -z "${CPU}"; then - echo >&2 "Empty CPU" - exit 1 -fi -if test -z "${ARCH}"; then - echo >&2 "Empty ARCH" - exit 1 -fi -if test -z "${LIBC}"; then - echo >&2 "Empty LIBC" - exit 1 -fi diff --git a/rules_toolchain/e2e/local/triplet/BUILD.bazel b/rules_toolchain/e2e/local/triplet/BUILD.bazel new file mode 100644 index 0000000..ac4b382 --- /dev/null +++ b/rules_toolchain/e2e/local/triplet/BUILD.bazel @@ -0,0 +1,15 @@ +load("@local//:triplet.bzl", "TRIPLET") +load("@bazel_skylib//rules:diff_test.bzl", "diff_test") +load("@bazel_skylib//rules:write_file.bzl", "write_file") + +write_file( + name = "expected", + out = "triplet.txt", + content = [TRIPLET.value], +) + +diff_test( + name = "test", + file1 = ":expected", + file2 = "@rules_toolchain//toolchain/triplet:local", +) -- GitLab From 89daef4619e03287052d00f1b5d6ceb95a3e43b9 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 19 Oct 2023 09:58:49 +0100 Subject: [PATCH 46/55] refactor(rules_toolchain): shift to `use_repo_rule`/`visibility` `use_repo_rule` is available in `6.4.0` and above. It _hugely_ simplifies what we want to do. That should be the new minimum version for our rulesets. As of writing, `6.4.0` is not released. The release candidates do not have the `use_repo_rule` added, yet. Most rules use `last_rc` Bazel version. `visibility` is available in 6.0+. --- rules_toolchain/.bazelversion | 2 + rules_toolchain/MODULE.bazel | 9 +- rules_toolchain/README.md | 12 +- rules_toolchain/e2e/.bazelversion | 2 + rules_toolchain/e2e/MODULE.bazel | 33 +++--- rules_toolchain/e2e/local/triplet/BUILD.bazel | 2 +- rules_toolchain/e2e/test/extension.bzl | 21 ---- .../e2e/test/fixture/repository.bzl | 8 +- .../e2e/toolchain/echo/resolved.bzl | 2 + .../constraint/libc/gnu/versions.bzl | 2 + .../constraint/os/linux/versions.bzl | 15 +-- rules_toolchain/toolchain/defs.bzl | 6 + rules_toolchain/toolchain/extensions.bzl | 3 - rules_toolchain/toolchain/local/extension.bzl | 107 ------------------ .../local/{symlink => select}/BUILD.bazel | 0 .../toolchain/local/select/repository.bzl | 75 ++++++++++++ .../toolchain/local/symlink/repository.bzl | 34 ------ .../toolchain/local/triplet/cpu.bzl | 2 + .../toolchain/local/triplet/detect.bzl | 2 + .../toolchain/local/triplet/libc.bzl | 4 +- .../toolchain/local/triplet/os.bzl | 2 + .../toolchain/local/triplet/repository.bzl | 8 +- .../toolchain/local/triplet/triplet.tmpl.bzl | 2 + .../toolchain/local/which/repository.bzl | 8 +- rules_toolchain/toolchain/resolved.bzl | 2 + .../toolchain/symlink/path/rule.bzl | 2 + .../toolchain/symlink/target/rule.bzl | 2 + rules_toolchain/toolchain/test/rule.bzl | 2 + rules_toolchain/toolchain/triplet/BUILD.bazel | 4 +- .../toolchain/triplet/TripletInfo.bzl | 2 + .../toolchain/triplet/VersionInfo.bzl | 2 + .../toolchain/triplet/VersionedInfo.bzl | 2 + rules_toolchain/toolchain/triplet/local.bzl | 5 + rules_toolchain/toolchain/triplet/rule.bzl | 2 + rules_toolchain/toolchain/triplet/split.bzl | 2 + rules_toolchain/toolchain/triplet/test.bzl | 2 + .../toolchain/triplet/triplets.bzl | 17 +-- .../toolchain/triplet/unversioned.bzl | 2 + 38 files changed, 175 insertions(+), 234 deletions(-) create mode 100644 rules_toolchain/.bazelversion create mode 100644 rules_toolchain/e2e/.bazelversion delete mode 100644 rules_toolchain/e2e/test/extension.bzl delete mode 100644 rules_toolchain/toolchain/extensions.bzl delete mode 100644 rules_toolchain/toolchain/local/extension.bzl rename rules_toolchain/toolchain/local/{symlink => select}/BUILD.bazel (100%) create mode 100644 rules_toolchain/toolchain/local/select/repository.bzl delete mode 100644 rules_toolchain/toolchain/local/symlink/repository.bzl create mode 100644 rules_toolchain/toolchain/triplet/local.bzl diff --git a/rules_toolchain/.bazelversion b/rules_toolchain/.bazelversion new file mode 100644 index 0000000..6543a03 --- /dev/null +++ b/rules_toolchain/.bazelversion @@ -0,0 +1,2 @@ +last_rc +# TODO: relax this once we have `use_rule_repo` diff --git a/rules_toolchain/MODULE.bazel b/rules_toolchain/MODULE.bazel index 7e93c3d..3a76922 100644 --- a/rules_toolchain/MODULE.bazel +++ b/rules_toolchain/MODULE.bazel @@ -1,12 +1,15 @@ module( name = "rules_toolchain", + bazel_compatibility = [ + ">=6.4.0", + ], ) bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "platforms", version = "0.0.7") -local = use_extension("//toolchain:extensions.bzl", "local") -local.triplet( +triplet = use_repo_rule("//toolchain/local/triplet:repository.bzl", "triplet") + +triplet( name = "local", ) -use_repo(local, "local") diff --git a/rules_toolchain/README.md b/rules_toolchain/README.md index 57d2a25..3f87b85 100644 --- a/rules_toolchain/README.md +++ b/rules_toolchain/README.md @@ -9,9 +9,8 @@ Add the following to `MODULE.bazel`: ```py -local = use_extension("@rules_toolchain//toolchain:extensions.bzl", "local") -local.which("echo") -use_repo(local, "echo") +which = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_which") +which("echo") ``` The `echo` tool will be found on the `PATH`. @@ -23,15 +22,14 @@ A repository with the `@echo//:echo` target will be created. Use `rules_download` to provide a hermetic, pre-built binary in `MODULE.bazel` ```py -download = use_extension("@rules_download//download:extensions.bzl", "download") -download.archive( +archive = use_repo_rule("@rules_download//download:defs.bzl", "download_archive") +archive( name = "coreutils-arm64-linux-gnu", srcs = ["coreutils"], integrity = "sha256-mlmkbeabyu4+5+cFiUSL6Ki4KFNqWu48gTjFc3NS43g=", strip_prefix = "coreutils-0.0.21-aarch64-unknown-linux-gnu", urls = ["https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-aarch64-unknown-linux-gnu.tar.gz"], ) -use_repo(download, "coreutils-arm64-linux-gnu") ``` A repository with the `@coreutils-arm64-linux-gnu//:coreutils` target will be created. @@ -104,6 +102,8 @@ Create `toolchain/echo/resolved.bzl` to provide the `resolved` rule that is used ```py load("@rules_toolchain//toolchain:resolved.bzl", _resolved = "export") +visibility("toolchain/echo/...") + DOC = _resolved.doc ATTRS = _resolved.attrs diff --git a/rules_toolchain/e2e/.bazelversion b/rules_toolchain/e2e/.bazelversion new file mode 100644 index 0000000..6543a03 --- /dev/null +++ b/rules_toolchain/e2e/.bazelversion @@ -0,0 +1,2 @@ +last_rc +# TODO: relax this once we have `use_rule_repo` diff --git a/rules_toolchain/e2e/MODULE.bazel b/rules_toolchain/e2e/MODULE.bazel index 60d9960..1138e73 100644 --- a/rules_toolchain/e2e/MODULE.bazel +++ b/rules_toolchain/e2e/MODULE.bazel @@ -1,5 +1,8 @@ module( name = "e2e", + bazel_compatibility = [ + ">=6.4.0", + ], ) bazel_dep(name = "bazel_skylib", version = "1.4.2") @@ -9,31 +12,33 @@ local_path_override( path = "..", ) -local = use_extension("@rules_toolchain//toolchain:extensions.bzl", "local") -use_repo(local, "local") -local.which(name = "echo") -use_repo(local, "echo") +which = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_which") + +which(name = "echo") register_toolchains("//toolchain/echo:all") -test = use_extension("//test:extension.bzl", "test") -test.fixture( +fixture = use_repo_rule("//test/fixture:repository.bzl", "fixture") + +fixture( name = "fixture-amd64-linux-gnu", ) -test.fixture( + +fixture( name = "fixture-arm64-linux-gnu", ) -test.fixture( + +fixture( name = "fixture-arm-linux-musl", ) -use_repo(test, "fixture-amd64-linux-gnu", "fixture-arm-linux-musl", "fixture-arm64-linux-gnu") -local.select( +select = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_select") + +select( name = "fixture", map = { - "@fixture-amd64-linux-gnu": "amd64-linux-gnu", - "@fixture-arm64-linux-gnu": "arm64-linux-gnu", - "@fixture-arm-linux-musl": "arm-linux-musl", + "amd64-linux-gnu": "@fixture-amd64-linux-gnu", + "arm64-linux-gnu": "@fixture-arm64-linux-gnu", + "arm-linux-musl": "@fixture-arm-linux-musl", }, ) -use_repo(local, "fixture") diff --git a/rules_toolchain/e2e/local/triplet/BUILD.bazel b/rules_toolchain/e2e/local/triplet/BUILD.bazel index ac4b382..f4d84f2 100644 --- a/rules_toolchain/e2e/local/triplet/BUILD.bazel +++ b/rules_toolchain/e2e/local/triplet/BUILD.bazel @@ -1,4 +1,4 @@ -load("@local//:triplet.bzl", "TRIPLET") +load("@rules_toolchain//toolchain/triplet:local.bzl", "TRIPLET") load("@bazel_skylib//rules:diff_test.bzl", "diff_test") load("@bazel_skylib//rules:write_file.bzl", "write_file") diff --git a/rules_toolchain/e2e/test/extension.bzl b/rules_toolchain/e2e/test/extension.bzl deleted file mode 100644 index e0c25f4..0000000 --- a/rules_toolchain/e2e/test/extension.bzl +++ /dev/null @@ -1,21 +0,0 @@ -load("//test/fixture:repository.bzl", _fixture = "export") - -fixture = tag_class( - doc = _fixture.doc, - attrs = { - "name": attr.string(doc = "Name of the generated repository.", mandatory = True), - } | _fixture.attrs, -) - -def implementation(mctx): - for mod in mctx.modules: - for d in mod.tags.fixture: - _fixture.rule(name = d.name, **{a: getattr(d, a) for a in _fixture.attrs}) - -test = module_extension( - doc = "An extension for creating test fixtures.", - implementation = implementation, - tag_classes = { - "fixture": fixture, - }, -) diff --git a/rules_toolchain/e2e/test/fixture/repository.bzl b/rules_toolchain/e2e/test/fixture/repository.bzl index c700795..a0400cf 100644 --- a/rules_toolchain/e2e/test/fixture/repository.bzl +++ b/rules_toolchain/e2e/test/fixture/repository.bzl @@ -1,5 +1,7 @@ DOC = "Creates a test fixture repository." +visibility("//...") + ATTRS = { "srcs": attr.label_list( doc = "Files that should be put into the repository.", @@ -28,9 +30,3 @@ fixture = repository_rule( attrs = ATTRS, configure = True, ) - -export = struct( - doc = DOC, - attrs = ATTRS, - rule = fixture, -) diff --git a/rules_toolchain/e2e/toolchain/echo/resolved.bzl b/rules_toolchain/e2e/toolchain/echo/resolved.bzl index 7aefaa9..cc8543a 100644 --- a/rules_toolchain/e2e/toolchain/echo/resolved.bzl +++ b/rules_toolchain/e2e/toolchain/echo/resolved.bzl @@ -1,5 +1,7 @@ load("@rules_toolchain//toolchain:resolved.bzl", _resolved = "export") +visibility("//toolchain/echo/...") + DOC = _resolved.doc.format(toolchain = "echo") ATTRS = _resolved.attrs diff --git a/rules_toolchain/toolchain/constraint/libc/gnu/versions.bzl b/rules_toolchain/toolchain/constraint/libc/gnu/versions.bzl index 9cd4d7d..ba04cd0 100644 --- a/rules_toolchain/toolchain/constraint/libc/gnu/versions.bzl +++ b/rules_toolchain/toolchain/constraint/libc/gnu/versions.bzl @@ -1,3 +1,5 @@ +visibility("//toolchain/...") + # git ls-remote --tags https://sourceware.org/git/glibc.git | # awk '{print $2}' | # grep -oe 'glibc-2\.[0-9]\+\(\.[0-9]\+\)\?$' | diff --git a/rules_toolchain/toolchain/constraint/os/linux/versions.bzl b/rules_toolchain/toolchain/constraint/os/linux/versions.bzl index 23e107a..8915269 100644 --- a/rules_toolchain/toolchain/constraint/os/linux/versions.bzl +++ b/rules_toolchain/toolchain/constraint/os/linux/versions.bzl @@ -1,5 +1,6 @@ load("@local//:triplet.bzl", "TRIPLET") -load("@bazel_skylib//lib:sets.bzl", "sets") + +visibility("//toolchain/...") LOCAL = TRIPLET.os.version and TRIPLET.os.version.value @@ -15,14 +16,4 @@ LTS = ( "5.15.131", ) -def _versions(value): - major, minor, patch = value.split(".") - return ["{}.{}.{}".format(major, minor, p) for p in range(int(patch))] - -VERSIONS = tuple(sets.to_list(sets.make([ - v - for v in list(LTS) + - [x for v in LTS for x in _versions(v)] + - [LOCAL] - if v != None -]))) +VERSIONS = LTS + tuple([LOCAL] if LOCAL != None else []) diff --git a/rules_toolchain/toolchain/defs.bzl b/rules_toolchain/toolchain/defs.bzl index e9d8be7..75feeea 100644 --- a/rules_toolchain/toolchain/defs.bzl +++ b/rules_toolchain/toolchain/defs.bzl @@ -2,8 +2,14 @@ load("//toolchain/triplet:TripletInfo.bzl", _TripletInfo = "TripletInfo") load("//toolchain/symlink/path:rule.bzl", _symlink_path = "path") load("//toolchain/symlink/target:rule.bzl", _symlink_target = "target") load("//toolchain/test:rule.bzl", _test = "test") +load("//toolchain/local/which:repository.bzl", _local_which = "which") +load("//toolchain/local/select:repository.bzl", _local_select = "select") + +visibility("public") ToolchainTripletInfo = _TripletInfo toolchain_symlink_path = _symlink_path toolchain_symlink_target = _symlink_target toolchain_test = _test +toolchain_local_which = _local_which +toolchain_local_select = _local_select diff --git a/rules_toolchain/toolchain/extensions.bzl b/rules_toolchain/toolchain/extensions.bzl deleted file mode 100644 index 7427385..0000000 --- a/rules_toolchain/toolchain/extensions.bzl +++ /dev/null @@ -1,3 +0,0 @@ -load("//toolchain/local:extension.bzl", _local = "local") - -local = _local diff --git a/rules_toolchain/toolchain/local/extension.bzl b/rules_toolchain/toolchain/local/extension.bzl deleted file mode 100644 index 07efbd3..0000000 --- a/rules_toolchain/toolchain/local/extension.bzl +++ /dev/null @@ -1,107 +0,0 @@ -load("//toolchain/local/which:repository.bzl", _which = "export") -load("//toolchain/local/triplet:detect.bzl", "detect") -load("//toolchain/local/triplet:repository.bzl", _triplet = "export") -load("//toolchain/local/symlink:repository.bzl", _symlink = "export") - -which = tag_class( - doc = _which.doc, - attrs = { - "name": attr.string(doc = "Name of the generated repository.", mandatory = True), - } | _which.attrs, -) - -triplet = tag_class( - doc = _triplet.doc, - attrs = { - "name": attr.string(doc = "Name of the generated repository.", mandatory = True), - } | _triplet.attrs, -) - -select = tag_class( - doc = """Select a repository based on the current local triplet. - -```py -local.select( - name = "coreutils", - map = { - "@coreutils-arm64-linux-gnu": "arm64-linux-gnu", - "@coreutils-amd64-linux-gnu": "amd64-linux-gnu", - } -) -``` -""", - attrs = { - "name": attr.string(doc = "Name of the generated repository.", mandatory = True), - "map": attr.label_keyed_string_dict( - doc = """Label to repositories that will be selected based on the triplet value. - -The values can use reduced precision triplets to do a generic select: - -```py -local.select( - name = "abc", - map = { - "@xzy": "amd64-linux.5.3.1-gnu.2.31", - "@foo": "amd64-linux-gnu", - "@rrr": "amd64-linux.6.3.0", - "@bar": "amd64-linux", - "@baz": "amd64", - "@def": "//conditions:default", - } -) -``` -""", - allow_empty = False, - ), - "no_match_error": attr.string( - doc = """Error message to raise when no match is found in map. - - Can use the `{triplet}` replacement to show the resolved local triplet.""", - default = "No repository match found for `{triplet}`", - ), - }, -) - -def implementation(mctx): - for mod in mctx.modules: - for d in mod.tags.which: - _which.rule(name = d.name, **{a: getattr(d, a) for a in _which.attrs}) - for d in mod.tags.triplet: - _triplet.rule(name = d.name, **{a: getattr(d, a) for a in _triplet.attrs}) - for d in mod.tags.select: - _symlink.rule(name = d.name, target = match(mctx, d)) - -def match(mctx, tag): - local = detect(mctx) - - map = {} - for label, triplet in tag.map.items(): - if triplet in map: - fail("Cannot have duplicate triplet values: {}".format(triplet)) - - map[triplet] = label - - selects = ( - "{}-{}-{}".format(local.cpu, local.os.value, local.libc.value), - "{}-{}-{}".format(local.cpu, local.os.kind, local.libc.kind), - "{}-{}".format(local.cpu, local.os.value), - "{}-{}".format(local.cpu, local.os.kind), - "{}".format(local.cpu), - "//conditions:default", - ) - - for key in selects: - if key in map: - return map[key] - - fail(tag.no_match_error.format(triplet = local.value)) - -local = module_extension( - doc = "An extension for working with the local (i.e. host) system.", - implementation = implementation, - tag_classes = { - "which": which, - "triplet": triplet, - "select": select, - }, -) diff --git a/rules_toolchain/toolchain/local/symlink/BUILD.bazel b/rules_toolchain/toolchain/local/select/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/local/symlink/BUILD.bazel rename to rules_toolchain/toolchain/local/select/BUILD.bazel diff --git a/rules_toolchain/toolchain/local/select/repository.bzl b/rules_toolchain/toolchain/local/select/repository.bzl new file mode 100644 index 0000000..aa33127 --- /dev/null +++ b/rules_toolchain/toolchain/local/select/repository.bzl @@ -0,0 +1,75 @@ +load("//toolchain/local/triplet:detect.bzl", "detect") +load("//toolchain/triplet:TripletInfo.bzl", "TripletInfo") + +visibility("//toolchain/...") + +DOC = "Selects and symlinks a repository based on the local machine triplet." + +ATTRS = { + "map": attr.string_dict( + doc = """Local triplet to repository mappings: + +``` +toolchian_local_select( + name = "abc", + map = { + "arm64-linux-gnu": "@abc-arm64-linux-gnu", + "arm64-linux-musl": "@abc-arm64-linux-musl", + }, +) +""", + mandatory = True, + allow_empty = False, + ), + "triplet": attr.string( + doc = "Overrides local machine triplet.", + ), + "no_match_error": attr.string( + doc = """Error message to raise when no match is found in map. + + Can use the `{triplet}` replacement to show the resolved local triplet.""", + default = "No repository match found for `{triplet}`", + ), +} + +def canonical(rctx, label): + # This is _flaky_, it depends on `MODULE.bazel` repository naming[1] + # [1]: https://bazel.build/external/extension#repository_names_and_visibility + prefix = "~".join(rctx.name.split("~")[:-1]) + return "@@{}~{}".format(prefix, label.removeprefix("@")) + +def implementation(rctx): + t = TripletInfo(rctx.attr.triplet or detect(rctx).value) + + selects = ( + "{}-{}-{}".format(t.cpu, t.os.value, t.libc.value), + "{}-{}-{}".format(t.cpu, t.os.kind, t.libc.kind), + "{}-{}".format(t.cpu, t.os.value), + "{}-{}".format(t.cpu, t.os.kind), + "{}".format(t.cpu), + "//conditions:default", + ) + + for select in selects: + if select in rctx.attr.map: + label = rctx.attr.map[select] + canon = canonical(rctx, label) + workspace = Label("{}//:WORKSPACE".format(canon)) + path = rctx.path(workspace) + + if not path.exists: + fail("Missing `{}` for `{}`: {}".format(label, select, path)) + + rctx.delete(".") + rctx.symlink(path.dirname, ".") + return + + fail(rctx.attr.no_match_error.format(triplet = t.value)) + +select = repository_rule( + doc = DOC, + implementation = implementation, + attrs = ATTRS, + local = True, + configure = True, +) diff --git a/rules_toolchain/toolchain/local/symlink/repository.bzl b/rules_toolchain/toolchain/local/symlink/repository.bzl deleted file mode 100644 index 681c1cd..0000000 --- a/rules_toolchain/toolchain/local/symlink/repository.bzl +++ /dev/null @@ -1,34 +0,0 @@ -DOC = "Creates a symlink repository." - -ATTRS = { - "target": attr.label( - doc = "Target repository.", - allow_single_file = True, - mandatory = True, - ), -} - -def implementation(rctx): - workspace = rctx.attr.target.workspace_name - label = Label("@@{}//:WORKSPACE".format(workspace)) - path = rctx.path(label) - - if not path.exists: - fail("Failed to resolve local respository workspace: {}".format(label)) - - rctx.delete(".") - rctx.symlink(path.dirname, ".") - -symlink = repository_rule( - doc = DOC, - implementation = implementation, - attrs = ATTRS, - local = True, - configure = True, -) - -export = struct( - doc = DOC, - attrs = ATTRS, - rule = symlink, -) diff --git a/rules_toolchain/toolchain/local/triplet/cpu.bzl b/rules_toolchain/toolchain/local/triplet/cpu.bzl index 90b996d..710b929 100644 --- a/rules_toolchain/toolchain/local/triplet/cpu.bzl +++ b/rules_toolchain/toolchain/local/triplet/cpu.bzl @@ -1,3 +1,5 @@ +visibility("//toolchain/local/triplet/...") + def cpu(rctx): """ Detects the host CPU. diff --git a/rules_toolchain/toolchain/local/triplet/detect.bzl b/rules_toolchain/toolchain/local/triplet/detect.bzl index 29b0af0..93ce87e 100644 --- a/rules_toolchain/toolchain/local/triplet/detect.bzl +++ b/rules_toolchain/toolchain/local/triplet/detect.bzl @@ -3,6 +3,8 @@ load(":cpu.bzl", "cpu") load(":os.bzl", "os") load(":libc.bzl", "libc") +visibility("//toolchain/local/...") + def detect(rctx): return TripletInfo("{}-{}-{}".format( cpu(rctx), diff --git a/rules_toolchain/toolchain/local/triplet/libc.bzl b/rules_toolchain/toolchain/local/triplet/libc.bzl index 593ca32..2f64d48 100644 --- a/rules_toolchain/toolchain/local/triplet/libc.bzl +++ b/rules_toolchain/toolchain/local/triplet/libc.bzl @@ -1,5 +1,7 @@ -load("//toolchain/triplet:VersionedInfo.bzl", "VersionedInfo") load("//toolchain/triplet:split.bzl", "split") +load("//toolchain/triplet:VersionedInfo.bzl", "VersionedInfo") + +visibility("//toolchain/local/triplet/...") def _unquote(value): if value[0] == '"' and value[-1] == '"': diff --git a/rules_toolchain/toolchain/local/triplet/os.bzl b/rules_toolchain/toolchain/local/triplet/os.bzl index b7810b1..00f80f9 100644 --- a/rules_toolchain/toolchain/local/triplet/os.bzl +++ b/rules_toolchain/toolchain/local/triplet/os.bzl @@ -1,6 +1,8 @@ load("//toolchain/triplet:split.bzl", "split") load("//toolchain/triplet:VersionedInfo.bzl", "VersionedInfo") +visibility("//toolchain/local/triplet/...") + def _header(rctx, path): """ Reads the Linux version header to determine the correct Linux version. diff --git a/rules_toolchain/toolchain/local/triplet/repository.bzl b/rules_toolchain/toolchain/local/triplet/repository.bzl index 85b8968..0a58f64 100644 --- a/rules_toolchain/toolchain/local/triplet/repository.bzl +++ b/rules_toolchain/toolchain/local/triplet/repository.bzl @@ -1,5 +1,7 @@ load(":detect.bzl", "detect") +visibility("//toolchain/...") + DOC = """Detects the host triplet. """ @@ -24,9 +26,3 @@ triplet = repository_rule( attrs = ATTRS, local = True, ) - -export = struct( - doc = DOC, - attrs = ATTRS, - rule = triplet, -) diff --git a/rules_toolchain/toolchain/local/triplet/triplet.tmpl.bzl b/rules_toolchain/toolchain/local/triplet/triplet.tmpl.bzl index da36686..25af60e 100644 --- a/rules_toolchain/toolchain/local/triplet/triplet.tmpl.bzl +++ b/rules_toolchain/toolchain/local/triplet/triplet.tmpl.bzl @@ -1,3 +1,5 @@ load("@rules_toolchain//toolchain:defs.bzl", "ToolchainTripletInfo") +visibility("public") + TRIPLET = ToolchainTripletInfo("{{value}}") diff --git a/rules_toolchain/toolchain/local/which/repository.bzl b/rules_toolchain/toolchain/local/which/repository.bzl index e513636..d5cb732 100644 --- a/rules_toolchain/toolchain/local/which/repository.bzl +++ b/rules_toolchain/toolchain/local/which/repository.bzl @@ -1,3 +1,5 @@ +visibility("//toolchain/...") + DOC = """Creates a repository that provides a binary target wrapping a local binary found on `PATH`. The resulting repository has a `toolchain_symlink_path` target which can be used with the native `toolchain` rule to expose the local binary as a toolchain. @@ -55,9 +57,3 @@ which = repository_rule( "PATH", ], ) - -export = struct( - doc = DOC, - attrs = ATTRS, - rule = which, -) diff --git a/rules_toolchain/toolchain/resolved.bzl b/rules_toolchain/toolchain/resolved.bzl index 2814016..d6657c5 100644 --- a/rules_toolchain/toolchain/resolved.bzl +++ b/rules_toolchain/toolchain/resolved.bzl @@ -1,3 +1,5 @@ +visibility("public") + DOC = """Resolved toolchain information for the `{toolchain}` toolchain. This target is runnable via: diff --git a/rules_toolchain/toolchain/symlink/path/rule.bzl b/rules_toolchain/toolchain/symlink/path/rule.bzl index 4d58250..7d5e18f 100644 --- a/rules_toolchain/toolchain/symlink/path/rule.bzl +++ b/rules_toolchain/toolchain/symlink/path/rule.bzl @@ -1,3 +1,5 @@ +visibility("//toolchain/...") + ATTRS = { "path": attr.string( doc = "The path to a binary to symlink.", diff --git a/rules_toolchain/toolchain/symlink/target/rule.bzl b/rules_toolchain/toolchain/symlink/target/rule.bzl index 329ff6a..1c4a94c 100644 --- a/rules_toolchain/toolchain/symlink/target/rule.bzl +++ b/rules_toolchain/toolchain/symlink/target/rule.bzl @@ -1,3 +1,5 @@ +visibility("//toolchain/...") + ATTRS = { "target": attr.label( doc = "The binary file to symlink.", diff --git a/rules_toolchain/toolchain/test/rule.bzl b/rules_toolchain/toolchain/test/rule.bzl index 88b5cc7..8bbb313 100644 --- a/rules_toolchain/toolchain/test/rule.bzl +++ b/rules_toolchain/toolchain/test/rule.bzl @@ -1,3 +1,5 @@ +visibility("//toolchain/...") + ATTRS = { "stdout": attr.label( doc = """The expected standard output. diff --git a/rules_toolchain/toolchain/triplet/BUILD.bazel b/rules_toolchain/toolchain/triplet/BUILD.bazel index 5a13be9..7a7903f 100644 --- a/rules_toolchain/toolchain/triplet/BUILD.bazel +++ b/rules_toolchain/toolchain/triplet/BUILD.bazel @@ -1,4 +1,4 @@ -load(":triplets.bzl", "UNVERSIONED") +load(":triplets.bzl", "TRIPLETS") load(":rule.bzl", "triplet") load(":test.bzl", "test") @@ -7,7 +7,7 @@ load(":test.bzl", "test") name = t.value, visibility = ["//visibility:public"], ) - for t in UNVERSIONED + for t in TRIPLETS ] alias( diff --git a/rules_toolchain/toolchain/triplet/TripletInfo.bzl b/rules_toolchain/toolchain/triplet/TripletInfo.bzl index 58095aa..99ee803 100644 --- a/rules_toolchain/toolchain/triplet/TripletInfo.bzl +++ b/rules_toolchain/toolchain/triplet/TripletInfo.bzl @@ -2,6 +2,8 @@ load("@bazel_skylib//lib:types.bzl", "types") load(":VersionedInfo.bzl", "VersionedInfo") load(":split.bzl", "split") +visibility("//toolchain/...") + def init(value): """ Initializes a `TripletInfo` provider. diff --git a/rules_toolchain/toolchain/triplet/VersionInfo.bzl b/rules_toolchain/toolchain/triplet/VersionInfo.bzl index 66365b3..8ef969d 100644 --- a/rules_toolchain/toolchain/triplet/VersionInfo.bzl +++ b/rules_toolchain/toolchain/triplet/VersionInfo.bzl @@ -1,6 +1,8 @@ load("@bazel_skylib//lib:types.bzl", "types") load(":split.bzl", "split") +visibility("//toolchain/...") + def init(value): """ Initializes a `VersionInfo` provider. diff --git a/rules_toolchain/toolchain/triplet/VersionedInfo.bzl b/rules_toolchain/toolchain/triplet/VersionedInfo.bzl index 85b2d81..3140c31 100644 --- a/rules_toolchain/toolchain/triplet/VersionedInfo.bzl +++ b/rules_toolchain/toolchain/triplet/VersionedInfo.bzl @@ -1,6 +1,8 @@ load("@bazel_skylib//lib:types.bzl", "types") load(":VersionInfo.bzl", "VersionInfo") +visibility("//toolchain/...") + def init(value): """ Initializes a `VersionedInfo` provider. diff --git a/rules_toolchain/toolchain/triplet/local.bzl b/rules_toolchain/toolchain/triplet/local.bzl new file mode 100644 index 0000000..e7a0915 --- /dev/null +++ b/rules_toolchain/toolchain/triplet/local.bzl @@ -0,0 +1,5 @@ +load("@local//:triplet.bzl", _LOCAL = "TRIPLET") + +visibility("public") + +TRIPLET = _LOCAL diff --git a/rules_toolchain/toolchain/triplet/rule.bzl b/rules_toolchain/toolchain/triplet/rule.bzl index ba7270b..2fa03d3 100644 --- a/rules_toolchain/toolchain/triplet/rule.bzl +++ b/rules_toolchain/toolchain/triplet/rule.bzl @@ -1,5 +1,7 @@ load(":TripletInfo.bzl", "TripletInfo") +visibility("//toolchain/...") + ATTRS = { "value": attr.string( doc = "A triplet value that overrides `name`.", diff --git a/rules_toolchain/toolchain/triplet/split.bzl b/rules_toolchain/toolchain/triplet/split.bzl index c85dd80..62a5f9c 100644 --- a/rules_toolchain/toolchain/triplet/split.bzl +++ b/rules_toolchain/toolchain/triplet/split.bzl @@ -1,3 +1,5 @@ +visibility("//toolchain/...") + def split(value, delimiter, map): """ Splits a value and invokes a callback based on the number of split elements. diff --git a/rules_toolchain/toolchain/triplet/test.bzl b/rules_toolchain/toolchain/triplet/test.bzl index 1790eb7..18ae4b7 100644 --- a/rules_toolchain/toolchain/triplet/test.bzl +++ b/rules_toolchain/toolchain/triplet/test.bzl @@ -2,6 +2,8 @@ load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") load(":TripletInfo.bzl", "TripletInfo") load(":unversioned.bzl", "unversioned") +visibility("//toolchain/test/...") + def implementation(ctx): env = analysistest.begin(ctx) target = analysistest.target_under_test(env) diff --git a/rules_toolchain/toolchain/triplet/triplets.bzl b/rules_toolchain/toolchain/triplet/triplets.bzl index 1b78a1a..213651e 100644 --- a/rules_toolchain/toolchain/triplet/triplets.bzl +++ b/rules_toolchain/toolchain/triplet/triplets.bzl @@ -1,17 +1,10 @@ -load("@rules_toolchain//toolchain/constraint/os/linux:versions.bzl", _LINUX = "VERSIONS") -load("@rules_toolchain//toolchain/constraint/libc/gnu:versions.bzl", _GNU = "VERSIONS") +load("@local//:triplet.bzl", LOCAL = "TRIPLET") load(":TripletInfo.bzl", "TripletInfo") -UNVERSIONED = ( +visibility("//toolchain/...") + +TRIPLETS = ( + LOCAL, TripletInfo("arm64-linux-gnu"), TripletInfo("amd64-linux-gnu"), ) - -LINUX_GNU = tuple([ - TripletInfo("{}-{}-{}".format(cpu, os, libc)) - for cpu in ("arm64", "amd64") - for os in ["linux.{}".format(v) for v in _LINUX] - for libc in ["gnu.{}".format(v) for v in _GNU] -]) - -TRIPLETS = UNVERSIONED + LINUX_GNU diff --git a/rules_toolchain/toolchain/triplet/unversioned.bzl b/rules_toolchain/toolchain/triplet/unversioned.bzl index a76780d..779bc74 100644 --- a/rules_toolchain/toolchain/triplet/unversioned.bzl +++ b/rules_toolchain/toolchain/triplet/unversioned.bzl @@ -1,5 +1,7 @@ load(":TripletInfo.bzl", "TripletInfo") +visibility("//toolchain/...") + def unversioned(triplet): """ Converts a `TripletInfo` into an unversioned one. -- GitLab From 40c856624657d84295b7c6505c4b72ba6e9f333d Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 14 Nov 2023 13:06:56 +0000 Subject: [PATCH 47/55] fix(rules_toolchain): support no legacy runfiles --- rules_toolchain/toolchain/test/rule.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules_toolchain/toolchain/test/rule.bzl b/rules_toolchain/toolchain/test/rule.bzl index 8bbb313..3c33f6d 100644 --- a/rules_toolchain/toolchain/test/rule.bzl +++ b/rules_toolchain/toolchain/test/rule.bzl @@ -48,8 +48,8 @@ def implementation(ctx): output = executable, substitutions = { "{{executable}}": str(toolchain.executable.short_path), - "{{stdout}}": str(ctx.file.stdout.path), - "{{stderr}}": str(ctx.file.stderr.path), + "{{stdout}}": str(ctx.file.stdout.short_path), + "{{stderr}}": str(ctx.file.stderr.short_path), }, is_executable = True, ) -- GitLab From 10dc491545ceb065df3cbcd2f6083a1024e37428 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 14 Nov 2023 13:04:18 +0000 Subject: [PATCH 48/55] chore(rules_toolchain): improve run commands Especially disabling legacy runfiles. --- rules_toolchain/.bazelrc | 11 +++++++++- rules_toolchain/.bazelrc.ci | 36 +++++++++++++++++++++++++++++++++ rules_toolchain/.gitignore | 1 + rules_toolchain/e2e/.bazelrc | 12 ++++++++--- rules_toolchain/e2e/.bazelrc.ci | 36 +++++++++++++++++++++++++++++++++ rules_toolchain/e2e/.gitignore | 1 + 6 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 rules_toolchain/.bazelrc.ci create mode 100644 rules_toolchain/e2e/.bazelrc.ci diff --git a/rules_toolchain/.bazelrc b/rules_toolchain/.bazelrc index 025f832..9931842 100644 --- a/rules_toolchain/.bazelrc +++ b/rules_toolchain/.bazelrc @@ -1,5 +1,14 @@ # Enable `bzlmod` common --enable_bzlmod +# Build cache +build --experimental_guard_against_concurrent_changes + +# Prevent `PATH` and `LD_LIBRARY_PATH` leaking into action enviroment +build --incompatible_strict_action_env + +# Prevent symlink forest under `.runfiles/wsname/external/repo` +build --nolegacy_external_runfiles + # User-specific .bazelrc -try-import user.bazelrc +try-import %workspace%/.bazelrc.user diff --git a/rules_toolchain/.bazelrc.ci b/rules_toolchain/.bazelrc.ci new file mode 100644 index 0000000..5af25a1 --- /dev/null +++ b/rules_toolchain/.bazelrc.ci @@ -0,0 +1,36 @@ +# Declare all run commands that are loaded +common --announce_rc + +# Use relative paths where possible for concise CI output +common --attempt_to_print_relative_paths + +# Prevent progress bars or similar +common --curses=no + +# CI "terminals" support colour +common --color=yes + +# Output timestamps for each command to aid debugging of CI runtime +common --show_timestamps + +# Do not wrap any output +common --terminal_columns=0 + +# Print relative paths where possible to reduce noise +common --attempt_to_print_relative_paths + +# Output as much information in the CI log about failures as possible +build --verbose_failures + +# Avoid building all targets when testing +test --build_tests_only + +# Noisy logs but allows debugging CI run failures +test --test_output=errors + +# Output as much information when a test exceeds a timeout +test --test_verbose_timeout_warnings + +# These locations are cached on the CI +build --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk +build --repository_cache=${CI_PROJECT_DIR}/.cache/bazel/repo diff --git a/rules_toolchain/.gitignore b/rules_toolchain/.gitignore index beb652d..b7cd8bf 100644 --- a/rules_toolchain/.gitignore +++ b/rules_toolchain/.gitignore @@ -3,3 +3,4 @@ /bazel-testlogs /bazel-rules_toolchain /bazel-out +/.bazelrc.user diff --git a/rules_toolchain/e2e/.bazelrc b/rules_toolchain/e2e/.bazelrc index f01df94..9931842 100644 --- a/rules_toolchain/e2e/.bazelrc +++ b/rules_toolchain/e2e/.bazelrc @@ -1,8 +1,14 @@ # Enable `bzlmod` common --enable_bzlmod -# Disable built-in toolchain detection -build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 +# Build cache +build --experimental_guard_against_concurrent_changes + +# Prevent `PATH` and `LD_LIBRARY_PATH` leaking into action enviroment +build --incompatible_strict_action_env + +# Prevent symlink forest under `.runfiles/wsname/external/repo` +build --nolegacy_external_runfiles # User-specific .bazelrc -try-import user.bazelrc +try-import %workspace%/.bazelrc.user diff --git a/rules_toolchain/e2e/.bazelrc.ci b/rules_toolchain/e2e/.bazelrc.ci new file mode 100644 index 0000000..5af25a1 --- /dev/null +++ b/rules_toolchain/e2e/.bazelrc.ci @@ -0,0 +1,36 @@ +# Declare all run commands that are loaded +common --announce_rc + +# Use relative paths where possible for concise CI output +common --attempt_to_print_relative_paths + +# Prevent progress bars or similar +common --curses=no + +# CI "terminals" support colour +common --color=yes + +# Output timestamps for each command to aid debugging of CI runtime +common --show_timestamps + +# Do not wrap any output +common --terminal_columns=0 + +# Print relative paths where possible to reduce noise +common --attempt_to_print_relative_paths + +# Output as much information in the CI log about failures as possible +build --verbose_failures + +# Avoid building all targets when testing +test --build_tests_only + +# Noisy logs but allows debugging CI run failures +test --test_output=errors + +# Output as much information when a test exceeds a timeout +test --test_verbose_timeout_warnings + +# These locations are cached on the CI +build --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk +build --repository_cache=${CI_PROJECT_DIR}/.cache/bazel/repo diff --git a/rules_toolchain/e2e/.gitignore b/rules_toolchain/e2e/.gitignore index 3ec2cc3..5ebc57e 100644 --- a/rules_toolchain/e2e/.gitignore +++ b/rules_toolchain/e2e/.gitignore @@ -3,3 +3,4 @@ /bazel-testlogs /bazel-e2e /bazel-out +/.bazelrc.user -- GitLab From bae871850ecc8e10e53da3d0cabf013abda620ba Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 14 Nov 2023 13:05:21 +0000 Subject: [PATCH 49/55] test(rules_toolchain): add sizes to targets --- rules_toolchain/e2e/local/triplet/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/rules_toolchain/e2e/local/triplet/BUILD.bazel b/rules_toolchain/e2e/local/triplet/BUILD.bazel index f4d84f2..9b542a7 100644 --- a/rules_toolchain/e2e/local/triplet/BUILD.bazel +++ b/rules_toolchain/e2e/local/triplet/BUILD.bazel @@ -10,6 +10,7 @@ write_file( diff_test( name = "test", + size = "small", file1 = ":expected", file2 = "@rules_toolchain//toolchain/triplet:local", ) -- GitLab From bd0481a8b711a8683686600656a67bb74693f34a Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 14 Nov 2023 13:05:44 +0000 Subject: [PATCH 50/55] fix(rules_toolchain): add `x86_64`/`aarch64` CPU targets --- rules_toolchain/toolchain/local/triplet/cpu.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rules_toolchain/toolchain/local/triplet/cpu.bzl b/rules_toolchain/toolchain/local/triplet/cpu.bzl index 710b929..081fc08 100644 --- a/rules_toolchain/toolchain/local/triplet/cpu.bzl +++ b/rules_toolchain/toolchain/local/triplet/cpu.bzl @@ -11,6 +11,8 @@ def cpu(rctx): A CPU string. """ return { + "x86_64": "amd64", "amd64": "amd64", "arm64": "arm64", + "aarch64": "arm64", }[rctx.os.arch] -- GitLab From 207541da408b4d49abc24e9fe425be463ec36b58 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 14 Nov 2023 13:06:09 +0000 Subject: [PATCH 51/55] fix(rules_toolchain): do a better job of processing `/etc/release` --- rules_toolchain/toolchain/local/triplet/libc.bzl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/rules_toolchain/toolchain/local/triplet/libc.bzl b/rules_toolchain/toolchain/local/triplet/libc.bzl index 2f64d48..d1d5c0b 100644 --- a/rules_toolchain/toolchain/local/triplet/libc.bzl +++ b/rules_toolchain/toolchain/local/triplet/libc.bzl @@ -9,12 +9,11 @@ def _unquote(value): return value def _release(rctx, path): - data = struct(**{ - k.lower(): _unquote(v) - for line in rctx.read(path).splitlines() - if "=" in line - for k, v in line.split("=", 1) - }) + content = rctx.read(path) + lines = content.splitlines() + pairs = [line.split("=", 1) for line in lines if "=" in line] + processed = {k.lower(): _unquote(v) for k, v in pairs} + data = struct(**processed) if data.id in ("arch", "debian", "fedora"): return VersionedInfo("gnu") -- GitLab From 880c090682f7f21f13dc33d514a8a87d72b406ec Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Tue, 14 Nov 2023 13:06:31 +0000 Subject: [PATCH 52/55] chore(rules_toolchain): improve `uname` warning --- rules_toolchain/toolchain/local/triplet/os.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules_toolchain/toolchain/local/triplet/os.bzl b/rules_toolchain/toolchain/local/triplet/os.bzl index 00f80f9..4b64c09 100644 --- a/rules_toolchain/toolchain/local/triplet/os.bzl +++ b/rules_toolchain/toolchain/local/triplet/os.bzl @@ -74,7 +74,7 @@ def _uname(rctx, path): }) if rctx.path("/.dockerenv").exists: - print("`uname` release is the host kernel inside a container.") + print("`uname` release is the host kernel inside a container. We recommend installing `/usr/include/linux/version.h` into the container.") return VersionedInfo("linux.{}.{}.{}".format(int(major), int(minor), int(patch))) -- GitLab From 99fbd23a1f3c86245132d266bb9686c4fbf89d1c Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 14 Nov 2023 21:36:12 +0000 Subject: [PATCH 53/55] chore: move `rules_toolchain` contents to project root --- .gitignore | 2 +- MODULE.bazel | 9 + MODULE.bazel.lock | 832 ++++++++++++++-- README.md | 119 ++- e2e/BUILD.bazel | 6 - e2e/MODULE.bazel | 32 + e2e/MODULE.bazel.lock | 926 ++++++++++++++++-- .../e2e => e2e}/local/select/BUILD.bazel | 0 .../e2e => e2e}/local/triplet/BUILD.bazel | 0 {rules_toolchain/e2e => e2e}/test/BUILD.bazel | 0 .../e2e => e2e}/test/fixture/BUILD.bazel | 0 .../e2e => e2e}/test/fixture/BUILD.tmpl.bazel | 0 .../e2e => e2e}/test/fixture/hello-world.txt | 0 .../e2e => e2e}/test/fixture/repository.bzl | 0 .../e2e => e2e}/toolchain/echo/BUILD.bazel | 0 .../e2e => e2e}/toolchain/echo/echo.sh | 0 .../toolchain/echo/hello-world.txt | 0 .../e2e => e2e}/toolchain/echo/resolved.bzl | 0 rules_toolchain/.bazelignore | 1 - rules_toolchain/.bazelrc | 14 - rules_toolchain/.bazelrc.ci | 36 - rules_toolchain/.bazelversion | 2 - rules_toolchain/.gitignore | 6 - rules_toolchain/MODULE.bazel | 15 - rules_toolchain/README.md | 129 --- rules_toolchain/WORKSPACE | 0 rules_toolchain/e2e/.bazelrc | 14 - rules_toolchain/e2e/.bazelrc.ci | 36 - rules_toolchain/e2e/.bazelversion | 2 - rules_toolchain/e2e/.gitignore | 6 - rules_toolchain/e2e/MODULE.bazel | 44 - rules_toolchain/e2e/WORKSPACE | 0 rules_toolchain/toolchain/defs.bzl | 15 - .../toolchain/symlink/target/BUILD.bazel | 0 rules_toolchain/toolchain/test/BUILD.bazel | 10 - rules_toolchain/toolchain/test/posix.tmpl.sh | 176 ---- rules_toolchain/toolchain/test/rule.bzl | 86 -- toolchain/BUILD.bazel | 6 - .../constraint/BUILD.bazel | 0 .../constraint/cpu/BUILD.bazel | 0 .../constraint/libc/BUILD.bazel | 0 .../constraint/libc/gnu/BUILD.bazel | 0 .../constraint/libc/gnu/versions.bzl | 0 .../constraint/os/BUILD.bazel | 0 .../constraint/os/linux/BUILD.bazel | 0 .../constraint/os/linux/versions.bzl | 0 toolchain/defs.bzl | 10 + toolchain/fixture.txt | 1 - .../toolchain => toolchain}/local/BUILD.bazel | 0 .../local/select}/BUILD.bazel | 0 .../local/select/repository.bzl | 0 .../local/triplet}/BUILD.bazel | 0 .../local/triplet/cpu.bzl | 0 .../local/triplet/detect.bzl | 0 .../local/triplet/libc.bzl | 0 .../local/triplet/os.bzl | 0 .../local/triplet/repository.bzl | 0 .../local/triplet/triplet.tmpl.bzl | 0 .../local/which}/BUILD.bazel | 0 .../local/which/BUILD.tmpl.bazel | 0 .../local/which/repository.bzl | 0 .../platform/BUILD.bazel | 0 .../toolchain => toolchain}/resolved.bzl | 0 .../symlink/path}/BUILD.bazel | 0 .../symlink/path/rule.bzl | 0 .../symlink/target}/BUILD.bazel | 0 .../symlink/target/rule.bzl | 0 toolchain/test/BUILD.bazel | 9 + .../toolchain => toolchain}/test/any | 0 .../toolchain => toolchain}/test/empty | 0 .../toolchain => toolchain}/test/non-empty | 0 toolchain/test/posix.tmpl.sh | 177 +++- toolchain/test/rule.bzl | 71 +- .../triplet/BUILD.bazel | 0 .../triplet/TripletInfo.bzl | 0 .../triplet/VersionInfo.bzl | 0 .../triplet/VersionedInfo.bzl | 0 .../toolchain => toolchain}/triplet/local.bzl | 0 .../toolchain => toolchain}/triplet/rule.bzl | 0 .../toolchain => toolchain}/triplet/split.bzl | 0 .../toolchain => toolchain}/triplet/test.bzl | 0 .../triplet/triplets.bzl | 0 .../triplet/unversioned.bzl | 0 83 files changed, 2009 insertions(+), 783 deletions(-) delete mode 100644 e2e/BUILD.bazel rename {rules_toolchain/e2e => e2e}/local/select/BUILD.bazel (100%) rename {rules_toolchain/e2e => e2e}/local/triplet/BUILD.bazel (100%) rename {rules_toolchain/e2e => e2e}/test/BUILD.bazel (100%) rename {rules_toolchain/e2e => e2e}/test/fixture/BUILD.bazel (100%) rename {rules_toolchain/e2e => e2e}/test/fixture/BUILD.tmpl.bazel (100%) rename {rules_toolchain/e2e => e2e}/test/fixture/hello-world.txt (100%) rename {rules_toolchain/e2e => e2e}/test/fixture/repository.bzl (100%) rename {rules_toolchain/e2e => e2e}/toolchain/echo/BUILD.bazel (100%) rename {rules_toolchain/e2e => e2e}/toolchain/echo/echo.sh (100%) rename {rules_toolchain/e2e => e2e}/toolchain/echo/hello-world.txt (100%) rename {rules_toolchain/e2e => e2e}/toolchain/echo/resolved.bzl (100%) delete mode 100644 rules_toolchain/.bazelignore delete mode 100644 rules_toolchain/.bazelrc delete mode 100644 rules_toolchain/.bazelrc.ci delete mode 100644 rules_toolchain/.bazelversion delete mode 100644 rules_toolchain/.gitignore delete mode 100644 rules_toolchain/MODULE.bazel delete mode 100644 rules_toolchain/README.md delete mode 100644 rules_toolchain/WORKSPACE delete mode 100644 rules_toolchain/e2e/.bazelrc delete mode 100644 rules_toolchain/e2e/.bazelrc.ci delete mode 100644 rules_toolchain/e2e/.bazelversion delete mode 100644 rules_toolchain/e2e/.gitignore delete mode 100644 rules_toolchain/e2e/MODULE.bazel delete mode 100644 rules_toolchain/e2e/WORKSPACE delete mode 100644 rules_toolchain/toolchain/defs.bzl delete mode 100644 rules_toolchain/toolchain/symlink/target/BUILD.bazel delete mode 100644 rules_toolchain/toolchain/test/BUILD.bazel delete mode 100755 rules_toolchain/toolchain/test/posix.tmpl.sh delete mode 100644 rules_toolchain/toolchain/test/rule.bzl rename {rules_toolchain/toolchain => toolchain}/constraint/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/constraint/cpu/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/constraint/libc/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/constraint/libc/gnu/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/constraint/libc/gnu/versions.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/constraint/os/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/constraint/os/linux/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/constraint/os/linux/versions.bzl (100%) delete mode 100644 toolchain/fixture.txt rename {rules_toolchain/toolchain => toolchain}/local/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain/local/select}/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/local/select/repository.bzl (100%) rename {rules_toolchain/toolchain/local/select => toolchain/local/triplet}/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/local/triplet/cpu.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/local/triplet/detect.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/local/triplet/libc.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/local/triplet/os.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/local/triplet/repository.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/local/triplet/triplet.tmpl.bzl (100%) rename {rules_toolchain/toolchain/local/triplet => toolchain/local/which}/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/local/which/BUILD.tmpl.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/local/which/repository.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/platform/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/resolved.bzl (100%) rename {rules_toolchain/toolchain/local/which => toolchain/symlink/path}/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/symlink/path/rule.bzl (100%) rename {rules_toolchain/toolchain/symlink/path => toolchain/symlink/target}/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/symlink/target/rule.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/test/any (100%) rename {rules_toolchain/toolchain => toolchain}/test/empty (100%) rename {rules_toolchain/toolchain => toolchain}/test/non-empty (100%) rename {rules_toolchain/toolchain => toolchain}/triplet/BUILD.bazel (100%) rename {rules_toolchain/toolchain => toolchain}/triplet/TripletInfo.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/triplet/VersionInfo.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/triplet/VersionedInfo.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/triplet/local.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/triplet/rule.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/triplet/split.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/triplet/test.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/triplet/triplets.bzl (100%) rename {rules_toolchain/toolchain => toolchain}/triplet/unversioned.bzl (100%) diff --git a/.gitignore b/.gitignore index 78c9d9f..b7cd8bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /.cache /bazel-bin /bazel-testlogs -/bazel-rules_placeholder +/bazel-rules_toolchain /bazel-out /.bazelrc.user diff --git a/MODULE.bazel b/MODULE.bazel index c4bf564..cf10183 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -5,3 +5,12 @@ module( ">=6.4.0", ], ) + +bazel_dep(name = "bazel_skylib", version = "1.4.2") +bazel_dep(name = "platforms", version = "0.0.7") + +triplet = use_repo_rule("//toolchain/local/triplet:repository.bzl", "triplet") + +triplet( + name = "local", +) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index ebe20f5..ecbd999 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1,6 +1,6 @@ { "lockFileVersion": 3, - "moduleFileHash": "00739f08c18e0704210a078643d314b473139c28fd054989fe83997c8453025f", + "moduleFileHash": "40376b7f2b286e2b47922cf35c49ab73256806d8f016a140a6e0ca8e3fe94475", "flags": { "cmdRegistries": [ "https://bcr.bazel.build/" @@ -23,10 +23,102 @@ "repoName": "rules_toolchain", "executionPlatformsToRegister": [], "toolchainsToRegister": [], + "extensionUsages": [ + { + "extensionBzlFile": "//:MODULE.bazel", + "extensionName": "_repo_rules", + "usingModule": "", + "location": { + "file": "@@//:MODULE.bazel", + "line": 0, + "column": 0 + }, + "imports": { + "local": "local" + }, + "devImports": [], + "tags": [ + { + "tagName": "//toolchain/local/triplet:repository.bzl%triplet", + "attributeValues": { + "name": "local" + }, + "devDependency": false, + "location": { + "file": "@@//:MODULE.bazel", + "line": 14, + "column": 8 + } + } + ], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], + "deps": { + "bazel_skylib": "bazel_skylib@1.4.2", + "platforms": "platforms@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + } + }, + "bazel_skylib@1.4.2": { + "name": "bazel_skylib", + "version": "1.4.2", + "key": "bazel_skylib@1.4.2", + "repoName": "bazel_skylib", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "//toolchains/unittest:cmd_toolchain", + "//toolchains/unittest:bash_toolchain" + ], + "extensionUsages": [], + "deps": { + "platforms": "platforms@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "bazel_skylib~1.4.2", + "urls": [ + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz" + ], + "integrity": "sha256-Zv/ZMVZlv6r8lrUiePV8fi3Qn17eJ56m05sr5HHn46o=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, + "platforms@0.0.7": { + "name": "platforms", + "version": "0.0.7", + "key": "platforms@0.0.7", + "repoName": "platforms", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], "extensionUsages": [], "deps": { + "rules_license": "rules_license@0.0.7", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "platforms", + "urls": [ + "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz" + ], + "integrity": "sha256-OlYcmee9vpFzqmU/1Xn+hJ8djWc5V4CrR3Cx84FDHVE=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } } }, "bazel_tools@_": { @@ -176,6 +268,33 @@ "bazel_tools": "bazel_tools@_" } }, + "rules_license@0.0.7": { + "name": "rules_license", + "version": "0.0.7", + "key": "rules_license@0.0.7", + "repoName": "rules_license", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_license~0.0.7", + "urls": [ + "https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz" + ], + "integrity": "sha256-RTHezLkTY5ww5cdRKgVNXYdWmNrrddjPkPKEN1/nw2A=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, "rules_cc@0.0.9": { "name": "rules_cc", "version": "0.0.9", @@ -306,7 +425,7 @@ "deps": { "platforms": "platforms@0.0.7", "rules_cc": "rules_cc@0.0.9", - "bazel_skylib": "bazel_skylib@1.3.0", + "bazel_skylib": "bazel_skylib@1.4.2", "rules_proto": "rules_proto@4.0.0", "rules_license": "rules_license@0.0.7", "bazel_tools": "bazel_tools@_", @@ -327,33 +446,6 @@ } } }, - "rules_license@0.0.7": { - "name": "rules_license", - "version": "0.0.7", - "key": "rules_license@0.0.7", - "repoName": "rules_license", - "executionPlatformsToRegister": [], - "toolchainsToRegister": [], - "extensionUsages": [], - "deps": { - "bazel_tools": "bazel_tools@_", - "local_config_platform": "local_config_platform@_" - }, - "repoSpec": { - "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "name": "rules_license~0.0.7", - "urls": [ - "https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz" - ], - "integrity": "sha256-RTHezLkTY5ww5cdRKgVNXYdWmNrrddjPkPKEN1/nw2A=", - "strip_prefix": "", - "remote_patches": {}, - "remote_patch_strip": 0 - } - } - }, "rules_proto@4.0.0": { "name": "rules_proto", "version": "4.0.0", @@ -363,7 +455,7 @@ "toolchainsToRegister": [], "extensionUsages": [], "deps": { - "bazel_skylib": "bazel_skylib@1.3.0", + "bazel_skylib": "bazel_skylib@1.4.2", "rules_cc": "rules_cc@0.0.9", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" @@ -440,34 +532,6 @@ } } }, - "platforms@0.0.7": { - "name": "platforms", - "version": "0.0.7", - "key": "platforms@0.0.7", - "repoName": "platforms", - "executionPlatformsToRegister": [], - "toolchainsToRegister": [], - "extensionUsages": [], - "deps": { - "rules_license": "rules_license@0.0.7", - "bazel_tools": "bazel_tools@_", - "local_config_platform": "local_config_platform@_" - }, - "repoSpec": { - "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "name": "platforms", - "urls": [ - "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz" - ], - "integrity": "sha256-OlYcmee9vpFzqmU/1Xn+hJ8djWc5V4CrR3Cx84FDHVE=", - "strip_prefix": "", - "remote_patches": {}, - "remote_patch_strip": 0 - } - } - }, "protobuf@3.19.6": { "name": "protobuf", "version": "3.19.6", @@ -477,7 +541,7 @@ "toolchainsToRegister": [], "extensionUsages": [], "deps": { - "bazel_skylib": "bazel_skylib@1.3.0", + "bazel_skylib": "bazel_skylib@1.4.2", "zlib": "zlib@1.3", "rules_python": "rules_python@0.4.0", "rules_cc": "rules_cc@0.0.9", @@ -568,7 +632,7 @@ } ], "deps": { - "bazel_skylib": "bazel_skylib@1.3.0", + "bazel_skylib": "bazel_skylib@1.4.2", "platforms": "platforms@0.0.7", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" @@ -587,38 +651,626 @@ "remote_patch_strip": 0 } } + } + }, + "moduleExtensions": { + "//:MODULE.bazel%_repo_rules": { + "general": { + "bzlTransitiveDigest": "mvwjHUR6LfdJXlUKr5URiiM5nIkorGaL+UsIyVuakBw=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "local": { + "bzlFile": "@@//toolchain/local/triplet:repository.bzl", + "ruleClassName": "triplet", + "attributes": { + "name": "_main~_repo_rules~local" + } + } + } + } }, - "bazel_skylib@1.3.0": { - "name": "bazel_skylib", - "version": "1.3.0", - "key": "bazel_skylib@1.3.0", - "repoName": "bazel_skylib", - "executionPlatformsToRegister": [], - "toolchainsToRegister": [ - "//toolchains/unittest:cmd_toolchain", - "//toolchains/unittest:bash_toolchain" - ], - "extensionUsages": [], - "deps": { - "platforms": "platforms@0.0.7", - "bazel_tools": "bazel_tools@_", - "local_config_platform": "local_config_platform@_" - }, - "repoSpec": { - "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "name": "bazel_skylib~1.3.0", - "urls": [ - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz" - ], - "integrity": "sha256-dNVE2W9KW7Yw1GXKi7z+Ix41lOWq5X4e2/F6brPKJQY=", - "strip_prefix": "", - "remote_patches": {}, - "remote_patch_strip": 0 + "@apple_support~1.5.0//crosstool:setup.bzl%apple_cc_configure_extension": { + "general": { + "bzlTransitiveDigest": "pMLFCYaRPkgXPQ8vtuNkMfiHfPmRBy6QJfnid4sWfv0=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "local_config_apple_cc": { + "bzlFile": "@@apple_support~1.5.0//crosstool:setup.bzl", + "ruleClassName": "_apple_cc_autoconf", + "attributes": { + "name": "apple_support~1.5.0~apple_cc_configure_extension~local_config_apple_cc" + } + }, + "local_config_apple_cc_toolchains": { + "bzlFile": "@@apple_support~1.5.0//crosstool:setup.bzl", + "ruleClassName": "_apple_cc_autoconf_toolchains", + "attributes": { + "name": "apple_support~1.5.0~apple_cc_configure_extension~local_config_apple_cc_toolchains" + } + } + } + } + }, + "@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": { + "general": { + "bzlTransitiveDigest": "O9sf6ilKWU9Veed02jG9o2HM/xgV/UAyciuFBuxrFRY=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "local_config_cc": { + "bzlFile": "@@bazel_tools//tools/cpp:cc_configure.bzl", + "ruleClassName": "cc_autoconf", + "attributes": { + "name": "bazel_tools~cc_configure_extension~local_config_cc" + } + }, + "local_config_cc_toolchains": { + "bzlFile": "@@bazel_tools//tools/cpp:cc_configure.bzl", + "ruleClassName": "cc_autoconf_toolchains", + "attributes": { + "name": "bazel_tools~cc_configure_extension~local_config_cc_toolchains" + } + } + } + } + }, + "@bazel_tools//tools/sh:sh_configure.bzl%sh_configure_extension": { + "general": { + "bzlTransitiveDigest": "hp4NgmNjEg5+xgvzfh6L83bt9/aiiWETuNpwNuF1MSU=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "local_config_sh": { + "bzlFile": "@@bazel_tools//tools/sh:sh_configure.bzl", + "ruleClassName": "sh_config", + "attributes": { + "name": "bazel_tools~sh_configure_extension~local_config_sh" + } + } + } + } + }, + "@rules_java~7.1.0//java:extensions.bzl%toolchains": { + "general": { + "bzlTransitiveDigest": "EXsxSX2vQjCcI8jYez/O+Yb9H5reAMhLL3WXGPD6Scw=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "remotejdk21_linux_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux//:jdk\",\n)\n" + } + }, + "remotejdk17_linux_s390x_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_s390x_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_s390x//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_s390x//:jdk\",\n)\n" + } + }, + "remotejdk17_macos_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos//:jdk\",\n)\n" + } + }, + "remotejdk21_macos_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk17_linux_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk21_macos_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "2a7a99a3ea263dbd8d32a67d1e6e363ba8b25c645c826f5e167a02bbafaff1fa", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-macosx_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_aarch64.tar.gz" + ] + } + }, + "remotejdk17_linux_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux//:jdk\",\n)\n" + } + }, + "remotejdk17_macos_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "314b04568ec0ae9b36ba03c9cbd42adc9e1265f74678923b19297d66eb84dcca", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64.tar.gz" + ] + } + }, + "remote_java_tools_windows": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remote_java_tools_windows", + "sha256": "c5c70c214a350f12cbf52da8270fa43ba629b795f3dd328028a38f8f0d39c2a1", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.1/java_tools_windows-v13.1.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.1/java_tools_windows-v13.1.zip" + ] + } + }, + "remotejdk11_win": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "43408193ce2fa0862819495b5ae8541085b95660153f2adcf91a52d3a1710e83", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-win_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip" + ] + } + }, + "remotejdk11_win_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win//:jdk\",\n)\n" + } + }, + "remotejdk11_linux_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "54174439f2b3fddd11f1048c397fe7bb45d4c9d66d452d6889b013d04d21c4de", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-linux_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz" + ] + } + }, + "remotejdk17_linux": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "b9482f2304a1a68a614dfacddcf29569a72f0fac32e6c74f83dc1b9a157b8340", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-linux_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_x64.tar.gz" + ] + } + }, + "remotejdk11_linux_s390x_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_s390x_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_s390x//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_s390x//:jdk\",\n)\n" + } + }, + "remotejdk11_linux_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux//:jdk\",\n)\n" + } + }, + "remotejdk11_macos": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "bcaab11cfe586fae7583c6d9d311c64384354fb2638eb9a012eca4c3f1a1d9fd", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-macosx_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz" + ] + } + }, + "remotejdk11_win_arm64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_win_arm64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "b8a28e6e767d90acf793ea6f5bed0bb595ba0ba5ebdf8b99f395266161e53ec2", + "strip_prefix": "jdk-11.0.13+8", + "urls": [ + "https://mirror.bazel.build/aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-aarch64.zip" + ] + } + }, + "remotejdk17_macos": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "640453e8afe8ffe0fb4dceb4535fb50db9c283c64665eebb0ba68b19e65f4b1f", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-macosx_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_x64.tar.gz" + ] + } + }, + "remotejdk21_macos": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "9639b87db586d0c89f7a9892ae47f421e442c64b97baebdff31788fbe23265bd", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-macosx_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_x64.tar.gz" + ] + } + }, + "remotejdk21_macos_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos//:jdk\",\n)\n" + } + }, + "remotejdk17_macos_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk17_win": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "192f2afca57701de6ec496234f7e45d971bf623ff66b8ee4a5c81582054e5637", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-win_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_x64.zip" + ] + } + }, + "remotejdk11_macos_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk11_linux_ppc64le_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_ppc64le_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_ppc64le//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_ppc64le//:jdk\",\n)\n" + } + }, + "remotejdk21_linux": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "0c0eadfbdc47a7ca64aeab51b9c061f71b6e4d25d2d87674512e9b6387e9e3a6", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-linux_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_x64.tar.gz" + ] + } + }, + "remote_java_tools_linux": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remote_java_tools_linux", + "sha256": "d134da9b04c9023fb6e56a5d4bffccee73f7bc9572ddc4e747778dacccd7a5a7", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.1/java_tools_linux-v13.1.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.1/java_tools_linux-v13.1.zip" + ] + } + }, + "remotejdk21_win": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "e9959d500a0d9a7694ac243baf657761479da132f0f94720cbffd092150bd802", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-win_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-win_x64.zip" + ] + } + }, + "remotejdk21_linux_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "1fb64b8036c5d463d8ab59af06bf5b6b006811e6012e3b0eb6bccf57f1c55835", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-linux_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_aarch64.tar.gz" + ] + } + }, + "remotejdk11_linux_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk11_linux_s390x": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_s390x", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "a58fc0361966af0a5d5a31a2d8a208e3c9bb0f54f345596fd80b99ea9a39788b", + "strip_prefix": "jdk-11.0.15+10", + "urls": [ + "https://mirror.bazel.build/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.15_10.tar.gz", + "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.15_10.tar.gz" + ] + } + }, + "remotejdk17_linux_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "6531cef61e416d5a7b691555c8cf2bdff689201b8a001ff45ab6740062b44313", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64.tar.gz" + ] + } + }, + "remotejdk17_win_arm64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_win_arm64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win_arm64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win_arm64//:jdk\",\n)\n" + } + }, + "remotejdk11_linux": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "a34b404f87a08a61148b38e1416d837189e1df7a040d949e743633daf4695a3c", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-linux_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz" + ] + } + }, + "remotejdk11_macos_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos//:jdk\",\n)\n" + } + }, + "remotejdk17_linux_ppc64le_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_ppc64le_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_ppc64le//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_ppc64le//:jdk\",\n)\n" + } + }, + "remotejdk17_win_arm64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_win_arm64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "6802c99eae0d788e21f52d03cab2e2b3bf42bc334ca03cbf19f71eb70ee19f85", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-win_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_aarch64.zip", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_aarch64.zip" + ] + } + }, + "remote_java_tools_darwin_arm64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remote_java_tools_darwin_arm64", + "sha256": "dab5bb87ec43e980faea6e1cec14bafb217b8e2f5346f53aa784fd715929a930", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.1/java_tools_darwin_arm64-v13.1.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.1/java_tools_darwin_arm64-v13.1.zip" + ] + } + }, + "remotejdk17_linux_ppc64le": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_ppc64le", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "00a4c07603d0218cd678461b5b3b7e25b3253102da4022d31fc35907f21a2efd", + "strip_prefix": "jdk-17.0.8.1+1", + "urls": [ + "https://mirror.bazel.build/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.8.1_1.tar.gz", + "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.8.1_1.tar.gz" + ] + } + }, + "remotejdk21_linux_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk11_win_arm64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_win_arm64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win_arm64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win_arm64//:jdk\",\n)\n" + } + }, + "local_jdk": { + "bzlFile": "@@rules_java~7.1.0//toolchains:local_java_repository.bzl", + "ruleClassName": "_local_java_repository_rule", + "attributes": { + "name": "rules_java~7.1.0~toolchains~local_jdk", + "java_home": "", + "version": "", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = {RUNTIME_VERSION},\n)\n" + } + }, + "remote_java_tools_darwin_x86_64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remote_java_tools_darwin_x86_64", + "sha256": "0db40d8505a2b65ef0ed46e4256757807db8162f7acff16225be57c1d5726dbc", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.1/java_tools_darwin_x86_64-v13.1.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.1/java_tools_darwin_x86_64-v13.1.zip" + ] + } + }, + "remote_java_tools": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remote_java_tools", + "sha256": "286bdbbd66e616fc4ed3f90101418729a73baa7e8c23a98ffbef558f74c0ad14", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.1/java_tools-v13.1.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.1/java_tools-v13.1.zip" + ] + } + }, + "remotejdk17_linux_s390x": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_s390x", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "ffacba69c6843d7ca70d572489d6cc7ab7ae52c60f0852cedf4cf0d248b6fc37", + "strip_prefix": "jdk-17.0.8.1+1", + "urls": [ + "https://mirror.bazel.build/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.8.1_1.tar.gz", + "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.8.1_1.tar.gz" + ] + } + }, + "remotejdk17_win_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win//:jdk\",\n)\n" + } + }, + "remotejdk11_linux_ppc64le": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_ppc64le", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "a8fba686f6eb8ae1d1a9566821dbd5a85a1108b96ad857fdbac5c1e4649fc56f", + "strip_prefix": "jdk-11.0.15+10", + "urls": [ + "https://mirror.bazel.build/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.15_10.tar.gz", + "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.15_10.tar.gz" + ] + } + }, + "remotejdk11_macos_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "7632bc29f8a4b7d492b93f3bc75a7b61630894db85d136456035ab2a24d38885", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-macosx_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz" + ] + } + }, + "remotejdk21_win_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_win//:jdk\",\n)\n" + } + } } } } - }, - "moduleExtensions": {} + } } diff --git a/README.md b/README.md index dfd2c73..3f87b85 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,126 @@ ## Getting Started +### Local Tool + Add the following to `MODULE.bazel`: ```py -bazel_dep(name="rules_toolchain", version="0.0.0") +which = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_which") +which("echo") +``` + +The `echo` tool will be found on the `PATH`. + +A repository with the `@echo//:echo` target will be created. + +### Downloaded Tool + +Use `rules_download` to provide a hermetic, pre-built binary in `MODULE.bazel` + +```py +archive = use_repo_rule("@rules_download//download:defs.bzl", "download_archive") +archive( + name = "coreutils-arm64-linux-gnu", + srcs = ["coreutils"], + integrity = "sha256-mlmkbeabyu4+5+cFiUSL6Ki4KFNqWu48gTjFc3NS43g=", + strip_prefix = "coreutils-0.0.21-aarch64-unknown-linux-gnu", + urls = ["https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-aarch64-unknown-linux-gnu.tar.gz"], +) ``` +A repository with the `@coreutils-arm64-linux-gnu//:coreutils` target will be created. + +### Toolchains + +Create a `toolchain/echo/BUILD.bazel` with the following: + +```py +load("@rules_toolchain//toolchain:defs.bzl", "toolchain_symlink_target", "toolchain_test") + +# Custom rule, described in the next section +load(":resolved.bzl", "resolved") + +# The `toolchain/echo:type` for registration +toolchain_type( + name = "type", +) + +# Register the `local` binary as a toolchain +# No `exec_compatible_with` constraints are needed as a local binary is always compatible with the execution platform +toolchain( + name = "local", + toolchain = "@echo", + toolchain_type = ":type", +) + +# Create a toolchain binary from the downloaded `coreutils` +toolchain_symlink_target( + name = "coreutils-arm64-linux-gnu", + target = "@coreutils-arm64-linux-gnu//:coreutils", +) + +# Create a symlink to the multi-call binary +toolchain_symlink_target( + name = "echo-arm64-linux-gnu", + basename = "echo", + target = ":coreutils-arm64-linux-gnu", +) + +# Register the hermetic toolchain +# Use constraints to signify what host machines the toolchain is compatible with +toolchain( + name = "arm64-linux", + toolchain = ":echo-arm64-linux-gnu", + toolchain_type = ":type", + exec_compatible_with = [ + "@rules_toolchain//toolchain/constraint/cpu:arm64", + "@rules_toolchain//toolchain/constraint/os:linux", + # Bazel _assumes_ `glibc` for Linux + # "@rules_toolchain//toolchain/constraint/libc:gnu", + ], +) + +# Provide a resolved toolchain target +resolved( + name = "resolved", + toolchain_type = ":type", +) +``` + +#### Resolved + +To work around a [quirk in Bazel][resolved], the resolution of the toolchain must be defined in a separate rule. + +`@rules_toolchain` provides the necessary building blocks for this rule. + +Create `toolchain/echo/resolved.bzl` to provide the `resolved` rule that is used above: + +```py +load("@rules_toolchain//toolchain:resolved.bzl", _resolved = "export") + +visibility("toolchain/echo/...") + +DOC = _resolved.doc + +ATTRS = _resolved.attrs + +implementation = _resolve.implementation + +resolved = _resolved.rule( + toolchain = Label("//toolchain/echo:type"), +) +``` + +### Run + +The `resolved` target allows toolchain that is compatible with the current machine to be executed: + +```py +bazelisk run -- //toolchain/echo:resolved "Hello, world!" +``` + +If the machine is compatible with the downloaded toolchain constraints, that will be used. Otherwise, it will fallback +to finding the toolchain on the local `PATH`. + +[resolved]: https://github.com/bazelbuild/bazel/issues/14009 diff --git a/e2e/BUILD.bazel b/e2e/BUILD.bazel deleted file mode 100644 index 02eecce..0000000 --- a/e2e/BUILD.bazel +++ /dev/null @@ -1,6 +0,0 @@ -load("@rules_toolchain//toolchain:defs.bzl", "toolchain_test") - -toolchain_test( - name = "test", - size = "small", -) diff --git a/e2e/MODULE.bazel b/e2e/MODULE.bazel index 7825f84..1138e73 100644 --- a/e2e/MODULE.bazel +++ b/e2e/MODULE.bazel @@ -5,8 +5,40 @@ module( ], ) +bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "rules_toolchain", version = "0.0.0") local_path_override( module_name = "rules_toolchain", path = "..", ) + +which = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_which") + +which(name = "echo") + +register_toolchains("//toolchain/echo:all") + +fixture = use_repo_rule("//test/fixture:repository.bzl", "fixture") + +fixture( + name = "fixture-amd64-linux-gnu", +) + +fixture( + name = "fixture-arm64-linux-gnu", +) + +fixture( + name = "fixture-arm-linux-musl", +) + +select = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_select") + +select( + name = "fixture", + map = { + "amd64-linux-gnu": "@fixture-amd64-linux-gnu", + "arm64-linux-gnu": "@fixture-arm64-linux-gnu", + "arm-linux-musl": "@fixture-arm-linux-musl", + }, +) diff --git a/e2e/MODULE.bazel.lock b/e2e/MODULE.bazel.lock index 0afb99c..947ce4d 100644 --- a/e2e/MODULE.bazel.lock +++ b/e2e/MODULE.bazel.lock @@ -1,6 +1,6 @@ { "lockFileVersion": 3, - "moduleFileHash": "5994db4b0cb0b6d41c15302e14e389188de639595869b573fcd2879139985020", + "moduleFileHash": "7ff95807f953adb3cee60c034542c31fd3f27dec0c2bfcc56a49d1259662afe0", "flags": { "cmdRegistries": [ "https://bcr.bazel.build/" @@ -13,7 +13,7 @@ "compatibilityMode": "ERROR" }, "localOverrideHashes": { - "rules_toolchain": "00739f08c18e0704210a078643d314b473139c28fd054989fe83997c8453025f", + "rules_toolchain": "40376b7f2b286e2b47922cf35c49ab73256806d8f016a140a6e0ca8e3fe94475", "bazel_tools": "922ea6752dc9105de5af957f7a99a6933c0a6a712d23df6aad16a9c399f7e787" }, "moduleDepGraph": { @@ -23,14 +23,136 @@ "key": "", "repoName": "e2e", "executionPlatformsToRegister": [], - "toolchainsToRegister": [], - "extensionUsages": [], + "toolchainsToRegister": [ + "//toolchain/echo:all" + ], + "extensionUsages": [ + { + "extensionBzlFile": "//:MODULE.bazel", + "extensionName": "_repo_rules", + "usingModule": "", + "location": { + "file": "@@//:MODULE.bazel", + "line": 0, + "column": 0 + }, + "imports": { + "echo": "echo", + "fixture-amd64-linux-gnu": "fixture-amd64-linux-gnu", + "fixture-arm64-linux-gnu": "fixture-arm64-linux-gnu", + "fixture-arm-linux-musl": "fixture-arm-linux-musl", + "fixture": "fixture" + }, + "devImports": [], + "tags": [ + { + "tagName": "@rules_toolchain//toolchain:defs.bzl%toolchain_local_which", + "attributeValues": { + "name": "echo" + }, + "devDependency": false, + "location": { + "file": "@@//:MODULE.bazel", + "line": 17, + "column": 6 + } + }, + { + "tagName": "//test/fixture:repository.bzl%fixture", + "attributeValues": { + "name": "fixture-amd64-linux-gnu" + }, + "devDependency": false, + "location": { + "file": "@@//:MODULE.bazel", + "line": 23, + "column": 8 + } + }, + { + "tagName": "//test/fixture:repository.bzl%fixture", + "attributeValues": { + "name": "fixture-arm64-linux-gnu" + }, + "devDependency": false, + "location": { + "file": "@@//:MODULE.bazel", + "line": 27, + "column": 8 + } + }, + { + "tagName": "//test/fixture:repository.bzl%fixture", + "attributeValues": { + "name": "fixture-arm-linux-musl" + }, + "devDependency": false, + "location": { + "file": "@@//:MODULE.bazel", + "line": 31, + "column": 8 + } + }, + { + "tagName": "@rules_toolchain//toolchain:defs.bzl%toolchain_local_select", + "attributeValues": { + "map": { + "amd64-linux-gnu": "@fixture-amd64-linux-gnu", + "arm64-linux-gnu": "@fixture-arm64-linux-gnu", + "arm-linux-musl": "@fixture-arm-linux-musl" + }, + "name": "fixture" + }, + "devDependency": false, + "location": { + "file": "@@//:MODULE.bazel", + "line": 37, + "column": 7 + } + } + ], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], "deps": { + "bazel_skylib": "bazel_skylib@1.4.2", "rules_toolchain": "rules_toolchain@_", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" } }, + "bazel_skylib@1.4.2": { + "name": "bazel_skylib", + "version": "1.4.2", + "key": "bazel_skylib@1.4.2", + "repoName": "bazel_skylib", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [ + "//toolchains/unittest:cmd_toolchain", + "//toolchains/unittest:bash_toolchain" + ], + "extensionUsages": [], + "deps": { + "platforms": "platforms@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "bazel_skylib~1.4.2", + "urls": [ + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz" + ], + "integrity": "sha256-Zv/ZMVZlv6r8lrUiePV8fi3Qn17eJ56m05sr5HHn46o=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, "rules_toolchain@_": { "name": "rules_toolchain", "version": "0.0.0", @@ -38,8 +160,41 @@ "repoName": "rules_toolchain", "executionPlatformsToRegister": [], "toolchainsToRegister": [], - "extensionUsages": [], + "extensionUsages": [ + { + "extensionBzlFile": "//:MODULE.bazel", + "extensionName": "_repo_rules", + "usingModule": "rules_toolchain@_", + "location": { + "file": "@@rules_toolchain~override//:MODULE.bazel", + "line": 0, + "column": 0 + }, + "imports": { + "local": "local" + }, + "devImports": [], + "tags": [ + { + "tagName": "//toolchain/local/triplet:repository.bzl%triplet", + "attributeValues": { + "name": "local" + }, + "devDependency": false, + "location": { + "file": "@@rules_toolchain~override//:MODULE.bazel", + "line": 14, + "column": 8 + } + } + ], + "hasDevUseExtension": false, + "hasNonDevUseExtension": true + } + ], "deps": { + "bazel_skylib": "bazel_skylib@1.4.2", + "platforms": "platforms@0.0.7", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" } @@ -191,6 +346,34 @@ "bazel_tools": "bazel_tools@_" } }, + "platforms@0.0.7": { + "name": "platforms", + "version": "0.0.7", + "key": "platforms@0.0.7", + "repoName": "platforms", + "executionPlatformsToRegister": [], + "toolchainsToRegister": [], + "extensionUsages": [], + "deps": { + "rules_license": "rules_license@0.0.7", + "bazel_tools": "bazel_tools@_", + "local_config_platform": "local_config_platform@_" + }, + "repoSpec": { + "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "platforms", + "urls": [ + "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz" + ], + "integrity": "sha256-OlYcmee9vpFzqmU/1Xn+hJ8djWc5V4CrR3Cx84FDHVE=", + "strip_prefix": "", + "remote_patches": {}, + "remote_patch_strip": 0 + } + } + }, "rules_cc@0.0.9": { "name": "rules_cc", "version": "0.0.9", @@ -321,7 +504,7 @@ "deps": { "platforms": "platforms@0.0.7", "rules_cc": "rules_cc@0.0.9", - "bazel_skylib": "bazel_skylib@1.3.0", + "bazel_skylib": "bazel_skylib@1.4.2", "rules_proto": "rules_proto@4.0.0", "rules_license": "rules_license@0.0.7", "bazel_tools": "bazel_tools@_", @@ -378,7 +561,7 @@ "toolchainsToRegister": [], "extensionUsages": [], "deps": { - "bazel_skylib": "bazel_skylib@1.3.0", + "bazel_skylib": "bazel_skylib@1.4.2", "rules_cc": "rules_cc@0.0.9", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" @@ -455,34 +638,6 @@ } } }, - "platforms@0.0.7": { - "name": "platforms", - "version": "0.0.7", - "key": "platforms@0.0.7", - "repoName": "platforms", - "executionPlatformsToRegister": [], - "toolchainsToRegister": [], - "extensionUsages": [], - "deps": { - "rules_license": "rules_license@0.0.7", - "bazel_tools": "bazel_tools@_", - "local_config_platform": "local_config_platform@_" - }, - "repoSpec": { - "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "name": "platforms", - "urls": [ - "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz" - ], - "integrity": "sha256-OlYcmee9vpFzqmU/1Xn+hJ8djWc5V4CrR3Cx84FDHVE=", - "strip_prefix": "", - "remote_patches": {}, - "remote_patch_strip": 0 - } - } - }, "protobuf@3.19.6": { "name": "protobuf", "version": "3.19.6", @@ -492,7 +647,7 @@ "toolchainsToRegister": [], "extensionUsages": [], "deps": { - "bazel_skylib": "bazel_skylib@1.3.0", + "bazel_skylib": "bazel_skylib@1.4.2", "zlib": "zlib@1.3", "rules_python": "rules_python@0.4.0", "rules_cc": "rules_cc@0.0.9", @@ -583,7 +738,7 @@ } ], "deps": { - "bazel_skylib": "bazel_skylib@1.3.0", + "bazel_skylib": "bazel_skylib@1.4.2", "platforms": "platforms@0.0.7", "bazel_tools": "bazel_tools@_", "local_config_platform": "local_config_platform@_" @@ -602,38 +757,675 @@ "remote_patch_strip": 0 } } + } + }, + "moduleExtensions": { + "//:MODULE.bazel%_repo_rules": { + "general": { + "bzlTransitiveDigest": "/3M749UD+XvXsUVUe82rrOR0fBWDVdiYpQ6mlpN1U1E=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "echo": { + "bzlFile": "@@rules_toolchain~override//toolchain/local/which:repository.bzl", + "ruleClassName": "which", + "attributes": { + "name": "_main~_repo_rules~echo" + } + }, + "fixture-amd64-linux-gnu": { + "bzlFile": "@@//test/fixture:repository.bzl", + "ruleClassName": "fixture", + "attributes": { + "name": "_main~_repo_rules~fixture-amd64-linux-gnu" + } + }, + "fixture-arm64-linux-gnu": { + "bzlFile": "@@//test/fixture:repository.bzl", + "ruleClassName": "fixture", + "attributes": { + "name": "_main~_repo_rules~fixture-arm64-linux-gnu" + } + }, + "fixture-arm-linux-musl": { + "bzlFile": "@@//test/fixture:repository.bzl", + "ruleClassName": "fixture", + "attributes": { + "name": "_main~_repo_rules~fixture-arm-linux-musl" + } + }, + "fixture": { + "bzlFile": "@@rules_toolchain~override//toolchain/local/select:repository.bzl", + "ruleClassName": "select", + "attributes": { + "map": { + "amd64-linux-gnu": "@fixture-amd64-linux-gnu", + "arm64-linux-gnu": "@fixture-arm64-linux-gnu", + "arm-linux-musl": "@fixture-arm-linux-musl" + }, + "name": "_main~_repo_rules~fixture" + } + } + } + } }, - "bazel_skylib@1.3.0": { - "name": "bazel_skylib", - "version": "1.3.0", - "key": "bazel_skylib@1.3.0", - "repoName": "bazel_skylib", - "executionPlatformsToRegister": [], - "toolchainsToRegister": [ - "//toolchains/unittest:cmd_toolchain", - "//toolchains/unittest:bash_toolchain" - ], - "extensionUsages": [], - "deps": { - "platforms": "platforms@0.0.7", - "bazel_tools": "bazel_tools@_", - "local_config_platform": "local_config_platform@_" - }, - "repoSpec": { - "bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl", - "ruleClassName": "http_archive", - "attributes": { - "name": "bazel_skylib~1.3.0", - "urls": [ - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz" - ], - "integrity": "sha256-dNVE2W9KW7Yw1GXKi7z+Ix41lOWq5X4e2/F6brPKJQY=", - "strip_prefix": "", - "remote_patches": {}, - "remote_patch_strip": 0 + "@apple_support~1.5.0//crosstool:setup.bzl%apple_cc_configure_extension": { + "general": { + "bzlTransitiveDigest": "pMLFCYaRPkgXPQ8vtuNkMfiHfPmRBy6QJfnid4sWfv0=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "local_config_apple_cc": { + "bzlFile": "@@apple_support~1.5.0//crosstool:setup.bzl", + "ruleClassName": "_apple_cc_autoconf", + "attributes": { + "name": "apple_support~1.5.0~apple_cc_configure_extension~local_config_apple_cc" + } + }, + "local_config_apple_cc_toolchains": { + "bzlFile": "@@apple_support~1.5.0//crosstool:setup.bzl", + "ruleClassName": "_apple_cc_autoconf_toolchains", + "attributes": { + "name": "apple_support~1.5.0~apple_cc_configure_extension~local_config_apple_cc_toolchains" + } + } + } + } + }, + "@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": { + "general": { + "bzlTransitiveDigest": "O9sf6ilKWU9Veed02jG9o2HM/xgV/UAyciuFBuxrFRY=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "local_config_cc": { + "bzlFile": "@@bazel_tools//tools/cpp:cc_configure.bzl", + "ruleClassName": "cc_autoconf", + "attributes": { + "name": "bazel_tools~cc_configure_extension~local_config_cc" + } + }, + "local_config_cc_toolchains": { + "bzlFile": "@@bazel_tools//tools/cpp:cc_configure.bzl", + "ruleClassName": "cc_autoconf_toolchains", + "attributes": { + "name": "bazel_tools~cc_configure_extension~local_config_cc_toolchains" + } + } + } + } + }, + "@bazel_tools//tools/sh:sh_configure.bzl%sh_configure_extension": { + "general": { + "bzlTransitiveDigest": "hp4NgmNjEg5+xgvzfh6L83bt9/aiiWETuNpwNuF1MSU=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "local_config_sh": { + "bzlFile": "@@bazel_tools//tools/sh:sh_configure.bzl", + "ruleClassName": "sh_config", + "attributes": { + "name": "bazel_tools~sh_configure_extension~local_config_sh" + } + } + } + } + }, + "@rules_java~7.1.0//java:extensions.bzl%toolchains": { + "general": { + "bzlTransitiveDigest": "EXsxSX2vQjCcI8jYez/O+Yb9H5reAMhLL3WXGPD6Scw=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "remotejdk21_linux_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux//:jdk\",\n)\n" + } + }, + "remotejdk17_linux_s390x_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_s390x_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_s390x//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_s390x//:jdk\",\n)\n" + } + }, + "remotejdk17_macos_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos//:jdk\",\n)\n" + } + }, + "remotejdk21_macos_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk17_linux_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk21_macos_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "2a7a99a3ea263dbd8d32a67d1e6e363ba8b25c645c826f5e167a02bbafaff1fa", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-macosx_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_aarch64.tar.gz" + ] + } + }, + "remotejdk17_linux_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux//:jdk\",\n)\n" + } + }, + "remotejdk17_macos_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "314b04568ec0ae9b36ba03c9cbd42adc9e1265f74678923b19297d66eb84dcca", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_aarch64.tar.gz" + ] + } + }, + "remote_java_tools_windows": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remote_java_tools_windows", + "sha256": "c5c70c214a350f12cbf52da8270fa43ba629b795f3dd328028a38f8f0d39c2a1", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.1/java_tools_windows-v13.1.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.1/java_tools_windows-v13.1.zip" + ] + } + }, + "remotejdk11_win": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "43408193ce2fa0862819495b5ae8541085b95660153f2adcf91a52d3a1710e83", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-win_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-win_x64.zip" + ] + } + }, + "remotejdk11_win_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win//:jdk\",\n)\n" + } + }, + "remotejdk11_linux_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "54174439f2b3fddd11f1048c397fe7bb45d4c9d66d452d6889b013d04d21c4de", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-linux_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_aarch64.tar.gz" + ] + } + }, + "remotejdk17_linux": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "b9482f2304a1a68a614dfacddcf29569a72f0fac32e6c74f83dc1b9a157b8340", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-linux_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_x64.tar.gz" + ] + } + }, + "remotejdk11_linux_s390x_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_s390x_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_s390x//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:s390x\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_s390x//:jdk\",\n)\n" + } + }, + "remotejdk11_linux_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux//:jdk\",\n)\n" + } + }, + "remotejdk11_macos": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "bcaab11cfe586fae7583c6d9d311c64384354fb2638eb9a012eca4c3f1a1d9fd", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-macosx_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_x64.tar.gz" + ] + } + }, + "remotejdk11_win_arm64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_win_arm64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "b8a28e6e767d90acf793ea6f5bed0bb595ba0ba5ebdf8b99f395266161e53ec2", + "strip_prefix": "jdk-11.0.13+8", + "urls": [ + "https://mirror.bazel.build/aka.ms/download-jdk/microsoft-jdk-11.0.13.8.1-windows-aarch64.zip" + ] + } + }, + "remotejdk17_macos": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "640453e8afe8ffe0fb4dceb4535fb50db9c283c64665eebb0ba68b19e65f4b1f", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-macosx_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-macosx_x64.tar.gz" + ] + } + }, + "remotejdk21_macos": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_macos", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "9639b87db586d0c89f7a9892ae47f421e442c64b97baebdff31788fbe23265bd", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-macosx_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-macosx_x64.tar.gz" + ] + } + }, + "remotejdk21_macos_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_macos//:jdk\",\n)\n" + } + }, + "remotejdk17_macos_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_macos_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk17_win": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "192f2afca57701de6ec496234f7e45d971bf623ff66b8ee4a5c81582054e5637", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-win_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_x64.zip" + ] + } + }, + "remotejdk11_macos_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_macos_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk11_linux_ppc64le_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_ppc64le_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_ppc64le//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_ppc64le//:jdk\",\n)\n" + } + }, + "remotejdk21_linux": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "0c0eadfbdc47a7ca64aeab51b9c061f71b6e4d25d2d87674512e9b6387e9e3a6", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-linux_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_x64.tar.gz" + ] + } + }, + "remote_java_tools_linux": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remote_java_tools_linux", + "sha256": "d134da9b04c9023fb6e56a5d4bffccee73f7bc9572ddc4e747778dacccd7a5a7", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.1/java_tools_linux-v13.1.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.1/java_tools_linux-v13.1.zip" + ] + } + }, + "remotejdk21_win": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_win", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "e9959d500a0d9a7694ac243baf657761479da132f0f94720cbffd092150bd802", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-win_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-win_x64.zip", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-win_x64.zip" + ] + } + }, + "remotejdk21_linux_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 21,\n)\n", + "sha256": "1fb64b8036c5d463d8ab59af06bf5b6b006811e6012e3b0eb6bccf57f1c55835", + "strip_prefix": "zulu21.28.85-ca-jdk21.0.0-linux_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu21.28.85-ca-jdk21.0.0-linux_aarch64.tar.gz" + ] + } + }, + "remotejdk11_linux_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_linux_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk11_linux_s390x": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_s390x", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "a58fc0361966af0a5d5a31a2d8a208e3c9bb0f54f345596fd80b99ea9a39788b", + "strip_prefix": "jdk-11.0.15+10", + "urls": [ + "https://mirror.bazel.build/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.15_10.tar.gz", + "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.15_10.tar.gz" + ] + } + }, + "remotejdk17_linux_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "6531cef61e416d5a7b691555c8cf2bdff689201b8a001ff45ab6740062b44313", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-linux_aarch64.tar.gz" + ] + } + }, + "remotejdk17_win_arm64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_win_arm64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win_arm64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win_arm64//:jdk\",\n)\n" + } + }, + "remotejdk11_linux": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "a34b404f87a08a61148b38e1416d837189e1df7a040d949e743633daf4695a3c", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-linux_x64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-linux_x64.tar.gz" + ] + } + }, + "remotejdk11_macos_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_macos_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:macos\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_macos//:jdk\",\n)\n" + } + }, + "remotejdk17_linux_ppc64le_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_ppc64le_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_ppc64le//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:ppc\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_linux_ppc64le//:jdk\",\n)\n" + } + }, + "remotejdk17_win_arm64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_win_arm64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "6802c99eae0d788e21f52d03cab2e2b3bf42bc334ca03cbf19f71eb70ee19f85", + "strip_prefix": "zulu17.44.53-ca-jdk17.0.8.1-win_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_aarch64.zip", + "https://cdn.azul.com/zulu/bin/zulu17.44.53-ca-jdk17.0.8.1-win_aarch64.zip" + ] + } + }, + "remote_java_tools_darwin_arm64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remote_java_tools_darwin_arm64", + "sha256": "dab5bb87ec43e980faea6e1cec14bafb217b8e2f5346f53aa784fd715929a930", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.1/java_tools_darwin_arm64-v13.1.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.1/java_tools_darwin_arm64-v13.1.zip" + ] + } + }, + "remotejdk17_linux_ppc64le": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_ppc64le", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "00a4c07603d0218cd678461b5b3b7e25b3253102da4022d31fc35907f21a2efd", + "strip_prefix": "jdk-17.0.8.1+1", + "urls": [ + "https://mirror.bazel.build/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.8.1_1.tar.gz", + "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_ppc64le_linux_hotspot_17.0.8.1_1.tar.gz" + ] + } + }, + "remotejdk21_linux_aarch64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_linux_aarch64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux_aarch64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:linux\", \"@platforms//cpu:aarch64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_linux_aarch64//:jdk\",\n)\n" + } + }, + "remotejdk11_win_arm64_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_win_arm64_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_11\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"11\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win_arm64//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:arm64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk11_win_arm64//:jdk\",\n)\n" + } + }, + "local_jdk": { + "bzlFile": "@@rules_java~7.1.0//toolchains:local_java_repository.bzl", + "ruleClassName": "_local_java_repository_rule", + "attributes": { + "name": "rules_java~7.1.0~toolchains~local_jdk", + "java_home": "", + "version": "", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = {RUNTIME_VERSION},\n)\n" + } + }, + "remote_java_tools_darwin_x86_64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remote_java_tools_darwin_x86_64", + "sha256": "0db40d8505a2b65ef0ed46e4256757807db8162f7acff16225be57c1d5726dbc", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.1/java_tools_darwin_x86_64-v13.1.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.1/java_tools_darwin_x86_64-v13.1.zip" + ] + } + }, + "remote_java_tools": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remote_java_tools", + "sha256": "286bdbbd66e616fc4ed3f90101418729a73baa7e8c23a98ffbef558f74c0ad14", + "urls": [ + "https://mirror.bazel.build/bazel_java_tools/releases/java/v13.1/java_tools-v13.1.zip", + "https://github.com/bazelbuild/java_tools/releases/download/java_v13.1/java_tools-v13.1.zip" + ] + } + }, + "remotejdk17_linux_s390x": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_linux_s390x", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 17,\n)\n", + "sha256": "ffacba69c6843d7ca70d572489d6cc7ab7ae52c60f0852cedf4cf0d248b6fc37", + "strip_prefix": "jdk-17.0.8.1+1", + "urls": [ + "https://mirror.bazel.build/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.8.1_1.tar.gz", + "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8.1%2B1/OpenJDK17U-jdk_s390x_linux_hotspot_17.0.8.1_1.tar.gz" + ] + } + }, + "remotejdk17_win_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk17_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_17\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"17\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk17_win//:jdk\",\n)\n" + } + }, + "remotejdk11_linux_ppc64le": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_linux_ppc64le", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "a8fba686f6eb8ae1d1a9566821dbd5a85a1108b96ad857fdbac5c1e4649fc56f", + "strip_prefix": "jdk-11.0.15+10", + "urls": [ + "https://mirror.bazel.build/github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.15_10.tar.gz", + "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.15_10.tar.gz" + ] + } + }, + "remotejdk11_macos_aarch64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk11_macos_aarch64", + "build_file_content": "load(\"@rules_java//java:defs.bzl\", \"java_runtime\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\nexports_files([\"WORKSPACE\", \"BUILD.bazel\"])\n\nfilegroup(\n name = \"jre\",\n srcs = glob(\n [\n \"jre/bin/**\",\n \"jre/lib/**\",\n ],\n allow_empty = True,\n # In some configurations, Java browser plugin is considered harmful and\n # common antivirus software blocks access to npjp2.dll interfering with Bazel,\n # so do not include it in JRE on Windows.\n exclude = [\"jre/bin/plugin2/**\"],\n ),\n)\n\nfilegroup(\n name = \"jdk-bin\",\n srcs = glob(\n [\"bin/**\"],\n # The JDK on Windows sometimes contains a directory called\n # \"%systemroot%\", which is not a valid label.\n exclude = [\"**/*%*/**\"],\n ),\n)\n\n# This folder holds security policies.\nfilegroup(\n name = \"jdk-conf\",\n srcs = glob(\n [\"conf/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-include\",\n srcs = glob(\n [\"include/**\"],\n allow_empty = True,\n ),\n)\n\nfilegroup(\n name = \"jdk-lib\",\n srcs = glob(\n [\"lib/**\", \"release\"],\n allow_empty = True,\n exclude = [\n \"lib/missioncontrol/**\",\n \"lib/visualvm/**\",\n ],\n ),\n)\n\njava_runtime(\n name = \"jdk\",\n srcs = [\n \":jdk-bin\",\n \":jdk-conf\",\n \":jdk-include\",\n \":jdk-lib\",\n \":jre\",\n ],\n # Provide the 'java` binary explicitly so that the correct path is used by\n # Bazel even when the host platform differs from the execution platform.\n # Exactly one of the two globs will be empty depending on the host platform.\n # When --incompatible_disallow_empty_glob is enabled, each individual empty\n # glob will fail without allow_empty = True, even if the overall result is\n # non-empty.\n java = glob([\"bin/java.exe\", \"bin/java\"], allow_empty = True)[0],\n version = 11,\n)\n", + "sha256": "7632bc29f8a4b7d492b93f3bc75a7b61630894db85d136456035ab2a24d38885", + "strip_prefix": "zulu11.66.15-ca-jdk11.0.20-macosx_aarch64", + "urls": [ + "https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz", + "https://cdn.azul.com/zulu/bin/zulu11.66.15-ca-jdk11.0.20-macosx_aarch64.tar.gz" + ] + } + }, + "remotejdk21_win_toolchain_config_repo": { + "bzlFile": "@@rules_java~7.1.0//toolchains:remote_java_repository.bzl", + "ruleClassName": "_toolchain_config", + "attributes": { + "name": "rules_java~7.1.0~toolchains~remotejdk21_win_toolchain_config_repo", + "build_file": "\nconfig_setting(\n name = \"prefix_version_setting\",\n values = {\"java_runtime_version\": \"remotejdk_21\"},\n visibility = [\"//visibility:private\"],\n)\nconfig_setting(\n name = \"version_setting\",\n values = {\"java_runtime_version\": \"21\"},\n visibility = [\"//visibility:private\"],\n)\nalias(\n name = \"version_or_prefix_version_setting\",\n actual = select({\n \":version_setting\": \":version_setting\",\n \"//conditions:default\": \":prefix_version_setting\",\n }),\n visibility = [\"//visibility:private\"],\n)\ntoolchain(\n name = \"toolchain\",\n target_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:runtime_toolchain_type\",\n toolchain = \"@remotejdk21_win//:jdk\",\n)\ntoolchain(\n name = \"bootstrap_runtime_toolchain\",\n # These constraints are not required for correctness, but prevent fetches of remote JDK for\n # different architectures. As every Java compilation toolchain depends on a bootstrap runtime in\n # the same configuration, this constraint will not result in toolchain resolution failures.\n exec_compatible_with = [\"@platforms//os:windows\", \"@platforms//cpu:x86_64\"],\n target_settings = [\":version_or_prefix_version_setting\"],\n toolchain_type = \"@bazel_tools//tools/jdk:bootstrap_runtime_toolchain_type\",\n toolchain = \"@remotejdk21_win//:jdk\",\n)\n" + } + } + } + } + }, + "@rules_toolchain~override//:MODULE.bazel%_repo_rules": { + "general": { + "bzlTransitiveDigest": "mvwjHUR6LfdJXlUKr5URiiM5nIkorGaL+UsIyVuakBw=", + "accumulatedFileDigests": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "local": { + "bzlFile": "@@rules_toolchain~override//toolchain/local/triplet:repository.bzl", + "ruleClassName": "triplet", + "attributes": { + "name": "rules_toolchain~override~_repo_rules~local" + } + } } } } - }, - "moduleExtensions": {} + } } diff --git a/rules_toolchain/e2e/local/select/BUILD.bazel b/e2e/local/select/BUILD.bazel similarity index 100% rename from rules_toolchain/e2e/local/select/BUILD.bazel rename to e2e/local/select/BUILD.bazel diff --git a/rules_toolchain/e2e/local/triplet/BUILD.bazel b/e2e/local/triplet/BUILD.bazel similarity index 100% rename from rules_toolchain/e2e/local/triplet/BUILD.bazel rename to e2e/local/triplet/BUILD.bazel diff --git a/rules_toolchain/e2e/test/BUILD.bazel b/e2e/test/BUILD.bazel similarity index 100% rename from rules_toolchain/e2e/test/BUILD.bazel rename to e2e/test/BUILD.bazel diff --git a/rules_toolchain/e2e/test/fixture/BUILD.bazel b/e2e/test/fixture/BUILD.bazel similarity index 100% rename from rules_toolchain/e2e/test/fixture/BUILD.bazel rename to e2e/test/fixture/BUILD.bazel diff --git a/rules_toolchain/e2e/test/fixture/BUILD.tmpl.bazel b/e2e/test/fixture/BUILD.tmpl.bazel similarity index 100% rename from rules_toolchain/e2e/test/fixture/BUILD.tmpl.bazel rename to e2e/test/fixture/BUILD.tmpl.bazel diff --git a/rules_toolchain/e2e/test/fixture/hello-world.txt b/e2e/test/fixture/hello-world.txt similarity index 100% rename from rules_toolchain/e2e/test/fixture/hello-world.txt rename to e2e/test/fixture/hello-world.txt diff --git a/rules_toolchain/e2e/test/fixture/repository.bzl b/e2e/test/fixture/repository.bzl similarity index 100% rename from rules_toolchain/e2e/test/fixture/repository.bzl rename to e2e/test/fixture/repository.bzl diff --git a/rules_toolchain/e2e/toolchain/echo/BUILD.bazel b/e2e/toolchain/echo/BUILD.bazel similarity index 100% rename from rules_toolchain/e2e/toolchain/echo/BUILD.bazel rename to e2e/toolchain/echo/BUILD.bazel diff --git a/rules_toolchain/e2e/toolchain/echo/echo.sh b/e2e/toolchain/echo/echo.sh similarity index 100% rename from rules_toolchain/e2e/toolchain/echo/echo.sh rename to e2e/toolchain/echo/echo.sh diff --git a/rules_toolchain/e2e/toolchain/echo/hello-world.txt b/e2e/toolchain/echo/hello-world.txt similarity index 100% rename from rules_toolchain/e2e/toolchain/echo/hello-world.txt rename to e2e/toolchain/echo/hello-world.txt diff --git a/rules_toolchain/e2e/toolchain/echo/resolved.bzl b/e2e/toolchain/echo/resolved.bzl similarity index 100% rename from rules_toolchain/e2e/toolchain/echo/resolved.bzl rename to e2e/toolchain/echo/resolved.bzl diff --git a/rules_toolchain/.bazelignore b/rules_toolchain/.bazelignore deleted file mode 100644 index c7ca8d0..0000000 --- a/rules_toolchain/.bazelignore +++ /dev/null @@ -1 +0,0 @@ -e2e diff --git a/rules_toolchain/.bazelrc b/rules_toolchain/.bazelrc deleted file mode 100644 index 9931842..0000000 --- a/rules_toolchain/.bazelrc +++ /dev/null @@ -1,14 +0,0 @@ -# Enable `bzlmod` -common --enable_bzlmod - -# Build cache -build --experimental_guard_against_concurrent_changes - -# Prevent `PATH` and `LD_LIBRARY_PATH` leaking into action enviroment -build --incompatible_strict_action_env - -# Prevent symlink forest under `.runfiles/wsname/external/repo` -build --nolegacy_external_runfiles - -# User-specific .bazelrc -try-import %workspace%/.bazelrc.user diff --git a/rules_toolchain/.bazelrc.ci b/rules_toolchain/.bazelrc.ci deleted file mode 100644 index 5af25a1..0000000 --- a/rules_toolchain/.bazelrc.ci +++ /dev/null @@ -1,36 +0,0 @@ -# Declare all run commands that are loaded -common --announce_rc - -# Use relative paths where possible for concise CI output -common --attempt_to_print_relative_paths - -# Prevent progress bars or similar -common --curses=no - -# CI "terminals" support colour -common --color=yes - -# Output timestamps for each command to aid debugging of CI runtime -common --show_timestamps - -# Do not wrap any output -common --terminal_columns=0 - -# Print relative paths where possible to reduce noise -common --attempt_to_print_relative_paths - -# Output as much information in the CI log about failures as possible -build --verbose_failures - -# Avoid building all targets when testing -test --build_tests_only - -# Noisy logs but allows debugging CI run failures -test --test_output=errors - -# Output as much information when a test exceeds a timeout -test --test_verbose_timeout_warnings - -# These locations are cached on the CI -build --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk -build --repository_cache=${CI_PROJECT_DIR}/.cache/bazel/repo diff --git a/rules_toolchain/.bazelversion b/rules_toolchain/.bazelversion deleted file mode 100644 index 6543a03..0000000 --- a/rules_toolchain/.bazelversion +++ /dev/null @@ -1,2 +0,0 @@ -last_rc -# TODO: relax this once we have `use_rule_repo` diff --git a/rules_toolchain/.gitignore b/rules_toolchain/.gitignore deleted file mode 100644 index b7cd8bf..0000000 --- a/rules_toolchain/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/.cache -/bazel-bin -/bazel-testlogs -/bazel-rules_toolchain -/bazel-out -/.bazelrc.user diff --git a/rules_toolchain/MODULE.bazel b/rules_toolchain/MODULE.bazel deleted file mode 100644 index 3a76922..0000000 --- a/rules_toolchain/MODULE.bazel +++ /dev/null @@ -1,15 +0,0 @@ -module( - name = "rules_toolchain", - bazel_compatibility = [ - ">=6.4.0", - ], -) - -bazel_dep(name = "bazel_skylib", version = "1.4.2") -bazel_dep(name = "platforms", version = "0.0.7") - -triplet = use_repo_rule("//toolchain/local/triplet:repository.bzl", "triplet") - -triplet( - name = "local", -) diff --git a/rules_toolchain/README.md b/rules_toolchain/README.md deleted file mode 100644 index 3f87b85..0000000 --- a/rules_toolchain/README.md +++ /dev/null @@ -1,129 +0,0 @@ -# `rules_toolchain` - -> A Bazel ruleset to enable concise toolchain registration. - -## Getting Started - -### Local Tool - -Add the following to `MODULE.bazel`: - -```py -which = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_which") -which("echo") -``` - -The `echo` tool will be found on the `PATH`. - -A repository with the `@echo//:echo` target will be created. - -### Downloaded Tool - -Use `rules_download` to provide a hermetic, pre-built binary in `MODULE.bazel` - -```py -archive = use_repo_rule("@rules_download//download:defs.bzl", "download_archive") -archive( - name = "coreutils-arm64-linux-gnu", - srcs = ["coreutils"], - integrity = "sha256-mlmkbeabyu4+5+cFiUSL6Ki4KFNqWu48gTjFc3NS43g=", - strip_prefix = "coreutils-0.0.21-aarch64-unknown-linux-gnu", - urls = ["https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-aarch64-unknown-linux-gnu.tar.gz"], -) -``` - -A repository with the `@coreutils-arm64-linux-gnu//:coreutils` target will be created. - -### Toolchains - -Create a `toolchain/echo/BUILD.bazel` with the following: - -```py -load("@rules_toolchain//toolchain:defs.bzl", "toolchain_symlink_target", "toolchain_test") - -# Custom rule, described in the next section -load(":resolved.bzl", "resolved") - -# The `toolchain/echo:type` for registration -toolchain_type( - name = "type", -) - -# Register the `local` binary as a toolchain -# No `exec_compatible_with` constraints are needed as a local binary is always compatible with the execution platform -toolchain( - name = "local", - toolchain = "@echo", - toolchain_type = ":type", -) - -# Create a toolchain binary from the downloaded `coreutils` -toolchain_symlink_target( - name = "coreutils-arm64-linux-gnu", - target = "@coreutils-arm64-linux-gnu//:coreutils", -) - -# Create a symlink to the multi-call binary -toolchain_symlink_target( - name = "echo-arm64-linux-gnu", - basename = "echo", - target = ":coreutils-arm64-linux-gnu", -) - -# Register the hermetic toolchain -# Use constraints to signify what host machines the toolchain is compatible with -toolchain( - name = "arm64-linux", - toolchain = ":echo-arm64-linux-gnu", - toolchain_type = ":type", - exec_compatible_with = [ - "@rules_toolchain//toolchain/constraint/cpu:arm64", - "@rules_toolchain//toolchain/constraint/os:linux", - # Bazel _assumes_ `glibc` for Linux - # "@rules_toolchain//toolchain/constraint/libc:gnu", - ], -) - -# Provide a resolved toolchain target -resolved( - name = "resolved", - toolchain_type = ":type", -) -``` - -#### Resolved - -To work around a [quirk in Bazel][resolved], the resolution of the toolchain must be defined in a separate rule. - -`@rules_toolchain` provides the necessary building blocks for this rule. - -Create `toolchain/echo/resolved.bzl` to provide the `resolved` rule that is used above: - -```py -load("@rules_toolchain//toolchain:resolved.bzl", _resolved = "export") - -visibility("toolchain/echo/...") - -DOC = _resolved.doc - -ATTRS = _resolved.attrs - -implementation = _resolve.implementation - -resolved = _resolved.rule( - toolchain = Label("//toolchain/echo:type"), -) -``` - -### Run - -The `resolved` target allows toolchain that is compatible with the current machine to be executed: - -```py -bazelisk run -- //toolchain/echo:resolved "Hello, world!" -``` - -If the machine is compatible with the downloaded toolchain constraints, that will be used. Otherwise, it will fallback -to finding the toolchain on the local `PATH`. - -[resolved]: https://github.com/bazelbuild/bazel/issues/14009 diff --git a/rules_toolchain/WORKSPACE b/rules_toolchain/WORKSPACE deleted file mode 100644 index e69de29..0000000 diff --git a/rules_toolchain/e2e/.bazelrc b/rules_toolchain/e2e/.bazelrc deleted file mode 100644 index 9931842..0000000 --- a/rules_toolchain/e2e/.bazelrc +++ /dev/null @@ -1,14 +0,0 @@ -# Enable `bzlmod` -common --enable_bzlmod - -# Build cache -build --experimental_guard_against_concurrent_changes - -# Prevent `PATH` and `LD_LIBRARY_PATH` leaking into action enviroment -build --incompatible_strict_action_env - -# Prevent symlink forest under `.runfiles/wsname/external/repo` -build --nolegacy_external_runfiles - -# User-specific .bazelrc -try-import %workspace%/.bazelrc.user diff --git a/rules_toolchain/e2e/.bazelrc.ci b/rules_toolchain/e2e/.bazelrc.ci deleted file mode 100644 index 5af25a1..0000000 --- a/rules_toolchain/e2e/.bazelrc.ci +++ /dev/null @@ -1,36 +0,0 @@ -# Declare all run commands that are loaded -common --announce_rc - -# Use relative paths where possible for concise CI output -common --attempt_to_print_relative_paths - -# Prevent progress bars or similar -common --curses=no - -# CI "terminals" support colour -common --color=yes - -# Output timestamps for each command to aid debugging of CI runtime -common --show_timestamps - -# Do not wrap any output -common --terminal_columns=0 - -# Print relative paths where possible to reduce noise -common --attempt_to_print_relative_paths - -# Output as much information in the CI log about failures as possible -build --verbose_failures - -# Avoid building all targets when testing -test --build_tests_only - -# Noisy logs but allows debugging CI run failures -test --test_output=errors - -# Output as much information when a test exceeds a timeout -test --test_verbose_timeout_warnings - -# These locations are cached on the CI -build --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk -build --repository_cache=${CI_PROJECT_DIR}/.cache/bazel/repo diff --git a/rules_toolchain/e2e/.bazelversion b/rules_toolchain/e2e/.bazelversion deleted file mode 100644 index 6543a03..0000000 --- a/rules_toolchain/e2e/.bazelversion +++ /dev/null @@ -1,2 +0,0 @@ -last_rc -# TODO: relax this once we have `use_rule_repo` diff --git a/rules_toolchain/e2e/.gitignore b/rules_toolchain/e2e/.gitignore deleted file mode 100644 index 5ebc57e..0000000 --- a/rules_toolchain/e2e/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/.cache -/bazel-bin -/bazel-testlogs -/bazel-e2e -/bazel-out -/.bazelrc.user diff --git a/rules_toolchain/e2e/MODULE.bazel b/rules_toolchain/e2e/MODULE.bazel deleted file mode 100644 index 1138e73..0000000 --- a/rules_toolchain/e2e/MODULE.bazel +++ /dev/null @@ -1,44 +0,0 @@ -module( - name = "e2e", - bazel_compatibility = [ - ">=6.4.0", - ], -) - -bazel_dep(name = "bazel_skylib", version = "1.4.2") -bazel_dep(name = "rules_toolchain", version = "0.0.0") -local_path_override( - module_name = "rules_toolchain", - path = "..", -) - -which = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_which") - -which(name = "echo") - -register_toolchains("//toolchain/echo:all") - -fixture = use_repo_rule("//test/fixture:repository.bzl", "fixture") - -fixture( - name = "fixture-amd64-linux-gnu", -) - -fixture( - name = "fixture-arm64-linux-gnu", -) - -fixture( - name = "fixture-arm-linux-musl", -) - -select = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_select") - -select( - name = "fixture", - map = { - "amd64-linux-gnu": "@fixture-amd64-linux-gnu", - "arm64-linux-gnu": "@fixture-arm64-linux-gnu", - "arm-linux-musl": "@fixture-arm-linux-musl", - }, -) diff --git a/rules_toolchain/e2e/WORKSPACE b/rules_toolchain/e2e/WORKSPACE deleted file mode 100644 index e69de29..0000000 diff --git a/rules_toolchain/toolchain/defs.bzl b/rules_toolchain/toolchain/defs.bzl deleted file mode 100644 index 75feeea..0000000 --- a/rules_toolchain/toolchain/defs.bzl +++ /dev/null @@ -1,15 +0,0 @@ -load("//toolchain/triplet:TripletInfo.bzl", _TripletInfo = "TripletInfo") -load("//toolchain/symlink/path:rule.bzl", _symlink_path = "path") -load("//toolchain/symlink/target:rule.bzl", _symlink_target = "target") -load("//toolchain/test:rule.bzl", _test = "test") -load("//toolchain/local/which:repository.bzl", _local_which = "which") -load("//toolchain/local/select:repository.bzl", _local_select = "select") - -visibility("public") - -ToolchainTripletInfo = _TripletInfo -toolchain_symlink_path = _symlink_path -toolchain_symlink_target = _symlink_target -toolchain_test = _test -toolchain_local_which = _local_which -toolchain_local_select = _local_select diff --git a/rules_toolchain/toolchain/symlink/target/BUILD.bazel b/rules_toolchain/toolchain/symlink/target/BUILD.bazel deleted file mode 100644 index e69de29..0000000 diff --git a/rules_toolchain/toolchain/test/BUILD.bazel b/rules_toolchain/toolchain/test/BUILD.bazel deleted file mode 100644 index 5a9399a..0000000 --- a/rules_toolchain/toolchain/test/BUILD.bazel +++ /dev/null @@ -1,10 +0,0 @@ -exports_files(["posix.tmpl.sh"]) - -exports_files( - [ - "any", - "non-empty", - "empty", - ], - visibility = ["//visibility:public"], -) diff --git a/rules_toolchain/toolchain/test/posix.tmpl.sh b/rules_toolchain/toolchain/test/posix.tmpl.sh deleted file mode 100755 index 0005c08..0000000 --- a/rules_toolchain/toolchain/test/posix.tmpl.sh +++ /dev/null @@ -1,176 +0,0 @@ -#! /bin/sh - -# e: quit on command errors -# u: quit on undefined variables -set -eu - -# Bazel substitutions -EXECUTABLE="{{executable}}" -STDOUT="{{stdout}}" -STDERR="{{stderr}}" -readonly EXECUTABLE STDOUT STDERR - -# Test environment -JUNIT="${XML_OUTPUT_FILE-junit.xml}" -readonly JUNIT - -# Run the toolchain executable and validate the output -if ! "${EXECUTABLE}" "${@}" >stdout.txt 2>stderr.txt; then - echo >&2 "Failed to run: ${EXECUTABLE} ${*}" - echo >&2 "stdout:" - while IFS= read -r LINE; do - echo >&2 "${LINE}" - done &2 "stderr:" - while IFS= read -r LINE; do - echo >&2 "${LINE}" - done &2 'ok %i - %s contained any content\n' "${INDEX}" "${FILEPATH}" - printf ' \n' "${FILEPATH}" -) - -non_empty() ( - INDEX="${1}" - FILEPATH="${2}" - - if ! test -s "${FILEPATH}"; then - printf >&2 'not ok %i - %s was an empty file when content was expected\n' "${INDEX}" "${FILEPATH}" - printf ' \n' "${FILEPATH}" - printf ' %s was an empty file when content was expected\n' "${FILEPATH}" - printf ' \n' - else - printf >&2 'ok %i - %s was an empty file\n' "${INDEX}" "${FILEPATH}" - printf ' \n' "${FILEPATH}" - fi -) - -empty() ( - INDEX="${1}" - FILEPATH="${2}" - - if test -s "${FILEPATH}"; then - printf >&2 'not ok %i - %s contained content when an empty file was expected\n' "${INDEX}" "${FILEPATH}" - printf ' \n' "${FILEPATH}" - printf ' %s contained unexpected content:\n' "${FILEPATH}" - while IFS= read -r LINE; do - printf '%s\n' "${LINE}" - done <"${FILEPATH}" - printf '%s\n' "${LINE}" - printf ' \n' - else - printf >&2 'ok %i - %s was a non-empty file\n' "${INDEX}" "${FILEPATH}" - printf ' \n' "${FILEPATH}" - fi -) - -diff() ( - INDEX="${1}" - FILEPATH="${2}" - EXPECTED="${3}" - - while true; do - FAILS=0 - IFS= read -r A <&3 || FAILS=$((FAILS + 1)) - IFS= read -r B <&4 || FAILS=$((FAILS + 1)) - if test "${FAILS}" -eq 1; then - printf >&2 'not ok %i - %s had a different number of lines to %s\n' "${INDEX}" "${FILEPATH}" "${EXPECTED}" - printf ' \n' "${FILEPATH}" - printf ' %s contained different line counts:\n' "${FILEPATH}" - printf '%s %s\n' '---' "${FILEPATH}" - printf '%s %s\n' '+++' "${EXPECTED}" - printf '@@ -1 +1 @@\n' - printf '%s%s\n' '-' "${A-}" - printf '%s%s\n' '+' "${B-}" - printf '\n' - printf ' \n' - exit - elif test "${FAILS}" -eq 2; then - exit - elif test "${A}" != "${B}"; then - printf >&2 'not ok %i: %s had different content to %s\n' "${INDEX}" "${FILEPATH}" "${EXPECTED}" - printf ' \n' "${FILEPATH}" - printf ' %s contained different content:\n' "${FILEPATH}" - printf '%s %s\n' '---' "${FILEPATH}" - printf '%s %s\n' '+++' "${EXPECTED}" - printf '@@ -1 +1 @@\n' - printf '%s%s\n' '-' "${A}" - printf '%s%s\n' '+' "${B}" - printf '\n' - printf ' \n' - exit - fi - done 3<"${FILEPATH}" 4<"${EXPECTED}" - - printf >&2 'ok %s - %s was a non-empty file\n' "${INDEX}" "${FILEPATH}" - printf ' \n' "${FILEPATH}" -) - -validate() ( - INDEX="${1}" - FILEPATH="${2}" - EXPECTED="${3}" - - if ! test -f "${FILEPATH}"; then - printf >&2 'not ok %i - %s not found\n' "${INDEX}" "${FILEPATH}" - printf ' \n' "${FILEPATH}" - printf ' %s was not found\n' "${FILEPATH}" - printf ' \n' - exit - elif ! test -f "${EXPECTED}"; then - printf >&2 'not ok %i - %s not found\n' "${INDEX}" "${EXPECTED}" - printf ' \n' "${FILEPATH}" - printf ' %s was not found\n' "${EXPECTED}" - printf ' \n' - exit - fi - - case "${EXPECTED}" in - *"/toolchain/test/any") - any "${INDEX}" "${FILEPATH}" - ;; - *"/toolchain/test/non-empty") - non_empty "${INDEX}" "${FILEPATH}" - ;; - *"/toolchain/test/empty") - empty "${INDEX}" "${FILEPATH}" - ;; - *) - diff "${INDEX}" "${FILEPATH}" "${EXPECTED}" - ;; - esac -) - -junit() ( - COUNT="${#}" - TESTS=$((COUNT / 2)) - readonly COUNT TESTS - printf '\n' "${TESTS}" - printf >&2 '1..%i\n' $((TESTS)) - INDEX=1 - while ! test -z ${2+x}; do - FILEPATH="${1}" - EXPECTED="${2}" - shift 2 - validate "${INDEX}" "${FILEPATH}" "${EXPECTED}" - INDEX=$((INDEX + 1)) - done - printf '\n' -) - -junit \ - stdout.txt "${STDOUT}" \ - stderr.txt "${STDERR}" \ - >"${JUNIT}" - -while IFS= read -r LINE; do - if test -z "${LINE#**}"; then - exit 1 - fi -done <"${JUNIT}" diff --git a/rules_toolchain/toolchain/test/rule.bzl b/rules_toolchain/toolchain/test/rule.bzl deleted file mode 100644 index 3c33f6d..0000000 --- a/rules_toolchain/toolchain/test/rule.bzl +++ /dev/null @@ -1,86 +0,0 @@ -visibility("//toolchain/...") - -ATTRS = { - "stdout": attr.label( - doc = """The expected standard output. - -Can be set to the following values for special handling: - -- `@rules_toolchain//toolchain/test:non-empty`: accept any non-empty output -- `@rules_toolchain//toolchain/test:empty`: require empty output -""", - default = ":non-empty", - allow_single_file = True, - ), - "stderr": attr.label( - doc = """The expected standard error. - -Can be set to the following values for special handling: - -- `@rules_toolchain//toolchain/test:non-empty`: accept any non-empty output -- `@rules_toolchain//toolchain/test:empty`: require empty output -""", - default = ":empty", - allow_single_file = True, - ), - "template": attr.label( - doc = """The template that is expanded into the binary. - -Can be overridden to a custom script that receives the following replacements: - -- `{{executable}}`: the toolchain executable path -- `{{stdout}}`: the expected standard output -- `{{stderr}}`: the expected standard error -""", - default = ":posix.tmpl.sh", - allow_single_file = True, - ), -} - -def implementation(ctx): - if len(ctx.attr.toolchains) != 1: - fail("Only one toolchain can be provided") - toolchain = ctx.attr.toolchains[0][platform_common.ToolchainInfo] - - executable = ctx.actions.declare_file("{}.executable".format(ctx.label.name)) - ctx.actions.expand_template( - template = ctx.file.template, - output = executable, - substitutions = { - "{{executable}}": str(toolchain.executable.short_path), - "{{stdout}}": str(ctx.file.stdout.short_path), - "{{stderr}}": str(ctx.file.stderr.short_path), - }, - is_executable = True, - ) - - return DefaultInfo( - executable = executable, - files = depset([executable]), - runfiles = ctx.runfiles([toolchain.executable, ctx.file.stdout, ctx.file.stderr]), - ) - -toolchain_test = rule( - doc = """Performs a simple test that a toolchain resolved to an executable. - -- Resolves the provided toolchain binary -- Executes with the provided arguments -- Captures `stdout` and `stderr` -- Can do optional `diff` checking of the output - -A common use case is to check that a toolchain can output some help text: - -``` -toolchain_test( - name = "test", - args = ["--help"], - toolchains = [":resolved"], -) -``` -""", - attrs = ATTRS, - implementation = implementation, - test = True, -) - -test = toolchain_test diff --git a/toolchain/BUILD.bazel b/toolchain/BUILD.bazel index 07fef9e..e69de29 100644 --- a/toolchain/BUILD.bazel +++ b/toolchain/BUILD.bazel @@ -1,6 +0,0 @@ -load("//toolchain/test:rule.bzl", "toolchain_test") - -toolchain_test( - name = "toolchain", - size = "small", -) diff --git a/rules_toolchain/toolchain/constraint/BUILD.bazel b/toolchain/constraint/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/constraint/BUILD.bazel rename to toolchain/constraint/BUILD.bazel diff --git a/rules_toolchain/toolchain/constraint/cpu/BUILD.bazel b/toolchain/constraint/cpu/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/constraint/cpu/BUILD.bazel rename to toolchain/constraint/cpu/BUILD.bazel diff --git a/rules_toolchain/toolchain/constraint/libc/BUILD.bazel b/toolchain/constraint/libc/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/constraint/libc/BUILD.bazel rename to toolchain/constraint/libc/BUILD.bazel diff --git a/rules_toolchain/toolchain/constraint/libc/gnu/BUILD.bazel b/toolchain/constraint/libc/gnu/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/constraint/libc/gnu/BUILD.bazel rename to toolchain/constraint/libc/gnu/BUILD.bazel diff --git a/rules_toolchain/toolchain/constraint/libc/gnu/versions.bzl b/toolchain/constraint/libc/gnu/versions.bzl similarity index 100% rename from rules_toolchain/toolchain/constraint/libc/gnu/versions.bzl rename to toolchain/constraint/libc/gnu/versions.bzl diff --git a/rules_toolchain/toolchain/constraint/os/BUILD.bazel b/toolchain/constraint/os/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/constraint/os/BUILD.bazel rename to toolchain/constraint/os/BUILD.bazel diff --git a/rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel b/toolchain/constraint/os/linux/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/constraint/os/linux/BUILD.bazel rename to toolchain/constraint/os/linux/BUILD.bazel diff --git a/rules_toolchain/toolchain/constraint/os/linux/versions.bzl b/toolchain/constraint/os/linux/versions.bzl similarity index 100% rename from rules_toolchain/toolchain/constraint/os/linux/versions.bzl rename to toolchain/constraint/os/linux/versions.bzl diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index 7de4ec9..75feeea 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -1,5 +1,15 @@ +load("//toolchain/triplet:TripletInfo.bzl", _TripletInfo = "TripletInfo") +load("//toolchain/symlink/path:rule.bzl", _symlink_path = "path") +load("//toolchain/symlink/target:rule.bzl", _symlink_target = "target") load("//toolchain/test:rule.bzl", _test = "test") +load("//toolchain/local/which:repository.bzl", _local_which = "which") +load("//toolchain/local/select:repository.bzl", _local_select = "select") visibility("public") +ToolchainTripletInfo = _TripletInfo +toolchain_symlink_path = _symlink_path +toolchain_symlink_target = _symlink_target toolchain_test = _test +toolchain_local_which = _local_which +toolchain_local_select = _local_select diff --git a/toolchain/fixture.txt b/toolchain/fixture.txt deleted file mode 100644 index af5626b..0000000 --- a/toolchain/fixture.txt +++ /dev/null @@ -1 +0,0 @@ -Hello, world! diff --git a/rules_toolchain/toolchain/local/BUILD.bazel b/toolchain/local/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/local/BUILD.bazel rename to toolchain/local/BUILD.bazel diff --git a/rules_toolchain/toolchain/BUILD.bazel b/toolchain/local/select/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/BUILD.bazel rename to toolchain/local/select/BUILD.bazel diff --git a/rules_toolchain/toolchain/local/select/repository.bzl b/toolchain/local/select/repository.bzl similarity index 100% rename from rules_toolchain/toolchain/local/select/repository.bzl rename to toolchain/local/select/repository.bzl diff --git a/rules_toolchain/toolchain/local/select/BUILD.bazel b/toolchain/local/triplet/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/local/select/BUILD.bazel rename to toolchain/local/triplet/BUILD.bazel diff --git a/rules_toolchain/toolchain/local/triplet/cpu.bzl b/toolchain/local/triplet/cpu.bzl similarity index 100% rename from rules_toolchain/toolchain/local/triplet/cpu.bzl rename to toolchain/local/triplet/cpu.bzl diff --git a/rules_toolchain/toolchain/local/triplet/detect.bzl b/toolchain/local/triplet/detect.bzl similarity index 100% rename from rules_toolchain/toolchain/local/triplet/detect.bzl rename to toolchain/local/triplet/detect.bzl diff --git a/rules_toolchain/toolchain/local/triplet/libc.bzl b/toolchain/local/triplet/libc.bzl similarity index 100% rename from rules_toolchain/toolchain/local/triplet/libc.bzl rename to toolchain/local/triplet/libc.bzl diff --git a/rules_toolchain/toolchain/local/triplet/os.bzl b/toolchain/local/triplet/os.bzl similarity index 100% rename from rules_toolchain/toolchain/local/triplet/os.bzl rename to toolchain/local/triplet/os.bzl diff --git a/rules_toolchain/toolchain/local/triplet/repository.bzl b/toolchain/local/triplet/repository.bzl similarity index 100% rename from rules_toolchain/toolchain/local/triplet/repository.bzl rename to toolchain/local/triplet/repository.bzl diff --git a/rules_toolchain/toolchain/local/triplet/triplet.tmpl.bzl b/toolchain/local/triplet/triplet.tmpl.bzl similarity index 100% rename from rules_toolchain/toolchain/local/triplet/triplet.tmpl.bzl rename to toolchain/local/triplet/triplet.tmpl.bzl diff --git a/rules_toolchain/toolchain/local/triplet/BUILD.bazel b/toolchain/local/which/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/local/triplet/BUILD.bazel rename to toolchain/local/which/BUILD.bazel diff --git a/rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel b/toolchain/local/which/BUILD.tmpl.bazel similarity index 100% rename from rules_toolchain/toolchain/local/which/BUILD.tmpl.bazel rename to toolchain/local/which/BUILD.tmpl.bazel diff --git a/rules_toolchain/toolchain/local/which/repository.bzl b/toolchain/local/which/repository.bzl similarity index 100% rename from rules_toolchain/toolchain/local/which/repository.bzl rename to toolchain/local/which/repository.bzl diff --git a/rules_toolchain/toolchain/platform/BUILD.bazel b/toolchain/platform/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/platform/BUILD.bazel rename to toolchain/platform/BUILD.bazel diff --git a/rules_toolchain/toolchain/resolved.bzl b/toolchain/resolved.bzl similarity index 100% rename from rules_toolchain/toolchain/resolved.bzl rename to toolchain/resolved.bzl diff --git a/rules_toolchain/toolchain/local/which/BUILD.bazel b/toolchain/symlink/path/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/local/which/BUILD.bazel rename to toolchain/symlink/path/BUILD.bazel diff --git a/rules_toolchain/toolchain/symlink/path/rule.bzl b/toolchain/symlink/path/rule.bzl similarity index 100% rename from rules_toolchain/toolchain/symlink/path/rule.bzl rename to toolchain/symlink/path/rule.bzl diff --git a/rules_toolchain/toolchain/symlink/path/BUILD.bazel b/toolchain/symlink/target/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/symlink/path/BUILD.bazel rename to toolchain/symlink/target/BUILD.bazel diff --git a/rules_toolchain/toolchain/symlink/target/rule.bzl b/toolchain/symlink/target/rule.bzl similarity index 100% rename from rules_toolchain/toolchain/symlink/target/rule.bzl rename to toolchain/symlink/target/rule.bzl diff --git a/toolchain/test/BUILD.bazel b/toolchain/test/BUILD.bazel index 53004d8..5a9399a 100644 --- a/toolchain/test/BUILD.bazel +++ b/toolchain/test/BUILD.bazel @@ -1 +1,10 @@ exports_files(["posix.tmpl.sh"]) + +exports_files( + [ + "any", + "non-empty", + "empty", + ], + visibility = ["//visibility:public"], +) diff --git a/rules_toolchain/toolchain/test/any b/toolchain/test/any similarity index 100% rename from rules_toolchain/toolchain/test/any rename to toolchain/test/any diff --git a/rules_toolchain/toolchain/test/empty b/toolchain/test/empty similarity index 100% rename from rules_toolchain/toolchain/test/empty rename to toolchain/test/empty diff --git a/rules_toolchain/toolchain/test/non-empty b/toolchain/test/non-empty similarity index 100% rename from rules_toolchain/toolchain/test/non-empty rename to toolchain/test/non-empty diff --git a/toolchain/test/posix.tmpl.sh b/toolchain/test/posix.tmpl.sh index 9d7eec9..0005c08 100644 --- a/toolchain/test/posix.tmpl.sh +++ b/toolchain/test/posix.tmpl.sh @@ -1,11 +1,176 @@ #! /bin/sh -# Strict shell -set -o errexit -o nounset +# e: quit on command errors +# u: quit on undefined variables +set -eu # Bazel substitutions -CODE="{{code}}" -readonly CODE +EXECUTABLE="{{executable}}" +STDOUT="{{stdout}}" +STDERR="{{stderr}}" +readonly EXECUTABLE STDOUT STDERR -# Simple! -exit "${CODE}" +# Test environment +JUNIT="${XML_OUTPUT_FILE-junit.xml}" +readonly JUNIT + +# Run the toolchain executable and validate the output +if ! "${EXECUTABLE}" "${@}" >stdout.txt 2>stderr.txt; then + echo >&2 "Failed to run: ${EXECUTABLE} ${*}" + echo >&2 "stdout:" + while IFS= read -r LINE; do + echo >&2 "${LINE}" + done &2 "stderr:" + while IFS= read -r LINE; do + echo >&2 "${LINE}" + done &2 'ok %i - %s contained any content\n' "${INDEX}" "${FILEPATH}" + printf ' \n' "${FILEPATH}" +) + +non_empty() ( + INDEX="${1}" + FILEPATH="${2}" + + if ! test -s "${FILEPATH}"; then + printf >&2 'not ok %i - %s was an empty file when content was expected\n' "${INDEX}" "${FILEPATH}" + printf ' \n' "${FILEPATH}" + printf ' %s was an empty file when content was expected\n' "${FILEPATH}" + printf ' \n' + else + printf >&2 'ok %i - %s was an empty file\n' "${INDEX}" "${FILEPATH}" + printf ' \n' "${FILEPATH}" + fi +) + +empty() ( + INDEX="${1}" + FILEPATH="${2}" + + if test -s "${FILEPATH}"; then + printf >&2 'not ok %i - %s contained content when an empty file was expected\n' "${INDEX}" "${FILEPATH}" + printf ' \n' "${FILEPATH}" + printf ' %s contained unexpected content:\n' "${FILEPATH}" + while IFS= read -r LINE; do + printf '%s\n' "${LINE}" + done <"${FILEPATH}" + printf '%s\n' "${LINE}" + printf ' \n' + else + printf >&2 'ok %i - %s was a non-empty file\n' "${INDEX}" "${FILEPATH}" + printf ' \n' "${FILEPATH}" + fi +) + +diff() ( + INDEX="${1}" + FILEPATH="${2}" + EXPECTED="${3}" + + while true; do + FAILS=0 + IFS= read -r A <&3 || FAILS=$((FAILS + 1)) + IFS= read -r B <&4 || FAILS=$((FAILS + 1)) + if test "${FAILS}" -eq 1; then + printf >&2 'not ok %i - %s had a different number of lines to %s\n' "${INDEX}" "${FILEPATH}" "${EXPECTED}" + printf ' \n' "${FILEPATH}" + printf ' %s contained different line counts:\n' "${FILEPATH}" + printf '%s %s\n' '---' "${FILEPATH}" + printf '%s %s\n' '+++' "${EXPECTED}" + printf '@@ -1 +1 @@\n' + printf '%s%s\n' '-' "${A-}" + printf '%s%s\n' '+' "${B-}" + printf '\n' + printf ' \n' + exit + elif test "${FAILS}" -eq 2; then + exit + elif test "${A}" != "${B}"; then + printf >&2 'not ok %i: %s had different content to %s\n' "${INDEX}" "${FILEPATH}" "${EXPECTED}" + printf ' \n' "${FILEPATH}" + printf ' %s contained different content:\n' "${FILEPATH}" + printf '%s %s\n' '---' "${FILEPATH}" + printf '%s %s\n' '+++' "${EXPECTED}" + printf '@@ -1 +1 @@\n' + printf '%s%s\n' '-' "${A}" + printf '%s%s\n' '+' "${B}" + printf '\n' + printf ' \n' + exit + fi + done 3<"${FILEPATH}" 4<"${EXPECTED}" + + printf >&2 'ok %s - %s was a non-empty file\n' "${INDEX}" "${FILEPATH}" + printf ' \n' "${FILEPATH}" +) + +validate() ( + INDEX="${1}" + FILEPATH="${2}" + EXPECTED="${3}" + + if ! test -f "${FILEPATH}"; then + printf >&2 'not ok %i - %s not found\n' "${INDEX}" "${FILEPATH}" + printf ' \n' "${FILEPATH}" + printf ' %s was not found\n' "${FILEPATH}" + printf ' \n' + exit + elif ! test -f "${EXPECTED}"; then + printf >&2 'not ok %i - %s not found\n' "${INDEX}" "${EXPECTED}" + printf ' \n' "${FILEPATH}" + printf ' %s was not found\n' "${EXPECTED}" + printf ' \n' + exit + fi + + case "${EXPECTED}" in + *"/toolchain/test/any") + any "${INDEX}" "${FILEPATH}" + ;; + *"/toolchain/test/non-empty") + non_empty "${INDEX}" "${FILEPATH}" + ;; + *"/toolchain/test/empty") + empty "${INDEX}" "${FILEPATH}" + ;; + *) + diff "${INDEX}" "${FILEPATH}" "${EXPECTED}" + ;; + esac +) + +junit() ( + COUNT="${#}" + TESTS=$((COUNT / 2)) + readonly COUNT TESTS + printf '\n' "${TESTS}" + printf >&2 '1..%i\n' $((TESTS)) + INDEX=1 + while ! test -z ${2+x}; do + FILEPATH="${1}" + EXPECTED="${2}" + shift 2 + validate "${INDEX}" "${FILEPATH}" "${EXPECTED}" + INDEX=$((INDEX + 1)) + done + printf '\n' +) + +junit \ + stdout.txt "${STDOUT}" \ + stderr.txt "${STDERR}" \ + >"${JUNIT}" + +while IFS= read -r LINE; do + if test -z "${LINE#**}"; then + exit 1 + fi +done <"${JUNIT}" diff --git a/toolchain/test/rule.bzl b/toolchain/test/rule.bzl index 17e4c11..3c33f6d 100644 --- a/toolchain/test/rule.bzl +++ b/toolchain/test/rule.bzl @@ -1,39 +1,84 @@ -visibility("//...") +visibility("//toolchain/...") ATTRS = { - "code": attr.int( - doc = "The exit code for the test.", - default = 0, + "stdout": attr.label( + doc = """The expected standard output. + +Can be set to the following values for special handling: + +- `@rules_toolchain//toolchain/test:non-empty`: accept any non-empty output +- `@rules_toolchain//toolchain/test:empty`: require empty output +""", + default = ":non-empty", + allow_single_file = True, ), - "template": attr.label( - doc = "The template script to expand.", + "stderr": attr.label( + doc = """The expected standard error. + +Can be set to the following values for special handling: + +- `@rules_toolchain//toolchain/test:non-empty`: accept any non-empty output +- `@rules_toolchain//toolchain/test:empty`: require empty output +""", + default = ":empty", allow_single_file = True, + ), + "template": attr.label( + doc = """The template that is expanded into the binary. + +Can be overridden to a custom script that receives the following replacements: + +- `{{executable}}`: the toolchain executable path +- `{{stdout}}`: the expected standard output +- `{{stderr}}`: the expected standard error +""", default = ":posix.tmpl.sh", + allow_single_file = True, ), } -DOC = "A simple placeholder test rule." - def implementation(ctx): - executable = ctx.actions.declare_file(ctx.label.name) + if len(ctx.attr.toolchains) != 1: + fail("Only one toolchain can be provided") + toolchain = ctx.attr.toolchains[0][platform_common.ToolchainInfo] + executable = ctx.actions.declare_file("{}.executable".format(ctx.label.name)) ctx.actions.expand_template( - output = executable, template = ctx.file.template, + output = executable, substitutions = { - "{{code}}": str(ctx.attr.code), + "{{executable}}": str(toolchain.executable.short_path), + "{{stdout}}": str(ctx.file.stdout.short_path), + "{{stderr}}": str(ctx.file.stderr.short_path), }, + is_executable = True, ) return DefaultInfo( executable = executable, files = depset([executable]), - runfiles = ctx.runfiles([executable]), + runfiles = ctx.runfiles([toolchain.executable, ctx.file.stdout, ctx.file.stderr]), ) toolchain_test = rule( + doc = """Performs a simple test that a toolchain resolved to an executable. + +- Resolves the provided toolchain binary +- Executes with the provided arguments +- Captures `stdout` and `stderr` +- Can do optional `diff` checking of the output + +A common use case is to check that a toolchain can output some help text: + +``` +toolchain_test( + name = "test", + args = ["--help"], + toolchains = [":resolved"], +) +``` +""", attrs = ATTRS, - doc = DOC, implementation = implementation, test = True, ) diff --git a/rules_toolchain/toolchain/triplet/BUILD.bazel b/toolchain/triplet/BUILD.bazel similarity index 100% rename from rules_toolchain/toolchain/triplet/BUILD.bazel rename to toolchain/triplet/BUILD.bazel diff --git a/rules_toolchain/toolchain/triplet/TripletInfo.bzl b/toolchain/triplet/TripletInfo.bzl similarity index 100% rename from rules_toolchain/toolchain/triplet/TripletInfo.bzl rename to toolchain/triplet/TripletInfo.bzl diff --git a/rules_toolchain/toolchain/triplet/VersionInfo.bzl b/toolchain/triplet/VersionInfo.bzl similarity index 100% rename from rules_toolchain/toolchain/triplet/VersionInfo.bzl rename to toolchain/triplet/VersionInfo.bzl diff --git a/rules_toolchain/toolchain/triplet/VersionedInfo.bzl b/toolchain/triplet/VersionedInfo.bzl similarity index 100% rename from rules_toolchain/toolchain/triplet/VersionedInfo.bzl rename to toolchain/triplet/VersionedInfo.bzl diff --git a/rules_toolchain/toolchain/triplet/local.bzl b/toolchain/triplet/local.bzl similarity index 100% rename from rules_toolchain/toolchain/triplet/local.bzl rename to toolchain/triplet/local.bzl diff --git a/rules_toolchain/toolchain/triplet/rule.bzl b/toolchain/triplet/rule.bzl similarity index 100% rename from rules_toolchain/toolchain/triplet/rule.bzl rename to toolchain/triplet/rule.bzl diff --git a/rules_toolchain/toolchain/triplet/split.bzl b/toolchain/triplet/split.bzl similarity index 100% rename from rules_toolchain/toolchain/triplet/split.bzl rename to toolchain/triplet/split.bzl diff --git a/rules_toolchain/toolchain/triplet/test.bzl b/toolchain/triplet/test.bzl similarity index 100% rename from rules_toolchain/toolchain/triplet/test.bzl rename to toolchain/triplet/test.bzl diff --git a/rules_toolchain/toolchain/triplet/triplets.bzl b/toolchain/triplet/triplets.bzl similarity index 100% rename from rules_toolchain/toolchain/triplet/triplets.bzl rename to toolchain/triplet/triplets.bzl diff --git a/rules_toolchain/toolchain/triplet/unversioned.bzl b/toolchain/triplet/unversioned.bzl similarity index 100% rename from rules_toolchain/toolchain/triplet/unversioned.bzl rename to toolchain/triplet/unversioned.bzl -- GitLab From 25588c7ea9085668cce01eb315666b08855d54cb Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 14 Nov 2023 21:54:59 +0000 Subject: [PATCH 54/55] chore: add license information --- .reuse/dep5 | 43 +++++++++++++++ LICENSES/CC0-1.0.txt | 121 +++++++++++++++++++++++++++++++++++++++++++ LICENSES/MIT.txt | 9 ++++ 3 files changed, 173 insertions(+) create mode 100644 .reuse/dep5 create mode 100644 LICENSES/CC0-1.0.txt create mode 100644 LICENSES/MIT.txt diff --git a/.reuse/dep5 b/.reuse/dep5 new file mode 100644 index 0000000..7d34270 --- /dev/null +++ b/.reuse/dep5 @@ -0,0 +1,43 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: bazel/bsp +Upstream-Contact: Arm Ltd. +Source: https://gitlab.gpu.arm.com/bazel/bsp + +Files: + *.bazel + *.bzl + *.py + *.sh + *.sh.in + *.tmpl.* + *.patch +Copyright: 2023 Arm Ltd. +License: MIT + +Files: + */archive.tar.xz + ci/docker/*/Dockerfile + .bazelrc + .editorconfig + .eslintrc + .flake8 + .gitignore + */.gitignore + .gitlab-ci.yml + .isort.cfg + .mypy.ini + .pre-commit-config.yaml + .prettierrc + .gitignore + .bazelrc + babel.config.json + commitlint.config.js + test/py/requirements.in + test/py/requirements.txt + *.md + *.txt + *.xml + *.tar + *.deb +Copyright: 2023 Arm Ltd. +License: CC0-1.0 diff --git a/LICENSES/CC0-1.0.txt b/LICENSES/CC0-1.0.txt new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/LICENSES/CC0-1.0.txt @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..037bb1c --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2023 Arm Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- GitLab From defbf607afbc4e442f78fd74aeffed1393ca9de5 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 15 Nov 2023 15:10:57 +0000 Subject: [PATCH 55/55] chore: use a released version of `ci/component/bazelisk` --- .gitlab-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 048eff7..c81760f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,5 @@ include: - - component: "${CI_SERVER_HOST}/ci/component/bazelisk@016de670d2db1297c14478a61ef1efa3531619f5" - inputs: - tag: "016de670d2db1297c14478a61ef1efa3531619f5" + - component: "${CI_SERVER_HOST}/ci/component/bazelisk@v1.0.0-alpha.1" default: tags: -- GitLab