pax_global_header00006660000000000000000000000064146207224570014523gustar00rootroot0000000000000052 comment=1d54ee3b4d185ed84d2f233ba8ba04ac32a0fdbf bazel_features-1.11.0/000077500000000000000000000000001462072245700145765ustar00rootroot00000000000000bazel_features-1.11.0/.bazelignore000066400000000000000000000000161462072245700170750ustar00rootroot00000000000000test/bcr_test bazel_features-1.11.0/.bazelrc000066400000000000000000000013241462072245700162210ustar00rootroot00000000000000# Bazel settings that apply to this repository. # Take care to document any settings that you expect users to apply. # Settings that apply only to CI are in .github/workflows/ci.bazelrc # Load any settings specific to the current user. # .bazelrc.user should appear in .gitignore so that settings are not shared with team members # This needs to be last statement in this # config, as the user configuration should be able to overwrite flags from this file. # See https://docs.bazel.build/versions/master/best-practices.html#bazelrc # (Note that we use .bazelrc.user so the file appears next to .bazelrc in directory listing, # rather than user.bazelrc as suggested in the Bazel docs) try-import %workspace%/.bazelrc.user bazel_features-1.11.0/.bazelversion000066400000000000000000000000061462072245700172760ustar00rootroot000000000000007.1.0 bazel_features-1.11.0/.bcr/000077500000000000000000000000001462072245700154225ustar00rootroot00000000000000bazel_features-1.11.0/.bcr/README.md000066400000000000000000000005561462072245700167070ustar00rootroot00000000000000# Bazel Central Registry When the ruleset is released, we want it to be published to the Bazel Central Registry automatically: This folder contains configuration files to automate the publish step. See for authoritative documentation about these files. bazel_features-1.11.0/.bcr/config.yml000066400000000000000000000003121462072245700174060ustar00rootroot00000000000000# See https://github.com/bazel-contrib/publish-to-bcr#a-note-on-release-automation # for guidance about whether to uncomment this section: # fixedReleaser: login: Wyverald email: wyverald@gmail.com bazel_features-1.11.0/.bcr/metadata.template.json000066400000000000000000000007401462072245700217100ustar00rootroot00000000000000{ "homepage": "https://github.com/bazel-contrib/bazel_features", "maintainers": [ { "email": "wyverald@gmail.com", "github": "Wyverald", "name": "Xudong Yang" }, { "github": "meteorcloudy", "name": "Yun Peng" }, { "email": "fabian@meumertzhe.im", "github": "fmeum", "name": "Fabian Meumertzheim" } ], "repository": ["github:bazel-contrib/bazel_features"], "versions": [], "yanked_versions": {} } bazel_features-1.11.0/.bcr/presubmit.yml000066400000000000000000000005101462072245700201530ustar00rootroot00000000000000bcr_test_module: module_path: test/bcr_test matrix: platform: - centos7 - debian10 - ubuntu2004 - macos - windows bazel: [6.x, 7.x] tasks: run_test_module: name: Run test module platform: ${{ platform }} bazel: ${{ bazel }} test_targets: - "//..." bazel_features-1.11.0/.bcr/source.template.json000066400000000000000000000002621462072245700214270ustar00rootroot00000000000000{ "integrity": "**leave this alone**", "strip_prefix": "{REPO}-{VERSION}", "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/bazel_features-{TAG}.tar.gz" } bazel_features-1.11.0/.github/000077500000000000000000000000001462072245700161365ustar00rootroot00000000000000bazel_features-1.11.0/.github/workflows/000077500000000000000000000000001462072245700201735ustar00rootroot00000000000000bazel_features-1.11.0/.github/workflows/ci.bazelrc000066400000000000000000000011101462072245700221230ustar00rootroot00000000000000# This file contains Bazel settings to apply on CI only. # It is referenced with a --bazelrc option in the call to bazel in ci.yaml # Debug where options came from build --announce_rc # This directory is configured in GitHub actions to be persisted between runs. build --disk_cache=~/.cache/bazel build --repository_cache=~/.cache/bazel-repo # Don't rely on test logs being easily accessible from the test runner, # though it makes the log noisier. test --test_output=errors # Allows tests to run bazelisk-in-bazel, since this is the cache folder used test --test_env=XDG_CACHE_HOME bazel_features-1.11.0/.github/workflows/ci.yaml000066400000000000000000000020571462072245700214560ustar00rootroot00000000000000name: CI # Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the main branch push: branches: [main] pull_request: branches: [main] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: concurrency: # Cancel previous actions from the same PR: https://stackoverflow.com/a/72408109 group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: unit_tests: uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v5 with: folders: '["."]' bcr_test: uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v5 with: folders: '["test/bcr_test"]' exclude: | [ {"bzlmodEnabled": false}, {"bazelversion": "5.4.0"} ] test: runs-on: ubuntu-latest needs: - unit_tests - bcr_test if: ${{ always() }} steps: - uses: cgrindel/gha_join_jobs@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} bazel_features-1.11.0/.github/workflows/release.yml000066400000000000000000000006301462072245700223350ustar00rootroot00000000000000# Cut a release whenever a new tag is pushed to the repo. # You should use an annotated tag, like `git tag -a v1.2.3` # and put the release notes into the commit message for the tag. name: Release on: push: tags: - "v*.*.*" jobs: release: uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v5 with: release_files: bazel_features-*.tar.gz prerelease: false bazel_features-1.11.0/.github/workflows/release_prep.sh000077500000000000000000000021731462072245700232030ustar00rootroot00000000000000#!/usr/bin/env bash set -o errexit -o nounset -o pipefail # Set by GH actions, see # https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables TAG=${GITHUB_REF_NAME} # The prefix is chosen to match what GitHub generates for source archives PREFIX="bazel_features-${TAG:1}" ARCHIVE="bazel_features-$TAG.tar.gz" git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') cat << EOF ## Using Bzlmod with Bazel 6 1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`. 2. Add to your \`MODULE.bazel\` file: \`\`\`starlark bazel_dep(name = "bazel_features", version = "${TAG:1}") \`\`\` ## Using WORKSPACE Paste this snippet into your `WORKSPACE.bazel` file: \`\`\`starlark load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "bazel_features", sha256 = "${SHA}", strip_prefix = "${PREFIX}", url = "https://github.com/bazel-contrib/bazel_features/releases/download/${TAG}/${ARCHIVE}", ) load("@bazel_features//:deps.bzl", "bazel_features_deps") bazel_features_deps() \`\`\` EOF bazel_features-1.11.0/.gitignore000066400000000000000000000000111462072245700165560ustar00rootroot00000000000000bazel-* bazel_features-1.11.0/.pre-commit-config.yaml000066400000000000000000000017161462072245700210640ustar00rootroot00000000000000# See CONTRIBUTING.md for instructions. # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks # Commitizen runs in commit-msg stage # but we don't want to run the other hooks on commit messages default_stages: [commit] # Use a slightly older version of node by default # as the default uses a very new version of GLIBC default_language_version: node: 16.18.0 repos: # Check formatting and lint for starlark code - repo: https://github.com/keith/pre-commit-buildifier rev: 4.0.1.1 hooks: - id: buildifier - id: buildifier-lint # Enforce that commit messages allow for later changelog generation - repo: https://github.com/commitizen-tools/commitizen rev: v2.18.0 hooks: # Requires that commitizen is already installed - id: commitizen stages: [commit-msg] - repo: https://github.com/pre-commit/mirrors-prettier rev: "v2.4.0" hooks: - id: prettier bazel_features-1.11.0/BUILD.bazel000066400000000000000000000013641462072245700164600ustar00rootroot00000000000000load("@bazel_skylib//:bzl_library.bzl", "bzl_library") filegroup( name = "bzl_files", srcs = glob(["*.bzl"]) + [ "//private:bzl_files", "@bazel_features_globals//:globals.bzl", "@bazel_features_version//:version.bzl", ], visibility = ["//visibility:public"], ) exports_files(["features.bzl"]) bzl_library( name = "features", srcs = ["features.bzl"], visibility = ["//visibility:public"], deps = [ "//private:util", "@bazel_features_globals//:globals", ], ) bzl_library( name = "deps", srcs = ["deps.bzl"], deps = [ "//private:repos", "@bazel_tools//tools/build_defs/repo:http.bzl", "@bazel_tools//tools/build_defs/repo:utils.bzl", ], ) bazel_features-1.11.0/CONTRIBUTING.md000066400000000000000000000010451462072245700170270ustar00rootroot00000000000000# How to Contribute ## Formatting Starlark files should be formatted by buildifier. We suggest using a pre-commit hook to automate this. First [install pre-commit](https://pre-commit.com/#installation), then run ```shell pre-commit install ``` Otherwise later tooling on CI may yell at you about formatting/linting violations. ## Releasing 1. Determine the next release version, following semver (could automate in the future from changelog) 1. Tag the repo and push it (or create a tag in GH UI) 1. Watch the automation run on GitHub actions bazel_features-1.11.0/LICENSE000066400000000000000000000261351462072245700156120ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. bazel_features-1.11.0/MODULE.bazel000066400000000000000000000005751462072245700166110ustar00rootroot00000000000000module( name = "bazel_features", version = "0.0.0", ) bazel_dep(name = "bazel_skylib", version = "1.6.1") bazel_dep( name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc", ) version = use_extension("//private:extensions.bzl", "version_extension") use_repo(version, "bazel_features_globals", "bazel_features_version") bazel_features-1.11.0/README.md000066400000000000000000000015131462072245700160550ustar00rootroot00000000000000# Bazel Features Use this to determine the availability of a Bazel feature in your ruleset. It works under the hood by comparing the Bazel version against a known range in which the feature is available. Example usage: ```starlark load("@bazel_features//:features.bzl", "bazel_features") if bazel_features.toolchains.has_optional_toolchains: # Do something ``` The [`features.bzl`](features.bzl) file contains the list of features. ### Accessing globals References to global Starlark symbols that do not exist cause load time errors, which means that their availability in Bazel cannot be tested via a regular feature. Instead, use `bazel_features.globals.`, which is `` if the symbol is available and `None` else. See [`globals.bzl`](private/globals.bzl) for the list of symbols that can be checked for in this way. bazel_features-1.11.0/WORKSPACE.bazel000066400000000000000000000021311462072245700171500ustar00rootroot00000000000000workspace(name = "bazel_features") load(":deps.bzl", "bazel_features_deps") bazel_features_deps() load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "io_bazel_stardoc", sha256 = "62bd2e60216b7a6fec3ac79341aa201e0956477e7c8f6ccc286f279ad1d96432", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.6.2/stardoc-0.6.2.tar.gz", "https://github.com/bazelbuild/stardoc/releases/download/0.6.2/stardoc-0.6.2.tar.gz", ], ) load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") stardoc_repositories() load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") rules_jvm_external_deps() load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") rules_jvm_external_setup() load("@io_bazel_stardoc//:deps.bzl", "stardoc_external_deps") stardoc_external_deps() load("@stardoc_maven//:defs.bzl", stardoc_pinned_maven_install = "pinned_maven_install") stardoc_pinned_maven_install() bazel_features-1.11.0/WORKSPACE.bzlmod000066400000000000000000000000001462072245700173330ustar00rootroot00000000000000bazel_features-1.11.0/deps.bzl000066400000000000000000000013421462072245700162420ustar00rootroot00000000000000"""Contains the macro bazel_features_deps to install WORKSPACE dependencies.""" load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("//private:repos.bzl", "bazel_features_repos") def bazel_features_deps(): bazel_features_repos() maybe( http_archive, name = "bazel_skylib", sha256 = "9f38886a40548c6e96c106b752f242130ee11aaa068a56ba7e56f4511f33e4f2", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.6.1/bazel-skylib-1.6.1.tar.gz", "https://github.com/bazelbuild/bazel-skylib/releases/download/1.6.1/bazel-skylib-1.6.1.tar.gz", ], ) bazel_features-1.11.0/features.bzl000066400000000000000000000127051462072245700171320ustar00rootroot00000000000000"""Defines all the features this module supports detecting.""" load("@bazel_features_globals//:globals.bzl", "globals") load("//private:util.bzl", "ge", "ge_same_major", "lt") _cc = struct( # Whether @bazel_tools//tools/cpp:optional_current_cc_toolchain and the `mandatory` parameter # on find_cpp_toolchain are available (#17308). # Note: While the target and parameter are available in 6.1.0, they only take effect in Bazel 7. find_cpp_toolchain_has_mandatory_param = ge("6.1.0"), # Whether `dsym_path` is no longer incorrectly quoted # https://github.com/bazelbuild/bazel/commit/7a04b220f30b92d11049157279ef0cfb5130870d fixed_dsym_path_quoting = ge_same_major("7.2.0") or ge("8.0.0-pre.20240404.3"), # Note: In Bazel 6.3 the `grep_includes` parameter is optional and a no-op in the cc_common API # In future Bazel versions it will be removed altogether. grep_includes_is_optional = ge("6.3.0"), # From 7.0.0-pre.20230724.1 on `ObjcProvider` no longer contains linking info # https://github.com/bazelbuild/bazel/commit/426f2254669f62b7d332094a0af6d4dc6200ad51 objc_linking_info_migrated = ge("7.0.0-pre.20230724.1"), # https://github.com/bazelbuild/bazel/commit/c8c3878088cb706b820d506a682e1156b7e8c64d swift_fragment_removed = ge("8.0.0-pre.20240101.1"), # Whether the Unix C/C++ toolchain passes -undefined dynamic_lookup to the # macOS linker. Added in commit # https://github.com/bazelbuild/bazel/commit/314cf1f9e4b332955c4800b2451db4e926c3e092 # and removed again in commit # https://github.com/bazelbuild/bazel/commit/4853dfd02ac7440a04caada830b7b61b6081bdfe. undefined_dynamic_lookup = ge("0.25.0") and lt("7.0.0-pre.20230118.2"), # Whether the treat_warnings_as_errors feature works on macOS. # https://github.com/bazelbuild/bazel/commit/3d7c5ae47e2a02ccd81eb8024f22d56ae7811c9b treat_warnings_as_errors_works_on_macos = ge("7.1.0"), ) _external_deps = struct( # Whether --enable_bzlmod is set, and thus, whether str(Label(...)) produces canonical label # literals (i.e., "@@repo//pkg:file"). is_bzlmod_enabled = str(Label("//:invalid")).startswith("@@"), # Whether module_extension has the os_dependent and arch_dependent parameters. # https://github.com/bazelbuild/bazel/commit/970b9dda7cd215a29d73a53871500bc4e2dc6142 module_extension_has_os_arch_dependent = ge("6.4.0"), # Whether repository_ctx#download has the block parameter, allowing parallel downloads (#19674) download_has_block_param = ge("7.1.0"), # Whether repository_ctx#download has the headers parameter, allowing arbitrary headers (#17829) download_has_headers_param = ge("7.1.0"), # Whether repository_ctx#extract has unicode filename extraction fix (#18448) extract_supports_unicode_filenames = ge("6.4.0"), # Whether the `bazel mod tidy` subcommand is available (#19674) # https://github.com/bazelbuild/bazel/commit/9f0f23211293589d812cb9ea4aaaead52486c52e # https://github.com/bazelbuild/bazel/commit/9fe80d33e129de521b696c330802aad9782db18f bazel_mod_tidy = ge_same_major("7.1.0") or ge("8.0.0-pre.20240213.1"), # Whether module_ctx.extension_metadata has the reproducible parameter (#19674) # https://github.com/bazelbuild/bazel/commit/c796aba6ee36970956ea32b46a2f121bb4d1818a # https://github.com/bazelbuild/bazel/commit/e730201e6bf8d6c1c80433b5b42305c3167a8660 extension_metadata_has_reproducible = ge_same_major("7.1.0") or ge("8.0.0-pre.20240213.1"), ) _flags = struct( # This flag was renamed in https://github.com/bazelbuild/bazel/pull/18313 allow_unresolved_symlinks = ( "allow_unresolved_symlinks" if ge("7.0.0-pre.20230628.2") else "experimental_allow_unresolved_symlinks" ), ) _java = struct( # Whether the JavaInfo constructor has add_exports/add_opens named parameters. Added in # https://github.com/bazelbuild/bazel/commit/d2783a3c3d1b899beb674e029bfea3519062e8be (HEAD) # https://github.com/bazelbuild/bazel/commit/e2249f91ff84541565d8ba841592a0a8a43fcb66 (7.0.0) java_info_constructor_module_flags = ge_same_major("7.0.0") or ge("8.0.0-pre.20240101.1"), ) _rules = struct( # Whether the computed_substitutions parameter of ctx.actions.expand_template and ctx.actions.template_dict are stable. # https://github.com/bazelbuild/bazel/commit/61c31d255b6ba65c372253f65043d6ea3f10e1f9 expand_template_has_computed_substitutions = ge("7.0.0-pre.20231011.2"), # Whether TemplateDict#add_joined allows the map_each callback to return a list of strings (#17306) template_dict_map_each_can_return_list = ge("6.1.0"), # Whether coverage_common.instrumented_files_info spports the # metadata_files parameter. Introduced in commit # https://github.com/bazelbuild/bazel/commit/ef54ef5d17a013c863c4e2fb0583e6bd209645f2. instrumented_files_info_has_metadata_files = ge("7.0.0-pre.20230710.5"), # Whether treeartifacts can have symlinks pointing outside of the tree artifact. (#21263) permits_treeartifact_uplevel_symlinks = ge("7.1.0"), ) _toolchains = struct( # Whether the mandatory parameter is available on the config_common.toolchain_type function, and thus, whether optional toolchains are supported # https://bazel.build/versions/6.0.0/extending/toolchains#optional-toolchains has_optional_toolchains = ge("6.0.0"), ) bazel_features = struct( cc = _cc, external_deps = _external_deps, flags = _flags, globals = globals, java = _java, rules = _rules, toolchains = _toolchains, ) bazel_features-1.11.0/private/000077500000000000000000000000001462072245700162505ustar00rootroot00000000000000bazel_features-1.11.0/private/BUILD.bazel000066400000000000000000000021541462072245700201300ustar00rootroot00000000000000load("@bazel_skylib//:bzl_library.bzl", "bzl_library") filegroup( name = "bzl_files", srcs = glob(["*.bzl"]), visibility = ["//visibility:public"], ) bzl_library( name = "parse", srcs = ["parse.bzl"], ) bzl_library( name = "util", srcs = ["util.bzl"], visibility = ["//:__subpackages__"], deps = [ ":parse", "@bazel_features_version//:version", ], ) bzl_library( name = "globals", srcs = ["globals.bzl"], visibility = ["//:__subpackages__"], ) bzl_library( name = "globals_repo", srcs = ["globals_repo.bzl"], visibility = ["//:__subpackages__"], deps = [ ":parse", ], ) bzl_library( name = "version_repo", srcs = ["version_repo.bzl"], visibility = ["//:__subpackages__"], ) bzl_library( name = "repos", srcs = ["repos.bzl"], visibility = ["//:__subpackages__"], deps = [ ":globals", ":globals_repo", ":version_repo", ], ) bzl_library( name = "extensions", srcs = ["extensions.bzl"], visibility = ["//:__subpackages__"], deps = [ ":repos", ], ) bazel_features-1.11.0/private/extensions.bzl000066400000000000000000000003111462072245700211530ustar00rootroot00000000000000"""Internal module extensions.""" load("@bazel_skylib//lib:modules.bzl", "modules") load("//private:repos.bzl", "bazel_features_repos") version_extension = modules.as_extension(bazel_features_repos) bazel_features-1.11.0/private/globals.bzl000066400000000000000000000006241462072245700204060ustar00rootroot00000000000000"""Internal constants.""" # Access any of these globals via bazel_features.globals. # If the current version of Bazel doesn't have this global, it will be None. GLOBALS = { # https://github.com/bazelbuild/bazel/pull/15232 "RunEnvironmentInfo": "5.3.0", # Only used for testing bazel_features itself. "DefaultInfo": "0.0.1", "__TestingOnly_NeverAvailable": "1000000000.0.0", } bazel_features-1.11.0/private/globals_repo.bzl000066400000000000000000000024441462072245700214350ustar00rootroot00000000000000"""Contains the internal repository rule globals_repo.""" load("//private:parse.bzl", "parse_version") def _globals_repo_impl(rctx): rctx.file( "BUILD.bazel", """\ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") exports_files(["globals.bzl"]) # This keeps stardoc happy if globals.bzl is pulled into a repository. bzl_library( name = "globals", srcs = ["globals.bzl"], visibility = ["//visibility:public"], ) """, ) bazel_version = parse_version(native.bazel_version) lines = ["globals = struct("] for global_, version in rctx.attr.globals.items(): if not _is_valid_identifier(global_): fail("Invalid global name: %s" % global_) value = global_ if bazel_version >= parse_version(version) else "None" lines.append(" %s = %s," % (global_, value)) lines.append(")") rctx.file("globals.bzl", "\n".join(lines)) globals_repo = repository_rule( _globals_repo_impl, # Force reruns on server restarts to keep native.bazel_version up-to-date. local = True, attrs = { "globals": attr.string_dict( mandatory = True, ), }, ) def _is_valid_identifier(s): if not s or s[0].isdigit(): return False return all([c.isalnum() or c == "_" for c in s.elems()]) bazel_features-1.11.0/private/parse.bzl000066400000000000000000000020451462072245700200740ustar00rootroot00000000000000"""Internal functions to parse versions.""" def _safe_int(s, v): if not s.isdigit(): fail("invalid Bazel version '{}': non-numeric segment '{}'".format(v, s)) return int(s) def _partition(s): for i in range(len(s)): c = s[i] if c == "-": return s[:i], s[i + 1:] if not c.isdigit() and c != ".": return s[:i], s[i:] return s, "" def parse_version(v): """Parses the given Bazel version string into a comparable value. Args: v (str): version string Returns: a triple ([major, minor, patch], is_released, prerelease) """ if not v: # An empty string is treated as a "dev version", which is greater than anything. v = "999999.999999.999999" release, prerelease = _partition(v.partition(" ")[0]) segments = release.split(".") if len(segments) != 3: fail("invalid Bazel version '{}': got {} dot-separated segments, want 3".format(v, len(segments))) return [_safe_int(s, v) for s in segments], not prerelease, prerelease bazel_features-1.11.0/private/repos.bzl000066400000000000000000000007331462072245700201140ustar00rootroot00000000000000"""Contains the macro bazel_features_repos to install internal repositories.""" load(":globals.bzl", "GLOBALS") load(":globals_repo.bzl", "globals_repo") load(":version_repo.bzl", "version_repo") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") def bazel_features_repos(): maybe( version_repo, name = "bazel_features_version" ) maybe( globals_repo, name = "bazel_features_globals", globals = GLOBALS, ) bazel_features-1.11.0/private/util.bzl000066400000000000000000000011541462072245700177370ustar00rootroot00000000000000"""Internal-only utility functions.""" load("@bazel_features_version//:version.bzl", "version") load(":parse.bzl", "parse_version") BAZEL_VERSION = parse_version(version) def le(v): return BAZEL_VERSION <= parse_version(v) def lt(v): return BAZEL_VERSION < parse_version(v) def ne(v): return BAZEL_VERSION != parse_version(v) def ge(v): return BAZEL_VERSION >= parse_version(v) def ge_same_major(v): pv = parse_version(v) # Version 1.2.3 parses to ([1, 2, 3], ...). return BAZEL_VERSION >= pv and BAZEL_VERSION[0][0] == pv[0][0] def gt(v): return BAZEL_VERSION > parse_version(v) bazel_features-1.11.0/private/version_repo.bzl000066400000000000000000000010761462072245700214770ustar00rootroot00000000000000"""Contains the internal repository rule version_repo.""" def _version_repo_impl(rctx): rctx.file( "BUILD.bazel", """ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") exports_files(["version.bzl"]) bzl_library( name = "version", srcs = ["version.bzl"], visibility = ["//visibility:public"], ) """, ) rctx.file("version.bzl", "version = '" + native.bazel_version + "'") version_repo = repository_rule( _version_repo_impl, # Force reruns on server restarts to keep native.bazel_version up-to-date. local = True, ) bazel_features-1.11.0/renovate.json000066400000000000000000000001431462072245700173120ustar00rootroot00000000000000{ "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": ["config:base"] } bazel_features-1.11.0/test/000077500000000000000000000000001462072245700155555ustar00rootroot00000000000000bazel_features-1.11.0/test/BUILD.bazel000066400000000000000000000003071462072245700174330ustar00rootroot00000000000000load(":bzl_test.bzl", "bzl_test") load(":test.bzl", "run_test") run_test(name = "tests") bzl_test( name = "features_bzl_test", src = "features_bzl_macro.bzl", deps = ["//:features"], ) bazel_features-1.11.0/test/bcr_test/000077500000000000000000000000001462072245700173625ustar00rootroot00000000000000bazel_features-1.11.0/test/bcr_test/.bazelrc000066400000000000000000000000451462072245700210040ustar00rootroot00000000000000try-import %workspace%/.bazelrc.user bazel_features-1.11.0/test/bcr_test/.bazelversion000066400000000000000000000000061462072245700220620ustar00rootroot000000000000007.0.2 bazel_features-1.11.0/test/bcr_test/BUILD.bazel000066400000000000000000000001501462072245700212340ustar00rootroot00000000000000load(":test.bzl", "bazel_features_test_suite") bazel_features_test_suite(name = "bazel_features_test") bazel_features-1.11.0/test/bcr_test/MODULE.bazel000066400000000000000000000002461462072245700213700ustar00rootroot00000000000000bazel_dep(name = "bazel_skylib", version = "1.4.2") bazel_dep(name = "bazel_features") local_path_override( module_name = "bazel_features", path = "../..", ) bazel_features-1.11.0/test/bcr_test/test.bzl000066400000000000000000000007761462072245700210640ustar00rootroot00000000000000"""Tests for `bazel_features` module.""" load("@bazel_features//:features.bzl", "bazel_features") load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest") def _is_bzlmod_enabled_test(ctx): env = unittest.begin(ctx) asserts.true(env, bazel_features.external_deps.is_bzlmod_enabled) return unittest.end(env) is_bzlmod_enabled_test = unittest.make(_is_bzlmod_enabled_test) def bazel_features_test_suite(name): return unittest.suite( name, is_bzlmod_enabled_test, ) bazel_features-1.11.0/test/bzl_test.bzl000066400000000000000000000030731462072245700201170ustar00rootroot00000000000000"""Macro for Ensuring Starlark Dependencies are Specified Properly""" load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc") def bzl_test(name, src, deps): """Provides build-time assurances that `bzl_library` declarations exist and are referenced properly. This macro relies upon Stardoc's ability to traverse `bzl_library` dependencies. If a Starlark dependency is loaded, but not specified as a dependency, the Stardoc utility will fail with a reasonably helpful error message. Interestingly, the Stardoc utility does not apply the same rigor to files that are directly specifed to it. Another point worth metioning is that the `src` file cannot be generated for this macro to work. If one tries to use a generated file, the `input` for the `stardoc` rule will resolve to the label for the generated file which will cause the Stardoc utility to not find the file. Specifying the input in different ways (i.e. filename vs target name) did not seem to affect this behavior. Args: name: The name of the build target. src: A non-generated Starlark file that loads the `bzl_library` that is being checked. deps: A `list` of deps for the Starlark file. Returns: """ macro_lib_name = name + "_macro_lib" bzl_library( name = macro_lib_name, srcs = [src], deps = deps, ) stardoc( name = name, out = macro_lib_name + ".md_", input = src, deps = [macro_lib_name], ) bazel_features-1.11.0/test/features_bzl_macro.bzl000066400000000000000000000004561462072245700221410ustar00rootroot00000000000000"""Macro used with bzl_test For more information, please see `bzl_test.bzl`. """ load("//:features.bzl", "bazel_features") def macro_with_doc(name): """This macro does nothing. Args: name: A `string` value. """ if name == None: return None return bazel_features bazel_features-1.11.0/test/test.bzl000066400000000000000000000041141462072245700172450ustar00rootroot00000000000000"""Provides a macro to do some loading-time test assertions.""" load("//private:util.bzl", "BAZEL_VERSION", "ge") load("//private:parse.bzl", "parse_version") load("//:features.bzl", "bazel_features") def _empty_test_impl(ctx): extension = ".bat" if ctx.attr.is_windows else ".sh" content = "exit 0" if ctx.attr.is_windows else "#!/usr/bin/env bash\nexit 0" executable = ctx.actions.declare_file(ctx.label.name + extension) ctx.actions.write( output = executable, is_executable = True, content = content, ) return [DefaultInfo( files = depset([executable]), executable = executable, )] _empty_test = rule( implementation = _empty_test_impl, attrs = {"is_windows": attr.bool(mandatory = True)}, test = True, ) def _assert_lt(a, b): if parse_version(a) >= parse_version(b): fail("expected '{}' to be less than '{}', but was not the case".format(a, b)) def run_test(name): """Performs some loading-time assertions about bazel_features' APIs, and creats a fake test target. Args: name: the name of the fake test target.""" # some basic version parsing/comparison tests _assert_lt("6.0.0", "6.0.1") _assert_lt("6.0.0rc3", "6.0.0") _assert_lt("6.0.0-pre8.9.10", "6.0.0rc3") _assert_lt("6.0.0 some build metadata", "6.1.0 some other build metadata") _assert_lt("6.0.0", "") # a smoke test on the actual current Bazel version if not ge("0.0.1"): fail("somehow the current Bazel version (parsed: '{}') is not >= 0.0.1".format(BAZEL_VERSION)) if not bazel_features.globals.DefaultInfo == DefaultInfo: fail("bazel_features.globals.DefaultInfo != DefaultInfo") if not bazel_features.globals.__TestingOnly_NeverAvailable == None: fail("bazel_features.globals.__TestingOnly_NeverAvailable != None") # the pseudo test target that doesn't actually test anything _empty_test( name = name, is_windows = select({ "@bazel_tools//src/conditions:host_windows": True, "//conditions:default": False, }), )