diff --git a/BUILD.bazel b/BUILD.bazel index bdaa860ae..1b5f0aa62 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,10 +1,22 @@ load("@io_bazel_rules_go//go:def.bzl", "nogo") -load("//:def.bzl", "gazelle") +load("//:def.bzl", "gazelle", "gazelle_binary") # gazelle:prefix github.com/bazelbuild/bazel-gazelle +# gazelle:exclude vendor +# gazelle:exclude third_party gazelle( name = "gazelle", command = "fix", + gazelle = ":gazelle_local", +) + +gazelle_binary( + name = "gazelle_local", + languages = [ + "//language/proto:go_default_library", + "//language/go:go_default_library", + "//internal/language/test_filegroup:go_default_library", + ], ) nogo( @@ -14,3 +26,43 @@ nogo( ) exports_files(["WORKSPACE"]) + +filegroup( + name = "all_files", + testonly = True, + # keep + srcs = glob(["vendor/**"]) + [ + ".bazelrc", + ".gitignore", + ".travis.yml", + "AUTHORS", + "BUILD.bazel", + "CODEOWNERS", + "CONTRIBUTING.md", + "CONTRIBUTORS", + "Design.rst", + "LICENSE", + "README.rst", + "WORKSPACE", + "def.bzl", + "deps.bzl", + "extend.rst", + "go.mod", + "go.sum", + "repository.rst", + "//cmd:all_files", + "//config:all_files", + "//flag:all_files", + "//internal:all_files", + "//label:all_files", + "//language:all_files", + "//merger:all_files", + "//pathtools:all_files", + "//repo:all_files", + "//resolve:all_files", + "//rule:all_files", + "//testtools:all_files", + "//walk:all_files", + ], + visibility = ["//visibility:public"], +) diff --git a/WORKSPACE b/WORKSPACE index d738ae6cb..a3e2e60f7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,11 +1,12 @@ workspace(name = "bazel_gazelle") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") -http_archive( +git_repository( name = "io_bazel_rules_go", - sha256 = "6776d68ebb897625dead17ae510eac3d5f6342367327875210df44dbe2aeeb19", - urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.17.1/rules_go-0.17.1.tar.gz"], + commit = "fabf03c1cd31bcf15fb945d932cef322b242be3a", + remote = "https://github.com/bazelbuild/rules_go", + shallow_since = "1561303606 -0400", ) load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") diff --git a/cmd/BUILD.bazel b/cmd/BUILD.bazel new file mode 100644 index 000000000..741830b64 --- /dev/null +++ b/cmd/BUILD.bazel @@ -0,0 +1,11 @@ +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "//cmd/autogazelle:all_files", + "//cmd/fetch_repo:all_files", + "//cmd/gazelle:all_files", + "//cmd/move_labels:all_files", + ], + visibility = ["//visibility:public"], +) diff --git a/cmd/autogazelle/BUILD.bazel b/cmd/autogazelle/BUILD.bazel index aa7b8e7f7..4d5659895 100644 --- a/cmd/autogazelle/BUILD.bazel +++ b/cmd/autogazelle/BUILD.bazel @@ -43,3 +43,17 @@ go_binary( embed = [":go_default_library"], visibility = ["//visibility:public"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "README.rst", + "autogazelle.bash", + "autogazelle.go", + "client_unix.go", + "server_unix.go", + ], + visibility = ["//visibility:public"], +) diff --git a/cmd/fetch_repo/BUILD.bazel b/cmd/fetch_repo/BUILD.bazel index ca45b9430..8830f4be8 100644 --- a/cmd/fetch_repo/BUILD.bazel +++ b/cmd/fetch_repo/BUILD.bazel @@ -24,3 +24,16 @@ go_test( embed = [":go_default_library"], deps = ["@org_golang_x_tools//go/vcs:go_default_library"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "fetch_repo.go", + "fetch_repo_test.go", + "module.go", + "vcs.go", + ], + visibility = ["//visibility:public"], +) diff --git a/cmd/gazelle/BUILD.bazel b/cmd/gazelle/BUILD.bazel index 8fa2980f6..d0a0e9da5 100644 --- a/cmd/gazelle/BUILD.bazel +++ b/cmd/gazelle/BUILD.bazel @@ -74,3 +74,25 @@ go_test( "@com_github_bazelbuild_buildtools//build:go_default_library", ], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "diff.go", + "diff_test.go", + "fix.go", + "fix-update.go", + "fix_test.go", + "gazelle.go", + "integration_test.go", + "langs.go", + "metaresolver.go", + "print.go", + "update-repos.go", + "update_repos_test.go", + "version.go", + ], + visibility = ["//visibility:public"], +) diff --git a/cmd/move_labels/BUILD.bazel b/cmd/move_labels/BUILD.bazel index 4615c4b33..9a70ca4ab 100644 --- a/cmd/move_labels/BUILD.bazel +++ b/cmd/move_labels/BUILD.bazel @@ -24,3 +24,14 @@ go_test( embed = [":go_default_library"], deps = ["//testtools:go_default_library"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "move_labels.go", + "move_labels_test.go", + ], + visibility = ["//visibility:public"], +) diff --git a/config/BUILD.bazel b/config/BUILD.bazel index 6b75ea6a9..f9b404a04 100644 --- a/config/BUILD.bazel +++ b/config/BUILD.bazel @@ -20,3 +20,15 @@ go_test( embed = [":go_default_library"], deps = ["//rule:go_default_library"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "config.go", + "config_test.go", + "constants.go", + ], + visibility = ["//visibility:public"], +) diff --git a/flag/BUILD.bazel b/flag/BUILD.bazel index dc8bc91b7..fa552f6df 100644 --- a/flag/BUILD.bazel +++ b/flag/BUILD.bazel @@ -6,3 +6,13 @@ go_library( importpath = "github.com/bazelbuild/bazel-gazelle/flag", visibility = ["//visibility:public"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "flag.go", + ], + visibility = ["//visibility:public"], +) diff --git a/internal/BUILD.bazel b/internal/BUILD.bazel index f17e6d2a4..5841d2471 100644 --- a/internal/BUILD.bazel +++ b/internal/BUILD.bazel @@ -1,46 +1,13 @@ -load("@io_bazel_rules_go//tests:bazel_tests.bzl", "bazel_test") - -_REPOSITORY_RULES_TEST_WORKSPACE = """ -load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") -go_rules_dependencies() -go_register_toolchains() - -# TODO(jayconrod): fix bazel_test so this isn't necessary -register_toolchains( - "@go_sdk//:go_darwin_amd64", - "@go_sdk//:go_linux_amd64", - "@go_sdk//:go_windows_amd64", -) - -load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository") -gazelle_dependencies(go_sdk = "go_sdk") - -go_repository( - name = "errors_go_git", - importpath = "github.com/pkg/errors", - commit = "30136e27e2ac8d167177e8a583aa4c3fea5be833", - patches = ["@bazel_gazelle//internal:repository_rules_test_errors.patch"], - patch_args = ["-p1"], -) - -go_repository( - name = "errors_go_mod", - importpath = "github.com/pkg/errors", - version = "v0.8.1", - sum ="h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=", -) -""" - -bazel_test( - name = "repository_rules_test", - command = "build", - externals = ["@bazel_gazelle//:WORKSPACE"], - extra_files = ["repository_rules_test_errors.patch"], - targets = [ - "@errors_go_git//:errors", - "@errors_go_mod//:go_default_library", +load("@io_bazel_rules_go//go/tools/bazel_testing:def.bzl", "go_bazel_test") + +# gazelle:exclude go_repository_test.go +go_bazel_test( + name = "go_repository_test", + srcs = ["go_repository_test.go"], + rule_files = [ + "@bazel_gazelle//:all_files", + "@io_bazel_rules_go//:all_files", ], - workspace = _REPOSITORY_RULES_TEST_WORKSPACE, ) # TODO(jayconrod): test fetch_repo error cases. @@ -52,3 +19,22 @@ exports_files( ], visibility = ["//visibility:public"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "gazelle.bash.in", + "gazelle_binary.bzl", + "go_repository.bzl", + "list_repository_tools_srcs.go", + "overlay_repository.bzl", + "repository_rules_test_errors.patch", + "//internal/gazellebinarytest:all_files", + "//internal/language:all_files", + "//internal/version:all_files", + "//internal/wspace:all_files", + ], + visibility = ["//visibility:public"], +) diff --git a/internal/gazellebinarytest/BUILD.bazel b/internal/gazellebinarytest/BUILD.bazel index f5a3bebc9..61c3754c3 100644 --- a/internal/gazellebinarytest/BUILD.bazel +++ b/internal/gazellebinarytest/BUILD.bazel @@ -34,3 +34,14 @@ go_test( rundir = ".", deps = ["//testtools:go_default_library"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "gazellebinary_test.go", + "xlang.go", + ], + visibility = ["//visibility:public"], +) diff --git a/internal/go_repository_test.go b/internal/go_repository_test.go new file mode 100644 index 000000000..7378726b8 --- /dev/null +++ b/internal/go_repository_test.go @@ -0,0 +1,72 @@ +/* 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. +*/ + +package go_repository_test + +import ( + "testing" + + "github.com/bazelbuild/rules_go/go/tools/bazel_testing" +) + +const mainWorkspace = ` +-- WORKSPACE -- +local_repository( + name = "io_bazel_rules_go", + path = "../io_bazel_rules_go", +) + +load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") + +go_rules_dependencies() + +go_register_toolchains(go_version = "host") + +local_repository( + name = "bazel_gazelle", + path = "../bazel_gazelle", +) + +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository") + +gazelle_dependencies() + +go_repository( + name = "errors_go_git", + importpath = "github.com/pkg/errors", + commit = "30136e27e2ac8d167177e8a583aa4c3fea5be833", + patches = ["@bazel_gazelle//internal:repository_rules_test_errors.patch"], + patch_args = ["-p1"], +) + +go_repository( + name = "errors_go_mod", + importpath = "github.com/pkg/errors", + version = "v0.8.1", + sum ="h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=", +) + +-- BUILD.bazel -- +` + +func TestMain(m *testing.M) { + bazel_testing.TestMain(m, bazel_testing.Args{Main: mainWorkspace}) +} + +func TestBuild(t *testing.T) { + if err := bazel_testing.RunBazel("build", "@errors_go_git//:errors", "@errors_go_mod//:go_default_library"); err != nil { + t.Fatal(err) + } +} diff --git a/internal/language/BUILD.bazel b/internal/language/BUILD.bazel new file mode 100644 index 000000000..cce0aafd2 --- /dev/null +++ b/internal/language/BUILD.bazel @@ -0,0 +1,6 @@ +filegroup( + name = "all_files", + testonly = True, + srcs = ["//internal/language/test_filegroup:all_files"], + visibility = ["//visibility:public"], +) diff --git a/internal/language/test_filegroup/BUILD.bazel b/internal/language/test_filegroup/BUILD.bazel new file mode 100644 index 000000000..a066a788c --- /dev/null +++ b/internal/language/test_filegroup/BUILD.bazel @@ -0,0 +1,26 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["lang.go"], + importpath = "github.com/bazelbuild/bazel-gazelle/internal/language/test_filegroup", + visibility = ["//visibility:public"], + deps = [ + "//config:go_default_library", + "//label:go_default_library", + "//language:go_default_library", + "//repo:go_default_library", + "//resolve:go_default_library", + "//rule:go_default_library", + ], +) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "lang.go", + ], + visibility = ["//visibility:public"], +) diff --git a/internal/language/test_filegroup/lang.go b/internal/language/test_filegroup/lang.go new file mode 100644 index 000000000..19ff33694 --- /dev/null +++ b/internal/language/test_filegroup/lang.go @@ -0,0 +1,99 @@ +/* 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. +*/ + +// Package test_filegroup generates an "all_files" filegroup target +// in each package. This target globs files in the same package and +// depends on subpackages. +// +// These rules are used for testing with go_bazel_test. +// +// This extension is experimental and subject to change. It is not included +// in the default Gazelle binary. +package test_filegroup + +import ( + "flag" + "path" + + "github.com/bazelbuild/bazel-gazelle/config" + "github.com/bazelbuild/bazel-gazelle/label" + "github.com/bazelbuild/bazel-gazelle/language" + "github.com/bazelbuild/bazel-gazelle/repo" + "github.com/bazelbuild/bazel-gazelle/resolve" + "github.com/bazelbuild/bazel-gazelle/rule" +) + +const testFilegroupName = "test_filegroup" + +type testFilegroupLang struct{} + +func NewLanguage() language.Language { + return &testFilegroupLang{} +} + +func (*testFilegroupLang) Name() string { return testFilegroupName } + +func (*testFilegroupLang) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) {} + +func (*testFilegroupLang) CheckFlags(fs *flag.FlagSet, c *config.Config) error { return nil } + +func (*testFilegroupLang) KnownDirectives() []string { return nil } + +func (*testFilegroupLang) Configure(c *config.Config, rel string, f *rule.File) {} + +func (*testFilegroupLang) Kinds() map[string]rule.KindInfo { + return kinds +} + +func (*testFilegroupLang) Loads() []rule.LoadInfo { return nil } + +func (*testFilegroupLang) Fix(c *config.Config, f *rule.File) {} + +func (*testFilegroupLang) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec { + return nil +} + +func (*testFilegroupLang) Embeds(r *rule.Rule, from label.Label) []label.Label { return nil } + +func (*testFilegroupLang) Resolve(c *config.Config, ix *resolve.RuleIndex, rc *repo.RemoteCache, r *rule.Rule, imports interface{}, from label.Label) { +} + +var kinds = map[string]rule.KindInfo{ + "filegroup": { + NonEmptyAttrs: map[string]bool{"srcs": true, "deps": true}, + MergeableAttrs: map[string]bool{"deps": true}, + }, +} + +func (*testFilegroupLang) GenerateRules(args language.GenerateArgs) language.GenerateResult { + r := rule.NewRule("filegroup", "all_files") + srcs := make([]string, 0, len(args.Subdirs)+len(args.RegularFiles)) + for _, f := range args.RegularFiles { + srcs = append(srcs, f) + } + for _, f := range args.Subdirs { + pkg := path.Join(args.Rel, f) + srcs = append(srcs, "//"+pkg+":all_files") + } + r.SetAttr("srcs", srcs) + r.SetAttr("testonly", true) + if args.File == nil || !args.File.HasDefaultVisibility() { + r.SetAttr("visibility", []string{"//visibility:public"}) + } + return language.GenerateResult{ + Gen: []*rule.Rule{r}, + Imports: []interface{}{nil}, + } +} diff --git a/internal/version/BUILD.bazel b/internal/version/BUILD.bazel index 30e5c5b64..7d39e6ee8 100644 --- a/internal/version/BUILD.bazel +++ b/internal/version/BUILD.bazel @@ -12,3 +12,14 @@ go_test( srcs = ["version_test.go"], embed = [":go_default_library"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "version.go", + "version_test.go", + ], + visibility = ["//visibility:public"], +) diff --git a/internal/wspace/BUILD.bazel b/internal/wspace/BUILD.bazel index d02dc45d0..003808204 100644 --- a/internal/wspace/BUILD.bazel +++ b/internal/wspace/BUILD.bazel @@ -13,3 +13,14 @@ go_test( srcs = ["finder_test.go"], embed = [":go_default_library"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "finder.go", + "finder_test.go", + ], + visibility = ["//visibility:public"], +) diff --git a/label/BUILD.bazel b/label/BUILD.bazel index aba86d98e..7a657c2a7 100644 --- a/label/BUILD.bazel +++ b/label/BUILD.bazel @@ -13,3 +13,14 @@ go_test( srcs = ["label_test.go"], embed = [":go_default_library"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "label.go", + "label_test.go", + ], + visibility = ["//visibility:public"], +) diff --git a/language/BUILD.bazel b/language/BUILD.bazel index 6259ea930..07ea5a3bf 100644 --- a/language/BUILD.bazel +++ b/language/BUILD.bazel @@ -11,3 +11,15 @@ go_library( "//rule:go_default_library", ], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "lang.go", + "//language/go:all_files", + "//language/proto:all_files", + ], + visibility = ["//visibility:public"], +) diff --git a/language/go/BUILD.bazel b/language/go/BUILD.bazel index c9575fc69..e1e2b683b 100644 --- a/language/go/BUILD.bazel +++ b/language/go/BUILD.bazel @@ -87,3 +87,32 @@ go_test( "@org_golang_x_tools//go/vcs:go_default_library", ], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "config.go", + "config_test.go", + "constants.go", + "def.bzl", + "fileinfo.go", + "fileinfo_go_test.go", + "fileinfo_test.go", + "fix.go", + "fix_test.go", + "generate.go", + "generate_test.go", + "kinds.go", + "known_go_imports.go", + "known_proto_imports.go", + "lang.go", + "package.go", + "resolve.go", + "resolve_test.go", + "std_package_list.go", + "//language/go/gen_std_package_list:all_files", + ], + visibility = ["//visibility:public"], +) diff --git a/language/go/gen_std_package_list/BUILD.bazel b/language/go/gen_std_package_list/BUILD.bazel index 92aac4602..54602a255 100644 --- a/language/go/gen_std_package_list/BUILD.bazel +++ b/language/go/gen_std_package_list/BUILD.bazel @@ -12,3 +12,13 @@ go_library( importpath = "github.com/bazelbuild/bazel-gazelle/language/go/gen_std_package_list", visibility = ["//visibility:private"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "gen_std_package_list.go", + ], + visibility = ["//visibility:public"], +) diff --git a/language/proto/BUILD.bazel b/language/proto/BUILD.bazel index 4f44e22b1..b7ed986ac 100644 --- a/language/proto/BUILD.bazel +++ b/language/proto/BUILD.bazel @@ -61,3 +61,28 @@ go_test( ) exports_files(["proto.csv"]) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "config.go", + "config_test.go", + "constants.go", + "fileinfo.go", + "fileinfo_test.go", + "fix.go", + "generate.go", + "generate_test.go", + "kinds.go", + "known_imports.go", + "lang.go", + "package.go", + "proto.csv", + "resolve.go", + "resolve_test.go", + "//language/proto/gen:all_files", + ], + visibility = ["//visibility:public"], +) diff --git a/language/proto/gen/BUILD.bazel b/language/proto/gen/BUILD.bazel index cd75a204c..a7b004d7e 100644 --- a/language/proto/gen/BUILD.bazel +++ b/language/proto/gen/BUILD.bazel @@ -13,3 +13,14 @@ go_binary( embed = [":go_default_library"], visibility = ["//:__subpackages__"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "gen_known_imports.go", + "update_proto_csv.go", + ], + visibility = ["//visibility:public"], +) diff --git a/merger/BUILD.bazel b/merger/BUILD.bazel index 8ea844e2d..85087079f 100644 --- a/merger/BUILD.bazel +++ b/merger/BUILD.bazel @@ -23,3 +23,15 @@ go_test( "//rule:go_default_library", ], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "fix.go", + "merger.go", + "merger_test.go", + ], + visibility = ["//visibility:public"], +) diff --git a/pathtools/BUILD.bazel b/pathtools/BUILD.bazel index ee6a6e131..acead21fd 100644 --- a/pathtools/BUILD.bazel +++ b/pathtools/BUILD.bazel @@ -12,3 +12,14 @@ go_test( srcs = ["path_test.go"], embed = [":go_default_library"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "path.go", + "path_test.go", + ], + visibility = ["//visibility:public"], +) diff --git a/repo/BUILD.bazel b/repo/BUILD.bazel index deaa16288..7933b7ccf 100644 --- a/repo/BUILD.bazel +++ b/repo/BUILD.bazel @@ -37,3 +37,21 @@ go_test( "@org_golang_x_tools//go/vcs:go_default_library", ], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "dep.go", + "godep.go", + "import_test.go", + "modules.go", + "remote.go", + "remote_test.go", + "repo.go", + "repo_test.go", + "stubs_test.go", + ], + visibility = ["//visibility:public"], +) diff --git a/resolve/BUILD.bazel b/resolve/BUILD.bazel index beaad9350..fda379b19 100644 --- a/resolve/BUILD.bazel +++ b/resolve/BUILD.bazel @@ -15,3 +15,14 @@ go_library( "//rule:go_default_library", ], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "config.go", + "index.go", + ], + visibility = ["//visibility:public"], +) diff --git a/rule/BUILD.bazel b/rule/BUILD.bazel index 21d5f7be8..dfa746b38 100644 --- a/rule/BUILD.bazel +++ b/rule/BUILD.bazel @@ -31,3 +31,23 @@ go_test( embed = [":go_default_library"], deps = ["@com_github_bazelbuild_buildtools//build:go_default_library"], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "directives.go", + "directives_test.go", + "expr.go", + "merge.go", + "platform.go", + "platform_strings.go", + "rule.go", + "rule_test.go", + "sort_labels.go", + "types.go", + "value.go", + ], + visibility = ["//visibility:public"], +) diff --git a/testtools/BUILD.bazel b/testtools/BUILD.bazel index f12bad522..fe346abe9 100644 --- a/testtools/BUILD.bazel +++ b/testtools/BUILD.bazel @@ -14,3 +14,14 @@ go_library( "//language:go_default_library", ], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "config.go", + "files.go", + ], + visibility = ["//visibility:public"], +) diff --git a/vendor/github.com/bazelbuild/buildtools/build/BUILD.bazel b/vendor/github.com/bazelbuild/buildtools/build/BUILD.bazel deleted file mode 100644 index 64a0c3da7..000000000 --- a/vendor/github.com/bazelbuild/buildtools/build/BUILD.bazel +++ /dev/null @@ -1,26 +0,0 @@ -# gazelle:exclude parse.y.go -load("@io_bazel_rules_go//go:def.bzl", "go_library") -load(":build_defs.bzl", "go_yacc") - -go_yacc( - src = "parse.y", - out = "parse.y.baz.go", -) - -go_library( - name = "go_default_library", - srcs = [ - "lex.go", - "parse.y.baz.go", # keep - "print.go", - "quote.go", - "rewrite.go", - "rule.go", - "syntax.go", - "walk.go", - ], - importmap = "github.com/bazelbuild/bazel-gazelle/vendor/github.com/bazelbuild/buildtools/build", - importpath = "github.com/bazelbuild/buildtools/build", - visibility = ["//visibility:public"], - deps = ["//vendor/github.com/bazelbuild/buildtools/tables:go_default_library"], -) diff --git a/vendor/github.com/bazelbuild/buildtools/tables/BUILD.bazel b/vendor/github.com/bazelbuild/buildtools/tables/BUILD.bazel deleted file mode 100644 index 5b95e2525..000000000 --- a/vendor/github.com/bazelbuild/buildtools/tables/BUILD.bazel +++ /dev/null @@ -1,12 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "jsonparser.go", - "tables.go", - ], - importmap = "github.com/bazelbuild/bazel-gazelle/vendor/github.com/bazelbuild/buildtools/tables", - importpath = "github.com/bazelbuild/buildtools/tables", - visibility = ["//visibility:public"], -) diff --git a/vendor/github.com/fsnotify/fsnotify/BUILD.bazel b/vendor/github.com/fsnotify/fsnotify/BUILD.bazel deleted file mode 100644 index 840f6b984..000000000 --- a/vendor/github.com/fsnotify/fsnotify/BUILD.bazel +++ /dev/null @@ -1,39 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "fen.go", - "fsnotify.go", - "inotify.go", - "inotify_poller.go", - "kqueue.go", - "open_mode_bsd.go", - "open_mode_darwin.go", - "windows.go", - ], - importmap = "github.com/bazelbuild/bazel-gazelle/vendor/github.com/fsnotify/fsnotify", - importpath = "github.com/fsnotify/fsnotify", - visibility = ["//visibility:public"], - deps = select({ - "@io_bazel_rules_go//go/platform:darwin": [ - "//vendor/golang.org/x/sys/unix:go_default_library", - ], - "@io_bazel_rules_go//go/platform:dragonfly": [ - "//vendor/golang.org/x/sys/unix:go_default_library", - ], - "@io_bazel_rules_go//go/platform:freebsd": [ - "//vendor/golang.org/x/sys/unix:go_default_library", - ], - "@io_bazel_rules_go//go/platform:linux": [ - "//vendor/golang.org/x/sys/unix:go_default_library", - ], - "@io_bazel_rules_go//go/platform:netbsd": [ - "//vendor/golang.org/x/sys/unix:go_default_library", - ], - "@io_bazel_rules_go//go/platform:openbsd": [ - "//vendor/golang.org/x/sys/unix:go_default_library", - ], - "//conditions:default": [], - }), -) diff --git a/vendor/github.com/pelletier/go-toml/BUILD.bazel b/vendor/github.com/pelletier/go-toml/BUILD.bazel deleted file mode 100644 index 756d13762..000000000 --- a/vendor/github.com/pelletier/go-toml/BUILD.bazel +++ /dev/null @@ -1,20 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "doc.go", - "keysparsing.go", - "lexer.go", - "marshal.go", - "parser.go", - "position.go", - "token.go", - "toml.go", - "tomltree_create.go", - "tomltree_write.go", - ], - importmap = "github.com/bazelbuild/bazel-gazelle/vendor/github.com/pelletier/go-toml", - importpath = "github.com/pelletier/go-toml", - visibility = ["//visibility:public"], -) diff --git a/vendor/github.com/pmezard/go-difflib/difflib/BUILD.bazel b/vendor/github.com/pmezard/go-difflib/difflib/BUILD.bazel deleted file mode 100644 index fc6cf7cfd..000000000 --- a/vendor/github.com/pmezard/go-difflib/difflib/BUILD.bazel +++ /dev/null @@ -1,9 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = ["difflib.go"], - importmap = "github.com/bazelbuild/bazel-gazelle/vendor/github.com/pmezard/go-difflib/difflib", - importpath = "github.com/pmezard/go-difflib/difflib", - visibility = ["//visibility:public"], -) diff --git a/vendor/golang.org/x/sys/unix/BUILD.bazel b/vendor/golang.org/x/sys/unix/BUILD.bazel deleted file mode 100644 index 7ff3aa126..000000000 --- a/vendor/golang.org/x/sys/unix/BUILD.bazel +++ /dev/null @@ -1,224 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "affinity_linux.go", - "aliases.go", - "asm_aix_ppc64.s", - "asm_darwin_386.s", - "asm_darwin_amd64.s", - "asm_darwin_arm.s", - "asm_darwin_arm64.s", - "asm_dragonfly_amd64.s", - "asm_freebsd_386.s", - "asm_freebsd_amd64.s", - "asm_freebsd_arm.s", - "asm_linux_386.s", - "asm_linux_amd64.s", - "asm_linux_arm.s", - "asm_linux_arm64.s", - "asm_linux_mips64x.s", - "asm_linux_mipsx.s", - "asm_linux_ppc64x.s", - "asm_linux_s390x.s", - "asm_netbsd_386.s", - "asm_netbsd_amd64.s", - "asm_netbsd_arm.s", - "asm_openbsd_386.s", - "asm_openbsd_amd64.s", - "asm_openbsd_arm.s", - "asm_solaris_amd64.s", - "bluetooth_linux.go", - "cap_freebsd.go", - "constants.go", - "dev_darwin.go", - "dev_dragonfly.go", - "dev_freebsd.go", - "dev_linux.go", - "dev_netbsd.go", - "dev_openbsd.go", - "dirent.go", - "endian_big.go", - "endian_little.go", - "env_unix.go", - "errors_freebsd_386.go", - "errors_freebsd_amd64.go", - "errors_freebsd_arm.go", - "fcntl.go", - "fcntl_darwin.go", - "fcntl_linux_32bit.go", - "ioctl.go", - "openbsd_pledge.go", - "openbsd_unveil.go", - "pagesize_unix.go", - "race.go", - "race0.go", - "sockcmsg_linux.go", - "sockcmsg_unix.go", - "str.go", - "syscall.go", - "syscall_bsd.go", - "syscall_darwin.go", - "syscall_darwin_386.go", - "syscall_darwin_amd64.go", - "syscall_darwin_arm.go", - "syscall_darwin_arm64.go", - "syscall_darwin_libSystem.go", - "syscall_dragonfly.go", - "syscall_dragonfly_amd64.go", - "syscall_freebsd.go", - "syscall_freebsd_386.go", - "syscall_freebsd_amd64.go", - "syscall_freebsd_arm.go", - "syscall_linux.go", - "syscall_linux_386.go", - "syscall_linux_amd64.go", - "syscall_linux_amd64_gc.go", - "syscall_linux_arm.go", - "syscall_linux_arm64.go", - "syscall_linux_gc.go", - "syscall_linux_gc_386.go", - "syscall_linux_mips64x.go", - "syscall_linux_mipsx.go", - "syscall_linux_ppc64x.go", - "syscall_linux_s390x.go", - "syscall_netbsd.go", - "syscall_netbsd_386.go", - "syscall_netbsd_amd64.go", - "syscall_netbsd_arm.go", - "syscall_openbsd.go", - "syscall_openbsd_386.go", - "syscall_openbsd_amd64.go", - "syscall_openbsd_arm.go", - "syscall_solaris.go", - "syscall_solaris_amd64.go", - "syscall_unix.go", - "syscall_unix_gc.go", - "syscall_unix_gc_ppc64x.go", - "timestruct.go", - "xattr_bsd.go", - "zerrors_darwin_386.go", - "zerrors_darwin_amd64.go", - "zerrors_darwin_arm.go", - "zerrors_darwin_arm64.go", - "zerrors_dragonfly_amd64.go", - "zerrors_freebsd_386.go", - "zerrors_freebsd_amd64.go", - "zerrors_freebsd_arm.go", - "zerrors_linux_386.go", - "zerrors_linux_amd64.go", - "zerrors_linux_arm.go", - "zerrors_linux_arm64.go", - "zerrors_linux_mips.go", - "zerrors_linux_mips64.go", - "zerrors_linux_mips64le.go", - "zerrors_linux_mipsle.go", - "zerrors_linux_ppc64.go", - "zerrors_linux_ppc64le.go", - "zerrors_linux_s390x.go", - "zerrors_netbsd_386.go", - "zerrors_netbsd_amd64.go", - "zerrors_netbsd_arm.go", - "zerrors_openbsd_386.go", - "zerrors_openbsd_amd64.go", - "zerrors_openbsd_arm.go", - "zerrors_solaris_amd64.go", - "zptrace386_linux.go", - "zptracearm_linux.go", - "zptracemips_linux.go", - "zptracemipsle_linux.go", - "zsyscall_darwin_386.1_11.go", - "zsyscall_darwin_386.go", - "zsyscall_darwin_386.s", - "zsyscall_darwin_amd64.1_11.go", - "zsyscall_darwin_amd64.go", - "zsyscall_darwin_amd64.s", - "zsyscall_darwin_arm.1_11.go", - "zsyscall_darwin_arm.go", - "zsyscall_darwin_arm.s", - "zsyscall_darwin_arm64.1_11.go", - "zsyscall_darwin_arm64.go", - "zsyscall_darwin_arm64.s", - "zsyscall_dragonfly_amd64.go", - "zsyscall_freebsd_386.go", - "zsyscall_freebsd_amd64.go", - "zsyscall_freebsd_arm.go", - "zsyscall_linux_386.go", - "zsyscall_linux_amd64.go", - "zsyscall_linux_arm.go", - "zsyscall_linux_arm64.go", - "zsyscall_linux_mips.go", - "zsyscall_linux_mips64.go", - "zsyscall_linux_mips64le.go", - "zsyscall_linux_mipsle.go", - "zsyscall_linux_ppc64.go", - "zsyscall_linux_ppc64le.go", - "zsyscall_linux_s390x.go", - "zsyscall_netbsd_386.go", - "zsyscall_netbsd_amd64.go", - "zsyscall_netbsd_arm.go", - "zsyscall_openbsd_386.go", - "zsyscall_openbsd_amd64.go", - "zsyscall_openbsd_arm.go", - "zsyscall_solaris_amd64.go", - "zsysctl_openbsd_386.go", - "zsysctl_openbsd_amd64.go", - "zsysctl_openbsd_arm.go", - "zsysnum_darwin_386.go", - "zsysnum_darwin_amd64.go", - "zsysnum_darwin_arm.go", - "zsysnum_darwin_arm64.go", - "zsysnum_dragonfly_amd64.go", - "zsysnum_freebsd_386.go", - "zsysnum_freebsd_amd64.go", - "zsysnum_freebsd_arm.go", - "zsysnum_linux_386.go", - "zsysnum_linux_amd64.go", - "zsysnum_linux_arm.go", - "zsysnum_linux_arm64.go", - "zsysnum_linux_mips.go", - "zsysnum_linux_mips64.go", - "zsysnum_linux_mips64le.go", - "zsysnum_linux_mipsle.go", - "zsysnum_linux_ppc64.go", - "zsysnum_linux_ppc64le.go", - "zsysnum_linux_s390x.go", - "zsysnum_netbsd_386.go", - "zsysnum_netbsd_amd64.go", - "zsysnum_netbsd_arm.go", - "zsysnum_openbsd_386.go", - "zsysnum_openbsd_amd64.go", - "zsysnum_openbsd_arm.go", - "ztypes_darwin_386.go", - "ztypes_darwin_amd64.go", - "ztypes_darwin_arm.go", - "ztypes_darwin_arm64.go", - "ztypes_dragonfly_amd64.go", - "ztypes_freebsd_386.go", - "ztypes_freebsd_amd64.go", - "ztypes_freebsd_arm.go", - "ztypes_linux_386.go", - "ztypes_linux_amd64.go", - "ztypes_linux_arm.go", - "ztypes_linux_arm64.go", - "ztypes_linux_mips.go", - "ztypes_linux_mips64.go", - "ztypes_linux_mips64le.go", - "ztypes_linux_mipsle.go", - "ztypes_linux_ppc64.go", - "ztypes_linux_ppc64le.go", - "ztypes_linux_s390x.go", - "ztypes_netbsd_386.go", - "ztypes_netbsd_amd64.go", - "ztypes_netbsd_arm.go", - "ztypes_openbsd_386.go", - "ztypes_openbsd_amd64.go", - "ztypes_openbsd_arm.go", - "ztypes_solaris_amd64.go", - ], - cgo = True, - importmap = "github.com/bazelbuild/bazel-gazelle/vendor/golang.org/x/sys/unix", - importpath = "golang.org/x/sys/unix", - visibility = ["//visibility:public"], -) diff --git a/vendor/golang.org/x/tools/go/vcs/BUILD.bazel b/vendor/golang.org/x/tools/go/vcs/BUILD.bazel deleted file mode 100644 index 23b8c6e33..000000000 --- a/vendor/golang.org/x/tools/go/vcs/BUILD.bazel +++ /dev/null @@ -1,14 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "discovery.go", - "env.go", - "http.go", - "vcs.go", - ], - importmap = "github.com/bazelbuild/bazel-gazelle/vendor/golang.org/x/tools/go/vcs", - importpath = "golang.org/x/tools/go/vcs", - visibility = ["//visibility:public"], -) diff --git a/walk/BUILD.bazel b/walk/BUILD.bazel index 0f6fff6f8..53b5f3aac 100644 --- a/walk/BUILD.bazel +++ b/walk/BUILD.bazel @@ -26,3 +26,15 @@ go_test( "//testtools:go_default_library", ], ) + +filegroup( + name = "all_files", + testonly = True, + srcs = [ + "BUILD.bazel", + "config.go", + "walk.go", + "walk_test.go", + ], + visibility = ["//visibility:public"], +) diff --git a/walk/config.go b/walk/config.go index 5b127a7a4..22b355836 100644 --- a/walk/config.go +++ b/walk/config.go @@ -41,6 +41,9 @@ func getWalkConfig(c *config.Config) *walkConfig { } func (wc *walkConfig) isExcluded(rel, base string) bool { + if base == ".git" { + return true + } f := path.Join(rel, base) for _, x := range wc.excludes { if f == x {