github.com/bazelbuild/bazel-gazelle@v0.36.1-0.20240520142334-61b277ba6fed/internal/bzlmod/non_module_deps.bzl (about)

     1  # Copyright 2023 The Bazel Authors. All rights reserved.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #    http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  
    15  load(
    16      "@bazel_gazelle_go_repository_config//:go_env.bzl",
    17      "GO_ENV",
    18  )
    19  load(
    20      "@go_host_compatible_sdk_label//:defs.bzl",
    21      "HOST_COMPATIBLE_SDK",
    22  )
    23  load(
    24      "//internal:go_repository_cache.bzl",
    25      "go_repository_cache",
    26  )
    27  load(
    28      "//internal:go_repository_tools.bzl",
    29      "go_repository_tools",
    30  )
    31  load(
    32      "//internal:is_bazel_module.bzl",
    33      "is_bazel_module",
    34  )
    35  load(
    36      "//internal/bzlmod:utils.bzl",
    37      "extension_metadata",
    38  )
    39  
    40  visibility("//")
    41  
    42  def _non_module_deps_impl(module_ctx):
    43      go_repository_cache(
    44          name = "bazel_gazelle_go_repository_cache",
    45          # Label.workspace_name is always a canonical name, so use a canonical label.
    46          go_sdk_name = "@" + HOST_COMPATIBLE_SDK.workspace_name,
    47          go_env = GO_ENV,
    48      )
    49      go_repository_tools(
    50          name = "bazel_gazelle_go_repository_tools",
    51          go_cache = Label("@bazel_gazelle_go_repository_cache//:go.env"),
    52      )
    53      is_bazel_module(
    54          name = "bazel_gazelle_is_bazel_module",
    55          is_bazel_module = True,
    56      )
    57      return extension_metadata(module_ctx, reproducible = True)
    58  
    59  non_module_deps = module_extension(
    60      _non_module_deps_impl,
    61  )