Add corrected setup-2drive-build and setup-ccache scripts

setup-2drive-build.sh now symlinks the AOSP source dir itself to the
NVMe (not just out/), preventing the OS SSD from filling during repo sync.
setup-ccache.sh persists all ccache env vars to ~/.bashrc so they survive
new shell sessions, and accepts cache size as an optional argument.
This commit is contained in:
oxmc
2026-06-04 01:46:46 -07:00
parent 7411a6937f
commit d61af0fb7f
2 changed files with 69 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# Move AOSP source to a second drive so the OS drive doesn't fill up.
# $1 = NVMe path to create as AOSP source root (e.g. /mnt/ssd/AOSP-Source)
# $2 = local path environ.py expects (e.g. /home/oxmc/PawletOS-Build/AOSP-Source)
#
# Out dir is handled separately via OUT_DIR in ~/.bashrc — no out/ symlink needed.
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: ./setup-2drive-build.sh <nvme-source-path> <local-source-symlink>"
echo " e.g.: ./setup-2drive-build.sh /mnt/ssd/AOSP-Source /home/oxmc/PawletOS-Build/AOSP-Source"
exit 1
fi
NVME_SOURCE="$1"
LOCAL_SOURCE="$2"
mkdir -p "$NVME_SOURCE"
if [ -L "$LOCAL_SOURCE" ]; then
echo "Existing symlink found, relinking..."
unlink "$LOCAL_SOURCE"
elif [ -d "$LOCAL_SOURCE" ]; then
echo "ERROR: $LOCAL_SOURCE is a real directory (has data on the OS drive)."
echo "Remove it first: rm -rf '$LOCAL_SOURCE'"
exit 1
fi
ln -s "$NVME_SOURCE" "$LOCAL_SOURCE"
echo "Done."
echo " AOSP source : $LOCAL_SOURCE -> $NVME_SOURCE"
echo " Build output: set OUT_DIR in ~/.bashrc (currently: ${OUT_DIR:-not set})"
+37
View File
@@ -0,0 +1,37 @@
#!/bin/bash
# Configure ccache for AOSP builds and persist settings to ~/.bashrc.
# $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"
export CCACHE_EXEC=/usr/bin/ccache
export USE_CCACHE=1
export CC_WRAPPER=ccache
export CXX_WRAPPER=ccache
if ! grep -q 'CCACHE_DIR' "$BASHRC"; then
cat >> "$BASHRC" << 'EOF'
# ccache (PawletOS build)
export CCACHE_DIR=/mnt/ssd/ccache
export CCACHE_EXEC=/usr/bin/ccache
export USE_CCACHE=1
export CC_WRAPPER=ccache
export CXX_WRAPPER=ccache
EOF
echo "ccache vars written to $BASHRC"
else
echo "~/.bashrc already has CCACHE_DIR — not duplicating"
fi
echo ""
CCACHE_DIR="$CCACHE_PATH" ccache -s