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@redhat.com>
---
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@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Disclaimer: I don't feel like I can review the patches properly. Not only because I never heard the term "symlink farm" before, but mostly because jenkins-ci. However I noticed two nits here and there. I hope it won't discourage others from review. I apologize in advance if it does. On Wed, Apr 18, 2018 at 05:25:21PM +0200, Andrea Bolognani wrote: >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 s/linke/link/ ? >place, setting $CC in the user's shell profile is no longer >necessary. > >Signed-off-by: Andrea Bolognani <abologna@redhat.com> >--- > 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 > With new enough ansible, you don't need the 'ccache' entry as this behaves similarly to `mkdir -p`: "If directory, all immediate subdirectories will be created if they do not exist, since 1.7 they will be created with the supplied permissions." [1] You can also use 'recurse' if doing more than just creating them. [1] https://docs.ansible.com/ansible/latest/modules/file_module.html Have a nice day Martin -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On Thu, 2018-04-19 at 17:36 +0200, Martin Kletzander wrote: > > Replicate the setup in the user's ~/.ccache directory so > > that it works across all guests. With the linke farm in > > s/linke/link/ ? Close: I actually meant to write Linkle[1] :P > > - name: '{{ flavor }}: Configure ccache' > > file: > > - path: /home/{{ flavor }}/.ccache > > + path: /home/{{ flavor }}/.{{ item }} > > state: directory > > owner: '{{ flavor }}' > > group: '{{ flavor }}' > > + with_items: > > + - ccache > > + - ccache/bin > > With new enough ansible, you don't need the 'ccache' entry as this > behaves similarly to `mkdir -p`: > > "If directory, all immediate subdirectories will be created if they do > not exist, since 1.7 they will be created with the supplied > permissions." [1] If you dig through the playbooks, you'll certainly find no lack of suboptimal or roundabout approaches to the problem at hand, mostly as a consequence of me pretty much figuring out Ansible as I went. I'll be make to get rid of this specific instance before pushing. More patches in the spirit would be very much welcome O:-) [1] https://zelda.gamepedia.com/Linkle -- Andrea Bolognani / Red Hat / Virtualization -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2025 Red Hat, Inc.