2020-08-11 13:05:55 -07:00
|
|
|
# no static linking for macos
|
2019-09-18 22:30:59 +12:00
|
|
|
LDFLAGS := -ldflags '-s'
|
2020-08-11 13:05:55 -07:00
|
|
|
# statically link binaries (to support alpine + scratch containers)
|
|
|
|
|
STATICLDFLAGS := -ldflags '-s -extldflags "-static"'
|
|
|
|
|
# avoid building code that is incompatible with static linking
|
|
|
|
|
TAGS := -tags netgo,osusergo,sqlite_omit_load_extension
|
2015-11-25 10:57:58 -08:00
|
|
|
|
2018-01-22 21:49:12 -08:00
|
|
|
.PHONY: all
|
2020-08-08 16:25:13 -07:00
|
|
|
all: build lint test
|
2015-11-25 10:57:58 -08:00
|
|
|
|
2018-01-22 21:49:12 -08:00
|
|
|
.PHONY: test
|
|
|
|
|
test:
|
2020-08-11 13:05:55 -07:00
|
|
|
go test -v $(TAGS) $(STATICLDFLAGS) ./...
|
2015-11-25 10:57:58 -08:00
|
|
|
|
2020-01-01 19:11:02 -10:00
|
|
|
.PHONY: fix
|
|
|
|
|
fix:
|
|
|
|
|
golangci-lint run --fix
|
|
|
|
|
|
2018-01-22 21:49:12 -08:00
|
|
|
.PHONY: lint
|
2015-11-25 10:57:58 -08:00
|
|
|
lint:
|
2018-12-01 22:28:47 -08:00
|
|
|
golangci-lint run
|
2015-11-25 10:57:58 -08:00
|
|
|
|
2018-04-15 20:34:19 -07:00
|
|
|
.PHONY: wait
|
|
|
|
|
wait:
|
2018-12-01 22:28:47 -08:00
|
|
|
dist/dbmate-linux-amd64 -e MYSQL_URL wait
|
|
|
|
|
dist/dbmate-linux-amd64 -e POSTGRESQL_URL wait
|
2020-08-08 00:38:48 +04:00
|
|
|
dist/dbmate-linux-amd64 -e CLICKHOUSE_URL wait
|
2018-04-15 20:34:19 -07:00
|
|
|
|
2018-01-22 21:49:12 -08:00
|
|
|
.PHONY: clean
|
|
|
|
|
clean:
|
2019-09-24 22:06:21 -07:00
|
|
|
rm -rf dist/*
|
2015-12-01 17:36:23 -08:00
|
|
|
|
2018-01-22 21:49:12 -08:00
|
|
|
.PHONY: build
|
2020-08-08 16:25:13 -07:00
|
|
|
build: clean build-linux-amd64
|
2019-09-18 22:30:59 +12:00
|
|
|
ls -lh dist
|
|
|
|
|
|
2020-08-08 16:25:13 -07:00
|
|
|
.PHONY: build-linux-amd64
|
|
|
|
|
build-linux-amd64:
|
2020-08-11 13:05:55 -07:00
|
|
|
GOOS=linux GOARCH=amd64 \
|
|
|
|
|
go build $(TAGS) $(STATICLDFLAGS) -o dist/dbmate-linux-amd64 .
|
2020-08-08 16:25:13 -07:00
|
|
|
|
|
|
|
|
.PHONY: build-all
|
|
|
|
|
build-all: clean build-linux-amd64
|
2020-08-11 13:05:55 -07:00
|
|
|
GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc-5 CXX=aarch64-linux-gnu-g++-5 \
|
|
|
|
|
go build $(TAGS) $(STATICLDFLAGS) -o dist/dbmate-linux-arm64 .
|
|
|
|
|
GOOS=darwin GOARCH=amd64 CC=o64-clang CXX=o64-clang++ \
|
|
|
|
|
go build $(TAGS) $(LDFLAGS) -o dist/dbmate-macos-amd64 .
|
|
|
|
|
GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix \
|
|
|
|
|
go build $(TAGS) $(STATICLDFLAGS) -o dist/dbmate-windows-amd64.exe .
|
2020-08-08 16:25:13 -07:00
|
|
|
ls -lh dist
|
2018-01-22 21:49:12 -08:00
|
|
|
|
2020-08-08 16:25:13 -07:00
|
|
|
.PHONY: docker-make
|
|
|
|
|
docker-make:
|
2020-03-15 08:58:05 -07:00
|
|
|
docker-compose build
|
2020-11-02 20:22:59 +13:00
|
|
|
docker-compose run --rm dev make
|
2020-03-15 08:58:05 -07:00
|
|
|
|
2020-11-02 20:22:59 +13:00
|
|
|
.PHONY: docker-sh
|
|
|
|
|
docker-sh:
|
|
|
|
|
-docker-compose run --rm dev
|