blob: 978400692b0d0e0c4044a1c226d676d435f28d18 [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
Diana Picus3124fb82016-04-25 15:37:25 +030041cextra=false
Renato Golin94cc1042016-04-26 11:02:23 +010042rt=false
Diana Picusdf02ca02016-05-03 13:44:42 +030043libcxx=false
44libcxxabi=false
45libunwind=false
Renato Golin94cc1042016-04-26 11:02:23 +010046linker=false
47debug=false
48tests=false
49web=false
Diana Picus72189fd2016-05-23 19:32:46 +030050
51clang_workdir=$LLVM_SRC/tools/clang
52extra_workdir=$LLVM_SRC/tools/clang/tools/extra
53rt_workdir=$LLVM_SRC/projects/compiler-rt
54libcxx_workdir=$LLVM_SRC/projects/libcxx
55libcxxabi_workdir=$LLVM_SRC/projects/libcxxabi
56libunwind_workdir=$LLVM_SRC/projects/libunwind
57lld_workdir=$LLVM_SRC/tools/lld
58lldb_workdir=$LLVM_SRC/tools/lldb
59test_workdir=$LLVM_SRC/projects/test-suite
60
61if [ -d $clang_workdir ]; then clang=true; fi
62if [ -d $extra_workdir ]; then cextra=true; fi
63if [ -d $rt_workdir ]; then rt=true; fi
64if [ -d $libcxx_workdir ]; then libcxx=true; fi
65if [ -d $libcxxabi_workdir ]; then libcxxabi=true; fi
66if [ -d $libunwind_workdir ]; then libunwind=true; fi
67if [ -d $lld_workdir ]; then linker=true; fi
68if [ -d $lldb_workdir ]; then debug=true; fi
69if [ -d $test_workdir ]; then tests=true; fi
Renato Golin94cc1042016-04-26 11:02:23 +010070
Diana Picusdf02ca02016-05-03 13:44:42 +030071while getopts "wa" opt; do
Renato Golin94cc1042016-04-26 11:02:23 +010072 case $opt in
Renato Golin94cc1042016-04-26 11:02:23 +010073 w)
74 web=true
75 ;;
76 a)
Diana Picusdf02ca02016-05-03 13:44:42 +030077 clang=true
Diana Picus3124fb82016-04-25 15:37:25 +030078 cextra=true
Renato Golin94cc1042016-04-26 11:02:23 +010079 rt=true
Diana Picusdf02ca02016-05-03 13:44:42 +030080 libcxx=true
81 libcxxabi=true
82 libunwind=true
Renato Golin94cc1042016-04-26 11:02:23 +010083 linker=true
84 debug=true
85 tests=true
86 ;;
87 *)
Diana Picusdf02ca02016-05-03 13:44:42 +030088 echo "Syntax: $prog [-(w)eb pages] [-(a)ll]"
89 echo "Syncs the repos that are currently linked into the llvm source tree"
90 echo "-w forces sync for the web repos (which are never linked)"
91 echo "-a forces sync for non-web repos that are not linked"
Renato Golin94cc1042016-04-26 11:02:23 +010092 exit 1
93 ;;
94 esac
95done
96
Diana Picus72189fd2016-05-23 19:32:46 +030097llvm_repos=$LLVM_ROOT/repos
98
Renato Golin94cc1042016-04-26 11:02:23 +010099# Compulsory updates
Diana Picus72189fd2016-05-23 19:32:46 +0300100repo_sync LLVM $llvm_repos/llvm $LLVM_SRC
Diana Picusdf02ca02016-05-03 13:44:42 +0300101
102if $clang; then
Diana Picus72189fd2016-05-23 19:32:46 +0300103 repo_sync Clang $llvm_repos/clang $clang_workdir
Diana Picusdf02ca02016-05-03 13:44:42 +0300104fi
Renato Golin94cc1042016-04-26 11:02:23 +0100105
106# Optional updates
Diana Picus3124fb82016-04-25 15:37:25 +0300107if $cextra; then
Diana Picus72189fd2016-05-23 19:32:46 +0300108 repo_sync ClangToolsExtra $llvm_repos/clang-tools-extra $extra_workdir
Diana Picus3124fb82016-04-25 15:37:25 +0300109fi
110
Renato Golin94cc1042016-04-26 11:02:23 +0100111if $rt; then
Diana Picus72189fd2016-05-23 19:32:46 +0300112 repo_sync RT $llvm_repos/compiler-rt $rt_workdir
Renato Golin94cc1042016-04-26 11:02:23 +0100113fi
114
Diana Picusdf02ca02016-05-03 13:44:42 +0300115if $libcxx; then
Diana Picus72189fd2016-05-23 19:32:46 +0300116 repo_sync LibC++ $llvm_repos/libcxx $libcxx_workdir
Diana Picusdf02ca02016-05-03 13:44:42 +0300117fi
118
119if $libcxxabi; then
Diana Picus72189fd2016-05-23 19:32:46 +0300120 repo_sync LibC++ABI $llvm_repos/libcxxabi $libcxxabi_workdir
Diana Picusdf02ca02016-05-03 13:44:42 +0300121fi
122
123if $libunwind; then
Diana Picus72189fd2016-05-23 19:32:46 +0300124 repo_sync LibUnwind $llvm_repos/libunwind $libunwind_workdir
Renato Golin94cc1042016-04-26 11:02:23 +0100125fi
126
127if $linker; then
Diana Picus72189fd2016-05-23 19:32:46 +0300128 repo_sync Linker $llvm_repos/lld $lld_workdir
Renato Golin94cc1042016-04-26 11:02:23 +0100129fi
130
131if $debug; then
Diana Picus72189fd2016-05-23 19:32:46 +0300132 repo_sync Debugger $llvm_repos/lldb $lldb_workdir
Renato Golin94cc1042016-04-26 11:02:23 +0100133fi
134
135if $tests; then
Diana Picus72189fd2016-05-23 19:32:46 +0300136 repo_sync Test-Suite $llvm_repos/test-suite $test_workdir
137 repo_sync LNT $llvm_repos/lnt $llvm_repos/lnt
138 repo_sync Zorg $llvm_repos/zorg $llvm_repos/zorg
Renato Golin94cc1042016-04-26 11:02:23 +0100139fi
140
141# These are pure SVN repos, not enabled with -a
142# You have to manually force with -w
143if $web; then
Diana Picus72189fd2016-05-23 19:32:46 +0300144 if [ -d $llvm_repos/www ]; then
Renato Golin94cc1042016-04-26 11:02:23 +0100145 echo " + Updating WWW"
Diana Picus72189fd2016-05-23 19:32:46 +0300146 cd $llvm_repos/www $llvm_repos/www
Renato Golin94cc1042016-04-26 11:02:23 +0100147 svn up
148 fi
Diana Picus72189fd2016-05-23 19:32:46 +0300149 if [ -d $llvm_repos/pubs ]; then
Renato Golin94cc1042016-04-26 11:02:23 +0100150 echo " + Updating Pubs"
Diana Picus72189fd2016-05-23 19:32:46 +0300151 cd $llvm_repos/pubs $llvm_repos/pubs
Renato Golin94cc1042016-04-26 11:02:23 +0100152 svn up
153 fi
154fi