summaryrefslogtreecommitdiffstats
path: root/abuild.in
diff options
context:
space:
mode:
authorJoseph Benden <joe@benden.us>2019-07-20 01:14:20 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2019-09-30 12:08:17 +0000
commitb1b47140eaf74c83a2f12fbff8971d1087e920a6 (patch)
treef45c1b6369f8c1cd643956b6ea612c9eaaedec36 /abuild.in
parent9be3a6c6a033c2151ae937aa437a960a55f8279c (diff)
downloadabuild-b1b47140eaf74c83a2f12fbff8971d1087e920a6.tar.bz2
abuild-b1b47140eaf74c83a2f12fbff8971d1087e920a6.tar.xz
feat: add support for ccache
This introduces basic support for ccache, during packaging builds. If you are building many packages, it is recommended to manually increase the maximum size of the ccache cache. This is typically achieved by modifying `~/.ccache/ccache.conf` and adjusting the `max_size` setting. Signed-off-by: Joseph Benden <joe@benden.us>
Diffstat (limited to 'abuild.in')
-rw-r--r--abuild.in31
1 files changed, 27 insertions, 4 deletions
diff --git a/abuild.in b/abuild.in
index 8483cf8..9250411 100644
--- a/abuild.in
+++ b/abuild.in
@@ -26,6 +26,8 @@ fi
: ${APK:="apk"}
: ${ADDUSER:="abuild-adduser"}
: ${ADDGROUP:="abuild-addgroup"}
+: ${CC:="gcc"}
+: ${CXX:="g++"}
apk_opt_wait="--wait 30"
@@ -2054,6 +2056,9 @@ builddeps() {
mhd=$(get_missing_deps "--root $CBUILDROOT --arch $CTARGET_ARCH" $hostdeps) || return 1
missing=$(echo $mbd $mhd)
+ # shall ccache be added?
+ [ -n "$USE_CCACHE" ] && missing="$missing ccache"
+
if [ -z "$install_deps" ]; then
# if we dont have any missing deps we are done now
[ -z "$missing" ] && return 0
@@ -2138,6 +2143,7 @@ rootbld() {
"$BUILD_ROOT/$SRCDEST" "$BUILD_ROOT/$REPODEST" \
"$BUILD_ROOT/tmp/pkg" "$BUILD_ROOT/tmp/src" \
"$BUILD_ROOT/usr/bin" "$pkgbasedir" "$REPODEST" \
+ "$BUILD_ROOT/$HOME/.ccache" \
"$srcdir"
cp /etc/abuild.conf /etc/group /etc/passwd "$BUILD_ROOT/etc"
@@ -2170,7 +2176,7 @@ rootbld() {
calcdeps
$SUDO_APK add --initdb --root "$BUILD_ROOT" --update \
- abuild alpine-base build-base git $hostdeps $builddeps
+ abuild alpine-base build-base git ccache $hostdeps $builddeps
local bwrap_opts=""
options_has "net" || bwrap_opts="$bwrap_opts --unshare-net"
@@ -2181,6 +2187,7 @@ rootbld() {
--bind "$BUILD_ROOT/$HOME" "$HOME" \
--ro-bind "$HOME/.abuild" "$HOME/.abuild" \
--ro-bind "$aportsgit" "$aportsgit" \
+ --bind "$HOME/.ccache" "$HOME/.ccache" \
--bind "$SRCDEST" "$SRCDEST" \
--bind "$BUILD_ROOT/tmp" /tmp \
--bind "$BUILD_ROOT/tmp/src" "$srcdir" \
@@ -2491,6 +2498,24 @@ if [ $(id -u) -eq 0 ] && [ -z "$FAKEROOTKEY" ]; then
FAKEROOT=
fi
+# check for ccache presence and maybe export its path
+if [ -n "$USE_CCACHE" ]; then
+ if ! command -v ccache >/dev/null; then
+ die "Ccache is enabled; however, the binary can not be found."
+ fi
+
+ if [ ! -d "$HOME/.ccache" ]; then
+ die "Ccache is enabled; however, the user cache directory is not found."
+ fi
+
+ if [ ! -f "$HOME/.ccache/ccache.conf" ]; then
+ die "Ccache is enabled; however, the ccache configuration file is not found."
+ fi
+
+ # prepend ccache path
+ export PATH="/usr/lib/ccache/bin:$PATH"
+fi
+
# find startdir
[ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)"
APKBUILD=$(readlink -f "$APKBUILD")
@@ -2509,9 +2534,7 @@ SRCDEST=${SRCDEST:-$startdir}
BUILD_ROOT=
-# set a default CC
-: ${CC:=gcc}
-export CC
+export CC CXX
cd "$startdir" || die
. "$APKBUILD"