-
-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathMakefile.dev
More file actions
87 lines (69 loc) · 5.25 KB
/
Makefile.dev
File metadata and controls
87 lines (69 loc) · 5.25 KB
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
# 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.
CHECK_FORMAT ?= ./bazel-bin/check_format.py
BAZEL_CACHE ?= ~/.cache/bazel
BAZEL_ARCHIVE ?= ~/bazel-cache.tar.bz2
# @envoy_api//:v3_protos must be built before invoking Makefile.api
API_DEPS = @envoy_api//:v3_protos
PROTOC_TARGET = @com_google_protobuf//:protoc
api: force-non-root Makefile.api install-bazelisk
PROTOC=`$(BAZEL) cquery --output=starlark --starlark:expr=target.files_to_run.executable.path $(PROTOC_TARGET) | grep "fastbuild.*/bin/external"`; \
CARGO_BAZEL_REPIN=true $(BAZEL) build $(PROTOC_TARGET) $(API_DEPS); \
file $${PROTOC} && PROTOC=$${PROTOC} $(MAKE) -f Makefile.api all
api-clean:
find go -name *.pb.go -delete
find go -name *.pb.validate.go -delete
find go -empty -type d -delete
mkdir -p go/contrib/envoy
mkdir go/envoy
$(CHECK_FORMAT): force-non-root SOURCE_VERSION install-bazelisk clang.bazelrc
CARGO_BAZEL_REPIN=true $(BAZEL) $(BAZEL_OPTS) build $(BAZEL_BUILD_OPTS) //:check_format.py
veryclean: force-non-root clean
-sudo $(BAZEL) $(BAZEL_OPTS) clean
-sudo rm -Rf $(BAZEL_CACHE)
precheck: force-non-root
tools/check_repositories.sh
FORMAT_EXCLUDED_PREFIXES = "./linux/" "./proxylib/" "./starter/" "./vendor/" "./go/" "./envoy_build_config/"
# The default set of sources assumes all relevant sources are dependecies of some tests!
TIDY_SOURCES ?= $(shell bazel query 'kind("source file", deps(//tests/...))' 2>/dev/null | sed -n "s/\/\/cilium:/cilium\//p; s/\/\/tests:/tests\//p")
# Must pass our bazel options to avoid discarding the analysis cache due to different options
# between this, check and build!
# Depend on the WORKSPACE and TIDY_SOURCES so that the database will be re-built if
# Envoy dependency or any of the source files has changed.
compile_commands.json: WORKSPACE $(TIDY_SOURCES) force-non-root
CARGO_BAZEL_REPIN=true BAZEL_STARTUP_OPTION_LIST="$(BAZEL_OPTS)" BAZEL_BUILD_OPTION_LIST="$(BAZEL_BUILD_OPTS)" tools/gen_compilation_database.py --include_all //cilium/... //starter/... //tests/...
# Default number of jobs, derived from available memory
TIDY_JOBS ?= $$(( $(shell sed -n "s/^MemAvailable: *\([0-9]*\).*\$$/\1/p" /proc/meminfo) / 4500000 ))
# tidy uses run-clang-tidy, .clang-tidy must be present in the project directory and configured to
# ignore the same headers as .clangd. Unfortunately the configuration format is different.
tidy: compile_commands.json force-non-root
run-clang-tidy -quiet -extra-arg="-Wno-unknown-pragmas" -checks=misc-include-cleaner -j $(TIDY_JOBS) $(TIDY_SOURCES) || echo "clang-tidy check failed, run 'make tidy-fix' locally to fix tidy errors."
tidy-fix: compile_commands.json force-non-root
echo "clang-tidy fix results can contain duplicate or misplaced includes, check before committing!"
run-clang-tidy -fix -format -style=file -quiet -extra-arg="-Wno-unknown-pragmas" -checks=misc-include-cleaner -j $(TIDY_JOBS) $(TIDY_SOURCES) || echo "clang-tidy fix produced changes, please commit them."
tidy-fix-head: compile_commands.json force-non-root
echo "clang-tidy fix results can contain duplicate or misplaced includes, check before committing!"
run-clang-tidy -fix -format -style=file -quiet -extra-arg="-Wno-unknown-pragmas" -checks=misc-include-cleaner -j $(TIDY_JOBS) $(shell git diff-tree --no-commit-id --name-only -r --diff-filter=d HEAD) || echo "clang-tidy fix produced changes, please commit them."
format: force-non-root
CARGO_BAZEL_REPIN=true $(BAZEL) $(BAZEL_OPTS) run $(BAZEL_BUILD_OPTS) @envoy//tools/code_format:check_format -- --path "$(PWD)" --skip_envoy_build_rule_check --add-excluded-prefixes $(FORMAT_EXCLUDED_PREFIXES) --bazel_tools_check_excluded_paths="./" --build_fixer_check_excluded_paths="./" check || echo "Format check failed, run 'make format-fix' locally to fix formatting errors."
format-fix: force-non-root
CARGO_BAZEL_REPIN=true $(BAZEL) $(BAZEL_OPTS) run $(BAZEL_BUILD_OPTS) @envoy//tools/code_format:check_format -- --path "$(PWD)" --skip_envoy_build_rule_check --add-excluded-prefixes $(FORMAT_EXCLUDED_PREFIXES) --bazel_tools_check_excluded_paths="." --build_fixer_check_excluded_paths="./" fix
# Run tests without debug by default.
tests: $(COMPILER_DEP) force-non-root SOURCE_VERSION proxylib/libcilium.so install-bazelisk
CARGO_BAZEL_REPIN=true $(BAZEL) $(BAZEL_OPTS) test $(BAZEL_BUILD_OPTS) //:envoy_binary_test $(BAZEL_FILTER)
CARGO_BAZEL_REPIN=true $(BAZEL) $(BAZEL_OPTS) test $(BAZEL_BUILD_OPTS) $(BAZEL_TEST_OPTS) //tests/... $(BAZEL_FILTER)
$(MAKE) -C proxylib test
debug-tests: $(COMPILER_DEP) force-non-root SOURCE_VERSION install-bazelisk
CARGO_BAZEL_REPIN=true $(BAZEL) $(BAZEL_OPTS) test $(BAZEL_BUILD_OPTS) -c dbg $(BAZEL_TEST_OPTS) //:envoy_binary_test $(BAZEL_FILTER)
CARGO_BAZEL_REPIN=true $(BAZEL) $(BAZEL_OPTS) test $(BAZEL_BUILD_OPTS) -c dbg $(BAZEL_TEST_OPTS) //tests/... $(BAZEL_FILTER)