forked from sqldef/sqldef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
69 lines (55 loc) · 2.55 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# This doesn't work for psqldef due to lib/pq
GOFLAGS := -tags netgo -installsuffix netgo -ldflags '-w -s --extldflags "-static" -X main.version=$(shell git describe --tags --abbrev=0)'
GOVERSION=$(shell go version)
GOOS=$(word 1,$(subst /, ,$(lastword $(GOVERSION))))
GOARCH=$(word 2,$(subst /, ,$(lastword $(GOVERSION))))
BUILD_DIR=build/$(GOOS)-$(GOARCH)
# Because ghr doesn't support cross-compiling, cgo cross-build of mattn/go-sqlite3 is failing.
# We should use https://github.com/karalabe/xgo or something to support sqlite3def in non-Linux OSes.
SQLITE3_OS=linux
.PHONY: all build clean deps package package-zip package-targz
all: build
build: deps
mkdir -p $(BUILD_DIR)
cd cmd/mysqldef && GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GOFLAGS) -o ../../$(BUILD_DIR)/mysqldef
cd cmd/psqldef && GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GOFLAGS) -o ../../$(BUILD_DIR)/psqldef
cd cmd/sqlite3def && GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GOFLAGS) -o ../../$(BUILD_DIR)/sqlite3def
cd cmd/mssqldef && GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(GOFLAGS) -o ../../$(BUILD_DIR)/mssqldef
clean:
rm -rf build package
deps:
go get -t ./...
package:
$(MAKE) package-targz GOOS=linux GOARCH=amd64
$(MAKE) package-targz GOOS=linux GOARCH=386
$(MAKE) package-targz GOOS=linux GOARCH=arm64
$(MAKE) package-targz GOOS=linux GOARCH=arm
$(MAKE) package-zip GOOS=darwin GOARCH=amd64
$(MAKE) package-zip GOOS=darwin GOARCH=arm64
$(MAKE) package-zip GOOS=windows GOARCH=amd64
$(MAKE) package-zip GOOS=windows GOARCH=386
package-zip: build
mkdir -p package
cd $(BUILD_DIR) && zip ../../package/mssqldef_$(GOOS)_$(GOARCH).zip mssqldef
cd $(BUILD_DIR) && zip ../../package/mysqldef_$(GOOS)_$(GOARCH).zip mysqldef
cd $(BUILD_DIR) && zip ../../package/psqldef_$(GOOS)_$(GOARCH).zip psqldef
if [ "$(GOOS)" = "$(SQLITE3_OS)" ]; then \
cd $(BUILD_DIR) && zip ../../package/sqlite3def_$(GOOS)_$(GOARCH).zip sqlite3def; \
fi
package-targz: build
mkdir -p package
cd $(BUILD_DIR) && tar zcvf ../../package/mssqldef_$(GOOS)_$(GOARCH).tar.gz mssqldef
cd $(BUILD_DIR) && tar zcvf ../../package/mysqldef_$(GOOS)_$(GOARCH).tar.gz mysqldef
cd $(BUILD_DIR) && tar zcvf ../../package/psqldef_$(GOOS)_$(GOARCH).tar.gz psqldef
if [ "$(GOOS)" = "$(SQLITE3_OS)" ]; then \
cd $(BUILD_DIR) && tar zcvf ../../package/sqlite3def_$(GOOS)_$(GOARCH).tar.gz sqlite3def; \
fi
test: test-mysqldef test-psqldef test-sqlite3def test-mssqldef
test-mysqldef:
cd cmd/mysqldef && go test
test-psqldef:
cd cmd/psqldef && go test
test-sqlite3def:
cd cmd/sqlite3def && go test
test-mssqldef:
cd cmd/mssqldef && go test