-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
102 lines (83 loc) · 3.08 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
GO ?= go
GOLANGCI_LINT ?= $$($(GO) env GOPATH)/bin/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.61.0
GOGOPROTOBUF ?= protoc-gen-gogofaster
GOGOPROTOBUF_VERSION ?= v1.3.1
COMMIT ?= "$(shell git describe --long --dirty --always --match "" || true)"
VERSION ?= "$(shell git describe --tags --abbrev=0 || true)"
LDFLAGS ?= -s -w -X github.com/fairdatasociety/fairOS-dfs.commit="$(COMMIT)" -X github.com/fairdatasociety/fairOS-dfs.version="$(VERSION)"
DEST ?= "$(shell (go list ./... | grep -v wasm))"
.PHONY: all
all: lint vet test-race binary
.PHONY: binary
binary: export CGO_ENABLED=1
binary: dist FORCE
$(GO) version
$(GO) build -trimpath -ldflags "$(LDFLAGS)" -o dist/dfs ./cmd/dfs
$(GO) build -trimpath -ldflags "$(LDFLAGS)" -o dist/dfs-cli ./cmd/dfs-cli
dist:
mkdir $@
.PHONY: lint
lint: linter
$(GOLANGCI_LINT) run
.PHONY: linter
linter:
test -f $(GOLANGCI_LINT) || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$($(GO) env GOPATH)/bin $(GOLANGCI_LINT_VERSION)
.PHONY: swagger
swagger:
which swag || ( echo "install swag for your system from https://github.com/swaggo/swag" && exit 1)
swag init -g ./cmd/server.go -d cmd/dfs,pkg/api,cmd/common,pkg/dir,pkg/file,pkg/pod,pkg/user,pkg/collection,pkg/act,pkg/utils -o ./swagger
.PHONY: vet
vet:
$(GO) vet "$(DEST)"
.PHONY: test-race
test-race:
$(GO) test -race -timeout 30m -v "$(DEST)"
.PHONY: test
test:
$(GO) test -v "$(DEST)" -timeout=30m
.PHONY: githooks
githooks:
ln -f -s ../../.githooks/pre-push.bash .git/hooks/pre-push
.PHONY: protobuftools
protobuftools:
which protoc || ( echo "install protoc for your system from https://github.com/protocolbuffers/protobuf/releases" && exit 1)
which $(GOGOPROTOBUF) || ( cd /tmp && GO111MODULE=on $(GO) get -u github.com/gogo/protobuf/$(GOGOPROTOBUF)@$(GOGOPROTOBUF_VERSION) )
.PHONY: protobuf
protobuf: GOFLAGS=-mod=mod # use modules for protobuf file include option
protobuf: protobuftools
$(GO) generate -run protoc "$(DEST)"
.PHONY: clean
clean:
$(GO) clean
rm -rf dist/
.PHONY: release
release:
docker run --rm --privileged \
--env-file .release-env \
-v ~/go/pkg/mod:/go/pkg/mod \
-v `pwd`:/go/src/github.com/fairDataSociety/fairOS-dfs \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/fairDataSociety/fairOS-dfs \
ghcr.io/goreleaser/goreleaser-cross:v1.21.0 release --clean
.PHONY: release-dry-run
release-dry-run:
docker run --rm --privileged \
-v ~/go/pkg/mod:/go/pkg/mod \
-v ~/go/bin:/go/bin \
-v `pwd`:/go/src/github.com/fairDataSociety/fairOS-dfs \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/fairDataSociety/fairOS-dfs \
ghcr.io/goreleaser/goreleaser-cross:v1.21.0 release \
--clean --skip-validate=true --skip-publish
.PHONY: wasm
wasm:
@GOOS=js GOARCH=wasm $(GO) build -ldflags="-s -w" -o fairos.wasm ./wasm
@gzip -9 -v -c fairos.wasm > fairos.wasm.gz
.PHONY: android
android:
$(GO) get golang.org/x/mobile/bind
gomobile init
gomobile bind -androidapi 21 -o fairos.aar -target=android -ldflags "$(LDFLAGS)" github.com/fairdatasociety/fairOS-dfs/gomobile
$(GO) mod tidy
FORCE: