-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
68 lines (53 loc) · 2.2 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
WORKDIR := $(shell pwd)
TARGET := target
TARGET_DIR = $(WORKDIR)/$(TARGET)
NATIVEOS := $(shell go version | awk -F '[ /]' '{print $$4}')
NATIVEARCH := $(shell go version | awk -F '[ /]' '{print $$5}')
INTEGRATION := trapd
BINARY_NAME = nri-$(INTEGRATION)
GO_PKGS := $(shell go list ./... | grep -v "/vendor/")
GO_FILES := ./src/
all: build
build: check-version clean validate test compile
clean:
@echo "=== $(INTEGRATION) === [ clean ]: Removing binaries and coverage file..."
@rm -rfv bin coverage.xml $(TARGET)
tools: check-version
@echo "=== $(INTEGRATION) === [ tools ]: Installing tools required by the project..."
@go get $(GOTOOLS)
#@gometalinter.v2 --install
tools-update: check-version
@echo "=== $(INTEGRATION) === [ tools-update ]: Updating tools required by the project..."
@go get -u $(GOTOOLS)
#@gometalinter.v2 --install
deps: tools deps-only
deps-only:
@echo "=== $(INTEGRATION) === [ deps ]: Installing package dependencies required by the project..."
#@govendor sync
validate: deps
@echo "=== $(INTEGRATION) === [ validate ]: Validating source code running gometalinter..."
#@gometalinter.v2 --config=.gometalinter.json ./...
validate-all: deps
@echo "=== $(INTEGRATION) === [ validate ]: Validating source code running gometalinter..."
#@gometalinter.v2 --config=.gometalinter.json --enable=interfacer --enable=gosimple ./...
compile: deps
@echo "=== $(INTEGRATION) === [ compile ]: Building $(BINARY_NAME)..."
@go build -o bin/$(BINARY_NAME) ./src
compile-only: deps-only
@echo "=== $(INTEGRATION) === [ compile ]: Building $(BINARY_NAME)..."
@go build -o bin/$(BINARY_NAME) ./src
test: deps
@echo "=== $(INTEGRATION) === [ test ]: Running unit tests..."
@gocov test $(GO_PKGS) | gocov-xml > coverage.xml
check-version:
ifdef GOOS
ifneq "$(GOOS)" "$(NATIVEOS)"
$(error GOOS is not $(NATIVEOS). Cross-compiling is only allowed for 'clean', 'deps-only' and 'compile-only' targets)
endif
endif
ifdef GOARCH
ifneq "$(GOARCH)" "$(NATIVEARCH)"
$(error GOARCH variable is not $(NATIVEARCH). Cross-compiling is only allowed for 'clean', 'deps-only' and 'compile-only' targets)
endif
endif
.PHONY: all build clean tools tools-update deps validate compile test check-version