Skip to content

Commit 390de88

Browse files
authored
tools: remove go:build ignore and put xprog into new package (pingcap#56975)
1 parent 8fde2d6 commit 390de88

File tree

7 files changed

+28
-20
lines changed

7 files changed

+28
-20
lines changed

BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ exports_files([
1414
# gazelle:exclude build/linter/staticcheck
1515
# gazelle:exclude vendor
1616
# gazelle:exclude tools/patch-go
17-
# gazelle:exclude tools/check
1817
# gazelle:resolve go github.com/bazelbuild/buildtools/build @com_github_bazelbuild_buildtools//build:go_default_library
1918
gazelle(name = "gazelle")
2019

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ tools/bin/ut: tools/check/ut.go
302302
$(GO) build -o ../bin/ut ut.go
303303

304304
.PHONY: tools/bin/xprog
305-
tools/bin/xprog: tools/check/xprog.go
306-
cd tools/check; \
307-
$(GO) build -o ../bin/xprog xprog.go
305+
tools/bin/xprog: tools/check/xprog/xprog.go
306+
cd tools/check/xprog; \
307+
$(GO) build -o ../../bin/xprog xprog.go
308308

309309
.PHONY: tools/bin/revive
310310
tools/bin/revive:

build/nogo_config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@
314314
"/rules_go_work-*": "ignore generated code",
315315
"tools/check/ut.go": "ignore tools/check code",
316316
"cmd/mirror": "ignore cmd/mirror code",
317-
"tools/check/xprog.go": "ignore tools/check code",
317+
"tools/check/xprog/xprog.go": "ignore tools/check code",
318318
"cmd/pluginpkg/pluginpkg.go": "ignore cmd/pluginpkg code",
319319
"tools/check/xprog.go:": "ignore tools/check code",
320320
"tests/integrationtest/main.go": "ignore tests/integrationtest code",

tools/check/BUILD.bazel

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
load("@io_bazel_rules_go//go:def.bzl", "go_library")
1+
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
22

33
go_library(
44
name = "ut_lib",
55
srcs = ["ut.go"],
6-
importpath = "github.com/pingcap/tidb/cmd/tidb-server",
6+
importpath = "github.com/pingcap/tidb/tools/check",
77
visibility = ["//visibility:private"],
88
deps = [
9-
"@org_golang_x_tools//cover:go_default_library",
10-
"@org_uber_go_automaxprocs//maxprocs",
9+
"@org_golang_x_tools//cover",
10+
"@org_uber_go_automaxprocs//:automaxprocs",
1111
],
1212
)
1313

14-
go_library(
15-
name = "xprog_lib",
16-
srcs = ["xprog.go"],
17-
importpath = "github.com/pingcap/tidb/cmd/tidb-server",
18-
visibility = ["//visibility:private"],
14+
go_binary(
15+
name = "ut-server",
16+
embed = [":ut_lib"],
17+
visibility = ["//visibility:public"],
1918
)

tools/check/ut.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
//go:build ignore
16-
1715
package main
1816

1917
import (
@@ -427,7 +425,7 @@ func handleFlags(flag string) string {
427425

428426
func handleFlag(f string) (found bool) {
429427
tmp := os.Args[:0]
430-
for range len(os.Args) {
428+
for i := range len(os.Args) {
431429
if os.Args[i] == f {
432430
found = true
433431
continue
@@ -1009,7 +1007,7 @@ func filter(input []string, f func(string) bool) []string {
10091007
}
10101008

10111009
func shuffle(tasks []task) {
1012-
for range len(tasks) {
1010+
for i := range len(tasks) {
10131011
pos := rand.Intn(len(tasks))
10141012
tasks[i], tasks[pos] = tasks[pos], tasks[i]
10151013
}

tools/check/xprog/BUILD.bazel

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
2+
3+
go_library(
4+
name = "xprog_lib",
5+
srcs = ["xprog.go"],
6+
importpath = "github.com/pingcap/tidb/tools/check/xprog",
7+
visibility = ["//visibility:private"],
8+
)
9+
10+
go_binary(
11+
name = "xprog",
12+
embed = [":xprog_lib"],
13+
visibility = ["//visibility:public"],
14+
)

tools/check/xprog.go tools/check/xprog/xprog.go

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
//go:build ignore
16-
1715
package main
1816

1917
import (

0 commit comments

Comments
 (0)