Skip to content

Commit 9b249f9

Browse files
committed
Make variables of vprotogen easier to find
1 parent edefca7 commit 9b249f9

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Diff for: infra/vprotogen/main.go

+3-10
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,10 @@ import (
88
"runtime"
99
"strings"
1010

11+
"v2ray.com/core"
1112
"v2ray.com/core/common"
1213
)
1314

14-
var protoFilesUsingProtocGenGoFast = map[string]bool{"proxy/vless/encoding/addons.proto": true}
15-
16-
var protocMap = map[string]string{
17-
"windows": filepath.Join(".dev", "protoc", "windows", "protoc.exe"),
18-
"darwin": filepath.Join(".dev", "protoc", "macos", "protoc"),
19-
"linux": filepath.Join(".dev", "protoc", "linux", "protoc"),
20-
}
21-
2215
func main() {
2316
pwd, wdErr := os.Getwd()
2417
if wdErr != nil {
@@ -27,7 +20,7 @@ func main() {
2720
}
2821

2922
GOBIN := common.GetGOBIN()
30-
protoc := protocMap[runtime.GOOS]
23+
protoc := core.ProtocMap[runtime.GOOS]
3124

3225
protoFilesMap := make(map[string][]string)
3326
walkErr := filepath.Walk("./", func(path string, info os.FileInfo, err error) error {
@@ -56,7 +49,7 @@ func main() {
5649
for _, files := range protoFilesMap {
5750
for _, relProtoFile := range files {
5851
var args []string
59-
if protoFilesUsingProtocGenGoFast[relProtoFile] {
52+
if core.ProtoFilesUsingProtocGenGoFast[relProtoFile] {
6053
args = []string{"--gofast_out", pwd, "--plugin", "protoc-gen-gofast=" + GOBIN + "/protoc-gen-gofast"}
6154
} else {
6255
args = []string{"--go_out", pwd, "--go-grpc_out", pwd, "--plugin", "protoc-gen-go=" + GOBIN + "/protoc-gen-go", "--plugin", "protoc-gen-go-grpc=" + GOBIN + "/protoc-gen-go-grpc"}

Diff for: proto.go

+13
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,16 @@ package core
44
//go:generate go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc
55
//go:generate go install -v github.com/gogo/protobuf/protoc-gen-gofast
66
//go:generate go run ./infra/vprotogen/main.go
7+
8+
import "path/filepath"
9+
10+
// ProtoFilesUsingProtocGenGoFast is the map of Proto files
11+
// that use `protoc-gen-gofast` to generate pb.go files
12+
var ProtoFilesUsingProtocGenGoFast = map[string]bool{"proxy/vless/encoding/addons.proto": true}
13+
14+
// ProtocMap is the map of paths to `protoc` binary excutable files of specific platform
15+
var ProtocMap = map[string]string{
16+
"windows": filepath.Join(".dev", "protoc", "windows", "protoc.exe"),
17+
"darwin": filepath.Join(".dev", "protoc", "macos", "protoc"),
18+
"linux": filepath.Join(".dev", "protoc", "linux", "protoc"),
19+
}

0 commit comments

Comments
 (0)