bug 1303980 - update minidump_stackwalk.sh to build Breakpad from git repo (NPOTB) draft
authorTed Mielczarek <ted@mielczarek.org>
Tue, 20 Sep 2016 06:56:01 -0400
changeset 415536 c5f278e2b8e87bf4e70140d721871ff24e9732cf
parent 415495 62f79d676e0e11b3ad59a5425b3ebb3ec5bbefb5
child 415537 d5827e4f6a5efdfa79ebb592442ad50f15356df3
push id29903
push userbmo:ted@mielczarek.org
push dateTue, 20 Sep 2016 17:29:15 +0000
bugs1303980
milestone52.0a1
bug 1303980 - update minidump_stackwalk.sh to build Breakpad from git repo (NPOTB) MozReview-Commit-ID: DA80ulpEaJt
taskcluster/scripts/misc/minidump_stackwalk.sh
--- a/taskcluster/scripts/misc/minidump_stackwalk.sh
+++ b/taskcluster/scripts/misc/minidump_stackwalk.sh
@@ -1,48 +1,51 @@
 #!/bin/bash
 #
 # This script builds minidump_stackwalk binaries from the Google Breakpad
 # source for all of the operating systems that we run Firefox tests on:
 # Linux x86, Linux x86-64, Windows x86, OS X x86-64.
 #
-# It expects to be run in the luser/breakpad-builder:0.5 Docker image and
+# It expects to be run in the luser/breakpad-builder:0.7 Docker image and
 # needs access to the relengapiproxy to download internal tooltool files.
 
 set -v -e -x
 
