Skip to content

Commit 4d955d4

Browse files
committed
WIP: Upgrade bazel version
1 parent f21c433 commit 4d955d4

File tree

10 files changed

+2819
-79
lines changed

10 files changed

+2819
-79
lines changed

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.6.1
1+
8.2.1

MODULE.bazel

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module(name = "bazel_watcher")
22

3-
bazel_dep(name = "bazel_skylib", version = "1.6.1")
4-
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
5-
bazel_dep(name = "rules_go", version = "0.53.0", repo_name = "io_bazel_rules_go")
6-
bazel_dep(name = "gazelle", version = "0.34.0", repo_name = "bazel_gazelle")
3+
bazel_dep(name = "bazel_skylib", version = "1.7.1")
4+
bazel_dep(name = "rules_proto", version = "7.0.2")
5+
bazel_dep(name = "rules_go", version = "0.55.1", repo_name = "io_bazel_rules_go")
6+
bazel_dep(name = "gazelle", version = "0.36.0", repo_name = "bazel_gazelle")
7+
bazel_dep(name = "bazel_features", version = "1.21.0")
78

89
# Configure Go SDK
910
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")

MODULE.bazel.lock

Lines changed: 2756 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/ibazel/main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ var Version = "Development"
2929

3030
var overrideableStartupFlags []string = []string{
3131
"--bazelrc",
32+
"--bazelrc=",
33+
"--nobazelrc",
3234
"--home_rc",
3335
"--nohome_rc",
3436
"--output_base",
3537
}
3638

