blob: ce5d5cdf6884be29c69a5e0df77c38ef12651ad1 [file] [log] [blame]
Austin Schuh70cc9552019-01-21 19:46:48 -08001#!/bin/bash
2#
3# Ceres Solver - A fast non-linear least squares minimizer
4# Copyright 2015 Google Inc. All rights reserved.
5# http://ceres-solver.org/
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are met:
9#
10# * Redistributions of source code must retain the above copyright notice,
11# this list of conditions and the following disclaimer.
12# * Redistributions in binary form must reproduce the above copyright notice,
13# this list of conditions and the following disclaimer in the documentation
14# and/or other materials provided with the distribution.
15# * Neither the name of Google Inc. nor the names of its contributors may be
16# used to endorse or promote products derived from this software without
17# specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29# POSSIBILITY OF SUCH DAMAGE.
30#
31# Author: mierle@gmail.com (Keir Mierle)
32#
33# Note: You will need Sphinx and Pygments installed for this to work.
34
35if [ -z $1 ] ; then
36 echo 'usage: scripts/make_release <version>'
37 echo ' must be run from toplevel Ceres source directory'
38 exit 1
39fi
40
41TMP="/tmp/ceres-solver-$1"
42DOCS_TMP="/tmp/ceres-solver-docs-$1"
43VERSION=$(grep '#define CERES_VERSION_' include/ceres/version.h | \
44 sed -e 's/#define CERES_VERSION_STRING.*$//' | \
45 sed -e 's/\(^#define CERES_VERSION_[MR^S].[A-Z]*\) \([0-9]\)/\2/' | \
46 tr '\n' '.' | \
47 sed -e 's/..$//')
48GIT_COMMIT=$(git log -1 HEAD |grep commit)
49
50if [[ $1 != $VERSION ]] ; then
51 echo "ERROR: Version from the command line $1 does not match CERES_VERSION"
52 echo " in include/ceres/version.h, which is $VERSION. You may not be in the "
53 echo " toplevel source dir."
54 exit 1
55fi
56
57# Export repository.
58git checkout-index -f -a --prefix=$TMP/
59
60# Build the VERSION file.
61VERSIONFILE=$TMP/VERSION
62echo "version $VERSION" >> $VERSIONFILE
63echo "$GIT_COMMIT" >> $VERSIONFILE
64
65# Build the documentation.
66python $TMP/scripts/make_docs.py $TMP $DOCS_TMP
67cp -pr $DOCS_TMP/html $TMP/docs
68
69# Build the tarball.
70cd /tmp
71tar -cvzf "ceres-solver-$1.tar.gz" "ceres-solver-$1"
72
73# Don't leave a mess behind.
74rm -rf $TMP
75rm -rf $DOCS_TMP
76
77# Reminder to upload.
78cat <<EOF
79
80TODO:
81 - Upload /tmp/ceres-solver-$1.tar.gz
82EOF