34 lines
1.0 KiB
Bash
Executable File
34 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Configure ccache directory and size.
|
|
# NOTE: Android 13+ build system blocks CC_WRAPPER/CXX_WRAPPER — ccache cannot
|
|
# wrap the compiler. CCACHE_DIR is set for reference only; Soong handles caching.
|
|
# $1 = cache size limit (default: 30G)
|
|
|
|
CCACHE_PATH=/mnt/ssd/ccache
|
|
CACHE_SIZE="${1:-30G}"
|
|
BASHRC="$HOME/.bashrc"
|
|
|
|
mkdir -p "$CCACHE_PATH"
|
|
|
|
CCACHE_DIR="$CCACHE_PATH" ccache -M "$CACHE_SIZE"
|
|
CCACHE_DIR="$CCACHE_PATH" ccache --set-config=compression=true
|
|
CCACHE_DIR="$CCACHE_PATH" ccache --set-config=compression_level=1
|
|
|
|
export CCACHE_DIR="$CCACHE_PATH"
|
|
|
|
if ! grep -q 'CCACHE_DIR' "$BASHRC"; then
|
|
cat >> "$BASHRC" << 'EOF'
|
|
|
|
# ccache dir (Android 16 — compiler wrapping not supported, Soong handles caching)
|
|
export CCACHE_DIR=/mnt/ssd/ccache
|
|
EOF
|
|
echo "CCACHE_DIR written to $BASHRC"
|
|
else
|
|
# Remove any CC_WRAPPER/CXX_WRAPPER/USE_CCACHE/CCACHE_EXEC lines if present
|
|
sed -i '/CC_WRAPPER\|CXX_WRAPPER\|USE_CCACHE\|CCACHE_EXEC/d' "$BASHRC"
|
|
echo "Cleaned up unsupported ccache wrapper vars from $BASHRC"
|
|
fi
|
|
|
|
echo ""
|
|
CCACHE_DIR="$CCACHE_PATH" ccache -s
|