forked from sqldef/sqldef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (50 loc) · 2.34 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
# 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)
.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
cd $(BUILD_DIR) && zip ../../package/sqlite3def_$(GOOS)_$(GOARCH).zip sqlite3def
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
cd $(BUILD_DIR) && tar zcvf ../../package/sqlite3def_$(GOOS)_$(GOARCH).tar.gz sqlite3def
test: test-mysqldef test-psqldef test-sqlite3def test-mssqldef test-sqlparser
test-mysqldef:
cd cmd/mysqldef && MYSQL_HOST=127.0.0.1 go test
test-psqldef:
cd cmd/psqldef && PGHOST=127.0.0.1 PGSSLMODE=disable go test
test-sqlite3def:
cd cmd/sqlite3def && go test
test-mssqldef:
cd cmd/mssqldef && go test
test-sqlparser:
cd sqlparser && go test