xref: /aosp_15_r20/external/bazel-skylib/gazelle/setup.bzl (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1# Copyright 2019 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"""Dependency registration helpers for the gazelle plugin."""
16
17load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
18load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
19
20def bazel_skylib_gazelle_plugin_setup(go_version = "1.20.5", register_go_toolchains = True):
21    """Set up the dependencies needed by the Gazelle plugin.
22
23    Args:
24      go_version: The version of Go registered as part of the build as a string
25      register_go_toolchains: A boolean indicating whether or not to register the Go toolchains. Defaults to `True`
26    """
27    go_rules_dependencies()
28
29    if register_go_toolchains:
30        go_register_toolchains(version = go_version)
31
32    gazelle_dependencies()
33