xref: /aosp_15_r20/external/llvm/utils/crosstool/create-snapshots.sh (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker#!/bin/bash
2*9880d681SAndroid Build Coastguard Worker#
3*9880d681SAndroid Build Coastguard Worker# Creates LLVM SVN snapshots: llvm-$REV.tar.bz2 and llvm-gcc-4.2-$REV.tar.bz2,
4*9880d681SAndroid Build Coastguard Worker# where $REV is an SVN revision of LLVM.  This is used for creating stable
5*9880d681SAndroid Build Coastguard Worker# tarballs which can be used to build known-to-work crosstools.
6*9880d681SAndroid Build Coastguard Worker#
7*9880d681SAndroid Build Coastguard Worker# Syntax:
8*9880d681SAndroid Build Coastguard Worker#   $0 [REV] -- grabs the revision $REV from SVN; if not specified, grabs the
9*9880d681SAndroid Build Coastguard Worker#   latest SVN revision.
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Workerset -o nounset
12*9880d681SAndroid Build Coastguard Workerset -o errexit
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerreadonly LLVM_PROJECT_SVN="http://llvm.org/svn/llvm-project"
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard WorkergetLatestRevisionFromSVN() {
17*9880d681SAndroid Build Coastguard Worker  svn info ${LLVM_PROJECT_SVN} | egrep ^Revision | sed 's/^Revision: //'
18*9880d681SAndroid Build Coastguard Worker}
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workerreadonly REV="${1:-$(getLatestRevisionFromSVN)}"
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard WorkercreateTarballFromSVN() {
23*9880d681SAndroid Build Coastguard Worker  local module=$1
24*9880d681SAndroid Build Coastguard Worker  local log="${module}.log"
25*9880d681SAndroid Build Coastguard Worker  echo "Running: svn export -r ${REV} ${module}; log in ${log}"
26*9880d681SAndroid Build Coastguard Worker  svn -q export -r ${REV} ${LLVM_PROJECT_SVN}/${module}/trunk \
27*9880d681SAndroid Build Coastguard Worker      ${module} > ${log} 2>&1
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker  # Create "module-revision.tar.bz2" packages from the SVN checkout dirs.
30*9880d681SAndroid Build Coastguard Worker  local tarball="${module}-${REV}.tar.bz2"
31*9880d681SAndroid Build Coastguard Worker  echo "Creating tarball: ${tarball}"
32*9880d681SAndroid Build Coastguard Worker  tar cjf ${tarball} ${module}
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Worker  echo "Cleaning up '${module}'"
35*9880d681SAndroid Build Coastguard Worker  rm -rf ${module} ${log}
36*9880d681SAndroid Build Coastguard Worker}
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Workerfor module in "llvm" "llvm-gcc-4.2"; do
39*9880d681SAndroid Build Coastguard Worker  createTarballFromSVN ${module}
40*9880d681SAndroid Build Coastguard Workerdone
41*9880d681SAndroid Build Coastguard Worker
42