Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: remove go:build ignore and put xprog into new package #56975

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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