envsetup.sh: Setup and enable ccache
Signed-off-by: minaripenguin <minaripenguin@users.noreply.github.com> Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
parent
9cb1a65893
commit
d3af54e75c
23
envsetup.sh
23
envsetup.sh
@ -2122,6 +2122,29 @@ set_global_paths
|
||||
source_vendorsetup
|
||||
addcompletions
|
||||
|
||||
# check and set ccache path on envsetup
|
||||
if [ -z "${CCACHE_EXEC}" ]; then
|
||||
if command -v ccache &>/dev/null; then
|
||||
export USE_CCACHE=1
|
||||
export CCACHE_EXEC=$(command -v ccache)
|
||||
[ -z "${CCACHE_DIR}" ] && export CCACHE_DIR="$HOME/.ccache"
|
||||
echo "ccache directory found, CCACHE_DIR set to: $CCACHE_DIR" >&2
|
||||
CCACHE_MAXSIZE="${CCACHE_MAXSIZE:-40G}"
|
||||
DIRECT_MODE="${DIRECT_MODE:-false}"
|
||||
$CCACHE_EXEC -o compression=true -o direct_mode="${DIRECT_MODE}" -M "${CCACHE_MAXSIZE}" \
|
||||
&& echo "ccache enabled, CCACHE_EXEC set to: $CCACHE_EXEC, CCACHE_MAXSIZE set to: $CCACHE_MAXSIZE, direct_mode set to: $DIRECT_MODE" >&2 \
|
||||
|| echo "Warning: Could not set cache size limit. Please check ccache configuration." >&2
|
||||
CURRENT_CCACHE_SIZE=$(du -sh "$CCACHE_DIR" 2>/dev/null | cut -f1)
|
||||
if [ -n "$CURRENT_CCACHE_SIZE" ]; then
|
||||
echo "Current ccache size is: $CURRENT_CCACHE_SIZE" >&2
|
||||
else
|
||||
echo "No cached files in ccache." >&2
|
||||
fi
|
||||
else
|
||||
echo "Error: ccache not found. Please install ccache." >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
export ANDROID_BUILD_TOP=$(gettop)
|
||||
|
||||
. $ANDROID_BUILD_TOP/vendor/lineage/build/envsetup.sh
|
||||
|
Loading…
Reference in New Issue
Block a user