Skip to content

Commit 80e5afd

Browse files
author
Steve Ayers
authored
Update to protoc 3.8.0 (uber#459)
* Update to protoc 3.8.0w * Updates to fix breaking change in dependendencies
1 parent 6a473a4 commit 80e5afd

File tree

8 files changed

+72
-14
lines changed

8 files changed

+72
-14
lines changed

docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Recommended base config file:
122122

123123
```yaml
124124
protoc:
125-
version: 3.7.1
125+
version: 3.8.0
126126
lint:
127127
group: uber2
128128
```

docs/faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ prototool cache update
1717
# Cache to a specific directory path/to/cache
1818
prototool cache update --cache-path path/to/cache
1919
# Cache using custom configuration data instead of finding a prototool.yaml file using the file discovery mechanism
20-
prototool cache update --config-data '{"protoc":{"version":"3.7.1"}}'
20+
prototool cache update --config-data '{"protoc":{"version":"3.8.0"}}'
2121
```
2222

2323
There is also a command `prototool cache delete` which will delete all cached assets of

docs/protoc.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ for more details.
2121
- Otherwise, if on Linux, `$HOME/.cache/prototool` will be used, or on Darwin,
2222
`$HOME/Library/Caches/prototool` will be used.
2323

24-
By default, `protoc` version `3.7.1` is downloaded, however this is configurable in your
24+
By default, `protoc` version `3.8.0` is downloaded, however this is configurable in your
2525
`prototool.yaml` file.
2626

2727
```yaml
2828
protoc:
29-
version: 3.7.1
29+
version: 3.8.0
3030
```
3131
3232
Downloads are safe to run concurrently across processes, for example if using from Bazel, as

etc/config/example/prototool.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ excludes:
88
# Protoc directives.
99
protoc:
1010
# The Protobuf version to use from https://github.com/protocolbuffers/protobuf/releases.
11-
# By default use 3.7.1.
11+
# By default use 3.8.0.
1212
# You probably want to set this to make your builds completely reproducible.
13-
version: 3.7.1
13+
version: 3.8.0
1414

1515
# Additional paths to include with -I to protoc.
1616
# By default, the directory of the config file is included,

example/proto/prototool.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
protoc:
2-
version: 3.7.1
2+
version: 3.8.0
33
lint:
44
group: uber2
55
rules:

internal/cmd/cmd_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ func TestCompile(t *testing.T) {
8181
t,
8282
false,
8383
false,
84-
`testdata/compile/extra_import/extra_import.proto:1:1:Import "dep.proto" was not used.`,
84+
`testdata/compile/extra_import/extra_import.proto:6:1:Import "dep.proto" was not used.`,
8585
"testdata/compile/extra_import/extra_import.proto",
8686
)
8787
assertDoCompileFiles(
8888
t,
8989
false,
9090
false,
91-
`testdata/compile/json/json_camel_case_conflict.proto:1:1:The JSON camel-case name of field "helloworld" conflicts with field "helloWorld". This is not allowed in proto3.`,
91+
`testdata/compile/json/json_camel_case_conflict.proto:7:9:The JSON camel-case name of field "helloworld" conflicts with field "helloWorld". This is not allowed in proto3.`,
9292
"testdata/compile/json/json_camel_case_conflict.proto",
9393
)
9494
assertDoCompileFiles(
@@ -110,7 +110,8 @@ func TestCompile(t *testing.T) {
110110
t,
111111
false,
112112
false,
113-
`testdata/compile/recursive/one.proto:1:1:File recursively imports itself one.proto -> two.proto -> one.proto.`,
113+
`testdata/compile/recursive/one.proto:5:1:File recursively imports itself one.proto -> two.proto -> one.proto.
114+
testdata/compile/recursive/one.proto:5:1:Import "two.proto" was not found or had errors.`,
114115
"testdata/compile/recursive/one.proto",
115116
)
116117
assertDoCompileFiles(

internal/protoc/compiler.go

+60-3
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,20 @@ var (
5252
// backup that does not require this to be at the beginning of the line
5353
fullPluginFailedRegexp = regexp.MustCompile("(.*)--.*_out: protoc-gen-(.*): Plugin failed with status code (.*).$")
5454

55-
extraImportRegexp = regexp.MustCompile("^(.*): warning: Import (.*) but not used.$")
55+
// protoc started printing line and column information in 3.8.0
56+
extraImport380Regexp = regexp.MustCompile(`^(.*):(\d+):(\d+): warning: Import (.*) but not used.$`)
57+
extraImportRegexp = regexp.MustCompile("^(.*): warning: Import (.*) but not used.$")
58+
// protoc started printing line and column information in 3.8.0
59+
recursiveImport380Regexp = regexp.MustCompile(`^(.*):(\d+):(\d+): File recursively imports itself: (.*)$`)
5660
recursiveImportRegexp = regexp.MustCompile("^(.*): File recursively imports itself: (.*)$")
5761
directoryDoesNotExistRegexp = regexp.MustCompile("^(.*): warning: directory does not exist.$")
5862
fileNotFoundRegexp = regexp.MustCompile("^(.*): File not found.$")
5963
// protoc outputs both this line and fileNotFound, so we end up ignoring this one
6064
// TODO figure out what the error is for errors in the import
61-
importNotFoundRegexp = regexp.MustCompile("^(.*): Import (.*) was not found or had errors.$")
62-
noSyntaxSpecifiedRegexp = regexp.MustCompile(`No syntax specified for the proto file: (.*)\. Please use`)
65+
importNotFoundRegexp = regexp.MustCompile("^(.*): Import (.*) was not found or had errors.$")
66+
noSyntaxSpecifiedRegexp = regexp.MustCompile(`No syntax specified for the proto file: (.*)\. Please use`)
67+
// protoc started printing line and column information in 3.8.0
68+
jsonCamelCase380Regexp = regexp.MustCompile(`^(.*):(\d+):(\d+): (The JSON camel-case name of field.*)$`)
6369
jsonCamelCaseRegexp = regexp.MustCompile("^(.*): (The JSON camel-case name of field.*)$")
6470
isNotDefinedRegexp = regexp.MustCompile("^(.*): (.*) is not defined.$")
6571
seemsToBeDefinedRegexp = regexp.MustCompile(`^(.*): (".*" seems to be defined in ".*", which is not imported by ".*". To use it here, please add the necessary import.)$`)
@@ -649,6 +655,25 @@ func (c *compiler) parseProtocLine(cmdMeta *cmdMeta, protocLine string) *text.Fa
649655
Message: `No syntax specified. Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version.`,
650656
}
651657
}
658+
if matches := extraImport380Regexp.FindStringSubmatch(protocLine); len(matches) > 4 {
659+
if cmdMeta.protoSet.Config.Compile.AllowUnusedImports {
660+
return nil
661+
}
662+
line, err := strconv.Atoi(matches[2])
663+
if err != nil {
664+
return c.handleUninterpretedProtocLine(protocLine)
665+
}
666+
column, err := strconv.Atoi(matches[3])
667+
if err != nil {
668+
return c.handleUninterpretedProtocLine(protocLine)
669+
}
670+
return &text.Failure{
671+
Filename: bestFilePath(cmdMeta, matches[1]),
672+
Line: line,
673+
Column: column,
674+
Message: fmt.Sprintf(`Import "%s" was not used.`, matches[4]),
675+
}
676+
}
652677
if matches := extraImportRegexp.FindStringSubmatch(protocLine); len(matches) > 2 {
653678
if cmdMeta.protoSet.Config.Compile.AllowUnusedImports {
654679
return nil
@@ -658,6 +683,22 @@ func (c *compiler) parseProtocLine(cmdMeta *cmdMeta, protocLine string) *text.Fa
658683
Message: fmt.Sprintf(`Import "%s" was not used.`, matches[2]),
659684
}
660685
}
686+
if matches := recursiveImport380Regexp.FindStringSubmatch(protocLine); len(matches) > 4 {
687+
line, err := strconv.Atoi(matches[2])
688+
if err != nil {
689+
return c.handleUninterpretedProtocLine(protocLine)
690+
}
691+
column, err := strconv.Atoi(matches[3])
692+
if err != nil {
693+
return c.handleUninterpretedProtocLine(protocLine)
694+
}
695+
return &text.Failure{
696+
Filename: bestFilePath(cmdMeta, matches[1]),
697+
Line: line,
698+
Column: column,
699+
Message: fmt.Sprintf(`File recursively imports itself %s.`, matches[4]),
700+
}
701+
}
661702
if matches := recursiveImportRegexp.FindStringSubmatch(protocLine); len(matches) > 2 {
662703
return &text.Failure{
663704
Filename: bestFilePath(cmdMeta, matches[1]),
@@ -687,6 +728,22 @@ func (c *compiler) parseProtocLine(cmdMeta *cmdMeta, protocLine string) *text.Fa
687728
// see comments at top
688729
return nil
689730
}
731+
if matches := jsonCamelCase380Regexp.FindStringSubmatch(protocLine); len(matches) > 4 {
732+
line, err := strconv.Atoi(matches[2])
733+
if err != nil {
734+
return c.handleUninterpretedProtocLine(protocLine)
735+
}
736+
column, err := strconv.Atoi(matches[3])
737+
if err != nil {
738+
return c.handleUninterpretedProtocLine(protocLine)
739+
}
740+
return &text.Failure{
741+
Filename: bestFilePath(cmdMeta, matches[1]),
742+
Line: line,
743+
Column: column,
744+
Message: matches[4],
745+
}
746+
}
690747
if matches := jsonCamelCaseRegexp.FindStringSubmatch(protocLine); len(matches) > 2 {
691748
return &text.Failure{
692749
Filename: bestFilePath(cmdMeta, matches[1]),

internal/vars/vars.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ const (
2929
// github.com/protocolbuffers/protobuf to use.
3030
//
3131
// See https://github.com/protocolbuffers/protobuf/releases for the latest release.
32-
DefaultProtocVersion = "3.7.1"
32+
DefaultProtocVersion = "3.8.0"
3333
)

0 commit comments

Comments
 (0)