2021-10-05 13:36:06 +03:00
|
|
|
GO_BUILD_FLAGS=-trimpath
|
|
|
|
GO_BUILD_LDFLAGS=-s -w
|
|
|
|
|
2021-09-27 23:42:34 +03:00
|
|
|
all: test fq
|
2020-06-08 03:29:51 +03:00
|
|
|
|
|
|
|
.PHONY: fq
|
2021-09-18 19:22:27 +03:00
|
|
|
fq: VERSION=$(shell git describe --all --long --dirty 2>/dev/null || echo nogit)
|
2020-06-08 03:29:51 +03:00
|
|
|
fq:
|
2021-10-06 13:02:03 +03:00
|
|
|
CGO_ENABLED=0 go build -o fq -ldflags "${GO_BUILD_LDFLAGS} -X main.version=${VERSION}" ${GO_BUILD_FLAGS} .
|
2020-06-08 03:29:51 +03:00
|
|
|
|
|
|
|
.PHONY: test
|
2021-09-27 23:42:34 +03:00
|
|
|
test: testgo testjq testcli
|
|
|
|
|
|
|
|
.PHONY: testgo
|
2021-08-21 19:52:29 +03:00
|
|
|
# figure out all go pakges with test files
|
2021-09-27 23:42:34 +03:00
|
|
|
testgo: PKGS=$(shell find . -name "*_test.go" | xargs -n 1 dirname | sort | uniq)
|
|
|
|
testgo:
|
2021-10-27 15:56:42 +03:00
|
|
|
go test -race ${VERBOSE} ${COVER} ${PKGS}
|
2021-08-21 19:52:29 +03:00
|
|
|
|
2021-09-27 23:42:34 +03:00
|
|
|
.PHONY: testgov
|
|
|
|
testgov: export VERBOSE=-v
|
|
|
|
testgov: testgo
|
2021-08-21 19:52:29 +03:00
|
|
|
|
2021-09-14 14:05:57 +03:00
|
|
|
.PHONY: testjq
|
2021-09-19 11:51:18 +03:00
|
|
|
testjq: fq
|
2021-11-08 15:45:55 +03:00
|
|
|
@pkg/interp/testjq.sh ./fq pkg/interp/*_test.jq
|
2020-06-08 03:29:51 +03:00
|
|
|
|
2021-09-18 19:23:28 +03:00
|
|
|
.PHONY: testcli
|
2021-09-19 11:51:18 +03:00
|
|
|
testcli: fq
|
|
|
|
@pkg/cli/test.sh ./fq pkg/cli/test.exp
|
2021-09-18 13:31:03 +03:00
|
|
|
|
2021-09-28 14:15:55 +03:00
|
|
|
.PHONY: actual
|
2021-09-27 23:42:34 +03:00
|
|
|
actual: export WRITE_ACTUAL=1
|
|
|
|
actual: testgo
|
|
|
|
|
2021-09-28 14:15:55 +03:00
|
|
|
.PHONY: cover
|
2021-10-27 15:56:42 +03:00
|
|
|
cover: COVER=-cover -coverpkg=./... -coverprofile=cover.out
|
2021-09-27 23:42:34 +03:00
|
|
|
cover: test
|
|
|
|
go tool cover -html=cover.out -o cover.out.html
|
|
|
|
cat cover.out.html | grep '<option value="file' | sed -E 's/.*>(.*) \((.*)%\)<.*/\2 \1/' | sort -rn
|
|
|
|
|
2020-06-08 03:29:51 +03:00
|
|
|
.PHONY: doc
|
2021-10-10 03:17:29 +03:00
|
|
|
doc: fq doc/file.mp3 doc/file.mp4 doc/formats.svg doc/demo.svg
|
2021-09-19 11:51:18 +03:00
|
|
|
@doc/mdsh.sh ./fq *.md doc/*.md
|
2020-06-08 03:29:51 +03:00
|
|
|
|
2021-10-10 03:17:29 +03:00
|
|
|
.PHONY: doc/demo.svg
|
|
|
|
doc/demo.svg: fq
|
|
|
|
(cd doc ; ./demo.sh ../fq) | go run github.com/wader/ansisvg@master > doc/demo.svg
|
|
|
|
|
2021-09-19 11:27:56 +03:00
|
|
|
.PHONY: doc/formats.svg
|
2021-09-19 11:51:18 +03:00
|
|
|
doc/formats.svg: fq
|
2021-11-01 19:44:37 +03:00
|
|
|
# ignore graphviz version as it causes diff when nothing has changed
|
2021-11-02 18:15:21 +03:00
|
|
|
./fq -rnf doc/formats_diagram.jq | dot -Tsvg | sed 's/Generated by graphviz.*//' > doc/formats.svg
|
2021-09-19 11:27:56 +03:00
|
|
|
|
2020-06-08 03:29:51 +03:00
|
|
|
doc/file.mp3: Makefile
|
|
|
|
ffmpeg -y -f lavfi -i sine -f lavfi -i testsrc -map 0:0 -map 1:0 -t 20ms "$@"
|
|
|
|
|
|
|
|
doc/file.mp4: Makefile
|
|
|
|
ffmpeg -y -f lavfi -i sine -f lavfi -i testsrc -c:a aac -c:v h264 -f mp4 -t 20ms "$@"
|
|
|
|
|
|
|
|
.PHONY: gogenerate
|
|
|
|
gogenerate:
|
|
|
|
go generate -x ./...
|
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint:
|
2021-08-21 12:25:21 +03:00
|
|
|
# bump: make-golangci-lint /golangci-lint@v([\d.]+)/ git:https://github.com/golangci/golangci-lint.git|^1
|
2021-11-03 19:20:38 +03:00
|
|
|
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0 run
|
2020-06-08 03:29:51 +03:00
|
|
|
|
|
|
|
.PHONY: depgraph.svg
|
|
|
|
depgraph.svg:
|
2021-08-20 16:20:13 +03:00
|
|
|
go run github.com/kisielk/godepgraph@latest github.com/wader/fq | dot -Tsvg -o godepgraph.svg
|
2020-06-08 03:29:51 +03:00
|
|
|
|
2021-08-31 15:14:12 +03:00
|
|
|
# make memprof ARGS=". test.mp3"
|
|
|
|
# make cpuprof ARGS=". test.mp3"
|
2020-06-08 03:29:51 +03:00
|
|
|
.PHONY: prof
|
|
|
|
prof:
|
2021-12-12 17:25:28 +03:00
|
|
|
go build -tags profile -o fq.prof fq.go
|
2021-08-31 15:14:12 +03:00
|
|
|
CPUPROFILE=fq.cpu.prof MEMPROFILE=fq.mem.prof ./fq.prof ${ARGS}
|
2020-06-08 03:29:51 +03:00
|
|
|
.PHONY: memprof
|
|
|
|
memprof: prof
|
|
|
|
go tool pprof -http :5555 fq.prof fq.mem.prof
|
|
|
|
|
|
|
|
.PHONY: cpuprof
|
|
|
|
cpuprof: prof
|
|
|
|
go tool pprof -http :5555 fq.prof fq.cpu.prof
|
|
|
|
|
|
|
|
.PHONY: update-gomodreplace
|
2021-08-17 13:06:32 +03:00
|
|
|
update-gomod:
|
|
|
|
GOPROXY=direct go get -d github.com/wader/readline@fq
|
|
|
|
GOPROXY=direct go get -d github.com/wader/gojq@fq
|
|
|
|
go mod tidy
|
2021-11-16 19:11:26 +03:00
|
|
|
|
|
|
|
# TODO: as decode recovers panic and "repanics" unrecoverable errors this is a bit hacky at the moment
|
|
|
|
# fuzz code is not suppose to print to stderr so log to file
|
|
|
|
.PHONY: fuzz
|
|
|
|
fuzz:
|
|
|
|
# in other terminal: tail -f /tmp/repanic
|
|
|
|
REPANIC_LOG=/tmp/repanic gotip test -tags fuzz -v -fuzz=Fuzz ./format/
|