github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/Makefile (about) 1 GOBUILD=go build -trimpath 2 3 ARCH ?= $(shell uname -m) 4 OS ?= $(shell uname) 5 6 7 # if you change the name of this variable please change it in generate-git-info.sh file 8 PHPSPY_VERSION ?= 66b6fdb2f9da1d87912b46b7faf68796d471c209 9 10 ifeq ("$(OS)", "Darwin") 11 ifeq ("$(ARCH)", "arm64") 12 # on a mac it's called arm64 which rust doesn't know about 13 # see https://unix.stackexchange.com/questions/461179/what-is-the-difference-between-different-implemetation-of-arm64-aarch64-for-linu 14 ARCH=aarch64 15 # this makes it work better on M1 machines 16 GODEBUG=asyncpreemptoff=1 17 endif 18 endif 19 20 ALL_SPIES = ebpfspy,dotnetspy,phpspy,debugspy 21 ifeq ("$(OS)", "Linux") 22 ENABLED_SPIES_RELEASE ?= ebpfspy,phpspy,dotnetspy 23 else 24 ENABLED_SPIES_RELEASE ?= dotnetspy 25 endif 26 ENABLED_SPIES ?= none 27 28 ifeq ("$(OS)", "Linux") 29 THIRD_PARTY_DEPENDENCIES ?= "build-phpspy-dependencies" 30 else 31 THIRD_PARTY_DEPENDENCIES ?= "" 32 endif 33 34 EXTRA_GO_TAGS ?= 35 CGO_CFLAGS ?= 36 CGO_LDFLAGS ?= 37 EXTRA_CGO_CFLAGS ?= 38 EXTRA_CGO_LDFLAGS ?= 39 GO_TAGS = $(ENABLED_SPIES)$(EXTRA_GO_TAGS) 40 ALPINE_TAG = 41 42 ifneq (,$(findstring ebpfspy,$(GO_TAGS))) 43 EXTRA_CGO_CFLAGS := $(EXTRA_CGO_CFLAGS) -I$(abspath ./third_party/libbpf/lib/include) \ 44 -I$(abspath ./third_party/bcc/lib/include) 45 EXTRA_CGO_LDFLAGS := $(EXTRA_CGO_LDFLAGS) -L$(abspath ./third_party/libbpf/lib/lib64) -lbpf \ 46 -L$(abspath ./third_party/bcc/lib/lib) -lbcc-syms -lstdc++ -lelf -lz 47 THIRD_PARTY_DEPENDENCIES := $(THIRD_PARTY_DEPENDENCIES) build-profile-bpf build-bcc build-libbpf 48 endif 49 50 ifeq ("$(OS)", "Linux") 51 ifeq ("$(shell cat /etc/os-release | grep ^ID=)", "ID=alpine") 52 GO_TAGS := $(GO_TAGS),musl 53 ALPINE_TAG := ,musl 54 else 55 56 endif 57 else 58 ifeq ("$(OS)", "Darwin") 59 60 endif 61 endif 62 63 OPEN= 64 ifeq ("$(OS)", "Linux") 65 OPEN=xdg-open 66 else 67 OPEN=open 68 endif 69 70 EMBEDDED_ASSETS_DEPS ?= "assets-release" 71 EXTRA_LDFLAGS ?= 72 73 ifndef $(GOPATH) 74 GOPATH=$(shell go env GOPATH || true) 75 export GOPATH 76 endif 77 78 -include .env 79 export 80 81 PYROSCOPE_LOG_LEVEL ?= debug 82 PYROSCOPE_BADGER_LOG_LEVEL ?= error 83 PYROSCOPE_STORAGE_PATH ?= tmp/pyroscope-storage 84 85 .PHONY: all 86 all: build ## Runs the build target 87 88 .PHONY: build-phpspy-static-library 89 build-phpspy-static-library: ## builds phpspy static library 90 mkdir -p ./out 91 $(GOBUILD) -tags nogospy,phpspy,clib$(ALPINE_TAG) -ldflags "$(shell scripts/generate-build-flags.sh false)" -buildmode=c-archive -o "./out/libpyroscope.phpspy.a" ./pkg/agent/clib 92 ifeq ("$(OS)", "Linux") 93 LC_CTYPE=C LANG=C strip --strip-debug ./out/libpyroscope.phpspy.a 94 ranlib ./out/libpyroscope.phpspy.a 95 endif 96 97 .PHONY: install-go-dependencies 98 install-go-dependencies: ## installs golang dependencies 99 go mod download 100 101 .PHONY: build 102 build: ## Builds the binary 103 CGO_CFLAGS="$(CGO_CFLAGS) $(EXTRA_CGO_CFLAGS)" \ 104 CGO_LDFLAGS="$(CGO_LDFLAGS) $(EXTRA_CGO_LDFLAGS)" \ 105 $(GOBUILD) -tags "$(GO_TAGS)" -ldflags "$(EXTRA_LDFLAGS) $(shell scripts/generate-build-flags.sh)" -o ./bin/pyroscope ./cmd/pyroscope 106 107 .PHONY: build-release 108 build-release: embedded-assets ## Builds the release build 109 EXTRA_GO_TAGS=,embedassets,$(ENABLED_SPIES_RELEASE) $(MAKE) build 110 111 .PHONY: build-panel 112 build-panel: 113 NODE_ENV=production $(shell yarn bin webpack) --config scripts/webpack/webpack.panel.js 114 115 .PHONY: build-phpspy-dependencies 116 build-phpspy-dependencies: ## Builds the PHP dependency 117 cd third_party && cd phpspy_src || (git clone https://github.com/pyroscope-io/phpspy.git phpspy_src && cd phpspy_src) 118 cd third_party/phpspy_src && git checkout $(PHPSPY_VERSION) 119 cd third_party/phpspy_src && make clean static 120 cp third_party/phpspy_src/libphpspy.a third_party/phpspy/libphpspy.a 121 122 .PHONY: build-libbpf 123 build-libbpf: 124 $(MAKE) -C third_party/libbpf 125 126 .PHONY: build-bcc 127 build-bcc: 128 $(MAKE) -C third_party/bcc 129 130 .PHONY: build-profile-bpf 131 build-profile-bpf: build-libbpf 132 CFLAGS="-I$(abspath ./third_party/libbpf/lib/include)" $(MAKE) -C pkg/agent/ebpfspy/bpf 133 134 135 .PHONY: build-third-party-dependencies 136 build-third-party-dependencies: $(shell echo $(THIRD_PARTY_DEPENDENCIES)) ## Builds third party dep 137 138 .PHONY: test 139 test: ## Runs the test suite 140 go test -race -tags debugspy $(shell go list ./... | grep -v /examples/) 141 142 .PHONY: coverage 143 coverage: ## Runs the test suite with coverage 144 go test -race -tags debugspy -coverprofile=coverage -covermode=atomic $(shell go list ./... | grep -v /examples/) 145 146 .PHONY: server 147 server: ## Start the Pyroscope Server 148 bin/pyroscope server $(SERVERPARAMS) 149 150 .PHONY: install-web-dependencies 151 install-web-dependencies: ## Install the web dependencies 152 yarn install --ignore-engines 153 154 .PHONY: install-build-web-dependencies 155 install-build-web-dependencies: ## Install web dependencies only necessary for a build 156 NODE_ENV=production yarn install --frozen-lockfile --ignore-engines 157 158 .PHONY: assets 159 assets: install-web-dependencies ## deprecated 160 @echo "This command is deprecated, please use `make dev` to develop locally" 161 exit 1 162 # yarn dev 163 164 .PHONY: assets-watch 165 assets-watch: install-web-dependencies ## deprecated 166 @echo "This command is deprecated, please use `make dev` to develop locally" 167 exit 1 168 # yarn dev -- --watch 169 170 .PHONY: assets-release 171 assets-release: ## Configure the assets for release 172 rm -rf webapp/public/assets 173 rm -rf webapp/public/*.html 174 yarn build 175 176 .PHONY: assets-size-build 177 assets-size-build: assets-release ## Build assets for the size report 178 mv webapp/public/assets/app*.js webapp/public/assets/app.js 179 180 .PHONY: embedded-assets 181 embedded-assets: install-dev-tools $(shell echo $(EMBEDDED_ASSETS_DEPS)) ## Configure the assets along with dev tools 182 183 .PHONY: lint 184 lint: ## Run the lint across the codebase 185 go run "$(shell scripts/pinned-tool.sh github.com/mgechev/revive)" -config revive.toml -exclude ./pkg/agent/pprof/... -exclude ./vendor/... -exclude ./examples/... -formatter stylish ./... 186 187 .PHONY: lint-summary 188 lint-summary: ## Get the lint summary 189 $(MAKE) lint | grep 'https://revive.run' | sed 's/[ ()0-9,]*//' | sort 190 191 .PHONY: ensure-logrus-not-used 192 ensure-logrus-not-used: ## Verify if logrus not used in codebase 193 @! go run "$(shell scripts/pinned-tool.sh github.com/kisielk/godepgraph)" -nostdlib -s ./pkg/agent/profiler/ | grep ' -> "github.com/sirupsen/logrus' \ 194 || (echo "\n^ ERROR: make sure ./pkg/agent/profiler/ does not depend on logrus. We don't want users' logs to be tainted. Talk to @petethepig if have questions\n" &1>2; exit 1) 195 196 @! go run "$(shell scripts/pinned-tool.sh github.com/kisielk/godepgraph)" -nostdlib -s ./pkg/agent/clib/ | grep ' -> "github.com/sirupsen/logrus' \ 197 || (echo "\n^ ERROR: make sure ./pkg/agent/clib/ does not depend on logrus. We don't want users' logs to be tainted. Talk to @petethepig if have questions\n" &1>2; exit 1) 198 199 .PHONY: clib-deps 200 clib-deps: 201 go run "$(shell scripts/pinned-tool.sh github.com/kisielk/godepgraph)" -tags nogospy ./pkg/agent/clib/ | dot -Tsvg -o ./tmp/clib-deps.svg 202 203 .PHONY: unused 204 unused: ## Staticcheck for unused code 205 staticcheck -f stylish -tags $(ALL_SPIES) -unused.whole-program ./... 206 207 .PHONY: install-dev-tools 208 install-dev-tools: ## Install dev tools 209 go install github.com/cosmtrek/air@latest 210 cat tools/tools.go | grep _ | awk -F'"' '{print $$2}' | xargs -tI {} go install {} 211 212 .PHONY: web-bootstrap 213 web-bootstrap: install-web-dependencies 214 yarn bootstrap 215 # build webapp just to get its dependencies built 216 # otherwise when first running, the webapp will fail to build since its deps don't exist yet 217 yarn build:webapp > /dev/null 218 219 .PHONY: dev 220 dev: install-web-dependencies ## Start webpack and pyroscope server. Use this one for working on pyroscope 221 PYROSCOPE_ANALYTICS_OPT_OUT=true goreman -exit-on-error -f scripts/dev-procfile start 222 223 .PHONY: godoc 224 godoc: ## Generate godoc 225 sleep 5 && $(OPEN) http://localhost:8090/pkg/github.com/pyroscope-io/pyroscope/ & 226 godoc -http :8090 227 228 .PHONY: go-deps-graph 229 go-deps-graph: ## Generate the deps graph 230 sh scripts/dependency-graph.sh 231 open -a "/Applications/Google Chrome.app" tmp/go-deps-graph.svg 232 233 .PHONY: clean 234 clean: ## Clean up storage 235 rm -rf tmp/pyroscope-storage 236 $(MAKE) -C third_party/bcc clean 237 $(MAKE) -C third_party/libbpf clean 238 $(MAKE) -C pkg/agent/ebpfspy/bpf clean 239 240 .PHONY: update-contributors 241 update-contributors: ## Update the contributors 242 $(shell yarn bin contributor-faces) \ 243 -e pyroscopebot \ 244 -l 100 \ 245 . 246 247 .PHONY: preview-changelog 248 preview-changelog: ## Update the changelog 249 $(shell yarn bin conventional-changelog) -i CHANGELOG.md -p angular -u 250 251 .PHONY: update-changelog 252 update-changelog: ## Update the changelog 253 $(shell yarn bin conventional-changelog) -i CHANGELOG.md -p angular -s 254 sed -i '/Updates the list of contributors in README/d' CHANGELOG.md 255 sed -i '/docs: updates the list of contributors in README/d' CHANGELOG.md 256 sed -i '/Update README.md/d' CHANGELOG.md 257 258 .PHONY: update-protobuf 259 update-protobuf: ## Update the protobuf 260 go install google.golang.org/protobuf/cmd/protoc-gen-go 261 protoc --go_out=. pkg/convert/profile.proto 262 263 .PHONY: docker-dev 264 docker-dev: ## Build the docker dev 265 docker build . --tag pyroscope/pyroscope:dev --progress=plain 266 267 .PHONY: windows-dev 268 windows-dev: ## Build the windows dev 269 docker build --platform linux/amd64 -f Dockerfile.windows --progress=plain --output type=local,dest=out . 270 271 .PHONY: print-deps-error-message 272 print-deps-error-message: 273 @echo "" 274 @echo " NOTE: you can still build pyroscope without spies by adding ENABLED_SPIES=none before the build command:" 275 @echo " $$ ENABLED_SPIES=none make build" 276 @echo "" 277 exit 1 278 279 .PHONY: e2e-build 280 e2e-build: build assets-release 281 282 .PHONY: test-merge 283 test-merge: 284 curl --data 'foo;bar 100' http://localhost:4040/ingest?name="foo%7Bprofile_id=id1%7D" 285 curl --data 'foo;baz 200' http://localhost:4040/ingest?name="foo%7Bprofile_id=id2%7D" 286 @echo http://localhost:4040/tracing?queryID=$(shell curl --data '{"appName":"foo", "profiles":["id1", "id2"], "startTime":"now-1h", "endTime":"now"}' http://localhost:4040/merge | jq .queryID | tr -d '"') 287 288 help: ## Show this help 289 @egrep '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | sed 's/Makefile://' | awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-z0-9A-Z_-]+:.*?##/ { printf " \033[36m%-30s\033[0m %s\n", $$1, $$2 }'