forked from cilium/proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
120 lines (97 loc) · 3.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
# Copyright 2017-2021 Authors of Cilium
#
# 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.
include Makefile.defs
# COMPILER_DEP:=clang.bazelrc
ENVOY_BINS = cilium-envoy bazel-bin/cilium-envoy bazel-bin/cilium-envoy-deps
ENVOY_TESTS = bazel-bin/tests/*_test
SHELL=/bin/bash -o pipefail
BAZEL ?= $(QUIET) bazel
BAZEL_FILTER ?=
BAZEL_OPTS ?=
BAZEL_BUILD_OPTS ?=
ifdef BAZEL_REMOTE_CACHE
BAZEL_BUILD_OPTS += --remote_cache=$(BAZEL_REMOTE_CACHE)
endif
BAZEL_TEST_OPTS ?= $(BAZEL_BUILD_OPTS)
BAZEL_TEST_OPTS += --test_output=errors
ifdef CROSSARCH
$(info CROSS-COMPILING for arm64)
BAZEL_BUILD_OPTS += --incompatible_enable_cc_toolchain_resolution --platforms=//bazel/platforms:aarch64_cross --define=cross=aarch64
endif
BAZEL_ARCH = $(subst x86_64,k8,$(shell uname -m))
ifdef PKG_BUILD
all: cilium-envoy
else
include Makefile.dev
include Makefile.docker
# Fetch and install Bazel if needed
.PHONY: install-bazel
install-bazel:
tools/install_bazel.sh `cat .bazelversion`
endif
/usr/lib/llvm-10:
sudo apt install clang-10 llvm-10-dev clang-format-10 lld-10
clang.bazelrc: bazel/setup_clang.sh /usr/lib/llvm-10
bazel/setup_clang.sh /usr/lib/llvm-10
echo "build --config=clang" >> $@
envoy-deps-release: $(COMPILER_DEP)
@$(ECHO_BAZEL)
$(BAZEL) $(BAZEL_OPTS) build $(BAZEL_BUILD_OPTS) --config=release //:cilium-envoy-deps $(BAZEL_FILTER)
bazel-bin/cilium-envoy: $(COMPILER_DEP)
@$(ECHO_BAZEL)
$(BAZEL) $(BAZEL_OPTS) build $(BAZEL_BUILD_OPTS) --config=release //:cilium-envoy $(BAZEL_FILTER)
cilium-envoy: bazel-bin/cilium-envoy
mv $< $@
BAZEL_CACHE := $(subst --disk_cache=,,$(filter --disk_cache=%, $(BAZEL_BUILD_OPTS)))
install: bazel-bin/cilium-envoy
$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(INSTALL) -m 0755 -T $< $(DESTDIR)$(BINDIR)/cilium-envoy
ifdef COPY_CACHE_EXT
ifneq ($(BAZEL_CACHE),)
cp -ra $(BAZEL_CACHE) $(BAZEL_CACHE)$(COPY_CACHE_EXT)
endif
endif
# Remove the binaries and linkstamp to get fresh version SHA for the next build
clean: force
@$(ECHO_CLEAN) $(notdir $(shell pwd))
-$(QUIET) rm -f $(ENVOY_BINS) $(ENVOY_TESTS)
.PHONY: envoy-test-deps
envoy-test-deps: $(COMPILER_DEP)
@$(ECHO_BAZEL)
$(BAZEL) $(BAZEL_OPTS) build --build_tests_only $(BAZEL_BUILD_OPTS) --config=release -c fastbuild //:cilium-envoy-test-deps $(BAZEL_FILTER)
.PHONY: envoy-tests
envoy-tests: $(COMPILER_DEP)
@$(ECHO_BAZEL)
$(BAZEL) $(BAZEL_OPTS) test $(BAZEL_TEST_OPTS) --config=release -c fastbuild //tests/... $(BAZEL_FILTER)
ifdef COPY_CACHE_EXT
ifneq ($(BAZEL_CACHE),)
cp -ra $(BAZEL_CACHE) $(BAZEL_CACHE)$(COPY_CACHE_EXT)
endif
endif
.PHONY: \
install \
force \
force-non-root \
force-root
force :;
force-root:
ifndef PKG_BUILD
ifneq ($(USER),root)
$(error This target must be run as root!)
endif
endif
force-non-root:
ifeq ($(USER),root)
$(error This target cannot be run as root!)
endif