3739
var overrideableBazelFlags []string = []string{
40+
"--announce_rc",
3841
"--action_env",
3942
"--announce_rc",
4043
"--aspects",
@@ -53,6 +56,9 @@ var overrideableBazelFlags []string = []string{
5356
"--define=",
5457
"--dynamic_mode=",
5558
"--enable_bzlmod=",
59+
"--enable_bzlmod",
60+
"--enable_workspace",
61+
"--enable_workspace=",
5662
"--features=",
5763
"--flaky_test_attempts=",
5864
"--host_jvmopt",
@@ -62,6 +68,7 @@ var overrideableBazelFlags []string = []string{
6268
"-k",
6369
"--nocache_test_results",
6470
"--noenable_bzlmod",
71+
"--noenable_workspace",
6572
"--nostamp",
6673
"--output_groups=",
6774
"--override_repository=",
@@ -157,6 +164,7 @@ func parseArgs(in []string) (targets, startupArgs, bazelArgs, args []string) {
157164
if isOverrideableStartupFlag(arg) {
158165
startupArgs = append(startupArgs, arg)
159166
} else if isOverrideableBazelFlag(arg) {
167+
println("overriding bazel flag: %s", arg)
160168
bazelArgs = append(bazelArgs, arg)
161169
} else {
162170
// If none of those things then it's probably a target.
@@ -213,7 +221,7 @@ func applyDefaultBazelArgs(bazelArgs []string) []string {
213221
return bazelArgs
214222
}
215223
}
216-
if (isTerminal()) {
224+
if isTerminal() {
217225
return append(bazelArgs, "--isatty=1")
218226
} else {
219227
return append(bazelArgs, "--isatty=0")

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module github.com/bazelbuild/bazel-watcher
22

33
require (
4-
github.com/bazelbuild/rules_go v0.55.1
54
github.com/fsnotify/fsevents v0.1.1
65
github.com/fsnotify/fsnotify v1.9.0
76
github.com/golang/protobuf v1.5.4
@@ -14,8 +13,9 @@ require (
1413
)
1514

1615
require (
17-
golang.org/x/sys v0.28.0
18-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d
16+
github.com/bazelbuild/rules_go v0.55.1
17+
golang.org/x/sys v0.30.0
18+
golang.org/x/tools v0.30.0
1919
)
2020

2121
require google.golang.org/protobuf v1.36.3 // indirect

go.sum

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
github.com/bazelbuild/rules_go v0.53.0 h1:u160DT+RRb+Xb2aSO4piN8xhs4aZvWz2UDXCq48F4ao=
2-
github.com/bazelbuild/rules_go v0.53.0/go.mod h1:xB1jfsYHWlnZyPPxzlOSst4q2ZAwS251Mp9Iw6TPuBc=
31
github.com/bazelbuild/rules_go v0.55.1 h1:cQYGcunY8myOB+0Ym6PGQRhc/milkRcNv0my3XgxaDU=
42
github.com/bazelbuild/rules_go v0.55.1/go.mod h1:T90Gpyq4HDFlsrvtQa2CBdHNJ2P4rAu/uUTmQbanzf0=
53
github.com/fsnotify/fsevents v0.1.1 h1:/125uxJvvoSDDBPen6yUZbil8J9ydKZnnl3TWWmvnkw=
@@ -27,12 +25,12 @@ github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3
2725
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
2826
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
2927
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
30-
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
31-
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
28+
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
29+
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
3230
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
3331
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
34-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
35-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
32+
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
33+
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
3634
google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=
3735
google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
3836
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=

internal/bazel/bazel.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,14 @@ func (b *bazel) Test(args ...string) (*bytes.Buffer, error) {
383383
func (b *bazel) Run(args ...string) (*exec.Cmd, *bytes.Buffer, error) {
384384
b.WriteToStderr(true)
385385
b.WriteToStdout(true)
386-
stdoutBuffer, stderrBuffer := b.newCommand("run", append(b.args, args...)...)
386+
runArgs := append(b.args, args...)
387+
stdoutBuffer, stderrBuffer := b.newCommand("run",runArgs...)
387388
b.cmd.Stdin = os.Stdin
388389

389-
_, _ = stdoutBuffer.Write(stderrBuffer.Bytes())
390+
if _, err:=
391+
stdoutBuffer.Write(stderrBuffer.Bytes()); err != nil {
392+
return nil, nil, fmt.Errorf("sdout.write(): %w", err)
393+
}
390394

391395
err := b.cmd.Run()
392396
if err != nil {

internal/e2e/ibazel.go

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ const (
2222
defaultDelay = 50 * time.Second
2323
)
2424

25+
var defaultFlags = []string{
26+
"--graceful_termination_wait_duration=1s",
27+
}
28+
29+
var defaultStartupFlags = []string{
30+
"--enable_workspace",
31+
"--bazelrc=/dev/null",
32+
}
33+
34+
2535
type IBazelTester struct {
2636
t *testing.T
2737
ibazelLogFile string
@@ -35,7 +45,7 @@ type IBazelTester struct {
3545
}
3646

3747
func NewIBazelTester(t *testing.T) *IBazelTester {
38-
f, err := ioutil.TempFile("", "ibazel_output.*.log")
48+
f, err := os.CreateTemp("", "ibazel_output.*.log")
3949
if err != nil {
4050
panic(fmt.Sprintf("Error ioutil.Tempfile: %v", err))
4151
}
@@ -66,13 +76,14 @@ func (i *IBazelTester) Test(bazelArgs []string, targets ...string) {
6676
args := []string{"--bazel_path=" + i.bazelPath()}
6777
args = append(args,
6878
"--log_to_file="+i.ibazelLogFile,
69-
"--graceful_termination_wait_duration=1s")
79+
)
7080
args = append(args, "test")
71-
args = append(args, "--bazelrc=/dev/null")
81+
args = append(args, defaultStartupFlags...)
7282
args = append(args, targets...)
7383
args = append(args, bazelArgs...)
7484
i.cmd = exec.Command(ibazelPath, args...)
75-
i.t.Logf("ibazel invoked as: %s", strings.Join(i.cmd.Args, " "))
85+
i.t.Logf("ibazel invoked in %s as: %s", i.cmd.Dir,
86+
strings.Join(i.cmd.Args, " "))
7687

7788
i.stdoutBuffer = &Buffer{}
7889
i.cmd.Stdout = i.stdoutBuffer
@@ -89,15 +100,17 @@ func (i *IBazelTester) Coverage(bazelArgs []string, targets ...string) {
89100
i.t.Helper()
90101

91102
args := []string{"--bazel_path=" + i.bazelPath()}
103+
args = append(args, defaultFlags...)
92104
args = append(args,
93105
"--log_to_file="+i.ibazelLogFile,
94-
"--graceful_termination_wait_duration=1s")
106+
)
95107
args = append(args, "coverage")
96-
args = append(args, "--bazelrc=/dev/null")
108+
args = append(args, defaultStartupFlags...)
97109
args = append(args, targets...)
98110
args = append(args, bazelArgs...)
99111
i.cmd = exec.Command(ibazelPath, args...)
100-
i.t.Logf("ibazel invoked as: %s", strings.Join(i.cmd.Args, " "))
112+
i.t.Logf("ibazel invoked in %s as: %s", i.cmd.Dir,
113+
strings.Join(i.cmd.Args, " "))
101114

102115
i.stdoutBuffer = &Buffer{}
103116
i.cmd.Stdout = i.stdoutBuffer
@@ -112,19 +125,17 @@ func (i *IBazelTester) Coverage(bazelArgs []string, targets ...string) {
112125

113126
func (i *IBazelTester) Run(bazelArgs []string, target string) {
114127
i.t.Helper()
115-
i.run(target, bazelArgs, []string{
116-
"--log_to_file=" + i.ibazelLogFile,
117-
"--graceful_termination_wait_duration=1s",
118-
})
128+
i.run(target, bazelArgs, append(defaultFlags,
129+
"--log_to_file="+i.ibazelLogFile,
130+
))
119131
}
120132

121133
func (i *IBazelTester) RunWithProfiler(target string, profiler string) {
122134
i.t.Helper()
123-
i.run(target, []string{}, []string{
124-
"--log_to_file=" + i.ibazelLogFile,
125-
"--graceful_termination_wait_duration=1s",
126-
"--profile_dev=" + profiler,
127-
})
135+
i.run(target, []string{}, append(defaultFlags,
136+
"--log_to_file="+i.ibazelLogFile,
137+
"--profile_dev="+profiler,
138+
))
128139
}
129140

130141
func (i *IBazelTester) RunWithBazelFixCommands(target string) {
@@ -415,11 +426,13 @@ func (i *IBazelTester) runUnverified(target string, bazelArgs []string, addition
415426
args := []string{"--bazel_path=" + i.bazelPath()}
416427
args = append(args, additionalArgs...)
417428
args = append(args, "run")
418-
args = append(args, "--bazelrc=/dev/null")
429+
419430
args = append(args, target)
420431
args = append(args, bazelArgs...)
421432
i.cmd = exec.Command(ibazelPath, args...)
422-
i.t.Logf("ibazel invoked as: %s", strings.Join(i.cmd.Args, " "))
433+
i.t.Logf("ibazel invoked in %s as: %s in: %s",
434+
i.cmd.Dir, strings.Join(i.cmd.Args, " "),
435+
os.Getenv("TEST_TMPDIR"))
423436

424437
checkArgs := []string{"build"}
425438
checkArgs = append(checkArgs, target)
@@ -436,6 +449,8 @@ func (i *IBazelTester) runUnverified(target string, bazelArgs []string, addition
436449
if exitErr, ok := err.(*exec.ExitError); ok {
437450
status := exitErr.Sys().(syscall.WaitStatus)
438451
i.t.Fatalf("Unable to build target. Error code: %d\nStdout:\n%s\nStderr:\n%s", status.ExitStatus(), buildStdout.String(), buildStderr.String())
452+
} else {
453+
i.t.Fatalf("Unable to build target. %v", err)
439454
}
440455
}
441456
}

third_party/bazel/master/src/main/protobuf/analysis/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
load("@rules_proto//proto:defs.bzl", "proto_library")
21
load("@io_bazel_rules_go//go:def.bzl", "go_library")
32
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
3+
load("@rules_proto//proto:defs.bzl", "proto_library")
44

55
proto_library(
66
name = "analysis_proto",

third_party/bazel/master/src/main/protobuf/blaze_query/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
load("@rules_proto//proto:defs.bzl", "proto_library")
21
load("@io_bazel_rules_go//go:def.bzl", "go_library")
32
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
3+
load("@rules_proto//proto:defs.bzl", "proto_library")
44

55
proto_library(
66
name = "blaze_query_proto",

0 commit comments

Comments
 (0)