Enable icecream build feature sandbox/icecream
authory0169.zhang <y0169.zhang@samsung.com>
Mon, 23 Oct 2017 06:11:41 +0000 (14:11 +0800)
committery0169.zhang <y0169.zhang@samsung.com>
Tue, 24 Oct 2017 12:01:35 +0000 (20:01 +0800)
Change-Id: I6dbdfe2ce5b81d7567df6758b6133dd1be55fad1

build

diff --git a/build b/build
index ea0f11339ed974e3a74177b4e4f0bfa48ad70e05..97b73958100887036e82d3ae8fd1e944c3b6e2f0 100755 (executable)
--- a/build
+++ b/build
@@ -391,6 +391,11 @@ cleanup_and_exit () {
     else
        umount -n $BUILD_ROOT/proc/sys/fs/binfmt_misc 2> /dev/null || true
        umount -n $BUILD_ROOT/proc 2>/dev/null || true
+
+    if test ! "$icecream" -eq 0 ; then
+        umount -n $BUILD_ROOT/run/icecc 2>/dev/null
+    fi
+
     while true
     do
             umount -n $BUILD_ROOT/dev/pts 2>/dev/null
@@ -454,66 +459,113 @@ setupccache() {
 }
 
 setupicecream() {
-    local icecreamdir=/var/run/icecream
-    if test "$(readlink "$BUILD_ROOT/var/run")" = /run ; then
-       icecreamdir=/run/icecream
-    fi
     if test "$icecream" -eq 0 ; then
-       rm -rf "$BUILD_ROOT$icecreamdir"
-       rm -f "$BUILD_ROOT/etc/profile.d/build_icecream.sh"
-       return 0
+        rm -rf $BUILD_ROOT/run/icecc
+        rm -f $BUILD_ROOT/etc/profile.d/build_icecream.sh
+        return 0
     fi
 
-    if ! chroot "$BUILD_ROOT" rpm -q icecream >/dev/null 2>/dev/null; then
-       echo "*** icecream package not installed ***"
-       return 1
+    if test ! -d $BUILD_ROOT/run/icecc/; then
+        mkdir -p $BUILD_ROOT/run/icecc/
     fi
+    mount -o bind /run/icecc $BUILD_ROOT/run/icecc/
 
-    echo "using icecream with $icecream jobs"
-
-    if test -z "$CCACHE" ; then
-       echo 'export PATH=/usr/lib/icecc/bin:/opt/icecream/bin:$PATH' > "$BUILD_ROOT"/etc/profile.d/build_icecream.sh
-    else
-       echo 'export CCACHE_PATH=/usr/lib/icecc/bin:/opt/icecream/bin' > "$BUILD_ROOT"/etc/profile.d/build_icecream.sh
+    if test ! -d $BUILD_ROOT/opt/icecream/bin; then
+        mkdir -p $BUILD_ROOT/opt/icecream/bin
     fi
-
-    local icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT$icecreamdir/*.tar.{bz2,gz}`)
-    icecc_vers=${icecc_vers//$BUILD_ROOT/}
-
-    # XXX use changelog like autobuild does instead?
-    # only run create-env if compiler or glibc changed
-    if test -z "$icecc_vers" \
-       -o ! -e "$BUILD_ROOT/$icecc_vers" \
-       -o "$BUILD_ROOT/usr/bin/gcc" -nt "$BUILD_ROOT/$icecc_vers" \
-       -o "$BUILD_ROOT/usr/bin/g++" -nt "$BUILD_ROOT/$icecc_vers" \
-       -o "$BUILD_ROOT/usr/bin/as" -nt "$BUILD_ROOT/$icecc_vers" \
-       -o "$BUILD_ROOT/lib/libc.so.6" -nt "$BUILD_ROOT/$icecc_vers"
-    then
-       rm -rf "$BUILD_ROOT$icecreamdir"
-       mkdir -p "$BUILD_ROOT$icecreamdir"
-       if test -e "$BUILD_ROOT"/usr/bin/create-env ; then
-           createenv=/usr/bin/create-env
-       elif test -e "$BUILD_ROOT"/usr/lib/icecc/icecc-create-env ; then
-           createenv="/usr/lib/icecc/icecc-create-env /usr/bin/gcc /usr/bin/g++" # XXX
-       elif test -e "$BUILD_ROOT"/usr/lib64/icecc/icecc-create-env ; then
-           createenv="/usr/lib64/icecc/icecc-create-env /usr/bin/gcc /usr/bin/g++" # XXX
-       else
-           echo "create-env not found"
-           return 1
-       fi
-        echo "creating new env in '$icecreamdir'"
-       chroot $BUILD_ROOT bash -c "cd $icecreamdir; $createenv" || cleanup_and_exit 1
-       icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT/$icecreamdir/*.tar.{bz2,gz}`)
-       icecc_vers=${icecc_vers//$BUILD_ROOT/}
-       echo "created icecream environment $icecc_vers"
-    else
-       echo "reusing existing icecream environment $icecc_vers"
+    if test ! -d $BUILD_ROOT/opt/icecream/archive; then
+        mkdir -p $BUILD_ROOT/opt/icecream/archive
     fi
-    if test -n "$icecc_vers" ; then
-       echo "export ICECC_VERSION=$icecc_vers" >> "$BUILD_ROOT"/etc/profile.d/build_icecream.sh
+
+    if test ! -e $BUILD_ROOT/opt/icecream/archive/icecream-toolchain.tar.gz; then
+        #local url="http://109.123.123.21:8000/icecream-toolchain-arm.tar.gz"
+        #$BUILD_DIR/download "$BUILD_ROOT/opt/icecream/archive/" $url
+        echo "Create toolchain tarball for icecream..."
+        chroot "$BUILD_ROOT" tar czf icecream-toolchain.tar.gz /bin /emul /lib /usr
+        chroot "$BUILD_ROOT" mv icecream-toolchain.tar.gz /opt/icecream/archive/
     fi
+
+    for bin in gcc g++ cc c++ clang clang++
+    do
+        if test ! -e $BUILD_ROOT/opt/icecream/bin/$bin; then
+            chroot "$BUILD_ROOT" ln -s /emul/usr/bin/icecc /opt/icecream/bin/$bin > /dev/null 2>/dev/null
+        fi
+    done
+
+    for bin in armv7l-tizen-linux-gnueabi-gcc armv7l-tizen-linux-gnueabi-g++ aarch64-tizen-linux-gnueabi-gcc aarch64-tizen-linux-gnueabi-g++
+    do
+        if test -e $BUILD_ROOT/usr/bin/$bin; then
+            if test ! -e $BUILD_ROOT/opt/icecream/bin/$bin; then
+                chroot "$BUILD_ROOT" ln -s /emul/usr/bin/icecc /opt/icecream/bin/$bin > /dev/null 2>/dev/null
+            fi
+        fi
+    done
+
+    echo "export PATH=/opt/icecream/bin:\$PATH" >> $BUILD_ROOT/etc/profile.d/build_icecream.sh
+    echo "export ICECC_VERSION=/opt/icecream/archive/icecream-toolchain.tar.gz" >> $BUILD_ROOT/etc/profile.d/build_icecream.sh
 }
 
+#setupicecream() {
+#    local icecreamdir=/var/run/icecream
+#    if test "$(readlink "$BUILD_ROOT/var/run")" = /run ; then
+#      icecreamdir=/run/icecream
+#    fi
+#    if test "$icecream" -eq 0 ; then
+#      rm -rf "$BUILD_ROOT$icecreamdir"
+#      rm -f "$BUILD_ROOT/etc/profile.d/build_icecream.sh"
+#      return 0
+#    fi
+#
+#    if ! chroot "$BUILD_ROOT" rpm -q icecream >/dev/null 2>/dev/null; then
+#      echo "*** icecream package not installed ***"
+#      return 1
+#    fi
+#
+#    echo "using icecream with $icecream jobs"
+#
+#    if test -z "$CCACHE" ; then
+#      echo 'export PATH=/usr/lib/icecc/bin:/opt/icecream/bin:$PATH' > "$BUILD_ROOT"/etc/profile.d/build_icecream.sh
+#    else
+#      echo 'export CCACHE_PATH=/usr/lib/icecc/bin:/opt/icecream/bin' > "$BUILD_ROOT"/etc/profile.d/build_icecream.sh
+#    fi
+#
+#    local icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT$icecreamdir/*.tar.{bz2,gz}`)
+#    icecc_vers=${icecc_vers//$BUILD_ROOT/}
+#
+#    # XXX use changelog like autobuild does instead?
+#    # only run create-env if compiler or glibc changed
+#    if test -z "$icecc_vers" \
+#      -o ! -e "$BUILD_ROOT/$icecc_vers" \
+#      -o "$BUILD_ROOT/usr/bin/gcc" -nt "$BUILD_ROOT/$icecc_vers" \
+#      -o "$BUILD_ROOT/usr/bin/g++" -nt "$BUILD_ROOT/$icecc_vers" \
+#      -o "$BUILD_ROOT/usr/bin/as" -nt "$BUILD_ROOT/$icecc_vers" \
+#      -o "$BUILD_ROOT/lib/libc.so.6" -nt "$BUILD_ROOT/$icecc_vers"
+#    then
+#      rm -rf "$BUILD_ROOT$icecreamdir"
+#      mkdir -p "$BUILD_ROOT$icecreamdir"
+#      if test -e "$BUILD_ROOT"/usr/bin/create-env ; then
+#          createenv=/usr/bin/create-env
+#      elif test -e "$BUILD_ROOT"/usr/lib/icecc/icecc-create-env ; then
+#          createenv="/usr/lib/icecc/icecc-create-env /usr/bin/gcc /usr/bin/g++" # XXX
+#      elif test -e "$BUILD_ROOT"/usr/lib64/icecc/icecc-create-env ; then
+#          createenv="/usr/lib64/icecc/icecc-create-env /usr/bin/gcc /usr/bin/g++" # XXX
+#      else
+#          echo "create-env not found"
+#          return 1
+#      fi
+#        echo "creating new env in '$icecreamdir'"
+#      chroot $BUILD_ROOT bash -c "cd $icecreamdir; $createenv" || cleanup_and_exit 1
+#      icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT/$icecreamdir/*.tar.{bz2,gz}`)
+#      icecc_vers=${icecc_vers//$BUILD_ROOT/}
+#      echo "created icecream environment $icecc_vers"
+#    else
+#      echo "reusing existing icecream environment $icecc_vers"
+#    fi
+#    if test -n "$icecc_vers" ; then
+#      echo "export ICECC_VERSION=$icecc_vers" >> "$BUILD_ROOT"/etc/profile.d/build_icecream.sh
+#    fi
+#}
+
 setmemorylimit() {
     if test -n "$VM_IMAGE" -o -n "$RUNNING_IN_VM" ; then
        return