This repository has been archived by the owner on Aug 23, 2023. It is now read-only.
forked from sonic-net/sonic-telemetry
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
112 lines (94 loc) · 4.8 KB
/
Makefile
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
all: precheck deps telemetry
GO=/usr/local/go/bin/go
TOP_DIR := $(abspath ..)
TELEM_DIR := $(abspath .)
GOFLAGS:=
BUILD_DIR=build
GO_DEP_PATH=$(abspath .)/$(BUILD_DIR)
GO_MGMT_PATH=$(TOP_DIR)/sonic-mgmt-framework
GO_SONIC_TELEMETRY_PATH=$(TOP_DIR)
CVL_GOPATH=$(GO_MGMT_PATH)/build/gopkgs:$(GO_MGMT_PATH):$(GO_MGMT_PATH)/src/cvl/build
GOPATH = $(CVL_GOPATH):$(GO_DEP_PATH):$(GO_MGMT_PATH):/tmp/go:$(GO_SONIC_TELEMETRY_PATH):$(TELEM_DIR)
INSTALL := /usr/bin/install
SRC_FILES=$(shell find . -name '*.go' | grep -v '_test.go' | grep -v '/tests/')
TEST_FILES=$(wildcard *_test.go)
TELEMETRY_TEST_DIR = $(GO_MGMT_PATH)/build/tests/gnmi_server
TELEMETRY_TEST_BIN = $(TELEMETRY_TEST_DIR)/server.test
.PHONY : all precheck deps telemetry clean cleanall check install deinstall
ifdef DEBUG
GOFLAGS += -gcflags="all=-N -l"
endif
all: deps telemetry $(TELEMETRY_TEST_BIN)
precheck:
$(shell mkdir -p $(BUILD_DIR))
deps: $(BUILD_DIR)/.deps
$(BUILD_DIR)/.deps: $(MAKEFILE_LIST)
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/Workiva/go-datastructures/queue
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/openconfig/goyang
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/openconfig/ygot/ygot
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/golang/glog
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/go-redis/redis
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/c9s/goprocinfo/linux
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/golang/protobuf/proto
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/openconfig/gnmi/proto/gnmi
GOPATH=$(GO_DEP_PATH) $(GO) get -u golang.org/x/net/context
GOPATH=$(GO_DEP_PATH) $(GO) get -u google.golang.org/grpc
GOPATH=$(GO_DEP_PATH) $(GO) get -u google.golang.org/grpc/credentials
GOPATH=$(GO_DEP_PATH) $(GO) get -u gopkg.in/go-playground/validator.v9
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/gorilla/mux
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/openconfig/goyang
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/openconfig/ygot/ygot
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/google/gnxi/utils
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/jipanyang/gnxi/utils/xpath
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/jipanyang/gnmi/client/gnmi
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/xeipuuv/gojsonschema
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/openconfig/gnoi/system
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/msteinert/pam
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/dgrijalva/jwt-go
GOPATH=$(GO_DEP_PATH) $(GO) get -u gopkg.in/godbus/dbus.v5
GOPATH=$(GO_DEP_PATH) $(GO) get -u github.com/gogo/protobuf/gogoproto
touch $@
telemetry:$(BUILD_DIR)/telemetry $(BUILD_DIR)/dialout_client_cli $(BUILD_DIR)/gnmi_get $(BUILD_DIR)/gnmi_set $(BUILD_DIR)/gnmi_cli $(BUILD_DIR)/gnoi_client
$(BUILD_DIR)/telemetry:src/telemetry/telemetry.go
@echo "Building $@"
GOPATH=$(GOPATH) $(GO) build $(GOFLAGS) -o $@ $^
$(BUILD_DIR)/dialout_client_cli:src/dialout/dialout_client_cli/dialout_client_cli.go
GOPATH=$(GOPATH) $(GO) build $(GOFLAGS) -o $@ $^
$(BUILD_DIR)/gnmi_get:src/gnmi_clients/gnmi_get.go
GOPATH=$(GOPATH) $(GO) build $(GOFLAGS) -o $@ $^
$(BUILD_DIR)/gnmi_set:src/gnmi_clients/gnmi_set.go
GOPATH=$(GOPATH) $(GO) build $(GOFLAGS) -o $@ $^
$(BUILD_DIR)/gnmi_cli:src/gnmi_clients/src/github.com/openconfig/gnmi
GOPATH=$(PWD)/src/gnmi_clients:$(GOPATH) $(GO) build $(GOFLAGS) -o $@ github.com/openconfig/gnmi/cmd/gnmi_cli
$(BUILD_DIR)/gnoi_client:src/gnmi_clients/gnoi_client.go
GOPATH=$(PWD)/src/gnmi_clients:$(GOPATH) $(GO) build $(GOFLAGS) -o $@ $^
clean:
rm -rf $(BUILD_DIR)/telemetry
rm -rf $(TELEMETRY_TEST_DIR)
cleanall:
rm -rf $(BUILD_DIR)
rm -rf $(TELEMETRY_TEST_DIR)
check:
-$(GO) test -v ${GOPATH}/src/gnmi_server
$(TELEMETRY_TEST_BIN): $(TEST_FILES) $(SRC_FILES)
GOPATH=$(GOPATH) $(GO) test -c -cover gnmi_server -o $@
cp -r src/testdata $(TELEMETRY_TEST_DIR)
cp test/01_create_MyACL1_MyACL2.json $(TELEMETRY_TEST_DIR)
cp -r $(GO_MGMT_PATH)/debian/sonic-mgmt-framework/usr/sbin/schema $(TELEMETRY_TEST_DIR)
install:
$(INSTALL) -D $(BUILD_DIR)/telemetry $(DESTDIR)/usr/sbin/telemetry
$(INSTALL) -D $(BUILD_DIR)/dialout_client_cli $(DESTDIR)/usr/sbin/dialout_client_cli
$(INSTALL) -D $(BUILD_DIR)/gnmi_get $(DESTDIR)/usr/sbin/gnmi_get
$(INSTALL) -D $(BUILD_DIR)/gnmi_set $(DESTDIR)/usr/sbin/gnmi_set
$(INSTALL) -D $(BUILD_DIR)/gnmi_cli $(DESTDIR)/usr/sbin/gnmi_cli
$(INSTALL) -D $(BUILD_DIR)/gnoi_client $(DESTDIR)/usr/sbin/gnoi_client
mkdir -p $(DESTDIR)/usr/bin/
cp -r $(GO_MGMT_PATH)/debian/sonic-mgmt-framework/usr/sbin/schema $(DESTDIR)/usr/sbin
cp -r $(GO_MGMT_PATH)/debian/sonic-mgmt-framework/usr/sbin/schema $(DESTDIR)/usr/bin
cp -r $(GO_MGMT_PATH)/debian/sonic-mgmt-framework/usr/models $(DESTDIR)/usr/
deinstall:
rm $(DESTDIR)/usr/sbin/telemetry
rm $(DESTDIR)/usr/sbin/dialout_client_cli
rm $(DESTDIR)/usr/sbin/gnmi_get
rm $(DESTDIR)/usr/sbin/gnmi_set
rm $(DESTDIR)/usr/sbin/gnoi_client