Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports_files([
# ----------------------------------------------------
# Gazelle
# ----------------------------------------------------
# gazelle:prefix github.com/stackb/rules_proto
# gazelle:prefix github.com/stackb/rules_proto/v4
# gazelle:exclude vendor
# gazelle:exclude node_modules
# gazelle:go_generate_proto false
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `rules_proto (v4)`

![build-status](https://github.com/stackb/rules_proto/actions/workflows/ci.yaml/badge.svg)
![build-status](https://github.com/stackb/rules_proto/v4/actions/workflows/ci.yaml/badge.svg)
[![Go Reference](https://pkg.go.dev/badge/github.com/stackb/rules_proto.svg)](https://pkg.go.dev/github.com/stackb/rules_proto)

Bazel starlark rules for building protocol buffers +/- gRPC :sparkles:.
Expand Down
2 changes: 1 addition & 1 deletion cmd/examplegen/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_library(
"generator.go",
"template.go",
],
importpath = "github.com/stackb/rules_proto/cmd/examplegen",
importpath = "github.com/stackb/rules_proto/v4/cmd/examplegen",
visibility = ["//visibility:private"],
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/gazelle/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ go_library(
"profiler.go",
"update-repos.go",
],
importpath = "github.com/stackb/rules_proto/cmd/gazelle",
importpath = "github.com/stackb/rules_proto/v4/cmd/gazelle",
visibility = ["//visibility:public"],
deps = [
"//cmd/gazelle/internal/wspace",
Expand Down
2 changes: 1 addition & 1 deletion cmd/gazelle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To upgrade gazelle, one must:

- Compare changes in the source repo@version to the files here. It's easiest to
just copy over each file and see where the diffs are. Make sure `langs.go`
includes `github.com/stackb/rules_proto/language/protobuf`.
includes `github.com/stackb/rules_proto/v4/language/protobuf`.
- Since the `proto_gazelle.bzl` rule uses
`@bazel_gazelle//internal:gazelle.bash.in`, changes there must remain
compatible with proto_gazelle. Look at the diff there and make sure the
Expand Down
2 changes: 1 addition & 1 deletion cmd/gazelle/fix-update.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/bazelbuild/bazel-gazelle/resolve"
"github.com/bazelbuild/bazel-gazelle/rule"
"github.com/bazelbuild/bazel-gazelle/walk"
"github.com/stackb/rules_proto/cmd/gazelle/internal/wspace"
"github.com/stackb/rules_proto/v4/cmd/gazelle/internal/wspace"
)

// updateConfig holds configuration information needed to run the fix and
Expand Down
2 changes: 1 addition & 1 deletion cmd/gazelle/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"github.com/bazelbuild/bazel-gazelle/config"
"github.com/bazelbuild/bazel-gazelle/testtools"
"github.com/google/go-cmp/cmp"
"github.com/stackb/rules_proto/cmd/gazelle/internal/wspace"
"github.com/stackb/rules_proto/v4/cmd/gazelle/internal/wspace"
)

// skipIfWorkspaceVisible skips the test if the WORKSPACE file for the
Expand Down
2 changes: 1 addition & 1 deletion cmd/gazelle/internal/wspace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "wspace",
srcs = ["finder.go"],
importpath = "github.com/stackb/rules_proto/cmd/gazelle/internal/wspace",
importpath = "github.com/stackb/rules_proto/v4/cmd/gazelle/internal/wspace",
visibility = ["//visibility:public"],
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/gazelle/langs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"github.com/bazelbuild/bazel-gazelle/language"
golang "github.com/bazelbuild/bazel-gazelle/language/go"
"github.com/bazelbuild/bazel-gazelle/language/proto"
"github.com/stackb/rules_proto/language/proto_go_modules"
"github.com/stackb/rules_proto/language/protobuf"
"github.com/stackb/rules_proto/v4/language/proto_go_modules"
"github.com/stackb/rules_proto/v4/language/protobuf"
)

var languages = []language.Language{
Expand Down
2 changes: 1 addition & 1 deletion cmd/gazelle/update-repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/bazelbuild/bazel-gazelle/merger"
"github.com/bazelbuild/bazel-gazelle/repo"
"github.com/bazelbuild/bazel-gazelle/rule"
"github.com/stackb/rules_proto/cmd/gazelle/internal/wspace"
"github.com/stackb/rules_proto/v4/cmd/gazelle/internal/wspace"
)

type updateReposConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gencopy/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports_files(["gencopy.bash.in"])
go_library(
name = "gencopy_lib",
srcs = ["gencopy.go"],
importpath = "github.com/stackb/rules_proto/cmd/gencopy",
importpath = "github.com/stackb/rules_proto/v4/cmd/gencopy",
visibility = ["//visibility:private"],
deps = ["@com_github_google_go_cmp//cmp"],
)
Expand Down
14 changes: 7 additions & 7 deletions docs/CORE_RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Consider the following rule within the package `example/thing`:
```python
proto_compile(
name = "thing_go_compile",
output_mappings = ["thing.pb.go=github.com/stackb/rules_proto/example/thing/thing.pb.go"],
output_mappings = ["thing.pb.go=github.com/stackb/rules_proto/v4/example/thing/thing.pb.go"],
outputs = ["thing.pb.go"],
plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
proto = "thing_proto",
Expand All @@ -133,7 +133,7 @@ Let's temporarily comment out the `output_mappings` attribute and rebuild:
```python
proto_compile(
name = "thing_go_compile",
# output_mappings = ["thing.pb.go=github.com/stackb/rules_proto/example/thing/thing.pb.go"],
# output_mappings = ["thing.pb.go=github.com/stackb/rules_proto/v4/example/thing/thing.pb.go"],
outputs = ["thing.pb.go"],
plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
proto = "thing_proto",
Expand All @@ -142,7 +142,7 @@ proto_compile(

```sh
$ bazel build //example/thing:thing_go_compile
ERROR: /github.com/stackb/rules_proto/example/thing/BUILD.bazel:54:14: output 'example/thing/thing.pb.go' was not created
ERROR: /github.com/stackb/rules_proto/v4/example/thing/BUILD.bazel:54:14: output 'example/thing/thing.pb.go' was not created
```

What happened? Let's add a debugging attribute `verbose = True` on the rule:
Expand All @@ -152,7 +152,7 @@ after the `protoc` tool is invoked:
```python
proto_compile(
name = "thing_go_compile",
# output_mappings = ["thing.pb.go=github.com/stackb/rules_proto/example/thing/thing.pb.go"],
# output_mappings = ["thing.pb.go=github.com/stackb/rules_proto/v4/example/thing/thing.pb.go"],
outputs = ["thing.pb.go"],
plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
proto = "thing_proto",
Expand All @@ -169,17 +169,17 @@ $ bazel build //example/thing:thing_go_compile
./bazel-out/darwin-fastbuild/bin/external/com_google_protobuf/timestamp_proto-descriptor-set.proto.bin

##### SANDBOX AFTER RUNNING PROTOC
./bazel-out/darwin-fastbuild/bin/github.com/stackb/rules_proto/example/thing/thing.pb.go
./bazel-out/darwin-fastbuild/bin/github.com/stackb/rules_proto/v4/example/thing/thing.pb.go
```

So, the file was created, but not in the location we wanted. In this case the
`protoc-gen-go` plugin is not "playing nice" with Bazel. Because this
`thing.proto` has
`option go_package = "github.com/stackb/rules_proto/example/thing;thing";`, the
`option go_package = "github.com/stackb/rules_proto/v4/example/thing;thing";`, the
output location is no longer based on the `package`. This is a problem, because
Bazel semantics disallow declaring a File outside its package boundary. As a
result, we need to do a
`mv ./bazel-out/darwin-fastbuild/bin/github.com/stackb/rules_proto/example/thing/thing.pb.go ./bazel-out/darwin-fastbuild/bin/example/thing/thing.pb.go`
`mv ./bazel-out/darwin-fastbuild/bin/github.com/stackb/rules_proto/v4/example/thing/thing.pb.go ./bazel-out/darwin-fastbuild/bin/example/thing/thing.pb.go`
to relocate the file into its expected location before the action terminates.

Therefore, the `output_mappings` attribute is a list of entries that map file
Expand Down
8 changes: 4 additions & 4 deletions docs/GAZELLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ proto_library(

proto_compile(
name = "person_go_compile",
output_mappings = ["person.pb.go=github.com/stackb/rules_proto/example/person/person.pb.go"],
output_mappings = ["person.pb.go=github.com/stackb/rules_proto/v4/example/person/person.pb.go"],
outputs = ["person.pb.go"],
plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
proto = "person_proto",
Expand All @@ -244,7 +244,7 @@ proto_compile(
proto_go_library(
name = "person_go_proto",
srcs = ["person.pb.go"],
importpath = "github.com/stackb/rules_proto/example/person",
importpath = "github.com/stackb/rules_proto/v4/example/person",
visibility = ["//visibility:public"],
deps = [
"//example/place:place_go_proto",
Expand Down Expand Up @@ -280,7 +280,7 @@ With this change, we get:
proto_compiled_sources(
name = "person_go_compiled_sources",
srcs = ["person.pb.go"],
output_mappings = ["person.pb.go=github.com/stackb/rules_proto/example/person/person.pb.go"],
output_mappings = ["person.pb.go=github.com/stackb/rules_proto/v4/example/person/person.pb.go"],
plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
proto = "person_proto",
visibility = ["//visibility:public"],
Expand All @@ -305,7 +305,7 @@ gazelle extension:
go_library(
name = "person",
srcs = ["person.pb.go"],
importpath = "github.com/stackb/rules_proto/example/person",
importpath = "github.com/stackb/rules_proto/v4/example/person",
visibility = ["//visibility:public"],
deps = [
"//example/place:place_go_proto",
Expand Down
2 changes: 1 addition & 1 deletion docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ plugins that do things like:
## v3

The way gazelle stored resolve data in memory changed in 0.35. Uprading to this
in https://github.com/stackb/rules_proto/pull/357 was a breaking change.
in https://github.com/stackb/rules_proto/v4/pull/357 was a breaking change.

## v4

Expand Down
6 changes: 3 additions & 3 deletions example/assets/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ proto_library(
proto_compiled_sources(
name = "api_go_compiled_sources",
srcs = ["api.pb.go"],
output_mappings = ["api.pb.go=github.com/stackb/rules_proto/example/assets/api.pb.go"],
output_mappings = ["api.pb.go=github.com/stackb/rules_proto/v4/example/assets/api.pb.go"],
plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
proto = "api_proto",
visibility = ["//visibility:public"],
Expand All @@ -68,7 +68,7 @@ proto_compiled_sources(
proto_compiled_sources(
name = "api_request_go_compiled_sources",
srcs = ["api_request.pb.go"],
output_mappings = ["api_request.pb.go=github.com/stackb/rules_proto/example/assets/api_request.pb.go"],
output_mappings = ["api_request.pb.go=github.com/stackb/rules_proto/v4/example/assets/api_request.pb.go"],
plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
proto = "api_request_proto",
visibility = ["//visibility:public"],
Expand All @@ -77,7 +77,7 @@ proto_compiled_sources(
proto_compiled_sources(
name = "api_response_go_compiled_sources",
srcs = ["api_response.pb.go"],
output_mappings = ["api_response.pb.go=github.com/stackb/rules_proto/example/assets/api_response.pb.go"],
output_mappings = ["api_response.pb.go=github.com/stackb/rules_proto/v4/example/assets/api_response.pb.go"],
plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
proto = "api_response_proto",
visibility = ["//visibility:public"],
Expand Down
2 changes: 1 addition & 1 deletion example/assets/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/assets/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package example.assets;
import "example/assets/api_request.proto";
import "example/assets/api_response.proto";

option go_package = "github.com/stackb/rules_proto/example/assets;assets";
option go_package = "github.com/stackb/rules_proto/v4/example/assets;assets";

// ApiExchange is a demonstrative example of an API call that has a request and
// a response.
Expand Down
2 changes: 1 addition & 1 deletion example/assets/api_request.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/assets/api_request.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ syntax = "proto3";

package example.assets;

option go_package = "github.com/stackb/rules_proto/example/assets;assets";
option go_package = "github.com/stackb/rules_proto/v4/example/assets;assets";

message ApiRequest { repeated string header = 1; }
2 changes: 1 addition & 1 deletion example/assets/api_response.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/assets/api_response.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package example.assets;

option go_package = "github.com/stackb/rules_proto/example/assets;assets";
option go_package = "github.com/stackb/rules_proto/v4/example/assets;assets";

message ApiResponse {
int32 code = 1;
Expand Down
2 changes: 1 addition & 1 deletion example/golden/golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package golden
import (
"testing"

"github.com/stackb/rules_proto/pkg/goldentest"
"github.com/stackb/rules_proto/v4/pkg/goldentest"
)

func TestGoldens(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions example/golden/testdata/mappingsmerge/BUILD.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ proto_library(

proto_compile(
name = "mappingsmerge_go_compile",
output_mappings = ["example.pb.go=github.com/stackb/rules_proto/example/golden/mappingsmerge/example.pb.go"],
output_mappings = ["example.pb.go=github.com/stackb/rules_proto/v4/example/golden/mappingsmerge/example.pb.go"],
outputs = ["example.pb.go"],
plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
proto = "mappingsmerge_proto",
Expand All @@ -30,7 +30,7 @@ proto_compile(
proto_go_library(
name = "mappingsmerge_go_proto",
srcs = ["example.pb.go"],
importpath = "github.com/stackb/rules_proto/example/golden/mappingsmerge",
importpath = "github.com/stackb/rules_proto/v4/example/golden/mappingsmerge",
visibility = ["//visibility:public"],
deps = [
"@org_golang_google_protobuf//reflect/protoreflect",
Expand Down
6 changes: 3 additions & 3 deletions example/golden/testdata/mappingsmerge/BUILD.out
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ proto_library(
proto_compile(
name = "mappingsmerge_go_compile",
output_mappings = [
"example.pb.go=github.com/stackb/rules_proto/example/golden/mappingsmerge/example.pb.go",
"support.pb.go=github.com/stackb/rules_proto/example/golden/mappingsmerge/support.pb.go",
"example.pb.go=github.com/stackb/rules_proto/v4/example/golden/mappingsmerge/example.pb.go",
"support.pb.go=github.com/stackb/rules_proto/v4/example/golden/mappingsmerge/support.pb.go",
],
outputs = [
"example.pb.go",
Expand All @@ -42,7 +42,7 @@ proto_go_library(
"example.pb.go",
"support.pb.go",
],
importpath = "github.com/stackb/rules_proto/example/golden/mappingsmerge",
importpath = "github.com/stackb/rules_proto/v4/example/golden/mappingsmerge",
visibility = ["//visibility:public"],
deps = [
"@org_golang_google_protobuf//reflect/protoreflect",
Expand Down
2 changes: 1 addition & 1 deletion example/golden/testdata/mappingsmerge/example.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

option go_package = "github.com/stackb/rules_proto/example/golden/mappingsmerge";
option go_package = "github.com/stackb/rules_proto/v4/example/golden/mappingsmerge";

enum Enum{
UNKNOWN = 0;
Expand Down
2 changes: 1 addition & 1 deletion example/golden/testdata/mappingsmerge/support.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

option go_package = "github.com/stackb/rules_proto/example/golden/mappingsmerge";
option go_package = "github.com/stackb/rules_proto/v4/example/golden/mappingsmerge";

message M{}

Expand Down
2 changes: 1 addition & 1 deletion example/golden/testdata/proto_compiled_sources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ The <code>api/v1</code> subdirectory contains a typical proto.

The <code>src/idl</code> subdirectory contains a proto that also uses
<code>strip_import_prefix</code> (see
[#358](https://github.com/stackb/rules_proto/issues/358)).
[#358](https://github.com/stackb/rules_proto/v4/issues/358)).
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""proto_gazelle_data_test is a regression test.

See https://github.com/stackb/rules_proto/issues/342.
See https://github.com/stackb/rules_proto/v4/issues/342.

"""

Expand Down
4 changes: 2 additions & 2 deletions example/person/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ proto_compile(

proto_compile(
name = "person_go_compile",
output_mappings = ["person.pb.go=github.com/stackb/rules_proto/example/person/person.pb.go"],
output_mappings = ["person.pb.go=github.com/stackb/rules_proto/v4/example/person/person.pb.go"],
outputs = ["person.pb.go"],
plugins = ["@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go"],
proto = "person_proto",
Expand All @@ -48,7 +48,7 @@ proto_compile(
proto_go_library(
name = "person_go_proto",
srcs = ["person.pb.go"],
importpath = "github.com/stackb/rules_proto/example/person",
importpath = "github.com/stackb/rules_proto/v4/example/person",
visibility = ["//visibility:public"],
deps = [
"//example/place:place_go_proto",
Expand Down
2 changes: 1 addition & 1 deletion example/person/person.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package example.person;

option go_package = "github.com/stackb/rules_proto/example/person;person";
option go_package = "github.com/stackb/rules_proto/v4/example/person;person";

import "example/place/place.proto";

Expand Down
Loading
Loading