-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (53 loc) · 2.31 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
PACKAGE ?= github.com/alimy/hori
TARGET = hori
RELEASE_ROOT = release
RELEASE_LINUX_AMD64 = $(RELEASE_ROOT)/linux-amd64/$(TARGET)
RELEASE_DARWIN_AMD64 = $(RELEASE_ROOT)/darwin-amd64/$(TARGET)
RELEASE_DARWIN_ARM64 = $(RELEASE_ROOT)/darwin-arm64/$(TARGET)
RELEASE_WINDOWS_AMD64 = $(RELEASE_ROOT)/windows-amd64/$(TARGET)
GOFMT ?= gofmt -s -w
GOFILES := $(shell find . -name "*.go" -type f)
TAGS = jsoniter
LDFLAGS += -X "$(PACKAGE)/version.BuildTime=$(shell date -v+8H -u '+%Y-%m-%d %H:%M:%S %Z+8')"
LDFLAGS += -X "$(PACKAGE)/version.GitHash=$(shell git rev-parse --short=12 HEAD)"
.PHONY: default
default: run
.PHONY: build
build: fmt
go build -ldflags '$(LDFLAGS)' -tags '$(TAGS)' -o $(TARGET) main.go
.PHONY: build
run:
@go run -ldflags '$(LDFLAGS)' -tags '$(TAGS)' main.go serve
.PHONY: generate
generate:
@go generate mirc/main.go
@$(GOFMT) ./
.PHONY: release
release: linux-amd64 darwin-amd64 darwin-arm64 windows-x64
cp -rf build/scripts LICENSE README.md $(RELEASE_LINUX_AMD64)
cp -rf build/scripts LICENSE README.md $(RELEASE_DARWIN_AMD64)
cp -rf build/scripts LICENSE README.md $(RELEASE_DARWIN_ARM64)
cp -rf build/scripts LICENSE README.md $(RELEASE_WINDOWS_AMD64)
cd $(RELEASE_LINUX_AMD64)/.. && rm -f *.zip && zip -r $(TARGET)-linux_amd64.zip $(TARGET) && cd -
cd $(RELEASE_DARWIN_AMD64)/.. && rm -f *.zip && zip -r $(TARGET)-darwin_amd64.zip $(TARGET) && cd -
cd $(RELEASE_DARWIN_ARM64)/.. && rm -f *.zip && zip -r $(TARGET)-darwin_arm64.zip $(TARGET) && cd -
cd $(RELEASE_WINDOWS_AMD64)/.. && rm -f *.zip && zip -r $(TARGET)-windows_amd64.zip $(TARGET) && cd -
.PHONY: linux-amd64
linux-amd64:
@-rm -rf $(RELEASE_LINUX_AMD64)
GOOS=linux GOARCH=amd64 go build -ldflags '$(LDFLAGS)' -o $(RELEASE_LINUX_AMD64)/$(TARGET) main.go
.PHONY: darwin-amd64
darwin-amd64:
@-rm -rf $(RELEASE_DARWIN_AMD64)
GOOS=darwin GOARCH=amd64 go build -ldflags '$(LDFLAGS)' -o $(RELEASE_DARWIN_AMD64)/$(TARGET) main.go
.PHONY: darwin-arm64
darwin-arm64:
@-rm -rf $(RELEASE_DARWIN_ARM64)
GOOS=darwin GOARCH=arm64 go build -ldflags '$(LDFLAGS)' -o $(RELEASE_DARWIN_ARM64)/$(TARGET) main.go
.PHONY: windows-x64
windows-x64:
@-rm -rf $(RELEASE_WINDOWS_AMD64)
GOOS=windows GOARCH=amd64 go build -ldflags '$(LDFLAGS)' -o $(RELEASE_WINDOWS_AMD64)/$(TARGET) main.go
.PHONY: fmt
fmt:
$(GOFMT) $(GOFILES)