mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-13 08:30:03 +01:00
Build using native OS workers (#231)
This commit is contained in:
parent
06d8bb7567
commit
f69f1dea03
7 changed files with 123 additions and 96 deletions
80
Makefile
80
Makefile
|
|
@ -1,60 +1,58 @@
|
|||
# no static linking for macos
|
||||
LDFLAGS := -ldflags '-s'
|
||||
# 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,sqlite_json
|
||||
# enable cgo to build sqlite
|
||||
export CGO_ENABLED = 1
|
||||
|
||||
# strip binaries
|
||||
FLAGS := -tags sqlite_omit_load_extension,sqlite_json -ldflags '-s'
|
||||
|
||||
GOOS := $(shell go env GOOS)
|
||||
ifeq ($(GOOS),linux)
|
||||
# statically link binaries to support alpine linux
|
||||
FLAGS := -tags netgo,osusergo,sqlite_omit_load_extension,sqlite_json -ldflags '-s -extldflags "-static"'
|
||||
endif
|
||||
ifeq ($(GOOS),darwin)
|
||||
export SDKROOT ?= $(shell xcrun --sdk macosx --show-sdk-path)
|
||||
endif
|
||||
|
||||
OUTPUT ?= dbmate
|
||||
|
||||
.PHONY: all
|
||||
all: build test lint
|
||||
all: fix build wait test
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf dist
|
||||
|
||||
.PHONY: build
|
||||
build: clean
|
||||
go build -o dist/$(OUTPUT) $(FLAGS) .
|
||||
|
||||
.PHONY: ls
|
||||
ls:
|
||||
ls -lh dist/$(OUTPUT)
|
||||
file dist/$(OUTPUT)
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
go test -p 1 $(TAGS) $(STATICLDFLAGS) ./...
|
||||
|
||||
.PHONY: fix
|
||||
fix:
|
||||
golangci-lint run --fix
|
||||
go test -p 1 $(FLAGS) ./...
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
golangci-lint run
|
||||
|
||||
.PHONY: fix
|
||||
fix:
|
||||
golangci-lint run --fix
|
||||
|
||||
.PHONY: wait
|
||||
wait:
|
||||
dist/dbmate-linux-amd64 -e CLICKHOUSE_TEST_URL wait
|
||||
dist/dbmate-linux-amd64 -e MYSQL_TEST_URL wait
|
||||
dist/dbmate-linux-amd64 -e POSTGRES_TEST_URL wait
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf dist/*
|
||||
|
||||
.PHONY: build
|
||||
build: clean build-linux-amd64
|
||||
ls -lh dist
|
||||
|
||||
.PHONY: build-linux-amd64
|
||||
build-linux-amd64:
|
||||
GOOS=linux GOARCH=amd64 \
|
||||
go build $(TAGS) $(STATICLDFLAGS) -o dist/dbmate-linux-amd64 .
|
||||
|
||||
.PHONY: build-all
|
||||
build-all: clean build-linux-amd64
|
||||
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=darwin GOARCH=arm64 CC=o64-clang CXX=o64-clang++ \
|
||||
go build $(TAGS) $(LDFLAGS) -o dist/dbmate-macos-arm64 .
|
||||
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 .
|
||||
ls -lh dist
|
||||
dist/dbmate -e CLICKHOUSE_TEST_URL wait
|
||||
dist/dbmate -e MYSQL_TEST_URL wait
|
||||
dist/dbmate -e POSTGRES_TEST_URL wait
|
||||
|
||||
.PHONY: docker-all
|
||||
docker-all:
|
||||
docker-compose build
|
||||
docker-compose run --rm dev make
|
||||
docker-compose run --rm dev make all
|
||||
|
||||
.PHONY: docker-sh
|
||||
docker-sh:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue