forked from scaleway/scaleway-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
125 lines (93 loc) · 2.96 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Go parameters
GOCMD ?= go
GOBUILD ?= godep $(GOCMD) build
GOCLEAN ?= $(GOCMD) clean
GOINSTALL ?= $(GOCMD) install
GOTEST ?= godep $(GOCMD) test
GODEP ?= $(GOTEST) -i
GOFMT ?= gofmt -w
FPM_VERSION ?= $(shell ./dist/scw-Darwin-i386 --version | sed 's/.*v\([0-9.]*\),.*/\1/g')
FPM_DOCKER ?= \
-it --rm \
-v $(PWD)/dist:/output \
-w /output \
tenzer/fpm fpm
FPM_ARGS ?= \
-C /input/ \
-s dir \
--name=scw \
--no-depends \
--version=$(FPM_VERSION) \
--license=mit \
-m "Scaleway <[email protected]>"
NAME = scw
SRC = .
PACKAGES = api commands utils
REV = $(shell git rev-parse HEAD || echo "nogit")
TAG = $(shell git describe --tags --always || echo "nogit")
BUILDER = scaleway-cli-builder
BUILD_LIST = $(foreach int, $(SRC), $(int)_build)
CLEAN_LIST = $(foreach int, $(SRC) $(PACKAGES), $(int)_clean)
INSTALL_LIST = $(foreach int, $(SRC), $(int)_install)
IREF_LIST = $(foreach int, $(SRC) $(PACKAGES), $(int)_iref)
TEST_LIST = $(foreach int, $(SRC) $(PACKAGES), $(int)_test)
FMT_LIST = $(foreach int, $(SRC) $(PACKAGES), $(int)_fmt)
.PHONY: $(CLEAN_LIST) $(TEST_LIST) $(FMT_LIST) $(INSTALL_LIST) $(BUILD_LIST) $(IREF_LIST)
all: build
build: scwversion/version.go $(BUILD_LIST)
clean: $(CLEAN_LIST)
install: $(INSTALL_LIST)
test: $(TEST_LIST)
iref: $(IREF_LIST)
fmt: $(FMT_LIST)
.git:
touch $@
scwversion/version.go: .git
@sed 's/\(.*GITCOMMIT.* = \).*/\1"$(REV)"/;s/\(.*VERSION.* = \).*/\1"$(TAG)"/' scwversion/version.tpl > [email protected]
@if [ "$$(diff [email protected] $@ 2>&1)" != "" ]; then mv [email protected] $@; fi
@rm -f [email protected]
Godeps: scwversion/version.go
go get github.com/tools/godep
godep get
godep save
touch $@
$(BUILD_LIST): %_build: %_fmt %_iref
$(GOBUILD) -o $(NAME) ./$*
$(CLEAN_LIST): %_clean:
$(GOCLEAN) ./$*
$(INSTALL_LIST): %_install:
$(GOINSTALL) ./$*
$(IREF_LIST): %_iref: Godeps
$(GODEP) ./$*
$(TEST_LIST): %_test:
$(GOTEST) ./$*
$(FMT_LIST): %_fmt:
$(GOFMT) ./$*
cross: scwversion/version.go
docker build -t $(BUILDER) .
@docker rm scaleway-cli-builer 2>/dev/null || true
mkdir -p dist
docker run --name=$(BUILDER) $(BUILDER) tar -cf - /etc/ssl > dist/ssl.tar
docker cp $(BUILDER):/go/bin tmp
docker rm $(BUILDER)
touch tmp/bin/*
mv tmp/bin/* dist/
rm -rf tmp dist/godep
packages:
rm -f dist/*.deb
docker run -v $(PWD)/dist/scw-Linux-x86_64:/input/scw $(FPM_DOCKER) $(FPM_ARGS) -t deb -a x86_64 ./
docker run -v $(PWD)/dist/scw-Linux-i386:/input/scw $(FPM_DOCKER) $(FPM_ARGS) -t deb -a i386 ./
docker run -v $(PWD)/dist/scw-Linux-arm:/input/scw $(FPM_DOCKER) $(FPM_ARGS) -t deb -a arm ./
#publish_packages:
# docker run -v $(PWD)/dist moul/dput ppa:moul/scw dist/scw_$(FPM_VERSION)_arm.changes
travis_install:
go get golang.org/x/tools/cmd/cover
travis_run: build
godep go test -v -covermode=count $(foreach int, $(SRC) $(PACKAGES), ./$(int))
golint:
@go get github.com/golang/lint/golint
@for dir in */; do golint $$dir; done
prerelease:
git add -f Godeps/Godeps.json scwversion/version.go
postrelease:
git rm -f Godeps/Godeps.json scwversion/version.go