Explorar o código

remove old protogen

Darien Raymond %!s(int64=7) %!d(string=hai) anos
pai
achega
e8cad4a126
Modificáronse 2 ficheiros con 0 adicións e 103 borrados
  1. 0 7
      tools/genproto/genproto.go
  2. 0 96
      tools/genproto/main.go

+ 0 - 7
tools/genproto/genproto.go

@@ -1,7 +0,0 @@
-// +build windows darwin linux
-
-package genproto
-
-//go:generate go get -u "github.com/golang/protobuf/protoc-gen-go"
-//go:generate go get -u "github.com/golang/protobuf/proto"
-//go:generate go run main.go

+ 0 - 96
tools/genproto/main.go

@@ -1,96 +0,0 @@
-// +build generate
-
-package main
-
-import (
-	"bytes"
-	"fmt"
-	"io/ioutil"
-	"os"
-	"os/exec"
-	"path/filepath"
-	"runtime"
-	"strings"
-
-	"v2ray.com/core/common"
-)
-
-var protocMap = map[string]string{
-	"windows": filepath.Join(os.Getenv("GOPATH"), "src", "v2ray.com", "core", ".dev", "protoc", "windows", "protoc.exe"),
-	"darwin":  filepath.Join(os.Getenv("GOPATH"), "src", "v2ray.com", "core", ".dev", "protoc", "macos", "protoc"),
-	"linux":   filepath.Join(os.Getenv("GOPATH"), "src", "v2ray.com", "core", ".dev", "protoc", "linux", "protoc"),
-}
-
-func sdkPath(lang string) string {
-	path := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "v2ray", "sdk-"+lang, "proto")
-	os.MkdirAll(path, os.ModePerm)
-	return path
-}
-
-func main() {
-	protofiles := make(map[string][]string)
-	protoc := protocMap[runtime.GOOS]
-	gosrc := filepath.Join(os.Getenv("GOPATH"), "src")
-	reporoot := filepath.Join(gosrc, "v2ray.com", "core")
-
-	filepath.Walk(reporoot, func(path string, info os.FileInfo, err error) error {
-		if err != nil {
-			fmt.Println(err)
-			return err
-		}
-
-		if info.IsDir() {
-			return nil
-		}
-
-		dir := filepath.Dir(path)
-		filename := filepath.Base(path)
-		if strings.HasSuffix(filename, ".proto") {
-			protofiles[dir] = append(protofiles[dir], path)
-		}
-
-		return nil
-	})
-
-	for _, files := range protofiles {
-		args := []string{"--proto_path", gosrc, "--go_out", gosrc, "--java_out", sdkPath("java")}
-		args = append(args, files...)
-		cmd := exec.Command(protoc, args...)
-		cmd.Env = append(cmd.Env, os.Environ()...)
-		output, err := cmd.CombinedOutput()
-		if len(output) > 0 {
-			fmt.Println(string(output))
-		}
-		if err != nil {
-			fmt.Println(err)
-		}
-	}
-
-	common.Must(filepath.Walk(reporoot, func(path string, info os.FileInfo, err error) error {
-		if err != nil {
-			fmt.Println(err)
-			return err
-		}
-
-		if info.IsDir() {
-			return nil
-		}
-
-		if !strings.HasSuffix(info.Name(), ".pb.go") {
-			return nil
-		}
-
-		content, err := ioutil.ReadFile(path)
-		if err != nil {
-			return err
-		}
-		pos := bytes.Index(content, []byte("\npackage"))
-		if pos > 0 {
-			if err := ioutil.WriteFile(path, content[pos+1:], info.Mode()); err != nil {
-				return err
-			}
-		}
-
-		return nil
-	}))
-}