summaryrefslogtreecommitdiff
path: root/ccache.sh.in
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2024-10-05 13:47:38 +0000
committerCoprDistGit <infra@openeuler.org>2024-10-05 13:47:38 +0000
commit69e7afdb85a5b83ef746994fa96d2f259072983f (patch)
treea8265af768af7605cb18638d9d5af43d7d58cbb0 /ccache.sh.in
parent9d835d18dad0aaadead88bcbc4b395b8cce9f914 (diff)
automatic import of ccache
Diffstat (limited to 'ccache.sh.in')
-rw-r--r--ccache.sh.in27
1 files changed, 27 insertions, 0 deletions
diff --git a/ccache.sh.in b/ccache.sh.in
new file mode 100644
index 0000000..0ce4d64
--- /dev/null
+++ b/ccache.sh.in
@@ -0,0 +1,27 @@
+# Use ccache by default. Users who don't want that can set the CCACHE_DISABLE
+# environment variable in their personal profile.
+
+case ":${PATH:-}:" in
+ *:@LIBDIR@/ccache:*) ;;
+ *) PATH="@LIBDIR@/ccache${PATH:+:$PATH}" ;;
+esac
+
+# If @CACHEDIR@ is writable, use a shared cache there, except for root.
+# Users who don't want that even if they have the write permission can set
+# the CCACHE_DIR environment variable to another location and possibly unset
+# the CCACHE_UMASK environment variables in their personal profile.
+
+if [ -n "${CCACHE_DIR:-}" ] ; then
+ if [ ! -w "$CCACHE_DIR" ] ; then
+ # Reset broken settings maybe inherited when switching users (#651023).
+ unset CCACHE_DIR
+ unset CCACHE_UMASK
+ fi
+elif [ "${EUID:-}" != 0 ] ; then
+ if [ -w @CACHEDIR@ ] && [ -d @CACHEDIR@ ] ; then
+ # Set up the shared cache.
+ export CCACHE_DIR=@CACHEDIR@
+ export CCACHE_UMASK=002
+ unset CCACHE_HARDLINK
+ fi
+fi