@@ -2129,18 +2129,25 @@ source_vendorsetup
2129
2129
addcompletions
2130
2130
2131
2131
# check and set ccache path on envsetup
2132
- if [ -z ${CCACHE_EXEC} ]; then
2133
- ccache_path=$( which ccache)
2134
- if [ ! -z " $ccache_path " ]; then
2132
+ if [ -z " ${CCACHE_EXEC} " ]; then
2133
+ if command -v ccache & > /dev/null; then
2135
2134
export USE_CCACHE=1
2136
- export CCACHE_EXEC=" $ccache_path "
2137
- if [ -z ${CCACHE_DIR} ]; then
2138
- export CCACHE_DIR=${HOME} /.ccache
2135
+ export CCACHE_EXEC=$( command -v ccache)
2136
+ [ -z " ${CCACHE_DIR} " ] && export CCACHE_DIR=" $HOME /.ccache"
2137
+ echo " ccache directory found, CCACHE_DIR set to: $CCACHE_DIR " >&2
2138
+ CCACHE_MAXSIZE=" ${CCACHE_MAXSIZE:- 40G} "
2139
+ DIRECT_MODE=" ${DIRECT_MODE:- false} "
2140
+ $CCACHE_EXEC -o compression=true -o direct_mode=" ${DIRECT_MODE} " -M " ${CCACHE_MAXSIZE} " \
2141
+ && echo " ccache enabled, CCACHE_EXEC set to: $CCACHE_EXEC , CCACHE_MAXSIZE set to: $CCACHE_MAXSIZE , direct_mode set to: $DIRECT_MODE " >&2 \
2142
+ || echo " Warning: Could not set cache size limit. Please check ccache configuration." >&2
2143
+ CURRENT_CCACHE_SIZE=$( du -sh " $CCACHE_DIR " 2> /dev/null | cut -f1)
2144
+ if [ -n " $CURRENT_CCACHE_SIZE " ]; then
2145
+ echo " Current ccache size is: $CURRENT_CCACHE_SIZE " >&2
2146
+ else
2147
+ echo " No cached files in ccache." >&2
2139
2148
fi
2140
- $ccache_path -o compression=true
2141
- echo -e " ccache enabled and CCACHE_EXEC has been set to : $ccache_path "
2142
2149
else
2143
- echo -e " ccache not found installed! "
2150
+ echo " Error: ccache not found. Please install ccache. " >&2
2144
2151
fi
2145
2152
fi
2146
2153
0 commit comments