Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the shared ccache optional #844

Merged
merged 2 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/configuration_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ A set of options which can be used in any build file.
platform the associated docker image is based on, therefore no targets can
be specified.

* ``shared_ccache``: when set to ``true``, the executing user's ccache directory
is shared in the build container, which is configured to use ccache where
appropriate (default: ``false``).

Description of common options
-----------------------------

Expand Down
2 changes: 2 additions & 0 deletions ros_buildfarm/ci_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ def _get_ci_job_config(

'benchmark_patterns': build_file.benchmark_patterns,
'benchmark_schema': build_file.benchmark_schema,

'shared_ccache': build_file.shared_ccache,
}
job_config = expand_template(template_name, job_data)
return job_config
4 changes: 4 additions & 0 deletions ros_buildfarm/config/build_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def __init__(self, name, data): # noqa: D107
self.targets[os_name][os_code_name][arch] = \
data['targets'][os_name][os_code_name][arch]

self.shared_ccache = False
if 'shared_ccache' in data:
self.shared_ccache = bool(data['shared_ccache'])

def filter_distribution_files_by_tags(self, dist_files):
res = []

Expand Down
2 changes: 2 additions & 0 deletions ros_buildfarm/devel_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ def _get_devel_job_config(

'benchmark_patterns': build_file.benchmark_patterns,
'benchmark_schema': build_file.benchmark_schema,

'shared_ccache': build_file.shared_ccache,
}
job_config = expand_template(template_name, job_data)
return job_config
2 changes: 2 additions & 0 deletions ros_buildfarm/release_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,8 @@ def _get_binarydeb_job_config(
'timeout_minutes': build_file.jenkins_binary_job_timeout,

'credential_id': build_file.upload_credential_id,

'shared_ccache': build_file.shared_ccache,
}
job_config = expand_template(template_name, job_data)
return job_config
Expand Down
18 changes: 12 additions & 6 deletions ros_buildfarm/templates/ci/ci_job.xml.em
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ parameters = [
'docker build --force-rm -t $DOCKER_IMAGE_PREFIX.ci_build_and_install.%s .' % (rosdistro_name),
'echo "# END SECTION"',
'',
] + ([
'echo "# BEGIN SECTION: ccache stats (before)"',
'mkdir -p $HOME/.ccache',
'docker run' +
Expand All @@ -309,6 +310,7 @@ parameters = [
' "ccache -s"',
'echo "# END SECTION"',
'',
] if shared_ccache else []) + [
'echo "# BEGIN SECTION: Run Dockerfile - build and install"',
] + [
'export UNDERLAY%d_JOB_SPACE=$WORKSPACE/underlay%d/ros%d-linux' % (i + 1, i + 1, local_ros_version)
Expand All @@ -317,8 +319,8 @@ parameters = [
'docker run' +
' --rm ' +
' --cidfile=$WORKSPACE/docker_build_and_install/docker.cid' +
' -e CCACHE_DIR=/home/buildfarm/.ccache' +
' -v $HOME/.ccache:/home/buildfarm/.ccache' +
((' -e CCACHE_DIR=/home/buildfarm/.ccache' +
' -v $HOME/.ccache:/home/buildfarm/.ccache') if shared_ccache else '') +
' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm:ro' +
''.join([
' -v %s:/tmp/ws%s/install_isolated:ro' % (space, i if i > 1 else '')
Expand All @@ -328,6 +330,7 @@ parameters = [
' $DOCKER_IMAGE_PREFIX.ci_build_and_install.%s' % (rosdistro_name),
'cd -', # restore pwd when used in scripts
'echo "# END SECTION"',
] + ([
'',
'echo "# BEGIN SECTION: ccache stats (after)"',
'docker run' +
Expand All @@ -338,7 +341,7 @@ parameters = [
' $DOCKER_IMAGE_PREFIX.ci_build_and_install.%s' % (rosdistro_name) +
' "ccache -s"',
'echo "# END SECTION"',
]),
] if shared_ccache else [])),
))@
@(SNIPPET(
'builder_shell',
Expand Down Expand Up @@ -369,6 +372,7 @@ parameters = [
'docker build --force-rm -t $DOCKER_IMAGE_PREFIX.ci_build_and_test.%s .' % (rosdistro_name),
'echo "# END SECTION"',
'',
] + ([
'echo "# BEGIN SECTION: ccache stats (before)"',
'mkdir -p $HOME/.ccache',
'docker run' +
Expand All @@ -380,6 +384,7 @@ parameters = [
' "ccache -s"',
'echo "# END SECTION"',
'',
] if shared_ccache else []) + [
'echo "# BEGIN SECTION: Run Dockerfile - build and test"',
] + [
'export UNDERLAY%d_JOB_SPACE=$WORKSPACE/underlay%d/ros%d-linux' % (i + 1, i + 1, local_ros_version)
Expand All @@ -390,8 +395,8 @@ parameters = [
'docker run' +
' --rm ' +
' --cidfile=$WORKSPACE/docker_build_and_test/docker.cid' +
' -e CCACHE_DIR=/home/buildfarm/.ccache' +
' -v $HOME/.ccache:/home/buildfarm/.ccache' +
((' -e CCACHE_DIR=/home/buildfarm/.ccache' +
' -v $HOME/.ccache:/home/buildfarm/.ccache') if shared_ccache else '') +
' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm:ro' +
''.join([
' -v %s:/tmp/ws%s/install_isolated:ro' % (space, i if i > 1 else '')
Expand All @@ -401,6 +406,7 @@ parameters = [
' $DOCKER_IMAGE_PREFIX.ci_build_and_test.%s' % (rosdistro_name),
'cd -', # restore pwd when used in scripts
'echo "# END SECTION"',
] + ([
'',
'echo "# BEGIN SECTION: ccache stats (after)"',
'docker run' +
Expand All @@ -411,7 +417,7 @@ parameters = [
' $DOCKER_IMAGE_PREFIX.ci_build_and_test.%s' % (rosdistro_name) +
' "ccache -s"',
'echo "# END SECTION"',
]),
] if shared_ccache else [])),
))@
@(SNIPPET(
'builder_shell',
Expand Down
10 changes: 7 additions & 3 deletions ros_buildfarm/templates/devel/devel_job.xml.em
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ if pull_request:
'echo "# END SECTION"',
'',
'echo "# BEGIN SECTION: Run Dockerfile - build and install"',
] + ([
'if [ ! -d "$HOME/.ccache" ]; then mkdir $HOME/.ccache; fi',
] if shared_ccache else []) + [
('if [ ! -c /dev/nvidia[0-9] ]; then echo "--require-gpu-support is enabled but can not detect nvidia support installed" && exit 1; fi' if require_gpu_support else ''),
'docker run' +
(' --env=DISPLAY=:0.0 --env=QT_X11_NO_MITSHM=1 --volume=/tmp/.X11-unix:/tmp/.X11-unix:rw --gpus all' if require_gpu_support else '') +
Expand All @@ -210,7 +212,7 @@ if pull_request:
' -e=TRAVIS=$TRAVIS' +
' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm:ro' +
' -v $WORKSPACE/ws:/tmp/ws' +
' -v $HOME/.ccache:/home/buildfarm/.ccache' +
(' -v $HOME/.ccache:/home/buildfarm/.ccache' if shared_ccache else '') +
' devel_build_and_install.%s_%s' % (rosdistro_name, source_repo_spec.name.lower()),
'cd -', # restore pwd when used in scripts
'echo "# END SECTION"',
Expand All @@ -232,16 +234,18 @@ if pull_request:
'echo "# END SECTION"',
'',
'echo "# BEGIN SECTION: Run Dockerfile - build and test"',
''
'',
] + ([
'if [ ! -d "$HOME/.ccache" ]; then mkdir $HOME/.ccache; fi',
] if shared_ccache else []) + [
'docker run' +
(' --env=DISPLAY=:0.0 --env=QT_X11_NO_MITSHM=1 --volume=/tmp/.X11-unix:/tmp/.X11-unix:rw --gpus all' if require_gpu_support else '') +
' --rm ' +
' --cidfile=$WORKSPACE/docker_build_and_test/docker.cid' +
' -e=TRAVIS=$TRAVIS' +
' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm:ro' +
' -v $WORKSPACE/ws:/tmp/ws' +
' -v $HOME/.ccache:/home/buildfarm/.ccache' +
(' -v $HOME/.ccache:/home/buildfarm/.ccache' if shared_ccache else '') +
' devel_build_and_test.%s_%s' % (rosdistro_name, source_repo_spec.name.lower()),
'cd -', # restore pwd when used in scripts
'echo "# END SECTION"',
Expand Down
8 changes: 6 additions & 2 deletions ros_buildfarm/templates/release/deb/binarypkg_job.xml.em
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ but disabled since the package is blacklisted (or not whitelisted) in the config
'rm -fr $WORKSPACE/docker_build_binarydeb',
'mkdir -p $WORKSPACE/binarydeb',
'mkdir -p $WORKSPACE/docker_build_binarydeb',
] + ([
'if [ ! -d "$HOME/.ccache" ]; then mkdir $HOME/.ccache; fi',
] if shared_ccache else []) + [
'docker run' +
' --rm ' +
' --cidfile=$WORKSPACE/docker_generating_docker/docker.cid' +
Expand All @@ -136,7 +138,7 @@ but disabled since the package is blacklisted (or not whitelisted) in the config
' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm:ro' +
' -v $WORKSPACE/binarydeb:/tmp/binarydeb' +
' -v $WORKSPACE/docker_build_binarydeb:/tmp/docker_build_binarydeb' +
' -v $HOME/.ccache:/home/buildfarm/.ccache' + \
(' -v $HOME/.ccache:/home/buildfarm/.ccache' if shared_ccache else '') +
' binarydeb_task_generation.%s_%s_%s_%s_%s' % (rosdistro_name, os_name, os_code_name, arch, pkg_name),
'echo "# END SECTION"',
]),
Expand All @@ -159,7 +161,9 @@ but disabled since the package is blacklisted (or not whitelisted) in the config
'echo "# BEGIN SECTION: Run Dockerfile - build binarydeb"',
'# -e=HOME= is required to set a reasonable HOME for the user (not /)',
'# otherwise apt-src will fail',
] + ([
'if [ ! -d "$HOME/.ccache" ]; then mkdir $HOME/.ccache; fi',
] if shared_ccache else []) + [
'docker run' +
' --rm ' +
' --cidfile=$WORKSPACE/docker_build_binarydeb/docker.cid' +
Expand All @@ -168,7 +172,7 @@ but disabled since the package is blacklisted (or not whitelisted) in the config
' --net=host' +
' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm:ro' +
' -v $WORKSPACE/binarydeb:/tmp/binarydeb' +
' -v $HOME/.ccache:/home/buildfarm/.ccache' +
(' -v $HOME/.ccache:/home/buildfarm/.ccache' if shared_ccache else '') +
' binarydeb_build.%s_%s_%s_%s_%s' % (rosdistro_name, os_name, os_code_name, arch, pkg_name),
'echo "# END SECTION"',
]),
Expand Down
5 changes: 4 additions & 1 deletion ros_buildfarm/templates/release/rpm/binarypkg_job.xml.em
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ but disabled since the package is blacklisted (or not whitelisted) in the config
'echo "# BEGIN SECTION: Run Dockerfile - build binaryrpm"',
'rm -fr $WORKSPACE/binarypkg',
'mkdir -p $WORKSPACE/binarypkg/source',
] + ([
'if [ ! -d "$HOME/.ccache" ]; then mkdir $HOME/.ccache; fi',
] if shared_ccache else []) + [
cottsay marked this conversation as resolved.
Show resolved Hide resolved
'docker run' +
' --rm' +
' --privileged' +
Expand All @@ -131,7 +134,7 @@ but disabled since the package is blacklisted (or not whitelisted) in the config
' --net=host' +
' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm:ro' +
' -v $WORKSPACE/binarypkg:/tmp/binarypkg' +
' -v ~/.ccache:/home/buildfarm/.ccache' +
(' -v $HOME/.ccache:/home/buildfarm/.ccache' if shared_ccache else '') +
' binaryrpm.%s_%s_%s_%s_%s' % (rosdistro_name, os_name, os_code_name, arch, pkg_name),
'echo "# END SECTION"',
]),
Expand Down