forked from wentaojin/transferdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (51 loc) · 2.14 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
70
71
.PHONY: build assess prepare check reverseO2M reverseM2O all full csv comapre gotool clean help
CMDPATH="./cmd"
BINARYPATH="bin/transferdb"
CONFIGPATH="./example/config.toml"
REPO := github.com/wentaojin/transferdb
GOOS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
GOARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
GOENV := GO111MODULE=on CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH)
GO := $(GOENV) go
GOBUILD := $(GO) build
GORUN := $(GO) run
SHELL := /usr/bin/env bash
COMMIT := $(shell git describe --always --no-match --tags --dirty="-dev")
BUILDTS := $(shell date -u '+%Y-%m-%d %H:%M:%S')
GITHASH := $(shell git rev-parse HEAD)
GITREF := $(shell git rev-parse --abbrev-ref HEAD)
LDFLAGS := -w -s
LDFLAGS += -X "$(REPO)/config.Version=$(COMMIT)"
LDFLAGS += -X "$(REPO)/config.BuildTS=$(BUILDTS)"
LDFLAGS += -X "$(REPO)/config.GitHash=$(GITHASH)"
LDFLAGS += -X "$(REPO)/config.GitBranch=$(GITREF)"
build: clean gotool
$(GOBUILD) -ldflags '$(LDFLAGS)' -o $(BINARYPATH) $(CMDPATH)
assess: gotool
$(GORUN) $(CMDPATH) --config $(CONFIGPATH) --mode assess
prepare: gotool
$(GORUN) $(CMDPATH) --config $(CONFIGPATH) --mode prepare
reverseO2M: gotool
$(GORUN) $(CMDPATH) --config $(CONFIGPATH) --mode reverse -source oracle -target mysql
reverseM2O: gotool
$(GORUN) $(CMDPATH) --config $(CONFIGPATH) --mode reverse -source mysql -target oracle
check: gotool
$(GORUN) $(CMDPATH) --config $(CONFIGPATH) --mode check
all: gotool
$(GORUN) $(CMDPATH) --config $(CONFIGPATH) --mode all
compare: gotool
$(GORUN) $(CMDPATH) --config $(CONFIGPATH) --mode compare
full: gotool
$(GORUN) $(CMDPATH) --config $(CONFIGPATH) --mode full
csv: gotool
$(GORUN) $(CMDPATH) --config $(CONFIGPATH) --mode csv
gotool:
$(GO) mod tidy
clean:
@if [ -f ${BINARYPATH} ] ; then rm ${BINARYPATH} ; fi
help:
@echo "make - 格式化 Go 代码, 并编译生成二进制文件"
@echo "make build - 编译 Go 代码, 生成二进制文件"
@echo "make run - 直接运行 Go 代码"
@echo "make clean - 移除二进制文件和 vim swap files"
@echo "make gotool - 运行 Go 工具 'mod tidy'"