blob: 95e4954b3f20536b1a5e2f194c084b19f5ff3f71 [file] [log] [blame]
Renato Golin94cc1042016-04-26 11:02:23 +01001#!/usr/bin/env bash
2
Diana Picus72189fd2016-05-23 19:32:46 +03003# This script pulls all repositories selected with llvm-projs and rebases the
4# current branch on top of the new master.
Renato Golin94cc1042016-04-26 11:02:23 +01005
6. llvm-common
7
Diana Picus72189fd2016-05-23 19:32:46 +03008safe_run verify_env
9
Renato Golin94cc1042016-04-26 11:02:23 +010010function repo_sync () {
Diana Picus72189fd2016-05-23 19:32:46 +030011 project=$1
12 repo_dir=$2
13 worktree_dir=$3
14
15 if [ ! -d $repo_dir ]; then
16 echo " + Not updating $project (couldn't find source directory)"
Diana Picus09cd9b62016-04-25 18:04:06 +030017 return;
18 fi
Diana Picus72189fd2016-05-23 19:32:46 +030019
20 if [ ! -d $worktree_dir ]; then
21 echo " + Not updating $project (couldn't find worktree directory)"
22 return;
23 fi
24
25 echo " + Updating $project"
26
27 # To pull master, we must be in the repo dir (we shouldn't checkout master in
28 # the worktree dirs - by default, master lives in the repo dir)
29 cd $repo_dir
Renato Golin94cc1042016-04-26 11:02:23 +010030 safe_run git-refresh
Diana Picus72189fd2016-05-23 19:32:46 +030031
32 # To rebase the current branch, we must be in the worktree dir (we shouldn't
33 # checkout the current branch in the repo dir, because it is already checked
34 # out in the worktree dir)
35 cd $worktree_dir
36 safe_run git-rebase
Renato Golin94cc1042016-04-26 11:02:23 +010037}
38
39prog=`basename $0`
Diana Picusdf02ca02016-05-03 13:44:42 +030040clang=false
Renato Golin94cc1042016-04-26 11:02:23 +010041rt=false
Diana Picusdf02ca02016-05-03 13:44:42 +030042libcxx=false
43libcxxabi=false
44libunwind=false
Renato Golin94cc1042016-04-26 11:02:23 +010045linker=false
46debug=false
47tests=false
48web=false
Diana Picus72189fd2016-05-23 19:32:46 +030049
50clang_workdir=$LLVM_SRC/tools/clang
Diana Picus72189fd2016-05-23 19:32:46 +030051rt_workdir=$LLVM_SRC/projects/compiler-rt
52libcxx_workdir=$LLVM_SRC/projects/libcxx
53libcxxabi_workdir=$LLVM_SRC/projects/libcxxabi
54libunwind_workdir=$LLVM_SRC/projects/libunwind
55lld_workdir=$LLVM_SRC/tools/lld
56lldb_workdir=$LLVM_SRC/tools/lldb
57test_workdir=$LLVM_SRC/projects/test-suite
58
59if [ -d $clang_workdir ]; then clang=true; fi
Diana Picus72189fd2016-05-23 19:32:46 +030060if [ -d $rt_workdir ]; then rt=true; fi
61if [ -d $libcxx_workdir ]; then libcxx=true; fi
62if [ -d $libcxxabi_workdir ]; then libcxxabi=true; fi
63if [ -d $libunwind_workdir ]; then libunwind=true; fi
64if [ -d $lld_workdir ]; then linker=true; fi
65if [ -d $lldb_workdir ]; then debug=true; fi
66if [ -d $test_workdir ]; then tests=true; fi
Renato Golin94cc1042016-04-26 11:02:23 +010067
Diana Picusdf02ca02016-05-03 13:44:42 +030068while getopts "wa" opt; do
Renato Golin94cc1042016-04-26 11:02:23 +010069 case $opt in
Renato Golin94cc1042016-04-26 11:02:23 +010070 w)
71 web=true
72 ;;
73 a)
Diana Picusdf02ca02016-05-03 13:44:42 +030074 clang=true
Renato Golin94cc1042016-04-26 11:02:23 +010075 rt=true
Diana Picusdf02ca02016-05-03 13:44:42 +030076 libcxx=true
77 libcxxabi=true
78 libunwind=true
Renato Golin94cc1042016-04-26 11:02:23 +010079 linker=true
80 debug=true
81 tests=true
82 ;;
83 *)
Diana Picusdf02ca02016-05-03 13:44:42 +030084 echo "Syntax: $prog [-(w)eb pages] [-(a)ll]"
85 echo "Syncs the repos that are currently linked into the llvm source tree"
86 echo "-w forces sync for the web repos (which are never linked)"
87 echo "-a forces sync for non-web repos that are not linked"
Renato Golin94cc1042016-04-26 11:02:23 +010088 exit 1
89 ;;
90 esac
91done
92
Diana Picus72189fd2016-05-23 19:32:46 +030093llvm_repos=$LLVM_ROOT/repos
94
Renato Golin94cc1042016-04-26 11:02:23 +010095# Compulsory updates
Diana Picus72189fd2016-05-23 19:32:46 +030096repo_sync LLVM $llvm_repos/llvm $LLVM_SRC
Diana Picusdf02ca02016-05-03 13:44:42 +030097
98if $clang; then
Diana Picus72189fd2016-05-23 19:32:46 +030099 repo_sync Clang $llvm_repos/clang $clang_workdir
Diana Picusdf02ca02016-05-03 13:44:42 +0300100fi
Renato Golin94cc1042016-04-26 11:02:23 +0100101
Renato Golin94cc1042016-04-26 11:02:23 +0100102if $rt; then
Diana Picus72189fd2016-05-23 19:32:46 +0300103 repo_sync RT $llvm_repos/compiler-rt $rt_workdir
Renato Golin94cc1042016-04-26 11:02:23 +0100104fi
105
Diana Picusdf02ca02016-05-03 13:44:42 +0300106if $libcxx; then
Diana Picus72189fd2016-05-23 19:32:46 +0300107 repo_sync LibC++ $llvm_repos/libcxx $libcxx_workdir
Diana Picusdf02ca02016-05-03 13:44:42 +0300108fi
109
110if $libcxxabi; then
Diana Picus72189fd2016-05-23 19:32:46 +0300111 repo_sync LibC++ABI $llvm_repos/libcxxabi $libcxxabi_workdir
Diana Picusdf02ca02016-05-03 13:44:42 +0300112fi
113
114if $libunwind; then
Diana Picus72189fd2016-05-23 19:32:46 +0300115 repo_sync LibUnwind $llvm_repos/libunwind $libunwind_workdir
Renato Golin94cc1042016-04-26 11:02:23 +0100116fi
117
118if $linker; then
Diana Picus72189fd2016-05-23 19:32:46 +0300119 repo_sync Linker $llvm_repos/lld $lld_workdir
Renato Golin94cc1042016-04-26 11:02:23 +0100120fi
121
122if $debug; then
Diana Picus72189fd2016-05-23 19:32:46 +0300123 repo_sync Debugger $llvm_repos/lldb $lldb_workdir
Renato Golin94cc1042016-04-26 11:02:23 +0100124fi
125
126if $tests; then
Diana Picus72189fd2016-05-23 19:32:46 +0300127 repo_sync Test-Suite $llvm_repos/test-suite $test_workdir
128 repo_sync LNT $llvm_repos/lnt $llvm_repos/lnt
129 repo_sync Zorg $llvm_repos/zorg $llvm_repos/zorg
Renato Golin94cc1042016-04-26 11:02:23 +0100130fi
131
132# These are pure SVN repos, not enabled with -a
133# You have to manually force with -w
134if $web; then
Diana Picus72189fd2016-05-23 19:32:46 +0300135 if [ -d $llvm_repos/www ]; then
Renato Golin94cc1042016-04-26 11:02:23 +0100136 echo " + Updating WWW"
Diana Picus72189fd2016-05-23 19:32:46 +0300137 cd $llvm_repos/www $llvm_repos/www
Renato Golin94cc1042016-04-26 11:02:23 +0100138 svn up
139 fi
Diana Picus72189fd2016-05-23 19:32:46 +0300140 if [ -d $llvm_repos/pubs ]; then
Renato Golin94cc1042016-04-26 11:02:23 +0100141 echo " + Updating Pubs"
Diana Picus72189fd2016-05-23 19:32:46 +0300142 cd $llvm_repos/pubs $llvm_repos/pubs
Renato Golin94cc1042016-04-26 11:02:23 +0100143 svn up
144 fi
145fi