meson: use library() for libgstcheck instead of always building a shared lib
[platform/upstream/gstreamer.git] / scripts / git-update.sh
index bd66745..25cb7cc 100755 (executable)
@@ -6,39 +6,55 @@
 # run this from a directory that contains the checkouts for each of the
 # modules
 
-FAILURE=
+PIDS=
 
+CORE="\
+    gstreamer gst-plugins-base"
 MODULES="\
-    gstreamer gst-plugins-base \
     gst-plugins-good gst-plugins-ugly gst-plugins-bad \
-    gst-ffmpeg \
-    gst-python \
-    gnonlin"
+    gst-libav"
+EXTRA_MODULES="\
+    gst-editing-services \
+    gst-rtsp-server \
+    gst-python"
 
-for m in $MODULES; do
+tmp=${TMPDIR-/tmp}
+tmp=$tmp/git-update.$(date +%Y%m%d-%H%M-).$RANDOM.$RANDOM.$RANDOM.$$
+
+(umask 077 && mkdir "$tmp") || {
+  echo "Could not create temporary directory! Exiting." 1>&2
+  exit 1
+}
+
+ERROR_LOG="$tmp/failures.log"
+ERROR_RETURN=255
+
+CPUCORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu  2>/dev/null || echo "1")
+
+for m in $CORE $MODULES $EXTRA_MODULES; do
   if test -d $m; then
     echo "+ updating $m"
     cd $m
 
-    git pull origin master
+    git pull --rebase
     if test $? -ne 0
     then
+      echo "$m: update (trying stash, pull, stash apply)" >> $ERROR_LOG
       git stash
-      git pull origin master
+      git pull --rebase
       if test $? -ne 0
       then 
-        git stash apply
-        FAILURE="$FAILURE$m: update\n"
-      else
-        git stash apply
+        echo "$m: update" >> $ERROR_LOG
+        cd ..
+        continue
       fi
-      cd ..
-      continue
+      git stash apply
     fi
+
     git submodule update
     if test $? -ne 0
     then
-      FAILURE="$FAILURE$m: update\n"
+      echo "$m: update (submodule)" >> $ERROR_LOG
       cd ..
       continue
     fi
@@ -46,42 +62,89 @@ for m in $MODULES; do
   fi
 done
 
-# then build
-for m in $MODULES; do
-  if test -d $m; then
-    cd $m
+build()
+{
+  if test -d $1; then
+    cd $1
     if test ! -e Makefile
     then
-      ./autoregen.sh
-      if test $? -ne 0
+      if test -e autoregen.sh
       then
-        FAILURE="$FAILURE$m: autoregen.sh\n"
-        cd ..
-        continue
+        echo "+ $1: autoregen.sh"
+        ./autoregen.sh > "$tmp/$1-regen.log" 2>&1
+        if test $? -ne 0
+        then
+          echo "$1: autoregen.sh [$tmp/$1-regen.log]" >> $ERROR_LOG
+          cd ..
+          return $ERROR_RETURN
+        fi
+        echo "+ $1: autoregen.sh done"
+      else
+        echo "+ $1: autogen.sh"
+        ./autogen.sh > "$tmp/$1-gen.log" 2>&1
+        if test $? -ne 0
+        then
+          echo "$1: autogen.sh [$tmp/$1-gen.log]" >> $ERROR_LOG
+          cd ..
+          return $ERROR_RETURN
+        fi
+        echo "+ $1: autogen.sh done"
       fi
     fi
 
-    make $@
+    echo "+ $1: make"
+    MAKEFLAGS="-j$CPUCORES $MAKEFLAGS" make > "$tmp/$1-make.log" 2>&1
     if test $? -ne 0
     then
-      FAILURE="$FAILURE$m: make\n"
+      echo "$1: make [$tmp/$1-make.log]" >> $ERROR_LOG
       cd ..
-      continue
+      return $ERROR_RETURN
     fi
+    echo "+ $1: make done"
 
-    make $@ check
-    if test $? -ne 0
-    then
-      FAILURE="$FAILURE$m: check\n"
-      cd ..
-      continue
+    if test "x$CHECK" != "x"; then
+      echo "+ $1: make check"
+      make check > "$tmp/$1-check.log" 2>&1
+      if test $? -ne 0
+      then
+        echo "$1: check [$tmp/$1-check.log]" >> $ERROR_LOG
+        cd ..
+        return
+      fi
+      echo "+ $1: make check done"
     fi
     cd ..
   fi
-done
+}
 
-if test "x$FAILURE" != "x";  then
+beach()
+{
+if test -e $ERROR_LOG;  then
   echo "Failures:"
   echo
-  echo -e $FAILURE
+  cat $ERROR_LOG
+else
+  echo "Update done"
+  rm -rf "$tmp"
 fi
+exit
+}
+
+# build core and base plugins sequentially
+# exit if build fails (excluding checks)
+for m in $CORE; do
+  build $m
+  if [ $? -eq $ERROR_RETURN ]; then
+  beach
+  fi
+done
+
+# build other modules in parallel
+for m in $MODULES $EXTRA_MODULES; do
+  build $m &
+  PIDS="$PIDS $!"
+done
+wait $PIDS
+
+beach
+