2021-12-24 19:45:02 +03:00
|
|
|
GO_BUILD_FLAGS ?= -trimpath
|
|
|
|
GO_BUILD_LDFLAGS ?= -s -w
|
2021-10-05 13:36:06 +03:00
|
|
|
|
2021-09-27 23:42:34 +03:00
|
|
|
all: test fq
|
2020-06-08 03:29:51 +03:00
|
|
|
|
2022-12-04 11:41:55 +03:00
|
|
|
# used to force make to always redo
|
|
|
|
.PHONY: always
|
2020-06-08 03:29:51 +03:00
|
|
|
|
2022-12-04 11:41:55 +03:00
|
|
|
fq: always
|
|
|
|
CGO_ENABLED=0 go build -o fq -ldflags "${GO_BUILD_LDFLAGS}" ${GO_BUILD_FLAGS} .
|
2021-09-27 23:42:34 +03:00
|
|
|
|
2022-12-04 11:41:55 +03:00
|
|
|
test: always testgo testjq testcli
|
|
|
|
test-race: always testgo-race testjq testcli
|
2022-09-09 10:15:18 +03:00
|
|
|
|
2022-12-04 11:41:55 +03:00
|
|
|
# figure out all go packages with test files
|
2021-09-27 23:42:34 +03:00
|
|
|
testgo: PKGS=$(shell find . -name "*_test.go" | xargs -n 1 dirname | sort | uniq)
|
2022-12-04 11:41:55 +03:00
|
|
|
testgo: always
|
2022-09-09 10:15:18 +03:00
|
|
|
go test -timeout 20m ${RACE} ${VERBOSE} ${COVER} ${PKGS}
|
|
|
|
|
|
|
|
testgo-race: RACE=-race
|
|
|
|
testgo-race: testgo
|
2021-08-21 19:52:29 +03:00
|
|
|
|
2022-12-05 22:42:26 +03:00
|
|
|
testjq: $(shell find . -name "*.jq.test")
|
|
|
|
%.jq.test: fq
|
|
|
|
@echo $@
|
|
|
|
@./fq -rRs -L pkg/interp 'include "jqtest"; run_tests' $@
|
2020-06-08 03:29:51 +03:00
|
|
|
|
2021-09-19 11:51:18 +03:00
|
|
|
testcli: fq
|
2022-03-15 20:10:33 +03:00
|
|
|
@pkg/cli/test_exp.sh ./fq pkg/cli/test_repl.exp
|
|
|
|
@pkg/cli/test_exp.sh ./fq pkg/cli/test_cli_ctrlc.exp
|
|
|
|
@pkg/cli/test_exp.sh ./fq pkg/cli/test_cli_ctrld.exp
|
2021-09-18 13:31:03 +03:00
|
|
|
|
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
|
|
|
|
|
2022-12-04 11:41:55 +03:00
|
|
|
doc: always
|
|
|
|
doc: $(wildcard doc/*.svg)
|
|
|
|
doc: $(wildcard *.md doc/*.md)
|
2020-06-08 03:29:51 +03:00
|
|
|
|
2022-12-04 11:41:55 +03:00
|
|
|
%.md: fq
|
|
|
|
@doc/mdsh.sh ./fq $@
|
|
|
|
|
|
|
|
doc/%.svg: fq
|
|
|
|
(cd doc ; ../$@.sh ../fq) | go run github.com/wader/ansisvg@master > $@
|
2021-10-10 03:17:29 +03:00
|
|
|
|
2021-09-19 11:51:18 +03:00
|
|
|
doc/formats.svg: fq
|
2022-12-21 15:59:54 +03:00
|
|
|
@# ignore graphviz version as it causes diff when nothing has changed
|
2022-12-04 11:41:55 +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 "$@"
|
|
|
|
|
2022-12-04 11:41:55 +03:00
|
|
|
gogenerate: always
|
2020-06-08 03:29:51 +03:00
|
|
|
go generate -x ./...
|
|
|
|
|
2022-12-04 11:41:55 +03:00
|
|
|
lint: always
|
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
|
2022-07-18 19:04:25 +03:00
|
|
|
# bump: make-golangci-lint link "Release notes" https://github.com/golangci/golangci-lint/releases/tag/v$LATEST
|
2023-03-26 19:03:34 +03:00
|
|
|
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 run
|
2020-06-08 03:29:51 +03:00
|
|
|
|
2022-12-04 11:41:55 +03:00
|
|
|
depgraph.svg: always
|
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"
|
2022-12-04 11:41:55 +03:00
|
|
|
prof: always
|
|
|
|
go build -tags profile -o fq.prof .
|
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
|
|
|
memprof: prof
|
|
|
|
go tool pprof -http :5555 fq.prof fq.mem.prof
|
|
|
|
cpuprof: prof
|
|
|
|
go tool pprof -http :5555 fq.prof fq.cpu.prof
|
|
|
|
|
2022-12-04 11:41:55 +03:00
|
|
|
update-gomod: always
|
2021-08-17 13:06:32 +03:00
|
|
|
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
|
|
|
|
2022-10-10 22:06:01 +03:00
|
|
|
# Usage: make fuzz # fuzz all foramts
|
|
|
|
# Usage: make fuzz GROUP=mp4 # fuzz a group (each format is a group also)
|
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
|
2022-08-22 15:03:56 +03:00
|
|
|
# Retrigger:
|
2023-05-14 16:44:39 +03:00
|
|
|
# try to decode crash with all formats in order to see which one panicked:
|
2022-11-20 21:22:16 +03:00
|
|
|
# cat format/testdata/fuzz/FuzzFormats/... | go run dev/fuzzbytes.go | go run . -d bytes '. as $b | formats | keys[] as $f | $b | decode($f)'
|
2022-10-10 22:06:01 +03:00
|
|
|
# convert crash into raw bytes:
|
2022-12-21 15:59:54 +03:00
|
|
|
# cat format/testdata/fuzz/FuzzFormats/... | go run dev/fuzzbytes.go | fq -d bytes to_base64
|
|
|
|
# fq -n '"..." | from_base64 | ...'
|
2022-12-04 11:41:55 +03:00
|
|
|
fuzz: always
|
2021-11-16 19:11:26 +03:00
|
|
|
# in other terminal: tail -f /tmp/repanic
|
2023-03-31 13:29:11 +03:00
|
|
|
FUZZTEST=1 go test -v -run Fuzz -fuzz=Fuzz ./format/
|
2022-01-06 11:57:47 +03:00
|
|
|
|
|
|
|
# usage: make release VERSION=0.0.1
|
|
|
|
# tag forked dependeces for history and to make then stay around
|
2022-12-04 11:41:55 +03:00
|
|
|
release: always
|
2022-01-06 11:57:47 +03:00
|
|
|
release: WADER_GOJQ_COMMIT=$(shell go list -m -f '{{.Version}}' github.com/wader/gojq | sed 's/.*-\(.*\)/\1/')
|
|
|
|
release: WADER_READLINE_COMMIT=$(shell go list -m -f '{{.Version}}' github.com/wader/readline | sed 's/.*-\(.*\)/\1/')
|
|
|
|
release:
|
|
|
|
@echo "# wader/fq":
|
|
|
|
@echo "# make sure head is at wader/master"
|
|
|
|
@echo git fetch wader
|
|
|
|
@echo git show
|
|
|
|
@echo make lint test doc
|
|
|
|
@echo go mod tidy
|
|
|
|
@echo git diff
|
2022-01-19 14:20:52 +03:00
|
|
|
@echo
|
|
|
|
@echo "sed 's/version = "\\\(.*\\\)"/version = \"${VERSION}\"/' fq.go > fq.go.new && mv fq.go.new fq.go"
|
|
|
|
@echo git add fq.go
|
2022-01-21 14:16:34 +03:00
|
|
|
@echo git commit -m \"fq: Update version to ${VERSION}\"
|
2022-01-19 14:20:52 +03:00
|
|
|
@echo git push wader master
|
|
|
|
@echo
|
2022-01-06 11:57:47 +03:00
|
|
|
@echo "# make sure head master commit CI was successful"
|
|
|
|
@echo open https://github.com/wader/fq/commit/master
|
|
|
|
@echo git tag v${VERSION}
|
|
|
|
@echo
|
|
|
|
@echo "# wader/gojq:"
|
|
|
|
@echo git tag fq-v${VERSION} ${WADER_GOJQ_COMMIT}
|
|
|
|
@echo git push wader fq-v${VERSION}:fq-v${VERSION}
|
|
|
|
@echo
|
|
|
|
@echo "# wader/readline:"
|
|
|
|
@echo git tag fq-v${VERSION} ${WADER_READLINE_COMMIT}
|
|
|
|
@echo git push wader fq-v${VERSION}:fq-v${VERSION}
|
|
|
|
@echo
|
|
|
|
@echo "# wader/fq":
|
|
|
|
@echo git push wader v${VERSION}:v${VERSION}
|
|
|
|
@echo "# edit draft release notes and publish"
|