Home | History | Annotate | Download | only in scripts
      1 #!/bin/bash
      2 #
      3 # Ceres Solver - A fast non-linear least squares minimizer
      4 # Copyright 2012 Google Inc. All rights reserved.
      5 # http://code.google.com/p/ceres-solver/
      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 (at] gmail.com (Keir Mierle)
     32 #
     33 # Note: you will need a fairly complete latex installation, along with
     34 # pygments, for this to work.
     35 
     36 if [ -z $1 ] ; then
     37   echo 'usage: scripts/make_release <version>'
     38   echo '       must be run from toplevel Ceres source directory'
     39   exit 1
     40 fi
     41 
     42 TMP="/tmp/ceres-solver-$1"
     43 DOCS_TMP="/tmp/ceres-solver-docs-$1"
     44 VERSION=$(grep 'SET(CERES_VERSION' CMakeLists.txt | \
     45           sed -e 's/SET(CERES_VERSION //' | \
     46           sed -e 's/)//')
     47 ABI_VERSION=$(grep 'SET(CERES_ABI_VERSION' CMakeLists.txt | \
     48               sed -e 's/SET(CERES_ABI_VERSION //' | \
     49               sed -e 's/)//')
     50 VERSION_IN_HEADER=$(grep '#define CERES_VERSION' include/ceres/ceres.h | \
     51                     sed -e 's/#define CERES_VERSION //')
     52 ABI_VERSION_IN_HEADER=$(grep '#define CERES_ABI_VERSION' \
     53                               include/ceres/ceres.h | \
     54                         sed -e 's/#define CERES_ABI_VERSION //')
     55 GIT_COMMIT=$(git log -1 HEAD |grep commit)
     56 
     57 if [[ $1 != $VERSION ]] ; then
     58   echo "ERROR: Version from the command line $1 does not match CERES_VERSION"
     59   echo "       in CMakeLists.txt, which is $VERSION. You may not be in the "
     60   echo "       toplevel source dir."
     61   exit 1
     62 fi
     63 
     64 if [[ $VERSION_IN_HEADER != $VERSION ]] ; then
     65   echo "ERROR: CERES_VERSION version from include/ceres/ceres.h, which is"
     66   echo "       $VERSION_IN_HEADER, does not match the ABI version"
     67   echo "       from the toplevel CMakeLists.txt, which is $ABI_VERSION."
     68   echo "       You may not be in the toplevel source directory, or the"
     69   echo "       versions are out of sync."
     70   exit 1
     71 fi
     72 
     73 if [[ $ABI_VERSION_IN_HEADER != $ABI_VERSION ]] ; then
     74   echo "ERROR: CERES_ABI_VERSION from include/ceres/ceres.h, which is"
     75   echo "       $ABI_VERSION_IN_HEADER, does not match the ABI version"
     76   echo "       from the toplevel CMakeLists.txt, which is $ABI_VERSION."
     77   echo "       You may not be in the toplevel source directory, or the"
     78   echo "       versions are out of sync."
     79   exit 1
     80 fi
     81 
     82 # Clone the repository and clean out the git extras.
     83 git clone . $TMP
     84 rm -rf "$TMP/.git"
     85 
     86 # Build the VERSION file.
     87 VERSIONFILE=$TMP/VERSION
     88 echo "version $VERSION" >> $VERSIONFILE
     89 echo "abi_version $VERSION" >> $VERSIONFILE
     90 echo "$GIT_COMMIT" >> $VERSIONFILE
     91 
     92 # Build the documentation.
     93 cp -pr "$TMP/docs" $DOCS_TMP
     94 cd $DOCS_TMP
     95 curl http://minted.googlecode.com/files/minted.sty > minted.sty
     96 pdflatex -shell-escape ceres-solver && \
     97   bibtex ceres-solver && \
     98   pdflatex -shell-escape ceres-solver && \
     99   pdflatex -shell-escape ceres-solver
    100 cp $DOCS_TMP/ceres-solver.pdf "$TMP/docs/ceres-solver.pdf"
    101 cp $DOCS_TMP/ceres-solver.pdf "/tmp/ceres-solver-$1.pdf"
    102 
    103 # Build the tarball.
    104 cd /tmp
    105 tar -cvzf "ceres-solver-$1.tar.gz" "ceres-solver-$1"
    106 
    107 # Don't leave a mess behind.
    108 rm -rf $DOCS_TMP
    109 rm -rf $TMP
    110 
    111 # Reminder to upload.
    112 echo
    113 echo "TODO: upload /tmp/ceres-solver-$1.tar.gz"
    114 echo "TODO: upload /tmp/ceres-solver-$1.pdf"
    115 echo
    116