-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
46 lines (36 loc) · 1.5 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
#
# Makefile for Mattermost emoticon2emoji
#
SRC=plugin.go configuration.go emoticon.go matches.go
EXEC=plugin
CONF=plugin.yaml
PACKAGE_BASENAME=mattermost-plugin-emoticon2emoji
TEST=plugin_test.go
all: test-coverage dist-all
build: vendor $(SRC) $(CONF)
go build -o $(EXEC) $(SRC)
rebuild: clean build
$(PACKAGE_BASENAME).tar.gz: build
chmod a+x $(EXEC)
tar -czvf $@ $(EXEC) $(CONF)
TAR_PLUGIN_EXE_TRANSFORM = --transform 'flags=r;s|dist/intermediate/plugin_.*|$(EXEC)|'
ifneq (,$(findstring bsdtar,$(shell tar --version)))
TAR_PLUGIN_EXE_TRANSFORM = -s '|dist/intermediate/plugin_.*|$(EXEC)|'
endif
dist-all: vendor $(SRC) $(CONF)
rm -rf ./dist
go get github.com/mitchellh/gox
$(shell go env GOPATH)/bin/gox -osarch='darwin/amd64 linux/amd64 windows/amd64' -output 'dist/intermediate/plugin_{{.OS}}_{{.Arch}}'
tar -czvf dist/$(PACKAGE_BASENAME)-darwin-amd64.tar.gz $(TAR_PLUGIN_EXE_TRANSFORM) dist/intermediate/plugin_darwin_amd64 $(CONF)
tar -czvf dist/$(PACKAGE_BASENAME)-linux-amd64.tar.gz $(TAR_PLUGIN_EXE_TRANSFORM) dist/intermediate/plugin_linux_amd64 $(CONF)
tar -czvf dist/$(PACKAGE_BASENAME)-windows-amd64.tar.gz $(TAR_PLUGIN_EXE_TRANSFORM) dist/intermediate/plugin_windows_amd64.exe $(CONF)
rm -rf dist/intermediate
test: $(SRC) $(TEST)
go test -v .
test-coverage: $(SRC) $(TEST)
go test -race -coverprofile=coverage.txt -covermode=atomic
vendor: Gopkg.lock
go get github.com/golang/dep
dep ensure
clean:
rm -rf ./dist $(EXEC) $(PACKAGE_BASENAME).tar.gz