ccache can detect the name it's been called with and transparently invoke the compiler if it matches. The Fedora package uses this trick to enable ccache out of the box, but other operating systems and distributions leave the task up to the user. Replicate the setup in the user's ~/.ccache directory so that it works across all guests. With the linke farm in place, setting $CC in the user's shell profile is no longer necessary. Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx> --- guests/group_vars/all/main.yml | 2 +- guests/tasks/users.yml | 33 ++++++++++++++++++++++++++++++++- guests/templates/bashrc | 3 --- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/guests/group_vars/all/main.yml b/guests/group_vars/all/main.yml index b364acf..cd8ef25 100644 --- a/guests/group_vars/all/main.yml +++ b/guests/group_vars/all/main.yml @@ -9,7 +9,7 @@ jenkins_url: https://ci.centos.org/computer/{{ inventory_hostname }}/slave-agent # Environment variables and paths to commands/files that might be # OS-dependent. Can be overridden on a per-host basis VIRT_PREFIX: $HOME/build/libvirt -PATH: $VIRT_PREFIX/bin:$PATH +PATH: $VIRT_PREFIX/bin:$HOME/.ccache/bin:$PATH C_INCLUDE_PATH: $VIRT_PREFIX/include LD_LIBRARY_PATH: $VIRT_PREFIX/lib PKG_CONFIG_PATH: $VIRT_PREFIX/lib/pkgconfig diff --git a/guests/tasks/users.yml b/guests/tasks/users.yml index e691b32..033ca2a 100644 --- a/guests/tasks/users.yml +++ b/guests/tasks/users.yml @@ -53,10 +53,13 @@ - name: '{{ flavor }}: Configure ccache' file: - path: /home/{{ flavor }}/.ccache + path: /home/{{ flavor }}/.{{ item }} state: directory owner: '{{ flavor }}' group: '{{ flavor }}' + with_items: + - ccache + - ccache/bin - name: '{{ flavor }}: Configure ccache' copy: @@ -65,6 +68,34 @@ owner: '{{ flavor }}' group: '{{ flavor }}' +- name: '{{ flavor }}: Create ccache wrappers' + file: + src: '{{ ccache }}' + dest: /home/{{ flavor }}/.ccache/bin/{{ item }} + state: link + owner: '{{ flavor }}' + group: '{{ flavor }}' + with_items: + - cc + - clang + when: + - ccache != '' + - os_name == 'FreeBSD' + +- name: '{{ flavor }}: Create ccache wrappers' + file: + src: '{{ ccache }}' + dest: /home/{{ flavor }}/.ccache/bin/{{ item }} + state: link + owner: '{{ flavor }}' + group: '{{ flavor }}' + with_items: + - cc + - gcc + when: + - ccache != '' + - os_name != 'FreeBSD' + - name: '{{ flavor }}: Create shell profile' template: src: templates/{{ item }} diff --git a/guests/templates/bashrc b/guests/templates/bashrc index 65c82cd..866087e 100644 --- a/guests/templates/bashrc +++ b/guests/templates/bashrc @@ -11,12 +11,9 @@ export OSINFO_SYSTEM_DIR="{{ OSINFO_SYSTEM_DIR }}" export PERL5LIB="{{ PERL5LIB }}" export PYTHONPATH="{{ PYTHONPATH }}" -export CCACHE="{{ ccache }}" export MAKE="{{ make }}" export PYTHON="{{ python }}" -test "$CCACHE" && export CC="$CCACHE cc" - # Enable bash completion. Only needed on FreeBSD, the system-wide # shell profile will take care of it for us everywhere else bash_completion=/usr/local/share/bash-completion/bash_completion.sh -- 2.14.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list