-
-
Notifications
You must be signed in to change notification settings - Fork 414
Expand file tree
/
Copy pathproto.mk
More file actions
58 lines (48 loc) · 2.47 KB
/
Copy pathproto.mk
File metadata and controls
58 lines (48 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
define PROTOC_GEN
go install google.golang.org/protobuf/cmd/protoc-gen-go
protoc -I. -Iflow/layers --go_out $$GOPATH/src $1
endef
GEN_PROTO_FILES = $(patsubst %.proto,%.pb.go,$(shell find . -name *.proto | grep -v ^./vendor))
%.pb.go: %.proto
$(call PROTOC_GEN,$<)
flow/flow.pb.go: flow/flow.proto graffiti/filters/filters.proto
$(call PROTOC_GEN,flow/flow.proto)
# always export flow.ParentUUID as we need to store this information to know
# if it's a Outer or Inner packet.
sed -e 's/ParentUUID\(.*\),omitempty\(.*\)/ParentUUID\1\2/' \
-e 's/Protocol\(.*\),omitempty\(.*\)/Protocol\1\2/' \
-e 's/ICMPType\(.*\),omitempty\(.*\)/ICMPType\1\2/' \
-e 's/int64\(.*\),omitempty\(.*\)/int64\1\2/' \
-i $@
# add omitempty to RTT as it is not always filled
sed -e 's/json:"RTT"/json:"RTT,omitempty"/' -i $@
# do not export LastRawPackets used internally
sed -e 's/json:"LastRawPackets,omitempty"/json:"-"/g' -i $@
# add flowState to flow generated struct
sed -e 's/type Flow struct {/type Flow struct { XXX_state flowState `json:"-"`/' -i $@
# to fix generated layers import
sed -e 's/layers "flow\/layers"/layers "github.com\/skydive-project\/skydive\/flow\/layers"/' -i $@
sed -e 's/type FlowMetric struct {/\/\/ gendecoder\ntype FlowMetric struct {/' -i $@
sed -e 's/type FlowLayer struct {/\/\/ gendecoder\ntype FlowLayer struct {/' -i $@
sed -e 's/type TransportLayer struct {/\/\/ gendecoder\ntype TransportLayer struct {/' -i $@
sed -e 's/type ICMPLayer struct {/\/\/ gendecoder\ntype ICMPLayer struct {/' -i $@
sed -e 's/type IPMetric struct {/\/\/ gendecoder\ntype IPMetric struct {/' -i $@
sed -e 's/type TCPMetric struct {/\/\/ gendecoder\ntype TCPMetric struct {/' -i $@
# This is to allow calling go generate on flow/flow.pb.go
sed -e 's/DO NOT EDIT./DO NOT MODIFY/' -i $@
sed '1 i //go:generate go run github.com/skydive-project/skydive/graffiti/gendecoder' -i $@
gofmt -s -w $@
flow/flow.pb_easyjson.go: flow/flow.pb.go
go run github.com/mailru/easyjson/easyjson -all $<
graffiti/websocket/structmessage.pb.go: graffiti/websocket/structmessage.proto
$(call PROTOC_GEN,$<)
sed -e 's/type StructMessage struct {/type StructMessage struct { XXX_state structMessageState `json:"-"`/' -i graffiti/websocket/structmessage.pb.go
gofmt -s -w $@
.proto: $(GEN_PROTO_FILES)
.PHONY: .proto.touch
.proto.touch:
@echo $(GEN_PROTO_FILES) | xargs touch
.PHONY: .proto.clean
.proto.clean:
find . \( -name *.pb.go ! -path './vendor/*' \) -exec rm {} \;
rm -rf flow/layers/generated.proto