Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: tools/cmd/cproto/main.go

Issue 1571393006: server/discovery: add discovery service (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@prpc-server
Patch Set: rebased Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « server/prpc/pb.discovery_test.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "flag" 8 "flag"
9 "fmt" 9 "fmt"
10 "go/build" 10 "go/build"
11 "io/ioutil" 11 "io/ioutil"
12 "os" 12 "os"
13 "os/exec" 13 "os/exec"
14 "path" 14 "path"
15 "path/filepath" 15 "path/filepath"
16 "strings" 16 "strings"
17 "syscall" 17 "syscall"
18 18
19 "github.com/luci/luci-go/common/logging" 19 "github.com/luci/luci-go/common/logging"
20 "github.com/luci/luci-go/common/logging/gologger" 20 "github.com/luci/luci-go/common/logging/gologger"
21 gol "github.com/op/go-logging" 21 gol "github.com/op/go-logging"
22 "golang.org/x/net/context" 22 "golang.org/x/net/context"
23 ) 23 )
24 24
25 var ( 25 var (
26 » verbose = flag.Bool("verbose", false, "print debug messages to stderr ") 26 » verbose = flag.Bool("verbose", false, "print debug messages to std err")
27 » withDiscovery = flag.Bool(
28 » » "discovery", true,
29 » » "generate pb.discovery.go file")
27 withGithub = flag.Bool( 30 withGithub = flag.Bool(
28 "with-github", true, 31 "with-github", true,
29 "include $GOPATH/src/github.com in proto search path") 32 "include $GOPATH/src/github.com in proto search path")
30 withGoogleProtobuf = flag.Bool( 33 withGoogleProtobuf = flag.Bool(
31 "with-google-protobuf", true, 34 "with-google-protobuf", true,
32 "map .proto files in gitub.com/luci/luci-go/common/proto/google to google/protobuf/*.proto") 35 "map .proto files in gitub.com/luci/luci-go/common/proto/google to google/protobuf/*.proto")
33 renameToTestGo = flag.Bool( 36 renameToTestGo = flag.Bool(
34 "test", false, 37 "test", false,
35 "rename generated files from *.go to *_test.go") 38 "rename generated files from *.go to *_test.go")
36 ) 39 )
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 152 }
150 153
151 if *renameToTestGo { 154 if *renameToTestGo {
152 newName := strings.TrimSuffix(goFile, ".go") + "_test.go " 155 newName := strings.TrimSuffix(goFile, ".go") + "_test.go "
153 if err := os.Rename(goFile, newName); err != nil { 156 if err := os.Rename(goFile, newName); err != nil {
154 return err 157 return err
155 } 158 }
156 } 159 }
157 } 160 }
158 161
162 if !*withDiscovery {
163 return nil
164 }
159 // Generate pb.prpc.go 165 // Generate pb.prpc.go
160 discoveryFile := "pb.discovery.go" 166 discoveryFile := "pb.discovery.go"
161 if *renameToTestGo { 167 if *renameToTestGo {
162 discoveryFile = "pb.discovery_test.go" 168 discoveryFile = "pb.discovery_test.go"
163 } 169 }
164 return genDiscoveryFile(c, filepath.Join(dir, discoveryFile), descPath, packageName) 170 return genDiscoveryFile(c, filepath.Join(dir, discoveryFile), descPath, packageName)
165 } 171 }
166 172
167 func setupLogging(c context.Context) context.Context { 173 func setupLogging(c context.Context) context.Context {
168 logCfg := gologger.LoggerConfig{ 174 logCfg := gologger.LoggerConfig{
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 src := strings.TrimSuffix(dir, pkg) 237 src := strings.TrimSuffix(dir, pkg)
232 src = path.Clean(src) 238 src = path.Clean(src)
233 goPaths := strings.Split(os.Getenv("GOPATH"), string(filepath.ListSepara tor)) 239 goPaths := strings.Split(os.Getenv("GOPATH"), string(filepath.ListSepara tor))
234 for _, goPath := range goPaths { 240 for _, goPath := range goPaths {
235 if filepath.Join(goPath, "src") == src { 241 if filepath.Join(goPath, "src") == src {
236 return true, nil 242 return true, nil
237 } 243 }
238 } 244 }
239 return false, nil 245 return false, nil
240 } 246 }
OLDNEW
« no previous file with comments | « server/prpc/pb.discovery_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698