diff options
author | Renato Golin <renato.golin@linaro.org> | 2017-05-25 15:06:44 +0100 |
---|---|---|
committer | Renato Golin <renato.golin@linaro.org> | 2017-05-26 12:55:01 +0000 |
commit | 7365a8ab05c211ee916a364db1e035fbcfffffae (patch) | |
tree | 5cf4b211f2bf55e39a2443a875df98bad566ccab | |
parent | ce08cedbcb70ef3f51bd5a0dd548680312e146c6 (diff) |
tcwg-llvm-build.sh: Add list of projects to consider
As discussed in TCWG-1134, we need a list of projects to checkout if the
branch is master and there is a revision (buildbot and pre-commit base
cases) as well as a branch and no list (for pre-commit patch cases.
The relationship between lists and branches is that having a branch and
not being in the list is ok, but being in the list and not having a
branch is not. This patch addresses that, so that we can create any
number of trigger jobs without worrying about the parameters we pass.
It should either be safe, user error, or the job will bail.
Needs https://review.linaro.org/19777 to work.
Change-Id: I83fa889f3d3ebf80f08ffed218d4e72e40a88ecc
-rwxr-xr-x | tcwg-llvm-build.sh | 30 | ||||
-rwxr-xr-x | tcwg-llvm-common.sh | 14 |
2 files changed, 41 insertions, 3 deletions
diff --git a/tcwg-llvm-build.sh b/tcwg-llvm-build.sh index 3c2f4fb3..e52791bd 100755 --- a/tcwg-llvm-build.sh +++ b/tcwg-llvm-build.sh @@ -24,7 +24,8 @@ SYN_TOOLCHAIN_FILE="--toolchain-file=<file-name> (file name to copy the produced SYN_COMPILER="--compiler=clang|gcc" SYN_REPOSITORY="--repository=http://url/for/git/repo/" SYN_BRANCH="--branch=branchname" -SYNTAX="$0 $SYN_WORKSPACE $SYN_REVISION $SYN_ASSERTS $SYN_LINKJOBS $SYN_BUILDJOBS $SYN_TOOLCHAIN $SYN_BUILDID $SYN_TOOLCHAIN_FILE $SYN_CMAKEFLAGS $SYN_COMPILER $SYN_REPOSITORY $SYN_BRANCH" +SYN_PROJECTS="--projects='llvm clang etc'" +SYNTAX="$0 $SYN_WORKSPACE $SYN_REVISION $SYN_ASSERTS $SYN_LINKJOBS $SYN_BUILDJOBS $SYN_TOOLCHAIN $SYN_BUILDID $SYN_TOOLCHAIN_FILE $SYN_CMAKEFLAGS $SYN_COMPILER $SYN_REPOSITORY $SYN_BRANCH $SYN_PROJECTS" # Environment Variables and default values WORKSPACE=$(pwd) @@ -41,6 +42,7 @@ CMAKEFLAGS="" BUILDID="" REPOSITORY="https://git-us.linaro.org/toolchain/llvm" BRANCH="master" +PROJECTS="" # Command line parsing while [ "$#" -gt 0 ]; do @@ -148,6 +150,9 @@ while [ "$#" -gt 0 ]; do --cmakeflags) CMAKEFLAGS="$VAL" shift ;; + --projects) + PROJECTS="$VAL" + shift ;; *) echo "ERROR: Invalid argument '$1'" echo "Syntax: $SYNTAX" @@ -198,6 +203,8 @@ echo "TOOLCHAIN = $TOOLCHAIN" echo "CC = $CC" echo "CXX = $CXX" echo "CMAKEFLAGS = $CMAKEFLAGS" +echo "BRANCH = $BRANCH" +echo "PROJECTS = $PROJECTS" # Logs LOGBASE="$WORKSPACE/tcwg-llvm" @@ -208,11 +215,19 @@ LLVM_PROJECTS="llvm: clang:tools/clang lld:tools/lld compiler-rt:projects/compiler-rt libunwind:projects/libunwind libcxx:projects/libcxx libcxxabi:projects/libcxxabi" LLVM_REVS="" +CLONE_STATUS=0 { flock -s 9 for proj_ref in $LLVM_PROJECTS; do proj="$(echo "$proj_ref" | cut -d ":" -f 1)" dir="$(echo "$proj_ref" | cut -d ":" -f 2)" + + # If project list exists and it's not in there, ignore + if [ ! -z "$PROJECTS" ] && ! is_in_list "$proj" "$PROJECTS"; then + continue + fi + + # Only clone if the branch exists if has_remote_branch "$REPOSITORY/$proj.git" "$BRANCH"; then git clone -b "$BRANCH" "$REPOSITORY/$proj.git" \ --reference "$REFDIR/$proj" \ @@ -225,14 +240,25 @@ LLVM_REVS="" # Get the latest revision LLVM_REVS="$LLVM_REVS $(find_svn_rev "$SRCDIR/$dir")" fi + + # Error if we did specify projects list and branches, but not there + else + echo "ERROR: Project ($proj) specified in the list, but branch ($BRANCH) not found" + CLONE_STATUS=1 + break fi done # Get the latest revision from all repos if [ -z "$REVISION" ]; then - REVISION="r$(find_last_rev $LLVM_REVS)" + REVISION="r$(find_last_rev "$LLVM_REVS")" fi } 9>"$REFDIR.lock" +# Make sure we unlock the flock before returning +if [ "$CLONE_STATUS" -ne 0 ]; then + exit $CLONE_STATUS +fi + # CMake OPTIONS="-DLLVM_BUILD_TESTS=True " OPTIONS+="-DCMAKE_BUILD_TYPE='$BUILDTYPE' " diff --git a/tcwg-llvm-common.sh b/tcwg-llvm-common.sh index 180faa88..c7139b73 100755 --- a/tcwg-llvm-common.sh +++ b/tcwg-llvm-common.sh @@ -100,7 +100,7 @@ find_svn_rev() { # Find the largest revision of a list find_last_rev() { local LAST=0 - for rev in "$@"; do + for rev in $@; do [ "$rev" -gt "$LAST" ] && LAST=$rev done echo "$LAST" @@ -118,6 +118,18 @@ has_remote_branch() { fi } +# Find element in array +is_in_list() { + local ITEM="$1" + shift + for item in $@; do + if [ "$ITEM" = "$item" ]; then + return 0 + fi + done + return 1 +} + # Environment Variables and default values CPUS=$(nproc --all) # We may use between 500MB and 1GB per link job |