Skip to content

Commit

Permalink
Build with trace only if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwinger233 committed Jan 21, 2024
1 parent d36ba14 commit fe5d8f2
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ outline.json
go-mod/
node_modules/
*.log
.build_tags
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "control/kern/headers"]
path = control/kern/headers
url = https://github.com/daeuniverse/dae_bpf_headers
[submodule "trace/kern/headers"]
path = trace/kern/headers
url = https://github.com/daeuniverse/dae_bpf_headers
1 change: 1 addition & 0 deletions .gitmodules.d.mk
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
submodule_paths=control/kern/headers
submodule_paths=trace/kern/headers
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ MAX_MATCH_SET_LEN ?= 64
CFLAGS := -DMAX_MATCH_SET_LEN=$(MAX_MATCH_SET_LEN) $(CFLAGS)
NOSTRIP ?= n
STRIP_PATH := $(shell command -v $(STRIP) 2>/dev/null)
BUILD_TAGS_FILE := .build_tags
ifeq ($(strip $(NOSTRIP)),y)
STRIP_FLAG := -no-strip
else ifeq ($(wildcard $(STRIP_PATH)),)
Expand Down Expand Up @@ -47,7 +48,7 @@ dae: export CGO_ENABLED=0
endif
dae: ebpf
@echo $(CFLAGS)
go build -o $(OUTPUT) $(BUILD_ARGS) .
go build -tags=$(shell cat $(BUILD_TAGS_FILE)) -o $(OUTPUT) $(BUILD_ARGS) .
## End Dae Build

## Begin Git Submodules
Expand All @@ -74,6 +75,8 @@ submodule submodules: $(submodule_paths)
clean-ebpf:
@rm -f control/bpf_bpf*.go && \
rm -f control/bpf_bpf*.o
@rm -f trace/bpf_bpf*.go && \
rm -f trace/bpf_bpf*.o
fmt:
go fmt ./...

Expand All @@ -82,10 +85,13 @@ ebpf: export BPF_CLANG := $(CLANG)
ebpf: export BPF_STRIP_FLAG := $(STRIP_FLAG)
ebpf: export BPF_CFLAGS := $(CFLAGS)
ebpf: export BPF_TARGET := $(TARGET)
ebpf: export BPF_TRACE_TARGET := $(GOARCH)
ebpf: submodule clean-ebpf
@unset GOOS && \
unset GOARCH && \
unset GOARM && \
echo $(STRIP_FLAG) && \
go generate ./control/control.go
go generate ./control/control.go && \
go generate ./trace/trace.go && echo trace > $(BUILD_TAGS_FILE) || echo > $(BUILD_TAGS_FILE)

## End Ebpf
3 changes: 3 additions & 0 deletions cmd/trace.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build trace
// +build trace

/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright (c) 2022-2024, daeuniverse Organization <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion control/kern/headers
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/adrg/xdg v0.4.0
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df
github.com/bits-and-blooms/bloom/v3 v3.5.0
github.com/cilium/ebpf v0.11.0
github.com/cilium/ebpf v0.12.3
github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d
github.com/daeuniverse/outbound v0.0.0-20240101085641-7932e7df927d
github.com/daeuniverse/softwind v0.0.0-20231230065827-eed67f20d2c1
Expand All @@ -24,7 +24,7 @@ require (
github.com/x-cray/logrus-prefixed-formatter v0.5.2
golang.org/x/crypto v0.12.0
golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691
golang.org/x/sys v0.11.0
golang.org/x/sys v0.14.1-0.20231108175955-e4099bfacb8c
google.golang.org/protobuf v1.31.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/bits-and-blooms/bloom/v3 v3.5.0 h1:AKDvi1V3xJCmSR6QhcBfHbCN4Vf8FfxeWk
github.com/bits-and-blooms/bloom/v3 v3.5.0/go.mod h1:Y8vrn7nk1tPIlmLtW2ZPV+W7StdVMor6bC1xgpjMZFs=
github.com/cilium/ebpf v0.11.0 h1:V8gS/bTCCjX9uUnkUFUpPsksM8n1lXBAvHcpiFk1X2Y=
github.com/cilium/ebpf v0.11.0/go.mod h1:WE7CZAnqOL2RouJ4f1uyNhqr2P4CCvXFIqdRDUgWsVs=
github.com/cilium/ebpf v0.12.3 h1:8ht6F9MquybnY97at+VDZb3eQQr8ev79RueWeVaEcG4=
github.com/cilium/ebpf v0.12.3/go.mod h1:TctK1ivibvI3znr66ljgi4hqOT8EYQjz1KWBfb1UVgM=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d h1:hnC39MjR7xt5kZjrKlef7DXKFDkiX8MIcDXYC/6Jf9Q=
github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d/go.mod h1:VGWGgv7pCP5WGyHGUyb9+nq/gW0yBm+i/GfCNATOJ1M=
Expand Down Expand Up @@ -198,6 +200,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.1-0.20231108175955-e4099bfacb8c h1:3kC/TjQ+xzIblQv39bCOyRk8fbEeJcDHwbyxPUU2BpA=
golang.org/x/sys v0.14.1-0.20231108175955-e4099bfacb8c/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
2 changes: 1 addition & 1 deletion trace/kern/headers

0 comments on commit fe5d8f2

Please sign in to comment.