diff --git a/.SRCINFO b/.SRCINFO index e2e9d61..ea86f00 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -2,15 +2,14 @@ pkgbase = ccache-ext pkgdesc = pacman hook for adding more compiler links to ccache pkgver = 1 pkgrel = 1 + install = ccache-ext.install arch = any license = custom depends = ccache - source = nvcc-ccache.sh source = update-ccache-links.sh source = update-ccache-links.hook - sha256sums = c6db8aaddb625d28050e67122d3b1bf50d1e1e8d6a04cdca3dc195521b53f3c4 - sha256sums = 8df3de20c1e58615354ae6fc35b3f27692060bd33f2f80229346a6acb19687bd - sha256sums = 0fc326f0225ba865394090309d27d41339113248462ee41fea2e3646d7e1eb59 + sha256sums = d030775bced390d7f0f090f5b9c364229ebbd2e39b51da297784dd19502c866f + sha256sums = e7c0cb74b47371162262e1ad57590cbd41a3fdeaa4988370fde98ae19c75703c pkgname = ccache-ext diff --git a/PKGBUILD b/PKGBUILD index 101c296..ff42872 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -7,20 +7,14 @@ pkgdesc='pacman hook for adding more compiler links to ccache' arch=('any') license=('custom') depends=('ccache') -source=('nvcc-ccache.sh' - 'update-ccache-links.sh' +source=('update-ccache-links.sh' 'update-ccache-links.hook') -sha256sums=('c6db8aaddb625d28050e67122d3b1bf50d1e1e8d6a04cdca3dc195521b53f3c4' - '8df3de20c1e58615354ae6fc35b3f27692060bd33f2f80229346a6acb19687bd' - '0fc326f0225ba865394090309d27d41339113248462ee41fea2e3646d7e1eb59') +sha256sums=('d030775bced390d7f0f090f5b9c364229ebbd2e39b51da297784dd19502c866f' + 'e7c0cb74b47371162262e1ad57590cbd41a3fdeaa4988370fde98ae19c75703c') +install=$pkgname.install package() { install -d "${pkgdir}/usr/lib/ccache/bin" - # CUDA - if pacman -T "cuda" ; then - # /usr/lib/ccache/bin/nvcc cauese CMake failed to find CUDA - install -Dm755 nvcc-ccache.sh "${pkgdir}/usr/lib/ccache/bin/nvcc-ccache" - fi install -d "${pkgdir}/usr/bin" install -Dm755 update-ccache-links.sh "${pkgdir}/usr/bin/update-ccache-links" install -d "${pkgdir}/usr/share/libalpm/hooks" diff --git a/ccache-ext.install b/ccache-ext.install new file mode 100644 index 0000000..88b0789 --- /dev/null +++ b/ccache-ext.install @@ -0,0 +1,12 @@ +# arg 1: the old package version +post_remove() { + # Clear symlinks + echo "Clear extra ccache symlinks..." + for file in /usr/lib/ccache/bin/*; do + if ! pacman -Qo $file >/dev/null 2>&1 + then + echo "remove: $file" + rm $file + fi + done +} diff --git a/nvcc-ccache.sh b/nvcc-ccache.sh deleted file mode 100644 index a4307e9..0000000 --- a/nvcc-ccache.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -/usr/bin/ccache nvcc "$@" diff --git a/update-ccache-links.hook b/update-ccache-links.hook index 9d7c6c7..9ddcf13 100644 --- a/update-ccache-links.hook +++ b/update-ccache-links.hook @@ -28,6 +28,7 @@ Target = usr/bin/*-clang-[0-9]* Target = usr/bin/*-clang++-[0-9]* Target = usr/bin/*-g++-[0-9]* Target = usr/bin/*-gcc-[0-9]* +Target = opt/cuda/bin/nvcc [Action] Description = Updating ccache links... diff --git a/update-ccache-links.sh b/update-ccache-links.sh index 8103753..19ce277 100644 --- a/update-ccache-links.sh +++ b/update-ccache-links.sh @@ -1,5 +1,6 @@ -#!/bin/sh +#!/bin/bash +# Clear symlinks cd /usr/lib/ccache/bin for file in {c++,cc,clang,clang++,g++,gcc} {c++,cc,clang,clang++,g++,gcc}-[0-9]* *-{c++,cc,clang,clang++,g++,gcc} *-{c++,cc,clang,clang++,g++,gcc}-[0-9]* do @@ -9,6 +10,7 @@ do fi done +# Recreate synlinks cd /usr/bin for file in {c++,cc,clang,clang++,g++,gcc} {c++,cc,clang,clang++,g++,gcc}-[0-9]* *-{c++,cc,clang,clang++,g++,gcc} *-{c++,cc,clang,clang++,g++,gcc}-[0-9]* do @@ -17,3 +19,13 @@ do ln -s /usr/bin/ccache "/usr/lib/ccache/bin/$file" fi done + +# Update nvcc +{ + [ -f "/usr/lib/ccache/bin/nvcc-ccache" ] && rm "/usr/lib/ccache/bin/nvcc-ccache" + if [[ -f /opt/cuda/bin/nvcc ]] + then + echo -e "#!/bin/sh -\n/usr/bin/ccache /opt/cuda/bin/nvcc \"\$@\"" > /usr/lib/ccache/bin/nvcc-ccache + chmod 755 /usr/lib/ccache/bin/nvcc-ccache + fi +}