fork/gdu
git clone https://git.julia.blue/fork/gdu
d672bf4
ignore
1NAME := gdu 2MAJOR_VER := v5 3PACKAGE := github.com/dundee/$( NAME ) /$( MAJOR_VER ) 4CMD_GDU := cmd/gdu 5VERSION := $( shell git describe--tags 2 > /dev/null) 6NAMEVER := $( NAME ) -$( subst v,,$( VERSION )) 7DATE := $( shell date +'%Y-%m-%d' ) 8GOBIN := go 9GOFLAGS ?= -buildmode=pie -trimpath -mod=readonly -modcacherw -pgo=default.pgo 10GOFLAGS_STATIC ?= -trimpath -mod=readonly -modcacherw -pgo=default.pgo 11LDFLAGS := -s -w -extldflags '-static' \ 12 -X '$( PACKAGE ) /build.Version=$( VERSION ) ' \ 13 -X '$( PACKAGE ) /build.User=$( shell id -u -n )' \ 14 -X '$( PACKAGE ) /build.Time=$( shell LC_ALL =en_US.UTF-8date )' 15TAR := tar 16ifeq ($( shell uname -s ),Darwin) 17TAR := gtar# brew install gnu-tar 18endif 19 20all : clean tarball build-all build-docker man clean-uncompressed-dist shasums 21 22run : 23go run$( PACKAGE ) /$( CMD_GDU ) 24 25vendor : go.mod go.sum 26go mod vendor 27 28tarball : vendor 29 -mkdir dist 30$( TAR ) czf dist/$( NAMEVER ) .tgz--transform "s,^, $( NAMEVER ) /," --anchored --exclude dist--exclude test_dir--exclude coverage.txt--exclude webui/frontend/node_modules * 31 32build : 33@ echo "Version: " $( VERSION ) 34mkdir -p dist 35GOFLAGS =" $( GOFLAGS ) " CGO_ENABLED =0$( GOBIN ) build-ldflags= " $( LDFLAGS ) " -o dist/$( NAME ) $( PACKAGE ) /$( CMD_GDU ) 36 37build-static : 38@ echo "Version: " $( VERSION ) 39mkdir -p dist 40GOFLAGS =" $( GOFLAGS_STATIC ) " CGO_ENABLED =0$( GOBIN ) build-ldflags= " $( LDFLAGS ) " -o dist/$( NAME ) $( PACKAGE ) /$( CMD_GDU ) 41 42# build-web compiles and minifies the React web UI into webui/dist, which is 43# committed and embedded into the binary. Requires Node.js. Pure-Go builds 44# (build/build-static/build-all) do not need this; they use the committed dist. 45build-web : 46cd webui/frontend&& npm ci&& npm run build 47 48build-docker : 49@ echo "Version: " $( VERSION ) 50docker build .--tag ghcr.io/dundee/gdu:$( VERSION ) 51 52build-all : 53@ echo "Version: " $( VERSION ) 54 -mkdir dist 55CGO_ENABLED =0gox \ 56-os= "darwin" \ 57-arch= "amd64 arm64" \ 58-output= "dist/gdu_{{.OS}}_{{.Arch}}" \ 59-ldflags= " $( LDFLAGS ) " \ 60$( PACKAGE ) /$( CMD_GDU ) 61 62CGO_ENABLED =0gox \ 63-os= "windows" \ 64-arch= "amd64" \ 65-output= "dist/gdu_{{.OS}}_{{.Arch}}" \ 66-ldflags= " $( LDFLAGS ) " \ 67$( PACKAGE ) /$( CMD_GDU ) 68 69CGO_ENABLED =0gox \ 70-os= "linux freebsd netbsd openbsd" \ 71-output= "dist/gdu_{{.OS}}_{{.Arch}}" \ 72-ldflags= " $( LDFLAGS ) " \ 73$( PACKAGE ) /$( CMD_GDU ) 74 75GOFLAGS =" $( GOFLAGS ) " CGO_ENABLED =0GOOS =linuxGOARCH =amd64$( GOBIN ) build-ldflags= " $( LDFLAGS ) " -o dist/gdu_linux_amd64$( PACKAGE ) /$( CMD_GDU ) 76GOFLAGS =" $( GOFLAGS_STATIC ) " CGO_ENABLED =0GOOS =linuxGOARCH =amd64$( GOBIN ) build-ldflags= " $( LDFLAGS ) " -o dist/gdu_linux_amd64_static$( PACKAGE ) /$( CMD_GDU ) 77 78CGO_ENABLED =0GOOS =linuxGOARM =5GOARCH =arm$( GOBIN ) build-ldflags= " $( LDFLAGS ) " -o dist/gdu_linux_armv5l$( PACKAGE ) /$( CMD_GDU ) 79CGO_ENABLED =0GOOS =linuxGOARM =6GOARCH =arm$( GOBIN ) build-ldflags= " $( LDFLAGS ) " -o dist/gdu_linux_armv6l$( PACKAGE ) /$( CMD_GDU ) 80CGO_ENABLED =0GOOS =linuxGOARM =7GOARCH =arm$( GOBIN ) build-ldflags= " $( LDFLAGS ) " -o dist/gdu_linux_armv7l$( PACKAGE ) /$( CMD_GDU ) 81CGO_ENABLED =0GOOS =linuxGOARCH =arm64$( GOBIN ) build-ldflags= " $( LDFLAGS ) " -o dist/gdu_linux_arm64$( PACKAGE ) /$( CMD_GDU ) 82CGO_ENABLED =0GOOS =androidGOARCH =arm64$( GOBIN ) build-ldflags= " $( LDFLAGS ) " -o dist/gdu_android_arm64$( PACKAGE ) /$( CMD_GDU ) 83 84cd dist;for file in gdu_linux_* gdu_darwin_* gdu_netbsd_* gdu_openbsd_* gdu_freebsd_* gdu_android_*;do tar czf$ $file.tgz$ $file;done 85cd dist;for file in gdu_windows_*;do zip $ $file.zip$ $file;done 86 87gdu.1 : gdu.1.md 88sed 's/{{date}}/ $( DATE ) /g' gdu.1.md> gdu.1.date.md 89pandoc gdu.1.date.md-s -t man> gdu.1 90rm -f gdu.1.date.md 91 92man : gdu.1 93cp gdu.1 dist 94cd dist;tar czf gdu.1.tgz gdu.1 95 96show-man : 97sed 's/{{date}}/ $( DATE ) /g' gdu.1.md> gdu.1.date.md 98pandoc gdu.1.date.md-s -t man| man -l - 99 100test : 101gotestsum 102 103coverage : 104gotestsum -- -race -coverprofile=coverage.txt -covermode=atomic ./... 105 106coverage-html : coverage 107$( GOBIN ) tool cover-html=coverage.txt 108 109gobench : 110$( GOBIN ) test-bench=. $( PACKAGE ) /pkg/analyze 111 112heap-profile : 113$( GOBIN ) tool pprof-web http://localhost:6060/debug/pprof/heap 114 115pgo : 116wget -O cpu.pprof http://localhost:6060/debug/pprof/profile?seconds=30 117$( GOBIN ) tool pprof-proto cpu.pprof default.pgo> merged.pprof 118mv merged.pprof default.pgo 119 120trace : 121wget -O trace.out http://localhost:6060/debug/pprof/trace?seconds=30 122gotraceui ./trace.out 123 124profile : 125wget -O cpu.pprof http://localhost:6060/debug/pprof/profile?seconds=30 126$( GOBIN ) tool pprof-web cpu.pprof 127 128benchmark : 129sudo cpupower frequency-set-g performance 130hyperfine --export-markdown=docs/benchmarks/bench-cold.md \ 131--prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' \ 132--ignore-failure \ 133'dua ~' 'duc index ~' 'ncdu -0 -o /dev/null ~' \ 134'diskus ~' 'du -hs ~' 'dust -d0 ~' 'pdu ~' \ 135'gdu -npc ~' \ 136'gdu -npc --db=tmp.badger ~' \ 137'gdu -npc --db=tmp.db ~' \ 138'GOMAXPROCS=80 gdu -npc ~' 139hyperfine --export-markdown=docs/benchmarks/bench-warm.md \ 140--warmup 5 \ 141--ignore-failure \ 142'dua ~' 'duc index ~' 'ncdu -0 -o /dev/null ~' \ 143'diskus ~' 'du -hs ~' 'dust -d0 ~' 'pdu ~' \ 144'gdu -npc ~' \ 145'gdu -npc --db=tmp.badger ~' \ 146'gdu -npc --db=tmp.db ~' \ 147'GOMAXPROCS=100 gdu -npc ~' 148hyperfine -M 1--export-markdown=docs/benchmarks/bench-cold-big.md \ 149--prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' \ 150--ignore-failure \ 151'dua /' \ 152'diskus /' 'dust -d0 /' \ 153'gdu -npc /' 'GOMAXPROCS=5 gdu -npc /' 154sudo cpupower frequency-set-g schedutil 155 156benchmark-parameter-scan : 157sudo cpupower frequency-set-g performance 158hyperfine --export-markdown=docs/benchmarks/bench-cold-param-scan.md \ 159--prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' \ 160--ignore-failure \ 161-P procs 1 120-D 10 \ 162'GOMAXPROCS={procs} gdu -npc ~' 163hyperfine --export-markdown=docs/benchmarks/bench-warm-param-scan.md \ 164--warmup 5 \ 165--ignore-failure \ 166-P procs 90 200-D 10 \ 167'GOMAXPROCS={procs} gdu -npc ~' 168hyperfine -M 1--export-markdown=docs/benchmarks/bench-cold-big-param-scan.md \ 169--prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' \ 170--ignore-failure \ 171-P procs 1 10 \ 172'GOMAXPROCS={procs} gdu -npc /' 173sudo cpupower frequency-set-g schedutil 174 175lint : 176golangci-lint run-c .golangci.yml 177 178clean : 179$( GOBIN ) mod tidy 180 -rm coverage.txt 181 -rm -r test_dir 182 -rm -r vendor 183 -rm -r dist 184 185clean-uncompressed-dist : 186find dist-type f-not -name '*.tgz' -not -name '*.zip' -delete 187 188shasums : 189cd dist;sha256sum *> sha256sums.txt 190cd dist;gpg --sign --armor --detach-sign sha256sums.txt 191 192release : 193gh release create-t "gdu $( VERSION ) " $( VERSION ) ./dist/* 194 195install-dev-dependencies : 196$( GOBIN ) install gotest.tools/gotestsum@latest 197$( GOBIN ) install github.com/mitchellh/gox@latest 198$( GOBIN ) install honnef.co/go/gotraceui/cmd/gotraceui@latest 199$( GOBIN ) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.2 200 201.PHONY : run build build-static build-all build-web test gobench benchmark coverage coverage-html clean clean-uncompressed-dist man show-man release dev-build