diff --git a/BUILD.bazel b/BUILD.bazel index 13254b3a5d082..6d91066b8fd9a 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -14,7 +14,6 @@ exports_files([ # gazelle:exclude build/linter/staticcheck # gazelle:exclude vendor # gazelle:exclude tools/patch-go -# gazelle:exclude tools/check # gazelle:resolve go github.com/bazelbuild/buildtools/build @com_github_bazelbuild_buildtools//build:go_default_library gazelle(name = "gazelle") diff --git a/Makefile b/Makefile index e345db553379e..7b6149c8cd9fc 100644 --- a/Makefile +++ b/Makefile @@ -302,9 +302,9 @@ tools/bin/ut: tools/check/ut.go $(GO) build -o ../bin/ut ut.go .PHONY: tools/bin/xprog -tools/bin/xprog: tools/check/xprog.go - cd tools/check; \ - $(GO) build -o ../bin/xprog xprog.go +tools/bin/xprog: tools/check/xprog/xprog.go + cd tools/check/xprog; \ + $(GO) build -o ../../bin/xprog xprog.go .PHONY: tools/bin/revive tools/bin/revive: diff --git a/build/nogo_config.json b/build/nogo_config.json index 848d49c7784e3..c39589c483d2c 100644 --- a/build/nogo_config.json +++ b/build/nogo_config.json @@ -314,7 +314,7 @@ "/rules_go_work-*": "ignore generated code", "tools/check/ut.go": "ignore tools/check code", "cmd/mirror": "ignore cmd/mirror code", - "tools/check/xprog.go": "ignore tools/check code", + "tools/check/xprog/xprog.go": "ignore tools/check code", "cmd/pluginpkg/pluginpkg.go": "ignore cmd/pluginpkg code", "tools/check/xprog.go:": "ignore tools/check code", "tests/integrationtest/main.go": "ignore tests/integrationtest code", diff --git a/tools/check/BUILD.bazel b/tools/check/BUILD.bazel index 9a4c65b006f39..2d0b25d78ab4b 100644 --- a/tools/check/BUILD.bazel +++ b/tools/check/BUILD.bazel @@ -1,19 +1,18 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") go_library( name = "ut_lib", srcs = ["ut.go"], - importpath = "github.com/pingcap/tidb/cmd/tidb-server", + importpath = "github.com/pingcap/tidb/tools/check", visibility = ["//visibility:private"], deps = [ - "@org_golang_x_tools//cover:go_default_library", - "@org_uber_go_automaxprocs//maxprocs", + "@org_golang_x_tools//cover", + "@org_uber_go_automaxprocs//:automaxprocs", ], ) -go_library( - name = "xprog_lib", - srcs = ["xprog.go"], - importpath = "github.com/pingcap/tidb/cmd/tidb-server", - visibility = ["//visibility:private"], +go_binary( + name = "ut-server", + embed = [":ut_lib"], + visibility = ["//visibility:public"], ) diff --git a/tools/check/ut.go b/tools/check/ut.go index 2a69dab6b5825..5a8faa89fda8c 100644 --- a/tools/check/ut.go +++ b/tools/check/ut.go @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build ignore - package main import ( @@ -427,7 +425,7 @@ func handleFlags(flag string) string { func handleFlag(f string) (found bool) { tmp := os.Args[:0] - for range len(os.Args) { + for i := range len(os.Args) { if os.Args[i] == f { found = true continue @@ -1009,7 +1007,7 @@ func filter(input []string, f func(string) bool) []string { } func shuffle(tasks []task) { - for range len(tasks) { + for i := range len(tasks) { pos := rand.Intn(len(tasks)) tasks[i], tasks[pos] = tasks[pos], tasks[i] } diff --git a/tools/check/xprog/BUILD.bazel b/tools/check/xprog/BUILD.bazel new file mode 100644 index 0000000000000..79915e7610fa3 --- /dev/null +++ b/tools/check/xprog/BUILD.bazel @@ -0,0 +1,14 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "xprog_lib", + srcs = ["xprog.go"], + importpath = "github.com/pingcap/tidb/tools/check/xprog", + visibility = ["//visibility:private"], +) + +go_binary( + name = "xprog", + embed = [":xprog_lib"], + visibility = ["//visibility:public"], +) diff --git a/tools/check/xprog.go b/tools/check/xprog/xprog.go similarity index 99% rename from tools/check/xprog.go rename to tools/check/xprog/xprog.go index 1185df462f9a6..3eff62890a934 100644 --- a/tools/check/xprog.go +++ b/tools/check/xprog/xprog.go @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build ignore - package main import (