21
21
# while BSD sed requires an empty string as the following argument.
22
22
SED_INPLACE := sed $(shell sed --version 2>&1 | grep -q GNU && echo -i || echo "-i ''")
23
23
24
- ORG_ROOT := .
25
- REPO_ROOT := $(ORG_ROOT ) /cockroach
26
- PKG_ROOT := $(REPO_ROOT ) /pkg
27
- GITHUB_ROOT := $(REPO_ROOT ) /vendor/github.com
28
- GOGOPROTO_ROOT := $(GITHUB_ROOT ) /gogo/protobuf
29
- PROTOBUF_ROOT := $(GOGOPROTO_ROOT ) /protobuf
24
+ ORG_ROOT := .
25
+ REPO_ROOT := $(ORG_ROOT ) /cockroach
26
+ PKG_ROOT := $(REPO_ROOT ) /pkg
30
27
31
28
NATIVE_ROOT := $(PKG_ROOT ) /storage/engine
29
+ GITHUB_ROOT := $(REPO_ROOT ) /vendor/github.com
32
30
33
31
# Ensure we have an unambiguous GOPATH
34
32
GOPATH := $(realpath $(ORG_ROOT ) /../../..)
35
33
# ^ ^~ GOPATH
36
34
# |~ GOPATH/src
37
35
36
+ GOGO_PROTOBUF_PACKAGE := github.com/gogo/protobuf
37
+ GOGO_PROTOBUF_TYPES_PACKAGE := $(GOGO_PROTOBUF_PACKAGE ) /types
38
+ GOGO_PROTOBUF_PATH := $(GITHUB_ROOT ) /../$(GOGO_PROTOBUF_PACKAGE )
39
+ PROTOBUF_PATH := $(GOGO_PROTOBUF_PATH ) /protobuf
40
+
38
41
GOPATH_BIN := $(GOPATH ) /bin
39
42
PROTOC := $(GOPATH_BIN ) /protoc
40
43
PLUGIN_SUFFIX := gogoroach
41
44
PROTOC_PLUGIN := $(GOPATH_BIN ) /protoc-gen-$(PLUGIN_SUFFIX )
42
- GOGOPROTO_PROTO := $(GOGOPROTO_ROOT ) /gogoproto/gogo.proto
45
+ GOGOPROTO_PROTO := $(GOGO_PROTOBUF_PATH ) /gogoproto/gogo.proto
43
46
44
47
COREOS_PATH := $(GITHUB_ROOT ) /coreos
45
48
COREOS_RAFT_PROTOS := $(addprefix $(COREOS_PATH ) /etcd/raft/, $(sort $(shell git -C $(COREOS_PATH ) /etcd/raft ls-files --exclude-standard --cached --others -- '* .proto') ) )
@@ -48,9 +51,10 @@ GRPC_GATEWAY_PACKAGE := github.com/grpc-ecosystem/grpc-gateway
48
51
GRPC_GATEWAY_GOOGLEAPIS_PACKAGE := $(GRPC_GATEWAY_PACKAGE ) /third_party/googleapis
49
52
GRPC_GATEWAY_GOOGLEAPIS_PATH := $(GITHUB_ROOT ) /../$(GRPC_GATEWAY_GOOGLEAPIS_PACKAGE )
50
53
51
- # Map protobuf includes of annotations.proto to the Go package containing the
52
- # generated Go code.
53
- GRPC_GATEWAY_MAPPING := Mgoogle/api/annotations.proto=$(GRPC_GATEWAY_GOOGLEAPIS_PACKAGE ) /google/api
54
+ # Map protobuf includes to the Go package containing the generated Go code.
55
+ MAPPINGS :=
56
+ MAPPINGS := $(MAPPINGS ) Mgoogle/api/annotations.proto=$(GRPC_GATEWAY_GOOGLEAPIS_PACKAGE ) /google/api,
57
+ MAPPINGS := $(MAPPINGS ) Mgoogle/protobuf/timestamp.proto=$(GOGOPROTO_ROOT ) /protobuf/types,
54
58
55
59
GW_SERVER_PROTOS := $(PKG_ROOT ) /server/serverpb/admin.proto $(PKG_ROOT ) /server/serverpb/status.proto
56
60
GW_TS_PROTOS := $(PKG_ROOT ) /ts/tspb/timeseries.proto
@@ -61,7 +65,9 @@ GW_SOURCES := $(GW_PROTOS:%.proto=%.pb.gw.go)
61
65
GO_PROTOS := $(addprefix $(REPO_ROOT ) /, $(sort $(shell git -C $(REPO_ROOT ) ls-files --exclude-standard --cached --others -- '* .proto') ) )
62
66
GO_SOURCES := $(GO_PROTOS:%.proto=%.pb.go )
63
67
64
- UI_SOURCES := $(PKG_ROOT ) /ui/src/js/protos.js $(PKG_ROOT ) /ui/generated/protos.json $(PKG_ROOT ) /ui/generated/protos.d.ts
68
+ UI_JS := $(PKG_ROOT ) /ui/src/js/protos.js
69
+ UI_TS := $(PKG_ROOT ) /ui/src/js/protos.d.ts
70
+ UI_SOURCES := $(UI_JS ) $(UI_TS )
65
71
66
72
CPP_PROTOS := $(filter % /roachpb/metadata.proto % /roachpb/data.proto % /roachpb/internal.proto % /engine/enginepb/mvcc.proto % /engine/enginepb/rocksdb.proto % /hlc/timestamp.proto % /unresolved_addr.proto,$(GO_PROTOS ) )
67
73
CPP_HEADERS := $(subst ./,$(NATIVE_ROOT ) /,$(CPP_PROTOS:%.proto=%.pb.h ) )
@@ -84,42 +90,36 @@ IMPORT_PREFIX := github.com/$(REPO_NAME)/
84
90
$(GO_SOURCES ) : $(PROTOC ) $(GO_PROTOS ) $(GOGOPROTO_PROTO )
85
91
(cd $( REPO_ROOT) && git ls-files --exclude-standard --cached --others -- ' *.pb.go' | xargs rm -f)
86
92
for dir in $( sort $( dir $( GO_PROTOS) ) ) ; do \
87
- $(PROTOC ) -I.:$(GOGOPROTO_ROOT ) :$(PROTOBUF_ROOT ) :$(COREOS_PATH ) :$(GRPC_GATEWAY_GOOGLEAPIS_PATH ) --plugin=$(PROTOC_PLUGIN ) --$(PLUGIN_SUFFIX ) _out=$(GRPC_GATEWAY_MAPPING ) ,plugins=grpc,import_prefix=$(IMPORT_PREFIX ) :$(ORG_ROOT ) $$ dir/* .proto; \
93
+ $(PROTOC ) -I.:$(GOGO_PROTOBUF_PATH ) :$(PROTOBUF_PATH ) :$(COREOS_PATH ) :$(GRPC_GATEWAY_GOOGLEAPIS_PATH ) --plugin=$(PROTOC_PLUGIN ) --$(PLUGIN_SUFFIX ) _out=$(MAPPINGS ) ,plugins=grpc,import_prefix=$(IMPORT_PREFIX ) :$(ORG_ROOT ) $$ dir/* .proto; \
88
94
done
89
- $(SED_INPLACE ) -E ' /gogoproto/d' $(GO_SOURCES )
95
+ $(SED_INPLACE ) ' /import _/d' $(GO_SOURCES )
96
+ $(SED_INPLACE ) ' /gogoproto/d' $(GO_SOURCES )
90
97
$(SED_INPLACE ) -E ' s!import (fmt|math) "$(IMPORT_PREFIX)(fmt|math)"! !g' $(GO_SOURCES )
91
98
$(SED_INPLACE ) -E ' s!$(IMPORT_PREFIX)(errors|fmt|io|github\.com|golang\.org|google\.golang\.org)!\1!g' $(GO_SOURCES )
92
99
$(SED_INPLACE ) -E ' s!$(REPO_NAME)/(etcd)!coreos/\1!g' $(GO_SOURCES )
93
100
gofmt -s -w $(GO_SOURCES )
94
101
95
102
$(GW_SOURCES ) : $(GW_SERVER_PROTOS ) $(GW_TS_PROTOS ) $(GO_PROTOS ) $(GOGOPROTO_PROTO ) $(PROTOC )
96
103
(cd $( REPO_ROOT) && git ls-files --exclude-standard --cached --others -- ' *.pb.gw.go' | xargs rm -f)
97
- $(PROTOC ) -I.:$(GOGOPROTO_ROOT ) :$(PROTOBUF_ROOT ) :$(COREOS_PATH ) :$(GRPC_GATEWAY_GOOGLEAPIS_PATH ) --grpc-gateway_out=logtostderr=true,request_context=true:. $(GW_SERVER_PROTOS )
98
- $(PROTOC ) -I.:$(GOGOPROTO_ROOT ) :$(PROTOBUF_ROOT ) :$(COREOS_PATH ) :$(GRPC_GATEWAY_GOOGLEAPIS_PATH ) --grpc-gateway_out=logtostderr=true,request_context=true:. $(GW_TS_PROTOS )
99
-
100
- $(REPO_ROOT ) /build/yarn.installed : $(REPO_ROOT ) /build/package.json
101
- cd $(REPO_ROOT ) /build && yarn install
102
- touch $@
104
+ $(PROTOC ) -I.:$(GOGO_PROTOBUF_PATH ) :$(PROTOBUF_PATH ) :$(COREOS_PATH ) :$(GRPC_GATEWAY_GOOGLEAPIS_PATH ) --grpc-gateway_out=logtostderr=true,request_context=true:. $(GW_SERVER_PROTOS )
105
+ $(PROTOC ) -I.:$(GOGO_PROTOBUF_PATH ) :$(PROTOBUF_PATH ) :$(COREOS_PATH ) :$(GRPC_GATEWAY_GOOGLEAPIS_PATH ) --grpc-gateway_out=logtostderr=true,request_context=true:. $(GW_TS_PROTOS )
103
106
104
- PBJS_ARGS = --path $(ORG_ROOT ) --path $(GOGOPROTO_ROOT ) --path $(COREOS_PATH ) --path $(GRPC_GATEWAY_GOOGLEAPIS_PATH ) $(GW_PROTOS )
107
+ $(PKG_ROOT ) /ui/yarn.installed : $(PKG_ROOT ) /ui/package.json $(PKG_ROOT ) /ui/yarn.lock
108
+ $(MAKE ) -C $(PKG_ROOT ) /ui yarn.installed
105
109
106
- $(PKG_ROOT ) /ui/src/js/protos.js : $(REPO_ROOT ) /build/yarn.installed $(GO_PROTOS ) $(COREOS_RAFT_PROTOS )
110
+ $(UI_JS ) : $(GO_PROTOS ) $(COREOS_RAFT_PROTOS ) $(PKG_ROOT ) /ui/yarn.installed
107
111
# Add comment recognized by reviewable.
108
112
echo ' // GENERATED FILE DO NOT EDIT' > $@
109
- $(REPO_ROOT ) /build/node_modules/.bin/pbjs -t commonjs $(PBJS_ARGS ) >> $@
110
-
111
- $(PKG_ROOT ) /ui/generated/protos.json : $(REPO_ROOT ) /build/yarn.installed $(GO_PROTOS ) $(COREOS_RAFT_PROTOS )
112
- $(REPO_ROOT ) /build/node_modules/.bin/pbjs $(PBJS_ARGS ) > $@
113
+ $(REPO_ROOT ) /pkg/ui/node_modules/.bin/pbjs -t static-module -w es6 --strict-long --keep-case --path $(ORG_ROOT ) --path $(GOGO_PROTOBUF_PATH ) --path $(COREOS_PATH ) --path $(GRPC_GATEWAY_GOOGLEAPIS_PATH ) $(GW_PROTOS ) >> $@
113
114
114
- $(PKG_ROOT ) /ui/generated/protos.d.ts : $(PKG_ROOT ) /ui/generated/protos.json
115
+ $(UI_TS ) : $(UI_JS )
115
116
# Add comment recognized by reviewable.
116
117
echo ' // GENERATED FILE DO NOT EDIT' > $@
117
- $(REPO_ROOT ) /build/node_modules/.bin/proto2ts --file $(PKG_ROOT ) /ui/generated/protos.json >> $@
118
- $(SED_INPLACE ) -E ' /delete : string/d' $@ # This line produces a duplicate identifier error. Why?
118
+ $(REPO_ROOT ) /pkg/ui/node_modules/.bin/pbts $(UI_JS ) >> $@
119
119
120
120
$(CPP_HEADERS ) $(CPP_SOURCES ) : $(PROTOC ) $(CPP_PROTOS )
121
121
(cd $( REPO_ROOT) && git ls-files --exclude-standard --cached --others -- ' *.pb.h' ' *.pb.cc' | xargs rm -f)
122
- $(PROTOC ) -I.:$(GOGOPROTO_ROOT ) :$(PROTOBUF_ROOT ) --cpp_out=lite:$(NATIVE_ROOT ) $(CPP_PROTOS )
122
+ $(PROTOC ) -I.:$(GOGO_PROTOBUF_PATH ) :$(PROTOBUF_PATH ) --cpp_out=lite:$(NATIVE_ROOT ) $(CPP_PROTOS )
123
123
$(SED_INPLACE ) -E ' /gogoproto/d' $(CPP_HEADERS ) $(CPP_SOURCES )
124
124
@# For c++, protoc generates a directory structure mirroring the package
125
125
@# structure (and these directories must be in the include path), but cgo can
0 commit comments