Skip to content

Commit

Permalink
Handle long filenames on Windows in a few more places. (#2781)
Browse files Browse the repository at this point in the history
C.f. #1382
  • Loading branch information
pmuetschard authored Jan 11, 2021
1 parent 5648239 commit c403e77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions go/tools/builders/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ func simpleName(name string, names map[string]struct{}) (string, error) {
}

func appendFiles(goenv *env, archive string, files []string) error {
archive = abs(archive) // required for long filenames on Windows.

// Create an empty archive if one doesn't already exist.
// In Go 1.16, 'go tool pack r' reports an error if the archive doesn't exist.
// 'go tool pack c' copies export data in addition to creating the archive,
Expand Down
6 changes: 6 additions & 0 deletions go/tools/builders/protoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
)

Expand Down Expand Up @@ -77,6 +78,11 @@ func run(args []string) error {
for _, m := range imports {
options = append(options, fmt.Sprintf("M%v", m))
}
if runtime.GOOS == "windows" {
// Turn the plugin path into raw form, since we're handing it off to a non-go binary.
// This is required to work with long paths on Windows.
*plugin = "\\\\?\\" + abs(*plugin)
}
protoc_args := []string{
fmt.Sprintf("--%v_out=%v:%v", pluginName, strings.Join(options, ","), tmpDir),
"--plugin", fmt.Sprintf("%v=%v", strings.TrimSuffix(pluginBase, ".exe"), *plugin),
Expand Down

0 comments on commit c403e77

Please sign in to comment.