aboutsummaryrefslogtreecommitdiff
path: root/helpers/llvm-sync
blob: ee3c16d8ccb4184a3bde8ea7f72a4fd8bdaa7c45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash

# This script pulls all repositories selected with llvm-projs and rebases the
# current branch on top of the new master.

. llvm-common

safe_run verify_env

function repo_sync () {
  project=$1
  repo_dir=$2
  worktree_dir=$3

  if [ ! -d $repo_dir ]; then
    echo " + Not updating $project (couldn't find source directory)"
    return;
  fi

  if [ ! -d $worktree_dir ]; then
    echo " + Not updating $project (couldn't find worktree directory)"
    return;
  fi

  echo " + Updating $project"

  # To pull master, we must be in the repo dir (we shouldn't checkout master in
  # the worktree dirs - by default, master lives in the repo dir)
  cd $repo_dir
  safe_run git-refresh

  # To rebase the current branch, we must be in the worktree dir (we shouldn't
  # checkout the current branch in the repo dir, because it is already checked
  # out in the worktree dir)
  cd $worktree_dir
  safe_run git-rebase
}

prog=`basename $0`
clang=false
rt=false
libcxx=false
libcxxabi=false
libunwind=false
linker=false
debug=false
tests=false
web=false

clang_workdir=$LLVM_SRC/tools/clang
rt_workdir=$LLVM_SRC/projects/compiler-rt
libcxx_workdir=$LLVM_SRC/projects/libcxx
libcxxabi_workdir=$LLVM_SRC/projects/libcxxabi
libunwind_workdir=$LLVM_SRC/projects/libunwind
lld_workdir=$LLVM_SRC/tools/lld
lldb_workdir=$LLVM_SRC/tools/lldb
test_workdir=$LLVM_SRC/projects/test-suite

if [ -d $clang_workdir ]; then clang=true; fi
if [ -d $rt_workdir ]; then rt=true; fi
if [ -d $libcxx_workdir ]; then libcxx=true; fi
if [ -d $libcxxabi_workdir ]; then libcxxabi=true; fi
if [ -d $libunwind_workdir ]; then libunwind=true; fi
if [ -d $lld_workdir ]; then linker=true; fi
if [ -d $lldb_workdir ]; then debug=true; fi
if [ -d $test_workdir ]; then tests=true; fi

while getopts "wa" opt; do
  case $opt in
    w)
      web=true
      ;;
    a)
      clang=true
      rt=true
      libcxx=true
      libcxxabi=true
      libunwind=true
      linker=true
      debug=true
      tests=true
      ;;
    *)
      echo "Syntax: $prog [-(w)eb pages] [-(a)ll]"
      echo "Syncs the repos that are currently linked into the llvm source tree"
      echo "-w forces sync for the web repos (which are never linked)"
      echo "-a forces sync for non-web repos that are not linked"
      exit 1
      ;;
  esac
done

llvm_repos=$LLVM_ROOT/repos

# Compulsory updates
repo_sync LLVM $llvm_repos/llvm $LLVM_SRC

if $clang; then
  repo_sync Clang $llvm_repos/clang $clang_workdir
fi

# Optional updates
if $rt; then
  repo_sync RT $llvm_repos/compiler-rt $rt_workdir
fi

if $libcxx; then
  repo_sync LibC++ $llvm_repos/libcxx $libcxx_workdir
fi

if $libcxxabi; then
  repo_sync LibC++ABI $llvm_repos/libcxxabi $libcxxabi_workdir
fi

if $libunwind; then
  repo_sync LibUnwind $llvm_repos/libunwind $libunwind_workdir
fi

if $linker; then
  repo_sync Linker $llvm_repos/lld $lld_workdir
fi

if $debug; then
  repo_sync Debugger $llvm_repos/lldb $lldb_workdir
fi

if $tests; then
  repo_sync Test-Suite $llvm_repos/test-suite $test_workdir
  repo_sync LNT $llvm_repos/lnt $llvm_repos/lnt
  repo_sync Zorg $llvm_repos/zorg $llvm_repos/zorg
fi

# These are pure SVN repos, not enabled with -a
# You have to manually force with -w
if $web; then
  if [ -d $llvm_repos/www ]; then
    echo " + Updating WWW"
    cd $llvm_repos/www $llvm_repos/www
    svn up
  fi
  if [ -d $llvm_repos/pubs ]; then
    echo " + Updating Pubs"
    cd $llvm_repos/pubs $llvm_repos/pubs
    svn up
  fi
fi