2023-05-27 07:16:52 +03:00
|
|
|
PKG := github.com/neilotoole/sq
|
|
|
|
VERSION_PKG := $(PKG)/cli/buildinfo
|
|
|
|
BUILD_VERSION := $(shell git describe --tags --always --dirty)
|
|
|
|
BUILD_COMMIT := $(shell git rev-parse HEAD)
|
|
|
|
BUILD_TIMESTAMP := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
|
2023-11-19 03:05:48 +03:00
|
|
|
LDFLAGS := -X $(VERSION_PKG).Version=$(BUILD_VERSION) -X $(VERSION_PKG).Commit=$(BUILD_COMMIT) -X $(VERSION_PKG).Timestamp=$(BUILD_TIMESTAMP)
|
2023-08-21 19:05:17 +03:00
|
|
|
BUILD_TAGS := sqlite_vtable sqlite_stat4 sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_math_functions
|
2023-05-27 07:16:52 +03:00
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
2023-08-21 19:05:17 +03:00
|
|
|
@go test -tags "$(BUILD_TAGS)" ./...
|
2023-05-27 07:16:52 +03:00
|
|
|
|
|
|
|
.PHONY: install
|
|
|
|
install:
|
2023-08-21 19:05:17 +03:00
|
|
|
@go install -ldflags "$(LDFLAGS)" -tags "$(BUILD_TAGS)"
|
2023-05-27 07:16:52 +03:00
|
|
|
|
|
|
|
.PHONY: lint
|
|
|
|
lint:
|
|
|
|
@golangci-lint run --out-format tab --sort-results
|
2023-11-19 03:05:48 +03:00
|
|
|
@shellcheck ./install.sh
|
2023-05-27 07:16:52 +03:00
|
|
|
|
|
|
|
.PHONY: gen
|
|
|
|
gen:
|
|
|
|
@go generate ./...
|
2024-01-27 10:11:24 +03:00
|
|
|
@# Run betteralign on generated code
|
|
|
|
@# https://github.com/dkorunic/betteralign
|
|
|
|
@betteralign -apply ./libsq/ast/internal/slq &> /dev/null | true
|
2023-05-27 07:16:52 +03:00
|
|
|
|
|
|
|
.PHONY: fmt
|
|
|
|
fmt:
|
2023-11-20 04:06:36 +03:00
|
|
|
@# https://github.com/incu6us/goimports-reviser
|
2024-02-09 19:08:39 +03:00
|
|
|
@# Note that termz_windows.go is excluded because the tool seems
|
2024-01-25 07:01:24 +03:00
|
|
|
@# to mangle Go code that is guarded by build tags that
|
2024-02-09 19:08:39 +03:00
|
|
|
@# are not in use. Alas, we can't provide a double star glob,
|
|
|
|
@# e.g. **/*_windows.go, because filepath.Match doesn't support
|
|
|
|
@# double star, so we explicitly name the file.
|
2024-01-25 07:01:24 +03:00
|
|
|
@goimports-reviser -company-prefixes github.com/neilotoole -set-alias \
|
2024-02-09 19:08:39 +03:00
|
|
|
-excludes 'libsq/core/termz/termz_windows.go' \
|
2024-01-25 07:01:24 +03:00
|
|
|
-rm-unused -output write \
|
|
|
|
-project-name github.com/neilotoole/sq ./...
|
2023-11-20 04:06:36 +03:00
|
|
|
|
2023-05-27 07:16:52 +03:00
|
|
|
@# Use gofumpt instead of "go fmt"
|
2023-11-20 04:06:36 +03:00
|
|
|
@# https://github.com/mvdan/gofumpt
|
2023-05-27 07:16:52 +03:00
|
|
|
@gofumpt -w .
|