-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
71 lines (58 loc) · 1.73 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
IMAGE_NAME=registry.lab.dynatrace.org/oneagent/oneagent-nettracer:latest
USER=$(shell id -u)
DEBUG?=0
ifeq ($(DEBUG), 1)
BUILD_TYPE=Debug
else
BUILD_TYPE=Release
endif
DOCKER_SUDO=$(shell docker version > /dev/null 2>&1 || echo "sudo")
all: build-image build-project-docker test-project-docker
build-image:
$(DOCKER_SUDO) docker build --network=host \
--build-arg BUILD_TYPE=$(BUILD_TYPE) \
-t $(IMAGE_NAME) .
build-project-docker:
$(DOCKER_SUDO) docker run --rm \
-v $(shell pwd):/opt/mount:z \
$(IMAGE_NAME) \
cp -r /nettracer/build /opt/mount
$(DOCKER_SUDO) chown -R $(USER):$(USER) build
test-project-docker:
$(DOCKER_SUDO) docker run --rm \
-v $(shell pwd):/opt/mount:z \
$(IMAGE_NAME) \
bash -c 'cd /nettracer/build && make run-tests; \
cd /nettracer/build && mkdir -p /opt/mount/build && cp ./Testing/**/Test.xml --parents /opt/mount/build'
dump-bpf-docker:
$(DOCKER_SUDO) docker run --rm \
-v $(shell pwd):/nettracer:z \
--workdir=/nettracer \
$(IMAGE_NAME) \
bash -c 'export PATH="$$(dirname `find / -iname clang -type f`):$$PATH" && \
mkdir -p build && \
cd build && \
cmake -DCMAKE_BUILD_TYPE=Debug \
-DDEBUG_BPF=1
-DKERNEL_VERSION=4.15.0-101-generic .. && \
make bpf_program && \
llvm-objdump -t -S -no-show-raw-insn bin/nettracer-bpf.o'
delete-image:
$(DOCKER_SUDO) docker rmi -f $(IMAGE_NAME)
clean-docker: delete-image clean
build-project:
mkdir -p build && \
cd build && \
cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) .. && \
make -j `nproc`
test-project:
cd build && make run-tests
dump-bpf:
mkdir -p build && \
cd build && \
cmake -DCMAKE_BUILD_TYPE=Debug \
-DDEBUG_BPF=1 .. && \
make bpf_program && \
llvm-objdump -t -S -no-show-raw-insn bin/nettracer-bpf.o
clean:
rm -rf build