-
Notifications
You must be signed in to change notification settings - Fork 43
/
Makefile
102 lines (82 loc) · 3.86 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
GIT_VERSION := 3.8.4
VERSION := 3.8.4
GO_PREFIX := github.com/carbonblack/cb-event-forwarder
EL_VERSION := $(shell rpm -E %{rhel})
TARGET_OS=linux
RABBITMQ_SALT_INTERNAL := ${RABBITMQ_SALT}
export GO111MODULE=auto
.PHONY: clean test rpmbuild rpminstall build rpm check-env
cb-event-forwarder: build
check-env:
ifndef RABBITMQ_SALT
$(error RABBITMQ_SALT is not defined)
endif
getdeps:
go mod download -x
easyjson:
go get github.com/mailru/easyjson/...
generateeasyjsonmodels: easyjson
cd pkg/protobufmessageprocessor ; easyjson -all protobuf_json_structs.go
protocgengo:
go install google.golang.org/protobuf/cmd/protoc-gen-go
compile-protobufs: protocgengo
protoc --go_out=. pkg/sensorevents/sensor_events.proto
format:
go fmt cmd/cb-event-forwarder/*.go
build-no-static: compile-protobufs format
go build ./cmd/cb-event-forwarder
go build ./cmd/kafka-util
go build ./cmd/go-serviced
build:
go build -tags static ./cmd/cb-event-forwarder
go build -tags static ./cmd/kafka-util
go build -tags static ./cmd/go-serviced
rpmbuild: check-env
go build -tags static -ldflags "-X 'main.version=${VERSION}' -X 'main.rabbitMQSalt=${RABBITMQ_SALT_INTERNAL}'" ./cmd/cb-event-forwarder
go build -tags static -ldflags "-X 'main.version=${VERSION}'" ./cmd/kafka-util
go build -tags static -ldflags "-X 'main.version=${VERSION}'" ./cmd/go-serviced
rpminstall:
mkdir -p ${RPM_BUILD_ROOT}/usr/share/cb/integrations/event-forwarder
cp -p cb-event-forwarder ${RPM_BUILD_ROOT}/usr/share/cb/integrations/event-forwarder/cb-event-forwarder
cp -p kafka-util ${RPM_BUILD_ROOT}/usr/share/cb/integrations/event-forwarder/kafka-util
cp -p go-serviced ${RPM_BUILD_ROOT}/usr/share/cb/integrations/event-forwarder/go-serviced
cp -p cb-edr-fix-permissions.sh ${RPM_BUILD_ROOT}/usr/share/cb/integrations/event-forwarder/cb-edr-fix-permissions.sh
mkdir -p ${RPM_BUILD_ROOT}/etc/cb/integrations/event-forwarder
cp -p conf/cb-event-forwarder.example.ini ${RPM_BUILD_ROOT}/etc/cb/integrations/event-forwarder/cb-event-forwarder.conf
ifeq (${EL_VERSION},6)
mkdir -p ${RPM_BUILD_ROOT}/etc/init.d
cp -p init-scripts/cb-event-forwarder ${RPM_BUILD_ROOT}/etc/init.d/cb-event-forwarder
chmod 755 ${RPM_BUILD_ROOT}/etc/init.d/cb-event-forwarder
else
mkdir -p ${RPM_BUILD_ROOT}/etc/systemd/system
cp -p cb-event-forwarder.service ${RPM_BUILD_ROOT}/etc/systemd/system/cb-event-forwarder.service
endif
mkdir -p ${RPM_BUILD_ROOT}/usr/share/cb/integrations/event-forwarder/content
cp -rp static/* ${RPM_BUILD_ROOT}/usr/share/cb/integrations/event-forwarder/content
unittest: compile-protobufs
go test ./cmd/cb-event-forwarder
test: unittest
rm -rf test_output
rm -rf test_output_old
mkdir -p test_output/gold_output
python test/scripts/process_events_python.py test/raw_data test_output/gold_output
PYTHONIOENCODING=utf8 python test/scripts/compare_outputs.py test_output/gold_output test_output/go_output > test_output/output.txt
clean:
rm -f cb-event-forwarder
rm -rf test_output
rm -rf test_output_old
rm -rf dist
rm -rf build
rm -f VERSION
bench:
go test -bench=. ./cmd/cb-event-forwarder/
sdist:
mkdir -p ${RPM_OUTPUT_DIR}/SOURCES/cb-event-forwarder-${GIT_VERSION}/src/${GO_PREFIX}
echo "${GIT_VERSION}" > ${RPM_OUTPUT_DIR}/SOURCES/cb-event-forwarder-${GIT_VERSION}/VERSION
cp -rp cb-edr-fix-permissions.sh cb-event-forwarder.service pkg Makefile go.mod cmd static conf init-scripts ${RPM_OUTPUT_DIR}/SOURCES/cb-event-forwarder-${GIT_VERSION}/src/${GO_PREFIX}
cp -rp MANIFEST${EL_VERSION} ${RPM_OUTPUT_DIR}/SOURCES/cb-event-forwarder-${GIT_VERSION}/MANIFEST
cd ${RPM_OUTPUT_DIR}/SOURCES ; tar -cz -f cb-event-forwarder-${GIT_VERSION}.tar.gz cb-event-forwarder-${GIT_VERSION} ; cd ..
rpm: sdist
rpmbuild --define '_topdir ${RPM_OUTPUT_DIR}' --define 'version ${GIT_VERSION}' --define 'release 1' -bb cb-event-forwarder.rpm.spec
critic:
gocritic check -enableAll -disable='#experimental,#opinionated' ./cmd/cb-event-forwarder/*.go