forked from bazelbuild/bazel-skylib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from bazelbuild/main
Add the gazelle plugin to the distribution (bazelbuild#400)
- Loading branch information
Showing
12 changed files
with
246 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gazelle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
|
||
# The files needed for distribution | ||
filegroup( | ||
name = "distribution", | ||
srcs = glob( | ||
["*"], | ||
allow_empty = True, | ||
), | ||
visibility = [ | ||
"//:__pkg__", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "setup", | ||
srcs = ["setup.bzl"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@bazel_gazelle//:deps", | ||
"@io_bazel_rules_go//go:deps", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "workspace", | ||
srcs = ["workspace.bzl"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@bazel_skylib//:workspace", | ||
"@bazel_tools//tools/build_defs/repo:http.bzl", | ||
"@bazel_tools//tools/build_defs/repo:utils.bzl", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module( | ||
name = "bazel_skylib_gazelle_plugin", | ||
compatibility_level = 1, | ||
# If you change this, please also update @bazel_gazelle//:MODULE.bazel | ||
version = "1.3.0", | ||
) | ||
|
||
bazel_dep(name = "bazel_skylib", version = "1.3.0") | ||
bazel_dep(name = "gazelle", repo_name = "bazel_gazelle", version = "0.28.0") | ||
bazel_dep(name = "rules_go", repo_name = "io_bazel_rules_go", version = "0.35.0") | ||
|
||
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk") | ||
|
||
go_sdk.download( | ||
name = "go_sdk", | ||
version = "1.18", | ||
) | ||
|
||
use_repo(go_sdk, "go_sdk") | ||
|
||
register_toolchains("@go_sdk//:all") | ||
|
||
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps") | ||
|
||
go_deps.module( | ||
path = "github.com/bazelbuild/buildtools", | ||
sum = "h1:fmdo+fvvWlhldUcqkhAMpKndSxMN3vH5l7yow5cEaiQ=", | ||
version = "v0.0.0-20220531122519-a43aed7014c8", | ||
) | ||
|
||
use_repo(go_deps, "com_github_bazelbuild_buildtools") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
workspace(name = "bazel_skylib_gazelle_plugin") | ||
|
||
local_repository( | ||
name = "bazel_skylib", | ||
path = "..", | ||
) | ||
|
||
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") | ||
|
||
bazel_skylib_workspace() | ||
|
||
load(":workspace.bzl", "bazel_skylib_gazelle_plugin_workspace") | ||
|
||
bazel_skylib_gazelle_plugin_workspace() | ||
|
||
load(":setup.bzl", "bazel_skylib_gazelle_plugin_setup") | ||
|
||
bazel_skylib_gazelle_plugin_setup() | ||
|
||
# Provide a repository hint for Gazelle to inform it that the go package | ||
# github.com/bazelbuild/rules_go is available from io_bazel_rules_go and it | ||
# doesn't need to duplicatively fetch it. | ||
# gazelle:repository go_repository name=io_bazel_rules_go importpath=github.com/bazelbuild/rules_go | ||
# Another Gazelle repository hint. | ||
# gazelle:repository go_repository name=bazel_gazelle importpath=github.com/bazelbuild/bazel-gazelle/testtools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
workspace(name = "bazel_skylib_gazelle_plugin") | ||
|
||
# Provide a repository hint for Gazelle to inform it that the go package | ||
# github.com/bazelbuild/rules_go is available from io_bazel_rules_go and it | ||
# doesn't need to duplicatively fetch it. | ||
# gazelle:repository go_repository name=io_bazel_rules_go importpath=github.com/bazelbuild/rules_go | ||
# Another Gazelle repository hint. | ||
# gazelle:repository go_repository name=bazel_gazelle importpath=github.com/bazelbuild/bazel-gazelle/testtools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2019 The Bazel Authors. All rights reserved. | ||
# | ||
# 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. | ||
|
||
"""Dependency registration helpers for the gazelle plugin.""" | ||
|
||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") | ||
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") | ||
|
||
def bazel_skylib_gazelle_plugin_setup(go_version = "1.18.7", register_go_toolchains = True): | ||
"""Set up the dependencies needed by the Gazelle plugin. | ||
Args: | ||
go_version: The version of Go registered as part of the build as a string | ||
register_go_toolchains: A boolean indicating whether or not to register the Go toolchains. Defaults to `True` | ||
""" | ||
go_rules_dependencies() | ||
|
||
if register_go_toolchains: | ||
go_register_toolchains(version = go_version) | ||
|
||
gazelle_dependencies() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright 2019 The Bazel Authors. All rights reserved. | ||
# | ||
# 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. | ||
|
||
"""Dependency registration helpers for repositories which need to load bazel-skylib's gazelle plugin.""" | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") | ||
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") | ||
|
||
def bazel_skylib_gazelle_plugin_workspace(): | ||
"""Loads dependencies required to use skylib's gazelle plugin""" | ||
bazel_skylib_workspace() | ||
|
||
maybe( | ||
http_archive, | ||
name = "io_bazel_rules_go", | ||
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip", | ||
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip", | ||
], | ||
) | ||
|
||
maybe( | ||
http_archive, | ||
name = "bazel_gazelle", | ||
sha256 = "448e37e0dbf61d6fa8f00aaa12d191745e14f07c31cabfa731f0c8e8a4f41b97", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz", | ||
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz", | ||
], | ||
) |