forked from awslabs/soci-snapshotter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
130 lines (94 loc) · 4.27 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
129
130
# Copyright The containerd 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.
# Base path used to install.
CMD_DESTDIR ?= /usr/local
GO111MODULE_VALUE=auto
OUTDIR ?= $(CURDIR)/out
PKG=github.com/awslabs/soci-snapshotter
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags)
REVISION=$(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi)
GO_BUILDTAGS ?=
ifneq ($(STATIC),)
GO_BUILDTAGS += osusergo netgo static_build
endif
GO_TAGS=$(if $(GO_BUILDTAGS),-tags "$(strip $(GO_BUILDTAGS))",)
GO_LD_FLAGS=-ldflags '-s -w -X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) $(GO_EXTRA_LDFLAGS)
ifneq ($(STATIC),)
GO_LD_FLAGS += -extldflags "-static"
endif
GO_LD_FLAGS+='
SOCI_SNAPSHOTTER_PROJECT_ROOT ?= $(shell pwd)
LTAG_TEMPLATE_FLAG=-t ./.headers
FBS_FILE_PATH=$(CURDIR)/ztoc/fbs/ztoc.fbs
FBS_FILE_PATH_COMPRESSION=$(CURDIR)/ztoc/compression/fbs/zinfo.fbs
COMMIT=$(shell git rev-parse HEAD)
STARGZ_BINARY?=/usr/local/bin/containerd-stargz-grpc
CMD=soci-snapshotter-grpc soci
CMD_BINARIES=$(addprefix $(OUTDIR)/,$(CMD))
GO_BENCHMARK_TESTS?=.
.PHONY: all build check add-ltag install uninstall clean test integration release benchmarks build-benchmarks benchmarks-perf-test benchmarks-comparison-test
all: build
build: $(CMD)
FORCE:
soci-snapshotter-grpc: FORCE
cd cmd/ ; GO111MODULE=$(GO111MODULE_VALUE) go build -o $(OUTDIR)/$@ $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) $(GO_TAGS) ./soci-snapshotter-grpc
soci: FORCE
cd cmd/ ; GO111MODULE=$(GO111MODULE_VALUE) go build -o $(OUTDIR)/$@ $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) $(GO_TAGS) ./soci
check:
cd scripts/ ; ./check-all.sh
flatc:
rm -rf $(CURDIR)/ztoc/fbs/ztoc
flatc -o $(CURDIR)/ztoc/fbs -g $(FBS_FILE_PATH)
rm -rf $(CURDIR)/ztoc/compression/fbs/zinfo
flatc -o $(CURDIR)/ztoc/compression/fbs -g $(FBS_FILE_PATH_COMPRESSION)
install:
@echo "$@"
@mkdir -p $(CMD_DESTDIR)/bin
@install $(CMD_BINARIES) $(CMD_DESTDIR)/bin
uninstall:
@echo "$@"
@rm -f $(addprefix $(CMD_DESTDIR)/bin/,$(notdir $(CMD_BINARIES)))
clean:
rm -rf $(OUTDIR)
vendor:
@GO111MODULE=$(GO111MODULE_VALUE) go mod tidy
@cd ./cmd ; GO111MODULE=$(GO111MODULE_VALUE) go mod tidy
test:
@echo "$@"
@GO111MODULE=$(GO111MODULE_VALUE) go test $(GO_TEST_FLAGS) $(GO_LD_FLAGS) -race ./...
integration: build
@echo "$@"
@echo "SOCI_SNAPSHOTTER_PROJECT_ROOT=$(SOCI_SNAPSHOTTER_PROJECT_ROOT)"
@GO111MODULE=$(GO111MODULE_VALUE) SOCI_SNAPSHOTTER_PROJECT_ROOT=$(SOCI_SNAPSHOTTER_PROJECT_ROOT) ENABLE_INTEGRATION_TEST=true go test $(GO_TEST_FLAGS) -v -timeout=0 ./integration
release:
@echo "$@"
@$(SOCI_SNAPSHOTTER_PROJECT_ROOT)/scripts/create-releases.sh $(RELEASE_TAG)
go-benchmarks:
# -run matches TestXXX type functions. Setting it to ^$ ensures non-benchmark tests are not run
go test -run=^$$ -bench=$(GO_BENCHMARK_TESTS) -benchmem $(GO_BENCHMARK_FLAGS) ./...
benchmarks: benchmarks-perf-test benchmarks-comparison-test
build-benchmarks: benchmark/bin/PerfTests benchmark/bin/CompTests
benchmark/bin/PerfTests: FORCE
GO111MODULE=$(GO111MODULE_VALUE) go build -o $@ ./benchmark/performanceTest
benchmark/bin/CompTests: FORCE
GO111MODULE=$(GO111MODULE_VALUE) go build -o $@ ./benchmark/comparisonTest
benchmarks-perf-test: benchmark/bin/PerfTests
@echo "$@"
@cd benchmark/performanceTest ; sudo ../bin/PerfTests -show-commit $(BENCHMARK_FLAGS)
benchmarks-comparison-test: benchmark/bin/CompTests
@echo "$@"
@cd benchmark/comparisonTest ; sudo ../bin/CompTests $(BENCHMARK_FLAGS)
benchmarks-stargz:
@echo "$@"
@cd benchmark/stargzTest ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/StargzTests . && sudo ../bin/StargzTests $(COMMIT) ../singleImage.csv 10 $(STARGZ_BINARY)
benchmarks-parser:
@echo "$@"
@cd benchmark/parser ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/Parser .