-
Notifications
You must be signed in to change notification settings - Fork 58
/
Makefile
128 lines (105 loc) · 3 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
126
127
128
# Copyright 2019 Samaritan Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
.EXPORT_ALL_VARIABLES:
REPO_URI = github.com/samaritan-proxy/samaritan
VERSION = $(shell grep "Version = " consts/consts.go | cut -d '"' -f2)
BUILD_IN_DOCKER ?= 0
GO_VERSION ?= 1.13
GOOS ?= $(shell go env GOHOSTOS)
GOARCH ?= $(shell go env GOHOSTARCH)
GOFLAGS ?=
GOPROXY ?= $(shell go env GOPROXY)
.PHONY: build, all
build all:
@for target in $(notdir $(abspath $(wildcard cmd/*/))); do \
make $$target; \
done
# Add rules for all directories in cmd/
#
# Example:
# make samaritan
.PHONY: $(notdir $(abspath $(wildcard cmd/*/)))
ifeq ($(BUILD_IN_DOCKER), 1)
$(notdir $(abspath $(wildcard cmd/*/))):
$(info building $@ (GOOS: $(GOOS), GOARCH: $(GOARCH), GO_VERSION: $(GO_VERSION), BUILD_IN_DOCKER: $(BUILD_IN_DOCKER)))
@docker run --rm \
-e GOOS=$(GOOS) \
-e GOARCH=$(GOARCH) \
-e CGO_ENABLED=0 \
-e GOFLAGS=$(GOFLAGS) \
-e GOPROXY=$(GOPROXY) \
-e REPO_URI=$(REPO_URI) \
--mount type=bind,source=`pwd`,destination=/samaritan \
-w /samaritan \
golang:$(GO_VERSION) \
./hack/build.sh $@
else
local_go_version := $(shell go version | cut -d' ' -f3 | sed -e 's/go//g')
$(notdir $(abspath $(wildcard cmd/*/))):
$(info building $@ (GOOS: $(GOOS), GOARCH: $(GOARCH), GO_VERSION: $(local_go_version), BUILD_IN_DOCKER: $(BUILD_IN_DOCKER)))
@./hack/build.sh $@
endif
.PHONY: docs
docs:
docker run --rm \
--mount type=bind,source=`pwd`,destination=/samaritan \
-w /samaritan \
python:3.7-alpine \
sh -c "apk add bash && ./docs/build.sh"
.PHONY: pub-docs
pub-docs:
@./docs/publish.sh
.PHONY: dev-image
dev-image:
docker build -t samaritanproxy/sam-dev -f ./Dockerfile_dev .
.PHONY: push-dev-image
push-dev-image:
docker push samaritanproxy/sam-dev
.PHONY: generate
generate:
docker run --rm \
-e CGO_ENABLED=0 \
-e GOPROXY=$(GOPROXY) \
-e REPO_URI=$(REPO_URI) \
--mount type=bind,source=`pwd`,destination=/go/src/$(REPO_URI) \
samaritanproxy/sam-dev \
./hack/gen.sh
.PHONY: clean-proto
clean-proto:
@./hack/gen-proto.sh -c
.PHONY: sync-proto
sync-proto:
@./hack/sync-proto.sh
.PHONY: test
test:
@./hack/test-units.sh
.PHONY: integration-test
integration-test:
@./hack/test-integration.sh
.PHONY: ci
ci: build test integration-test
.PHONY: release
release:
./hack/release.sh
.PHONY: push-release-image
push-release-image:
docker push samaritanproxy/samaritan:${VERSION}
.PHONY: clean
clean:
@rm -rf bin
@rm -rf docs/site
@rm -rf .release
@find . -name "cover.out" -exec rm {} \;
@rm -f coverage.txt
@rm -rf .ci