-: BREAKPAD_REPO        ${BREAKPAD_REPO:=https://google-breakpad.googlecode.com/svn/trunk/}
-: BREAKPAD_REV         ${BREAKPAD_REV:=HEAD}
-: STACKWALK_HTTP_REPO  ${STACKWALK_HTTP_REPO:=https://hg.mozilla.org/users/tmielczarek_mozilla.com/stackwalk-http}
-: STACKWALK_HTTP_REV   ${STACKWALK_HTTP_REV:=default}
+# This is a pain to support properly with gclient.
+#: BREAKPAD_REPO        ${BREAKPAD_REPO:=https://google-breakpad.googlecode.com/svn/trunk/}
+: BREAKPAD_REV         "${BREAKPAD_REV:=master}"
+: STACKWALK_HTTP_REPO  "${STACKWALK_HTTP_REPO:=https://hg.mozilla.org/users/tmielczarek_mozilla.com/stackwalk-http}"
+: STACKWALK_HTTP_REV   "${STACKWALK_HTTP_REV:=default}"
 
-ncpu=`grep -c ^processor /proc/cpuinfo`
+ncpu=$(getconf _NPROCESSORS_ONLN)
 
 function build()
 {
     cd /tmp
     local platform=$1
     local strip_prefix=$2
     local configure_args=$3
     local make_args=$4
     local objdir=/tmp/obj-breakpad-$platform
     local ext=
     if test "$platform" = "win32"; then
         ext=.exe
     fi
-    rm -rf $objdir
-    mkdir $objdir
+    rm -rf "$objdir"
+    mkdir "$objdir"
     # First, build Breakpad
-    cd $objdir
-    CFLAGS="-O2 $CFLAGS" CXXFLAGS="-O2 $CXXFLAGS" /tmp/google-breakpad/configure --disable-tools $configure_args
+    cd "$objdir"
+    # shellcheck disable=SC2086
+    CFLAGS="-O2 $CFLAGS" CXXFLAGS="-O2 $CXXFLAGS" /tmp/breakpad/src/configure --disable-tools $configure_args
+    # shellcheck disable=SC2086
     make -j$ncpu $make_args src/libbreakpad.a src/third_party/libdisasm/libdisasm.a src/processor/stackwalk_common.o
     # Second, build stackwalk-http
-    make -f /tmp/stackwalk-http/Makefile BREAKPAD_SRCDIR=/tmp/google-breakpad BREAKPAD_OBJDIR=`pwd` OS=$platform -j$ncpu
-    ${strip_prefix}strip stackwalk${ext}
-    cp stackwalk${ext} /tmp/stackwalker/${platform}-minidump_stackwalk${ext}
+    make -f /tmp/stackwalk-http/Makefile BREAKPAD_SRCDIR=/tmp/breakpad/src "BREAKPAD_OBJDIR=$(pwd)" "OS=$platform" "-j$ncpu"
+    "${strip_prefix}strip" "stackwalk${ext}"
+    cp "stackwalk${ext}" "/tmp/stackwalker/${platform}-minidump_stackwalk${ext}"
 }
 
 function linux64()
 {
     export LDFLAGS="-static-libgcc -static-libstdc++"
     build linux64
     unset LDFLAGS
 }
@@ -54,48 +57,69 @@ function linux32()
     export CXXFLAGS="-m32 -I/tmp/libcurl-i386/include"
     build linux32 "" "--enable-m32"
     unset LDFLAGS CFLAGS CXXFLAGS
 }
 
 function macosx64()
 {
     cd /tmp
-    python tooltool.py -v --manifest=macosx-sdk.manifest --url=http://relengapi/tooltool/ fetch
-    tar xjf MacOSX10.6.sdk.tar.bz2
-    export MACOSX_SDK=/tmp/MacOSX10.6.sdk
+    if ! test -d MacOSX10.7.sdk; then
+      python tooltool.py -v --manifest=macosx-sdk.manifest --url=http://relengapi/tooltool/ fetch
+    fi
+    export MACOSX_SDK=/tmp/MacOSX10.7.sdk
     export CCTOOLS=/tmp/cctools
-    local FLAGS="-target x86_64-apple-darwin10 -mlinker-version=136 -B /tmp/cctools/bin -isysroot ${MACOSX_SDK} -mmacosx-version-min=10.6"
+    local FLAGS="-stdlib=libc++ -target x86_64-apple-darwin10 -mlinker-version=136 -B /tmp/cctools/bin -isysroot ${MACOSX_SDK} -mmacosx-version-min=10.7"
     export CC="clang $FLAGS"
     export CXX="clang++ $FLAGS -std=c++11"
-    local old_path=$PATH
-    export PATH=$PATH:/tmp/cctools/bin/
+    local old_path="$PATH"
+    export PATH="/tmp/clang/bin:/tmp/cctools/bin/:$PATH"
     export LD_LIBRARY_PATH=/usr/lib/llvm-3.6/lib/
 
     build macosx64 "/tmp/cctools/bin/x86_64-apple-darwin10-" "--host=x86_64-apple-darwin10" "AR=/tmp/cctools/bin/x86_64-apple-darwin10-ar"
 
     unset CC CXX LD_LIBRARY_PATH MACOSX_SDK CCTOOLS
-    export PATH=$old_path
+    export PATH="$old_path"
 }
 
 function win32()
 {
     export LDFLAGS="-static-libgcc -static-libstdc++"
     export CFLAGS="-D__USE_MINGW_ANSI_STDIO=1"
     export CXXFLAGS="-D__USE_MINGW_ANSI_STDIO=1"
     export ZLIB_DIR=/tmp/zlib-mingw
     build win32 "i686-w64-mingw32-" "--host=i686-w64-mingw32"
     unset LDFLAGS CFLAGS CXXFLAGS ZLIB_DIR
 }
 
 cd /tmp
-mkdir -p stackwalker
-if ! test -d google-breakpad; then
-    svn checkout -r $BREAKPAD_REV $BREAKPAD_REPO google-breakpad
+if ! test -d depot_tools; then
+  git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
+else
+  (cd depot_tools; git pull origin master)
 fi
-(cd google-breakpad; svn info)
+export PATH=$(pwd)/depot_tools:"$PATH"
+if ! test -d breakpad; then
+    mkdir breakpad
+    pushd breakpad
+    fetch breakpad
+    popd
+else
+    pushd breakpad/src
+    git pull origin master
+    popd
+fi
+pushd breakpad/src
+git checkout "${BREAKPAD_REV}"
+gclient sync
+popd
+
+(cd breakpad/src; git rev-parse master)
 if ! test -d stackwalk-http; then
-  hg clone -u $STACKWALK_HTTP_REV $STACKWALK_HTTP_REPO
+  hg clone -u "$STACKWALK_HTTP_REV" "$STACKWALK_HTTP_REPO"
+else
+  (cd stackwalk-http && hg pull "$STACKWALK_HTTP_REPO" && hg up "$STACKWALK_HTTP_REV")
 fi
+mkdir -p stackwalker
 linux64
 linux32
 macosx64
 win32