-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (61 loc) · 2.46 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
GOPATH := $(shell pwd)/vendor:$(shell pwd):$(shell echo $$GOPATH)
PATH := $(PATH):$(shell echo $$GOPATH/bin)
GOBIN := $(shell pwd)/bin
GONAME := scif
GOFILES?=$$(find . -name '*.go' | grep -v vendor | grep -v _extra )
VERSION := $(shell cat pkg/version/version.go |grep "const Version ="|cut -d"\"" -f2)
GIT_COMMIT := $(shell git rev-parse HEAD)
TARGET := $(shell echo $${PWD\#\#*/})
PID=/tmp/go-$(GONAME).pid
# Use linker flags to provide version/build settings to the target
LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(GIT_COMMIT)"
# go source files, ignore vendor directory
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
$(TARGET): $(SRC)
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build $(LDFLAGS) -o $(TARGET)
build:
@echo "GOPATH: $(GOPATH)"
@echo "LDFLAGS: $(LDFLAGS)"
@echo "GOFILES: $(GOFILES)"
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build $(LDFLAGS) -o bin/$(GONAME) ./cmd/scif
deps:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get -u golang.org/x/sys/unix
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get -u golang.org/x/lint/golint
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get -u github.com/spf13/cobra
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get -u github.com/google/shlex
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get -u github.com/mitchellh/gox
# dev creates binaries for testing scif locally. These are put
# into ./bin/ as well as $GOPATH/bin
dev: fmtcheck
go install -mod=vendor .
docs: fmt
godoc -notes="TODO|BUG" -http=:6060
fmt:
gofmt -w $(GOFILES)
vet:
go vet ./cmd/scif
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
get:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get .
install:
@echo "Installing to: $(GOBIN)"
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go install $(LDFLAGS) ./cmd/scif
uninstall: clean
@rm -f $$(which ${TARGET})
clean:
@rm -f $(TARGET)
release:
@mkdir -p dist
# for windows, need to install mousetrap and add windows back here
gox -os="linux darwin" -arch="amd64" -output="dist/scif_{{.OS}}_{{.Arch}}" ./cmd/scif
@cd dist/ && gzip *
simplify:
@gofmt -s -l -w $(SRC)
test:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test -v github.com/sci-f/scif-go/internal/pkg/logger
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test -v github.com/sci-f/scif-go/pkg/util
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test -v github.com/sci-f/scif-go/pkg/version
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test github.com/sci-f/scif-go/pkg/client
@bash test/run_tests.sh bin/scif || true
.PHONY: all build clean deps docs dev fmt fmtcheck get install uninstall vet simplify quickdev release test