Skip to content

Commit

Permalink
tools: remove go:build ignore and put xprog into new package (#56975)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Oct 30, 2024
1 parent 8fde2d6 commit 390de88
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 20 deletions.
1 change: 0 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion build/nogo_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 8 additions & 9 deletions tools/check/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"],
)
6 changes: 2 additions & 4 deletions tools/check/ut.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build ignore

package main

import (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
}
Expand Down
14 changes: 14 additions & 0 deletions tools/check/xprog/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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"],
)
2 changes: 0 additions & 2 deletions tools/check/xprog.go → tools/check/xprog/xprog.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build ignore

package main

import (
Expand Down

0 comments on commit 390de88

Please sign in to comment.