Skip to content

Commit f08593f

Browse files
committed
Code cleanup
1 parent dcd65da commit f08593f

File tree

11 files changed

+15
-159
lines changed

11 files changed

+15
-159
lines changed

cmd/gencopy/gencopy.bash.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ CONFIG_SHORT_PATH=@@CONFIG_SHORT_PATH@@
1313
# set -x
1414
# echo "PWD: $PWD"
1515
# find .
16-
# find ..
1716

1817
# Get the directory of the current script (part of the runfiles tree)
1918
script_dir=$(dirname "$0")

cmd/gencopy/gencopy.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
const (
1919
ModeUpdate = "update"
2020
ModeCheck = "check"
21+
debug = false
2122
)
2223

2324
var (
@@ -83,9 +84,6 @@ func copyFile(src, dst string, mode os.FileMode) error {
8384
return fmt.Errorf("copyFile: src not found: %s", src)
8485
}
8586

86-
// NOTE: for some reason the io.Copy approach was writing an empty file...
87-
// for now OK to copy in-memory
88-
8987
data, err := os.ReadFile(src)
9088
if err != nil {
9189
return err
@@ -231,7 +229,9 @@ func readConfig(workspaceRootDirectory string) (*Config, error) {
231229
cfg.FileMode = "0644"
232230
}
233231

234-
// log.Printf("%+v", cfg)
232+
if debug {
233+
log.Printf("%+v", cfg)
234+
}
235235

236236
return cfg, nil
237237
}

example/golden/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Have any `BUILD.bazel` files crept into the `vendor/` tree? These are globbed
2424
in `//:all_files` and the presence of one will elide files in that package from
2525
the glob. You might not see them because they are .gitignored.
2626

27-
```
28-
bazel query //:all_files --output build > all_files.BUILD
27+
```sh
28+
$ bazel query //:all_files --output build > all_files.BUILD
2929
```
3030

3131
Try and build from the main test workspace. To do that, open up rules_go in the

example/golden/builtin.MODULE.bazel

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +0,0 @@
1-
local_repository(
2-
name = "build_stack_rules_proto",
3-
path = "../build_stack_rules_proto",
4-
)
5-
6-
register_toolchains("@build_stack_rules_proto//toolchain:standard")
7-
8-
# == Externals ==
9-
10-
load("@build_stack_rules_proto//deps:core_deps.bzl", "core_deps")
11-
12-
core_deps()
13-
14-
# == Go ==
15-
16-
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
17-
18-
go_rules_dependencies()
19-
20-
go_register_toolchains(version = "1.18.2")
21-
22-
# == Gazelle ==
23-
24-
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
25-
26-
gazelle_dependencies()
27-
28-
# == Protobuf ==
29-
30-
load("@build_stack_rules_proto//deps:protobuf_core_deps.bzl", "protobuf_core_deps")
31-
32-
protobuf_core_deps()
Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +0,0 @@
1-
# ----------------------------------------------------
2-
# scala
3-
# ----------------------------------------------------
4-
5-
load("@build_stack_rules_proto//deps:scala_deps.bzl", "scala_deps")
6-
load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")
7-
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
8-
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
9-
load(
10-
"@rules_jvm_external//:defs.bzl",
11-
"maven_install",
12-
)
13-
load("@build_stack_rules_proto//rules/proto:proto_repository.bzl", "proto_repository")
14-
15-
scala_deps()
16-
17-
scala_config(scala_version = "2.12.18")
18-
19-
scala_repositories()
20-
21-
scala_register_toolchains()
22-
23-
# ----------------------------------------------------
24-
# maven
25-
# ----------------------------------------------------
26-
27-
maven_install(
28-
name = "maven_scala",
29-
artifacts = [
30-
"com.thesamet.scalapb:lenses_2.12:0.11.10",
31-
"com.thesamet.scalapb:scalapb-json4s_2.12:0.12.0",
32-
"com.thesamet.scalapb:scalapb-runtime_2.12:0.11.10",
33-
"com.thesamet.scalapb:scalapb-runtime-grpc_2.12:0.11.10",
34-
"com.thesamet.scalapb:scalapbc_2.12:0.11.10",
35-
"org.json4s:json4s-core_2.12:4.0.3",
36-
],
37-
fetch_sources = True,
38-
repositories = ["https://repo1.maven.org/maven2"],
39-
)
40-
41-
# ----------------------------------------------------
42-
# akka
43-
# ----------------------------------------------------
44-
45-
maven_install(
46-
name = "maven_akka",
47-
artifacts = [
48-
"com.lightbend.akka.grpc:akka-grpc-codegen_2.12:2.1.3",
49-
"com.lightbend.akka.grpc:akka-grpc-runtime_2.12:2.1.3",
50-
],
51-
fetch_sources = True,
52-
repositories = ["https://repo1.maven.org/maven2"],
53-
)
54-
55-
# ----------------------------------------------------
56-
# proto_repository
57-
# ----------------------------------------------------
58-
59-
proto_repository(
60-
name = "scalaapis",
61-
build_directives = ["gazelle:proto_language scala enabled true"],
62-
build_file_generation = "on",
63-
build_file_proto_mode = "file",
64-
cfgs = ["//:config.yaml"],
65-
sha256 = "1ac039f79b0825fe2e7e5ddf24e330632d63b70a7a42bfd39ded5bb1fb648811",
66-
# the typical importpath is 'scalapb/scalapb.proto', so strip the prefix up
67-
# to that directory.
68-
strip_prefix = "ScalaPB-a4e0e02c0f5b160877d5f97f6902dbec4c633afe/protobuf",
69-
type = "zip",
70-
urls = ["https://codeload.github.com/scalapb/ScalaPB/zip/a4e0e02c0f5b160877d5f97f6902dbec4c633afe"],
71-
)
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
# Using scala_deps here because it provides rules_jvm_external, there is nothing
2-
# scala-specific about this example.
3-
load("@build_stack_rules_proto//deps:scala_deps.bzl", "scala_deps")
4-
5-
scala_deps()

pkg/plugin/gogo/protobuf/protoc-gen-gogo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (p *GogoPlugin) Configure(ctx *protoc.PluginContext) *protoc.PluginConfigur
4040
return nil
4141
}
4242

43-
grpcOptions := p.grpcOptions(ctx.Rel, ctx.PluginConfig, ctx.ProtoLibrary)
43+
grpcOptions := p.grpcOptions(ctx.PluginConfig, ctx.ProtoLibrary)
4444
return &protoc.PluginConfiguration{
4545
Label: label.New("build_stack_rules_proto", "plugin/gogo/protobuf", "protoc-gen-"+p.variant),
4646
Outputs: p.outputs(ctx.ProtoLibrary),
@@ -73,7 +73,7 @@ func (p *GogoPlugin) outputs(lib protoc.ProtoLibrary) []string {
7373
return srcs
7474
}
7575

76-
func (p *GogoPlugin) grpcOptions(rel string, cfg protoc.LanguagePluginConfig, lib protoc.ProtoLibrary) []string {
76+
func (p *GogoPlugin) grpcOptions(cfg protoc.LanguagePluginConfig, lib protoc.ProtoLibrary) []string {
7777
// if the configuration specifically states that we don't want grpc, return
7878
// early
7979
if want, ok := cfg.Options[gogoGrpcPluginOption]; ok && !want {

pkg/protoc/proto_compile.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,12 @@ func (s *protoCompileRule) Rule(otherGen ...*rule.Rule) *rule.Rule {
140140
switch name {
141141
case "verbose":
142142
val := vals[0]
143-
if val == "True" || val == "true" {
143+
switch val {
144+
case "True", "true":
144145
newRule.SetAttr("verbose", true)
145-
} else if val == "False" || val == "false" {
146+
case "False", "false":
146147
newRule.SetAttr("verbose", false)
147-
} else {
148+
default:
148149
log.Printf("bad attr 'verbose' value: %q", val)
149150
}
150151
default:

pkg/protoc/starlark_util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func newStringList(in []string) *starlark.List {
5252
return starlark.NewList(values)
5353
}
5454

55-
func newStringListDict(in map[string]map[string]bool) *starlark.Dict {
55+
func newStringListDict(_ map[string]map[string]bool) *starlark.Dict {
5656
out := &starlark.Dict{}
5757
return out
5858
}

0 commit comments

Comments
 (0)