2021-06-26 18:19:21 +00:00
|
|
|
# Build zk in the current folder.
|
|
|
|
build:
|
|
|
|
$(call go,build)
|
|
|
|
|
|
|
|
# Build and install `zk` using go's default bin directory.
|
|
|
|
install:
|
|
|
|
$(call go,install)
|
|
|
|
|
|
|
|
# Run unit tests.
|
|
|
|
test:
|
|
|
|
$(call go,test,./...)
|
2021-04-24 12:11:09 +00:00
|
|
|
|
2022-01-10 13:28:14 +00:00
|
|
|
# Run end-to-end tests.
|
|
|
|
tesh: build
|
2022-01-10 16:04:17 +00:00
|
|
|
@PATH=".:$(shell pwd):$(PATH)" tesh tests tests/fixtures
|
2022-01-10 13:28:14 +00:00
|
|
|
|
2022-04-26 09:43:34 +00:00
|
|
|
# Run end-to-end tests and prints difference as raw bytes.
|
|
|
|
teshb: build
|
|
|
|
@PATH=".:$(shell pwd):$(PATH)" tesh -b tests tests/fixtures
|
|
|
|
|
2022-01-10 13:28:14 +00:00
|
|
|
# Update end-to-end tests.
|
|
|
|
tesh-update: build
|
2022-01-10 16:04:17 +00:00
|
|
|
PATH=".:$(shell pwd):$(PATH)" tesh -u tests tests/fixtures
|
2022-01-10 13:28:14 +00:00
|
|
|
|
2021-06-26 18:19:21 +00:00
|
|
|
# Produce a release bundle for all platforms.
|
|
|
|
dist: dist-macos dist-linux
|
2021-04-24 12:11:09 +00:00
|
|
|
rm -f zk
|
|
|
|
|
2021-06-26 18:19:21 +00:00
|
|
|
# Produce a release bundle for macOS.
|
|
|
|
dist-macos:
|
|
|
|
rm -f zk && make && zip -r "zk-${VERSION}-macos-`uname -m`.zip" zk
|
2021-04-24 12:11:09 +00:00
|
|
|
|
2021-06-26 18:19:21 +00:00
|
|
|
# Produce a release bundle for Linux.
|
2022-07-13 12:38:24 +00:00
|
|
|
dist-linux: dist-linux-amd64 dist-linux-arm64 dist-linux-i386
|
|
|
|
dist-linux-amd64:
|
|
|
|
rm -f zk && docker run --rm -v "${PWD}":/usr/src/zk -w /usr/src/zk mickaelmenu/zk-xcompile:linux-amd64 /bin/bash -c 'make' && tar -zcvf "zk-${VERSION}-linux-amd64.tar.gz" zk
|
|
|
|
dist-linux-arm64:
|
|
|
|
rm -f zk && docker run --rm -v "${PWD}":/usr/src/zk -w /usr/src/zk mickaelmenu/zk-xcompile:linux-arm64 /bin/bash -c 'make' && tar -zcvf "zk-${VERSION}-linux-arm64.tar.gz" zk
|
|
|
|
dist-linux-i386:
|
|
|
|
rm -f zk && docker run --rm -v "${PWD}":/usr/src/zk -w /usr/src/zk mickaelmenu/zk-xcompile:linux-i386 /bin/bash -c 'make' && tar -zcvf "zk-${VERSION}-linux-i386.tar.gz" zk
|
2021-04-24 12:11:09 +00:00
|
|
|
|
2021-06-26 18:19:21 +00:00
|
|
|
# Clean build products.
|
2021-04-24 12:11:09 +00:00
|
|
|
clean:
|
|
|
|
rm -rf zk*
|
2021-06-26 18:19:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
VERSION := `git describe --tags --match v[0-9]* 2> /dev/null`
|
|
|
|
BUILD := `git rev-parse --short HEAD`
|
|
|
|
|
|
|
|
ENV_PREFIX := CGO_ENABLED=1
|
|
|
|
# Add necessary env variables for Apple Silicon.
|
|
|
|
ifeq ($(shell uname -sm),Darwin arm64)
|
2022-05-14 08:44:39 +00:00
|
|
|
ENV_PREFIX := $(ENV) GOARCH=arm64
|
2021-06-26 18:19:21 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Wrapper around the go binary, to set all the default parameters.
|
|
|
|
define go
|
2022-05-14 08:44:39 +00:00
|
|
|
$(ENV_PREFIX) go $(1) -tags "fts5" -ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)" $(2)
|
2021-06-26 18:19:21 +00:00
|
|
|
endef
|
|
|
|
|