Skip to content

Commit 50a8591

Browse files
committed
all: build Windows protoc-gen-go as a .exe in a zip
Add a .exe suffix to the protoc-gen-go Windows binary. Use zip instead of tar for the Windows release archive. Fixes golang/protobuf#1323 Change-Id: If42fa6dfd8b5496148310fa2a3359161f1124229 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/321530 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
1 parent 24d799b commit 50a8591

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

integration_test.go

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package main
88

99
import (
1010
"archive/tar"
11+
"archive/zip"
1112
"bytes"
1213
"compress/gzip"
1314
"crypto/sha256"
@@ -392,18 +393,31 @@ func mustHandleFlags(t *testing.T) {
392393
t.Fatal(err)
393394
}
394395
out := new(bytes.Buffer)
395-
gz, _ := gzip.NewWriterLevel(out, gzip.BestCompression)
396-
gz.Comment = fmt.Sprintf("protoc-gen-go VERSION=%v GOOS=%v GOARCH=%v", v, goos, goarch)
397-
tw := tar.NewWriter(gz)
398-
tw.WriteHeader(&tar.Header{
399-
Name: "protoc-gen-go",
400-
Mode: int64(0775),
401-
Size: int64(len(in)),
402-
})
403-
tw.Write(in)
404-
tw.Close()
405-
gz.Close()
406-
if err := ioutil.WriteFile(binPath+".tar.gz", out.Bytes(), 0664); err != nil {
396+
suffix := ""
397+
comment := fmt.Sprintf("protoc-gen-go VERSION=%v GOOS=%v GOARCH=%v", v, goos, goarch)
398+
switch goos {
399+
case "windows":
400+
suffix = ".zip"
401+
zw := zip.NewWriter(out)
402+
zw.SetComment(comment)
403+
fw, _ := zw.Create("protoc-gen-go.exe")
404+
fw.Write(in)
405+
zw.Close()
406+
default:
407+
suffix = ".tar.gz"
408+
gz, _ := gzip.NewWriterLevel(out, gzip.BestCompression)
409+
gz.Comment = comment
410+
tw := tar.NewWriter(gz)
411+
tw.WriteHeader(&tar.Header{
412+
Name: "protoc-gen-go",
413+
Mode: int64(0775),
414+
Size: int64(len(in)),
415+
})
416+
tw.Write(in)
417+
tw.Close()
418+
gz.Close()
419+
}
420+
if err := ioutil.WriteFile(binPath+suffix, out.Bytes(), 0664); err != nil {
407421
t.Fatal(err)
408422
}
409423
}

0 commit comments

Comments
 (0)