| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # A script to send toolchain edits in tools/SRC (in git) to toolchain trybots. | 2 # A script to send toolchain edits in tools/SRC (in git) to toolchain trybots. |
| 3 | 3 |
| 4 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 4 # Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
| 7 | 7 |
| 8 cd "$(dirname "$0")" | 8 cd "$(dirname "$0")" |
| 9 source REVISIONS | 9 . REVISIONS |
| 10 if [[ ! -e "../.svn/gcl_info/changes/toolchain-try" ]] ; then | 10 |
| 11 # Create randomly named CL that consumes all local SVN edits. | 11 repos='binutils gcc glibc linux-headers-for-nacl newlib' |
| 12 random_name="" | 12 |
| 13 while ((${#random_name}<16)); do | 13 trybots_glibc_only="\ |
| 14 random_name="$random_name$( | 14 nacl-toolchain-precise64-glibc\ |
| 15 dd if=/dev/urandom bs=1 count=1 | | 15 " |
| 16 LC_ALL=C grep '[A-Za-z]')" | 16 trybots_glibc="\ |
| 17 done | 17 nacl-toolchain-precise64-glibc,\ |
| 18 SVN_EDITOR=true gcl change "$random_name" | 18 nacl-toolchain-mac-glibc,\ |
| 19 nacl-toolchain-win7-glibc\ |
| 20 " |
| 21 trybots_newlib="\ |
| 22 nacl-toolchain-precise64-newlib,\ |
| 23 nacl-toolchain-mac-newlib,\ |
| 24 nacl-toolchain-win7-newlib\ |
| 25 " |
| 26 |
| 27 tmp='.git-status$$' |
| 28 trap 'rm -f $tmp' 0 1 2 15 |
| 29 { git status --porcelain -uno > "$tmp" && |
| 30 [ -r "$tmp" ] && [ ! -s "$tmp" ] |
| 31 } || { |
| 32 echo >&2 "$0: Start with a clean working directory" |
| 33 exit 1 |
| 34 } |
| 35 |
| 36 test_all= |
| 37 test_glibc= |
| 38 test_newlib= |
| 39 tryname=try |
| 40 for repo in $repos; do |
| 41 revname="NACL_$(echo "$repo" | tr '[:lower:]-' '[:upper:]_')_COMMIT" |
| 42 patch="toolchain-try.${repo}.patch" |
| 43 (cd "SRC/$repo"; git diff "${!revname}..HEAD") > $patch |
| 44 if [ $? -ne 0 ]; then |
| 45 echo >&2 "$0: error: update SRC/$repo first" |
| 46 exit 2 |
| 47 fi |
| 48 if [ -s "$patch" ]; then |
| 49 git add "$patch" |
| 50 tryname="${tryname}-${repo}-$(cd "SRC/$repo"; |
| 51 git rev-list -n1 --abbrev-commit HEAD)" |
| 52 case "$repo" in |
| 53 newlib) test_newlib=yes ;; |
| 54 glibc) test_glibc=yes ;; |
| 55 *) test_newlib=yes |
| 56 test_glibc=yes |
| 57 test_all=yes ;; |
| 58 esac |
| 59 else |
| 60 rm -f "$patch" |
| 61 fi |
| 62 done |
| 63 |
| 64 if [ -z "$test_all" -a -z "$test_newlib" -a -n "$test_glibc" ]; then |
| 65 trybots="$trybots_glibc_only" |
| 66 else |
| 67 trybots="${test_newlib:+${trybots_newlib}}\ |
| 68 ${test_glibc:+${test_newlib:+,}${trybots_glibc}}" |
| 19 fi | 69 fi |
| 20 | 70 |
| 21 # Lazily create a CL called 'toolchain-try' to contain patches to code in | 71 if ! git rev-parse origin/master >/dev/null; then |
| 22 # tools/SRC. | 72 echo >&2 "$0: error: no origin/master branch" |
| 23 for i in binutils gcc glibc linux-headers-for-nacl newlib; do ( | 73 exit 3 |
| 24 revname="NACL_$(echo $i | tr '[:lower:]' '[:upper:]')_COMMIT" | |
| 25 if [[ "$revname" = "NACL_LINUX-HEADERS-FOR-NACL_COMMIT" ]] ; then | |
| 26 revname="LINUX_HEADERS_FOR_NACL_COMMIT" | |
| 27 fi | |
| 28 cd "SRC/$i" | |
| 29 git diff "${!revname}..HEAD" > ../../"toolchain-try.$i.patch" ) | |
| 30 svn add "toolchain-try.$i.patch" | |
| 31 done | |
| 32 if [[ ! -e "../.svn/gcl_info/changes/toolchain-try" ]] ; then | |
| 33 SVN_EDITOR=true gcl change toolchain-try | |
| 34 rm "../.svn/gcl_info/changes/$random_name" | |
| 35 fi | 74 fi |
| 36 BOTS=nacl-toolchain-precise64-glibc,nacl-toolchain-mac-glibc,\ | 75 |
| 37 nacl-toolchain-win7-glibc | 76 (set -x |
| 38 if (( $# >= 1 )) ; then | 77 git checkout -b "$tryname" origin/master |
| 39 gcl try toolchain-try --bot $BOTS -n "$1" | 78 git commit -m "toolchain trybot run: $tryname" |
| 40 else | 79 |
| 41 gcl try toolchain-try --bot $BOTS | 80 git try -b "$trybots" |
| 42 fi | 81 ) |
| OLD | NEW |