Search
SailfishOS Open Build Service
>
Projects
>
home:plfiorini
:
maui:devel
:
x86_64
>
build
> _service:tar_git:0017-Fix-ccache-support-for-sb2-and-KVM.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File _service:tar_git:0017-Fix-ccache-support-for-sb2-and-KVM.patch of Package build
From 11f800741c3eb1c2b41aef168e95e236f85295fd Mon Sep 17 00:00:00 2001 From: Islam Amer <islam.amer@jollamobile.com> Date: Thu, 25 Apr 2013 13:29:14 +0300 Subject: [PATCH] Fix ccache support for sb2 and KVM Make ccache work in SB2 and extend it to support KVM based building ( useful with patched bs_worker ). Written on top of patch from Juha Kallioinen Signed-off-by: Islam Amer <islam.amer@jollamobile.com> --- build | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/build b/build index c9b4116..25a2424 100644 --- a/build +++ b/build @@ -391,25 +391,40 @@ toshellscript() setupccache() { if [ "$ccache" = 1 ]; then - if mkdir -p $BUILD_ROOT/var/lib/build/ccache/bin; then - for i in $(ls $BUILD_ROOT/usr/bin | grep -E '^(cc|gcc|[cg][+][+])([-]?[234][.]?[0-9])*$'); do -# ln -sf /usr/bin/ccache $BUILD_ROOT/var/lib/build/ccache/bin/$i - rm -f $BUILD_ROOT/var/lib/build/ccache/bin/$i - test -e $BUILD_ROOT/usr/bin/$i || continue - echo '#! /bin/sh' > $BUILD_ROOT/var/lib/build/ccache/bin/$i - echo "test -e /usr/bin/$i || exit 1" >> $BUILD_ROOT/var/lib/build/ccache/bin/$i - echo 'export PATH=/opt/icecream/bin:/usr/bin:$PATH' >> $BUILD_ROOT/var/lib/build/ccache/bin/$i - echo "ccache $i \"\$@\"" >> $BUILD_ROOT/var/lib/build/ccache/bin/$i - chmod 755 $BUILD_ROOT/var/lib/build/ccache/bin/$i - echo "Installed ccache wrapper as $BUILD_ROOT/var/lib/build/ccache/bin/$i" + if mkdir -p $BUILD_TARGET/var/lib/build/ccache/bin; then + for i in $(ls $BUILD_TARGET/usr/bin | grep -E '^(cc|gcc|[cg][+][+])([-]?[234][.]?[0-9])*$'); do +# ln -sf /usr/bin/ccache $BUILD_TARGET/var/lib/build/ccache/bin/$i + echo "handling $i" + rm -f $BUILD_TARGET/var/lib/build/ccache/bin/$i + test -e $BUILD_TARGET/usr/bin/$i || continue + echo '#! /bin/sh' > $BUILD_TARGET/var/lib/build/ccache/bin/$i + echo "test -e /usr/bin/$i || exit 1" >> $BUILD_TARGET/var/lib/build/ccache/bin/$i + echo 'export PATH=/opt/icecream/bin:/usr/bin:$PATH' >> $BUILD_TARGET/var/lib/build/ccache/bin/$i + echo "ccache $i \"\$@\"" >> $BUILD_TARGET/var/lib/build/ccache/bin/$i + chmod 755 $BUILD_TARGET/var/lib/build/ccache/bin/$i + echo "Installed ccache wrapper as $BUILD_TARGET/var/lib/build/ccache/bin/$i" done fi - mkdir -p "$BUILD_ROOT"/.ccache - chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT/.ccache" - echo "export CCACHE_DIR=/.ccache" > "$BUILD_ROOT"/etc/profile.d/build_ccache.sh + mkdir -p "$BUILD_ROOT/home/abuild/.ccache" + echo "export CCACHE_DIR=/home/abuild/.ccache" > "$BUILD_ROOT"/etc/profile.d/build_ccache.sh echo 'export PATH=/var/lib/build/ccache/bin:$PATH' >> "$BUILD_ROOT"/etc/profile.d/build_ccache.sh + echo 'export CCACHE_TOOLS_PATH=/var/lib/build/ccache/bin' >> "$BUILD_ROOT"/etc/profile.d/build_ccache.sh + if [ -e "$BUILD_TARGET"/.build.oldpackages/ccache.db ]; then + echo "Found ccache from previous build, reusing..." + + tar -xzf "$BUILD_TARGET"/.build.oldpackages/ccache.db -C "$BUILD_ROOT"/home/abuild/ + echo "Old stats..." + CCACHE_DIR="$BUILD_ROOT"/home/abuild/.ccache ccache -s + echo "Zeroing stats..." + CCACHE_DIR="$BUILD_ROOT"/home/abuild/.ccache ccache -z + if [ -n "$BUILD_JOBS" ]; then + BUILD_JOBS=$(( BUILD_JOBS * 4 )) + echo "Overriding -j to $BUILD_JOBS..." + fi + fi + chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT/home/abuild/.ccache" else - rm -f "$BUILD_ROOT"/var/lib/build/ccache/bin/{gcc,g++,cc,c++} + rm -f "$BUILD_TARGET"/var/lib/build/ccache/bin/{gcc,g++,cc,c++} fi } @@ -662,6 +677,8 @@ detect_vm_2nd_stage() fi HOST="$MYHOSTNAME" + grep -q ccache /proc/cmdline && ccache=1 + return 0 } @@ -804,7 +821,10 @@ esac shopt -s nullglob if detect_vm_2nd_stage ; then - set "/.build-srcdir/$SPECFILE" + if [ "$ccache" = 1 ]; then + ARGS="--ccache" + fi + set "/.build-srcdir/$SPECFILE" "$@" "$ARGS" fi @@ -1751,11 +1771,14 @@ for SPECFILE in "${SPECFILES[@]}" ; do if [ "$VM_TYPE" = 'kvm' ]; then KVM_OPTIONS="$KVM_OPTIONS -cpu host" fi + if [ "$ccache" = 1 ]; then + CCACHE="ccache" + fi set -- $qemu_bin -no-reboot -nographic -net none $KVM_OPTIONS \ -kernel $vm_kernel \ -initrd $vm_initrd \ - -append "root=$qemu_rootdev panic=1 quiet no-kvmclock nmi_watchdog=0 rw elevator=noop console=$console init=$vm_init_script" \ + -append "root=$qemu_rootdev panic=1 quiet no-kvmclock nmi_watchdog=0 rw elevator=noop console=$console init=$vm_init_script $CCACHE" \ ${MEMSIZE:+-m $MEMSIZE} \ "${qemu_args[@]}" @@ -1769,7 +1792,11 @@ for SPECFILE in "${SPECFILES[@]}" ; do echo "starting sb2 part inside chroot.." echo "rootfs / rootfs rw 0 0" > $BUILD_ROOT/etc/mtab touch $BUILD_ROOT/.sb2chroot - chroot $BUILD_ROOT "$vm_init_script" + ARGS="" + if [ "$ccache" = 1 ]; then + ARGS="$ARGS --ccache" + fi + chroot $BUILD_ROOT "$vm_init_script" $ARGS BUILDSTATUS="$?" test "$BUILDSTATUS" != 255 || BUILDSTATUS=3 cleanup_and_exit "$BUILDSTATUS" @@ -2331,6 +2358,13 @@ if test -n "$RPMS" \ fi fi +echo "Checking for ccache output..." +if test -d $BUILD_ROOT/home/abuild/.ccache -a -d $BUILD_ROOT/$TOPDIR/OTHER ; then + echo "Saving ccache output for later rebuilds..." + CCACHE_DIR="$BUILD_ROOT"/home/abuild/.ccache ccache -s + tar -C $BUILD_ROOT/home/abuild -c .ccache -zf $BUILD_ROOT/$TOPDIR/OTHER/ccache.db +fi + if test -n "$RUNNING_IN_VM" -a -n "$VM_SWAP"; then echo "... saving built packages" swapoff "$VM_SWAP" -- 1.8.1.4