Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Makefile and add help information. exec make help will print e… #301

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

# CONTAINER_TOOL defines the container tool to be used for building images.
# Be aware that the target commands are only tested with Docker which is
# scaffolded by default. However, you might want to replace it to use other
# tools. (i.e. podman)
CONTAINER_TOOL ?= docker

# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
Expand All @@ -14,42 +27,57 @@ ldflags="-X $(VERSION_PKG).Version=$(TAG) -X $(VERSION_PKG).Commit=${GIT_COMMIT}
.PHONY: all
all: build-exporter build-skoop build-controller build-collector build-btfhack build-webconsole

##@ General

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Development

.PHONY: fmt
fmt:
fmt: ## Run go fmt against code.
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code.
go vet ./...

##@ Build

.PHONY: build-exporter
build-exporter:
build-exporter: ## Build exporter binary.
CGO_ENABLED=0 go build -o bin/inspector -ldflags $(ldflags) ./cmd/exporter

.PHONY: build-skoop
build-skoop:
build-skoop: ## Build skoop binary.
CGO_ENABLED=0 go build -o bin/skoop -ldflags $(ldflags) ./cmd/skoop

.PHONY: build-collector
build-collector:
build-collector: ## Build collector binary.
CGO_ENABLED=0 go build -o bin/pod-collector -ldflags $(ldflags) ./cmd/collector

.PHONY: build-controller
build-controller:
build-controller: ## Build controller binary.
go build -o bin/controller -ldflags $(ldflags) ./cmd/controller

.PHONY: build-btfhack
build-btfhack:
build-btfhack: ## Build btfhack binary.
CGO_ENABLED=0 go build -o bin/btfhack -ldflags $(ldflags) ./cmd/btfhack

.PHONY: build-webconsole
build-webconsole:
build-webconsole: ## Build webconsole binary.
cd webui && CGO_ENABLED=0 go build -o ../bin/webconsole -ldflags $(ldflags) .

##@ Dependencies
ifndef ignore-not-found
ignore-not-found = false
endif

.PHONY: generate-bpf
generate-bpf:
generate-bpf: ## Generate bpf.
go generate ./pkg/exporter/probe/...

.PHONY: generate-bpf-in-container
generate-bpf-in-container:
docker run --rm -v $(PWD):/go/src/github.com/alibaba/kubeskoop --workdir /go/src/github.com/alibaba/kubeskoop kubeskoop/bpf-build:go121-clang17 make generate-bpf
generate-bpf-in-container: ## Generate bpf in container.
$(CONTAINER_TOOL) run --rm -v $(PWD):/go/src/github.com/alibaba/kubeskoop --workdir /go/src/github.com/alibaba/kubeskoop kubeskoop/bpf-build:go121-clang17 make generate-bpf
Loading