-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (47 loc) · 1.19 KB
/
Copy pathMakefile
File metadata and controls
60 lines (47 loc) · 1.19 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
59
60
# SPDX-FileCopyrightText: 2024 Tobias Böhm <code@aibor.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
MAKEFLAGS := --no-builtin-rules
.ONESHELL:
BIN_DIR ?= bin
BPF_PACKAGE_DIR := ./internal/bpf
BINARY ?= $(BIN_DIR)/exceed2go
PIDONETEST_KERNEL ?= test-kernel
BPF2GO_FILE := $(BPF_PACKAGE_DIR)/exceed2go_bpfel.go
build: $(BINARY)
bpf: $(BPF2GO_FILE)
$(BINARY): $(shell find . -name '*.go' ! -name '*_test.go') $(BPF2GO_FILE)
CGO_ENABLED=0 go build -o "$@"
$(BPF2GO_FILE): $(wildcard bpf/*) $(wildcard bpf/libbpf/*) Makefile
cd ./internal/bpf
go generate .
llvm-objdump \
--source \
--no-show-raw-insn \
-g \
$(patsubst %.go,%.o,$(@F)) \
> $(patsubst %.go,%.dump,$(@F))
.PHONY: pidonetest
pidonetest: $(BPF2GO_FILE)
CGO_ENABLED=1 go test \
-exec "go tool virtrun \
-kernel $$(realpath $(PIDONETEST_KERNEL))" \
-v \
-race \
-coverpkg $$(go list ./... | tr '\n' ,) \
-cover \
-covermode atomic \
-coverprofile /tmp/cover.out \
$(PIDONETEST_FLAGS) \
./...
.PHONY: clean
clean:
@rm -frv \
$(BINARY)
.PHONY: cleangen
cleangen:
@rm -frv \
$(BPF2GO_FILE) \
$(patsubst %.go,%.dump,$(BPF2GO_FILE)) \
$(patsubst %.go,%.o,$(BPF2GO_FILE)) \
$(BPF_PACKAGE_DIR)/*_string.go