1GO_BUILD_FLAGS=-trimpath 2GO_BUILD_LDFLAGS=-s -w 3 4all: test fq 5 6.PHONY: fq 7fq: VERSION=$(shell git describe --all --long --dirty 2>/dev/null || echo nogit) 8fq: 9 CGO_ENABLED=0 go build -o fq -ldflags "${GO_BUILD_LDFLAGS} -X main.version=${VERSION}" ${GO_BUILD_FLAGS} . 10 11.PHONY: test 12test: testgo testjq testcli 13 14.PHONY: testgo 15# figure out all go pakges with test files 16testgo: PKGS=$(shell find . -name "*_test.go" | xargs -n 1 dirname | sort | uniq) 17testgo: 18 go test -race ${VERBOSE} ${COVER} ${PKGS} 19 20.PHONY: testgov 21testgov: export VERBOSE=-v 22testgov: testgo 23 24.PHONY: testjq 25testjq: fq 26 @pkg/interp/testjq.sh ./fq pkg/interp/*_test.jq 27 28.PHONY: testcli 29testcli: fq 30 @pkg/cli/test.sh ./fq pkg/cli/test.exp 31 32.PHONY: actual 33actual: export WRITE_ACTUAL=1 34actual: testgo 35 36.PHONY: cover 37cover: COVER=-cover -coverpkg=./... -coverprofile=cover.out 38cover: test 39 go tool cover -html=cover.out -o cover.out.html 40 cat cover.out.html | grep '<option value="file' | sed -E 's/.*>(.*) \((.*)%\)<.*/\2 \1/' | sort -rn 41 42.PHONY: doc 43doc: fq doc/file.mp3 doc/file.mp4 doc/formats.svg doc/demo.svg 44 @doc/mdsh.sh ./fq *.md doc/*.md 45 46.PHONY: doc/demo.svg 47doc/demo.svg: fq 48 (cd doc ; ./demo.sh ../fq) | go run github.com/wader/ansisvg@master > doc/demo.svg 49 50.PHONY: doc/formats.svg 51doc/formats.svg: fq 52# ignore graphviz version as it causes diff when nothing has changed 53 ./fq -rnf doc/formats_diagram.jq | dot -Tsvg | sed 's/Generated by graphviz.*//' > doc/formats.svg 54 55doc/file.mp3: Makefile 56 ffmpeg -y -f lavfi -i sine -f lavfi -i testsrc -map 0:0 -map 1:0 -t 20ms "$@" 57 58doc/file.mp4: Makefile 59 ffmpeg -y -f lavfi -i sine -f lavfi -i testsrc -c:a aac -c:v h264 -f mp4 -t 20ms "$@" 60 61.PHONY: gogenerate 62gogenerate: 63 go generate -x ./... 64 65.PHONY: lint 66lint: 67# bump: make-golangci-lint /golangci-lint@v([\d.]+)/ git:https://github.com/golangci/golangci-lint.git|^1 68 go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0 run 69 70.PHONY: depgraph.svg 71depgraph.svg: 72 go run github.com/kisielk/godepgraph@latest github.com/wader/fq | dot -Tsvg -o godepgraph.svg 73 74# make memprof ARGS=". test.mp3" 75# make cpuprof ARGS=". test.mp3" 76.PHONY: prof 77prof: 78 go build -tags profile -o fq.prof fq.go 79 CPUPROFILE=fq.cpu.prof MEMPROFILE=fq.mem.prof ./fq.prof ${ARGS} 80.PHONY: memprof 81memprof: prof 82 go tool pprof -http :5555 fq.prof fq.mem.prof 83 84.PHONY: cpuprof 85cpuprof: prof 86 go tool pprof -http :5555 fq.prof fq.cpu.prof 87 88.PHONY: update-gomodreplace 89update-gomod: 90 GOPROXY=direct go get -d github.com/wader/readline@fq 91 GOPROXY=direct go get -d github.com/wader/gojq@fq 92 go mod tidy 93 94# TODO: as decode recovers panic and "repanics" unrecoverable errors this is a bit hacky at the moment 95# fuzz code is not suppose to print to stderr so log to file 96.PHONY: fuzz 97fuzz: 98# in other terminal: tail -f /tmp/repanic 99 REPANIC_LOG=/tmp/repanic gotip test -tags fuzz -v -fuzz=Fuzz ./format/ 100