30 lines
753 B
Makefile
30 lines
753 B
Makefile
default:
|
|
go run *.go || (go get ./... && go run *.go)
|
|
|
|
watch:
|
|
(watchexec -e sql -- make schema-const) & \
|
|
(watchexec -e sql -- sqlc generate) & \
|
|
(watchexec -w sqlc.yaml -- sqlc generate) & \
|
|
(watchexec -e go -c -r -- go test ./... -count 1) & \
|
|
wait
|
|
# SQL Watcher done
|
|
|
|
# Puts the schema in a constant in go so it can be used to create the table directly
|
|
schema-const:
|
|
echo "// Code generated by Makefile. DO NOT EDIT." > internal/schema.go
|
|
echo "package internal\n" >> internal/schema.go
|
|
echo "const Schema = \`" >> internal/schema.go
|
|
cat db/schema.sql >> internal/schema.go
|
|
echo "\`" >> internal/schema.go
|
|
|
|
|
|
.PHONY: bench
|
|
bench:
|
|
make cleanup
|
|
make schema-const
|
|
sqlc generate
|
|
cd bench && go run main.go
|
|
|
|
cleanup:
|
|
rm -f bench/bench.db*
|