mirror of https://github.com/grpc/grpc.git
Use ccache for selected C++ and python builds (with redis server as cache) (#28661)
* add cmake support for ccache * cleanup: use --env-file for docker run invocations * make python build compatible with using ccache * enable building using ccache in selected kokoro jobs * print ccache stats and the end of run_tests.pypull/28682/head
parent
739e739322
commit
f23f1bb51f
16 changed files with 131 additions and 26 deletions
@ -0,0 +1,26 @@ |
||||
# Copyright 2022 The gRPC 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. |
||||
|
||||
# Configure ccache if requested by environment variable GRPC_BUILD_ENABLE_CCACHE |
||||
|
||||
if ($ENV{GRPC_BUILD_ENABLE_CCACHE}) |
||||
find_program(gRPC_CCACHE_BINARY ccache) |
||||
if(gRPC_CCACHE_BINARY) |
||||
message(STATUS "Will use ccache as compiler launcher: ${gRPC_CCACHE_BINARY}") |
||||
set(CMAKE_C_COMPILER_LAUNCHER ${gRPC_CCACHE_BINARY}) |
||||
set(CMAKE_CXX_COMPILER_LAUNCHER ${gRPC_CCACHE_BINARY}) |
||||
else() |
||||
message(STATUS "Build will not use ccache (ccache binary not found).") |
||||
endif() |
||||
endif() |
@ -0,0 +1,22 @@ |
||||
#!/bin/bash |
||||
# Copyright 2022 The gRPC 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. |
||||
|
||||
# Source this rc script to configure ccache (compiler cache to speed up builds) |
||||
|
||||
# Allow use of ccache in builds that support that. |
||||
export GRPC_BUILD_ENABLE_CCACHE=true |
||||
|
||||
# Redis instance housed in grpc-testing cloud project serves as the main compiler cache |
||||
export CCACHE_SECONDARY_STORAGE=redis://10.76.145.84:6379 |
@ -0,0 +1,31 @@ |
||||
#!/bin/bash |
||||
# Copyright 2022 The gRPC 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. |
||||
|
||||
# Source this rc script to create symlinks to ccache |
||||
|
||||
# TODO: handle values like "0", "false" etc. |
||||
if [ "${GRPC_BUILD_ENABLE_CCACHE}" != "" ] |
||||
then |
||||
if [ -x "$(command -v ccache)" ] |
||||
then |
||||
TEMP_CCACHE_BINDIR="$(mktemp -d)" |
||||
# TODO: symlinks for crosscompilers... |
||||
for compiler in "gcc" "g++" "clang" "clang++" "cc" "c++" |
||||
do |
||||
ln -s "$(which ccache)" "${TEMP_CCACHE_BINDIR}/${compiler}" |
||||
done |
||||
export PATH="${TEMP_CCACHE_BINDIR}:$PATH" |
||||
fi |
||||
fi |
@ -0,0 +1,17 @@ |
||||
# Pass this file to "docker run" using --env-file argument. |
||||
# Variables listed in this file will be set or propagated |
||||
# to the docker container. |
||||
|
||||
# TODO(jtattermusch): revisit whether this very old hack is still needed. |
||||
THIS_IS_REALLY_NEEDED="see https://github.com/docker/docker/issues/14203 for why docker is awful" |
||||
|
||||
# Kokoro sets environment variables for each build and we want them to be |
||||
# available inside the test docker containers. |
||||
KOKORO_BUILD_ID |
||||
KOKORO_BUILD_NUMBER |
||||
KOKORO_BUILD_URL |
||||
KOKORO_JOB_NAME |
||||
|
||||
# Propagate ccache configuration to the docker containers. |
||||
GRPC_BUILD_ENABLE_CCACHE |
||||
CCACHE_SECONDARY_STORAGE |
Loading…
Reference in new issue