1#!/bin/bash
2#
3# Copyright 2013 Google Inc. All Rights Reserved.
4# Author: sameeragarwal@google.com (Sameer Agarwal)
5#
6# Import the latest version of Ceres into google3.
7
8set -e
9set -x
10
11if [[ "google3" != "$(basename $(pwd))" ]] ; then
12  echo "ERROR: Not in toplevel google3 directory. Bailing."
13  exit 1
14fi
15
16declare -r google3_dir="$(pwd)"
17
18declare -r temp_repo="/tmp/ceres-solver"
19git clone \
20  /usr/local/google/home/sameeragarwal/ceres-solver -b testing\
21  $temp_repo
22
23cd $temp_repo
24declare -r commit="$(git log | head -1)"
25rm -rf .git
26
27# Get rid of the internal gtest and gmock code until the upstream
28# version moves it around appropriately.
29rm -rf internal/ceres/gtest*
30rm -rf internal/ceres/gmock*
31rm -rf internal/ceres/mock_log.h
32
33cd $google3_dir
34cp -R $temp_repo/* third_party/ceres
35
36cd third_party/ceres
37
38declare -r temp_readme="/tmp/README.google"
39rm -f $temp_readme
40
41echo "URL: https://ceres-solver.googlesource.com/ceres-solver/+/$commit" >> $temp_readme
42echo "Version: $commit" >> $temp_readme
43tail -n +3 README.google >> $temp_readme
44cp $temp_readme README.google
45