Debian Codegraph @

Makefile

raw symbols SCIP
1 # Copyright The containerd Authors.
2
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6
7 # http://www.apache.org/licenses/LICENSE-2.0
8
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15
16 # Base path used to install.
17 CMD_DESTDIR ?= /usr/local
18 GO111MODULE_VALUE=auto
19 OUTDIR ?= $(CURDIR)/out
20 PKG=github.com/awslabs/soci-snapshotter
21 VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags)
22 REVISION=$(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi)
23
24 GO_BUILDTAGS ?=
25 ifneq ($(STATIC),)
26 GO_BUILDTAGS += osusergo netgo static_build
27 endif
28 GO_TAGS=$(if $(GO_BUILDTAGS),-tags "$(strip $(GO_BUILDTAGS))",)
29
30 GO_LD_FLAGS=-ldflags '-s -w -X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) $(GO_EXTRA_LDFLAGS)
31 ifneq ($(STATIC),)
32 GO_LD_FLAGS += -extldflags "-static"
33 endif
34 GO_LD_FLAGS+='
35
36 SOCI_SNAPSHOTTER_PROJECT_ROOT ?= $(shell pwd)
37 LTAG_TEMPLATE_FLAG=-t ./.headers
38 FBS_FILE_PATH=$(CURDIR)/ztoc/fbs/ztoc.fbs
39 FBS_FILE_PATH_COMPRESSION=$(CURDIR)/ztoc/compression/fbs/zinfo.fbs
40 COMMIT=$(shell git rev-parse HEAD)
41 STARGZ_BINARY?=/usr/local/bin/containerd-stargz-grpc
42
43 CMD=soci-snapshotter-grpc soci
44
45 CMD_BINARIES=$(addprefix $(OUTDIR)/,$(CMD))
46
47 .PHONY: all build check add-ltag install uninstall clean test integration release
48
49 all: build
50
51 build: $(CMD)
52
53 FORCE:
54
55 soci-snapshotter-grpc: FORCE
56 cd cmd/ ; GO111MODULE=$(GO111MODULE_VALUE) go build -o $(OUTDIR)/$@ $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) $(GO_TAGS) ./soci-snapshotter-grpc
57
58 soci: FORCE
59 cd cmd/ ; GO111MODULE=$(GO111MODULE_VALUE) go build -o $(OUTDIR)/$@ $(GO_BUILD_FLAGS) $(GO_LD_FLAGS) $(GO_TAGS) ./soci
60
61 check:
62 cd scripts/ ; ./check-all.sh
63
64 flatc:
65 rm -rf $(CURDIR)/ztoc/fbs/ztoc
66 flatc -o $(CURDIR)/ztoc/fbs -g $(FBS_FILE_PATH)
67 rm -rf $(CURDIR)/ztoc/compression/fbs/zinfo
68 flatc -o $(CURDIR)/ztoc/compression/fbs -g $(FBS_FILE_PATH_COMPRESSION)
69
70 install:
71 @echo "$@"
72 @mkdir -p $(CMD_DESTDIR)/bin
73 @install $(CMD_BINARIES) $(CMD_DESTDIR)/bin
74
75 uninstall:
76 @echo "$@"
77 @rm -f $(addprefix $(CMD_DESTDIR)/bin/,$(notdir $(CMD_BINARIES)))
78
79 clean:
80 rm -rf $(OUTDIR)
81
82 vendor:
83 @GO111MODULE=$(GO111MODULE_VALUE) go mod tidy
84 @cd ./cmd ; GO111MODULE=$(GO111MODULE_VALUE) go mod tidy
85
86 test:
87 @echo "$@"
88 @GO111MODULE=$(GO111MODULE_VALUE) go test $(GO_TEST_FLAGS) $(GO_LD_FLAGS) -race ./...
89
90 integration: build
91 @echo "$@"
92 @echo "SOCI_SNAPSHOTTER_PROJECT_ROOT=$(SOCI_SNAPSHOTTER_PROJECT_ROOT)"
93 @GO111MODULE=$(GO111MODULE_VALUE) SOCI_SNAPSHOTTER_PROJECT_ROOT=$(SOCI_SNAPSHOTTER_PROJECT_ROOT) ENABLE_INTEGRATION_TEST=true go test $(GO_TEST_FLAGS) -v -timeout=0 ./integration
94
95 release:
96 @echo "$@"
97 @$(SOCI_SNAPSHOTTER_PROJECT_ROOT)/scripts/create-releases.sh $(RELEASE_TAG)
98
99 benchmarks:
100 @echo "$@"
101 @cd benchmark/performanceTest ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/PerfTests . && sudo ../bin/PerfTests
102 @cd benchmark/comparisonTest ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/CompTests . && sudo ../bin/CompTests
103
104 build-benchmarks:
105 @echo "$@"
106 @cd benchmark/performanceTest ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/PerfTests .
107 @cd benchmark/comparisonTest ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/CompTests .
108
109 benchmarks-perf-test:
110 @echo "$@"
111 @cd benchmark/performanceTest ; sudo rm -rf output ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/PerfTests . && sudo ../bin/PerfTests -show-commit
112
113 benchmarks-stargz:
114 @echo "$@"
115 @cd benchmark/stargzTest ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/StargzTests . && sudo ../bin/StargzTests $(COMMIT) ../singleImage.csv 10 $(STARGZ_BINARY)
116
117 benchmarks-parser:
118 @echo "$@"
119 @cd benchmark/parser ; GO111MODULE=$(GO111MODULE_VALUE) go build -o ../bin/Parser .