diff --git a/docs/.current_minor_release_number b/docs/.current_minor_release_number deleted file mode 100644 index 98d9bcb75..000000000 --- a/docs/.current_minor_release_number +++ /dev/null @@ -1 +0,0 @@ -17 diff --git a/docs/.current_release_number b/docs/.current_release_number deleted file mode 100644 index 3c032078a..000000000 --- a/docs/.current_release_number +++ /dev/null @@ -1 +0,0 @@ -18 diff --git a/docs/bash_helper_functions b/docs/bash_helper_functions new file mode 100755 index 000000000..66603e6d2 --- /dev/null +++ b/docs/bash_helper_functions @@ -0,0 +1,30 @@ +#/bin/sh +# +# This script defines some helper functions used by other scripts in the docs +# folder. + +get_short_revision_number() +{ + RESULT=`hg log -r $1 | grep changeset | awk '{print $2}' | sed -e 's/:.*//'` +} + +get_last_modified_date() +{ + RESULT=`hg log $1 -l1 --template '{date|date}\n' | awk '{ print $2" "$3", " $5}'` +} + +get_dlib_version() +{ + cat ../dlib/CMakeLists.txt | awk '/set\(CPACK_PACKAGE_VERSION_'$1'/{ match($2,"\"(.*)\"",a); print a[1]}' +} + + +# call like: set_dlib_version MAJOR 42 +set_dlib_version() +{ + sed -i -e 's/\(set(CPACK_PACKAGE_VERSION_'$1' *"\).*\(".*\)/\1'$2'\2/' ../dlib/CMakeLists.txt +} + +MAJOR_NUM=`get_dlib_version MAJOR` +MINOR_NUM=`get_dlib_version MINOR` +PATCH_NUM=`get_dlib_version PATCH` diff --git a/docs/makedocs b/docs/makedocs index 8a7eeccf2..ee0c21dde 100755 --- a/docs/makedocs +++ b/docs/makedocs @@ -1,4 +1,5 @@ #!/bin/bash +. bash_helper_functions report_failure () { @@ -70,11 +71,11 @@ htmlify_cmake () echo $1 >> $1.html; echo "
" >> $1.html;
 
-#  line 1: make comments green
-#  line 2: add links into the add_subdirectory directives
-#  line 3: make literal quotes red
-#  line 4: make the directives show up blue
-#  line 5: make variable names show up purple
+    #  line 1: make comments green
+    #  line 2: add links into the add_subdirectory directives
+    #  line 3: make literal quotes red
+    #  line 4: make the directives show up blue
+    #  line 5: make variable names show up purple
     sed -e "s/^\([ ]*#.*\)/\1<\/font>/" \
         -e "s/add_subdirectory\([ ]*\)(\([ ]*\)\([^ ]*\)\([ ]*\)\([^ )]*\)/add_subdirectory\1(\2\3\4\5<\/a>/"  \
         -e "s/\"\([^\"]*\)\"/\"\1<\/font>\"/g"  \
@@ -95,26 +96,15 @@ htmlify_python()
     done
 }
 
-get_short_revision_number()
-{    
-    RESULT=`hg log -r $1 | grep changeset | awk '{print $2}' | sed -e 's/:.*//'`  
-}
-
-get_last_modified_date()
-{
-    RESULT=`hg log $1 -l1 --template '{date|date}\n' | awk '{ print $2" "$3", " $5}'`
-}
 
 makedocs ()
 {
 
-    COUNTER_FILE=.current_release_number
-    MINOR_COUTNER_FILE=.current_minor_release_number
     REVNUM_FILE=.logger_revnum
 
 
 
-# figure out the short number that identifies this particular changeset
+    # figure out the short number that identifies this particular changeset
     get_short_revision_number `cat $REVNUM_FILE`
     LOGGER_REVNUM=$RESULT
 
@@ -124,22 +114,20 @@ makedocs ()
 
 
 
-# The revision number we are currently at
+    # The revision number we are currently at
     CHANGESET_ID=`hg id -i | sed -e 's/\+//'`
     get_short_revision_number $CHANGESET_ID 
     REVISION=$RESULT
 
 
-    MAJOR_NUM=`cat $COUNTER_FILE` 
-    MINOR_NUM=`cat $MINOR_COUTNER_FILE` 
     if [ "$1" = "makerel" ] 
         then
         RELEASE=${MAJOR_NUM}.${MINOR_NUM} 
     else
-        RELEASE=${MAJOR_NUM}.`echo ${MINOR_NUM}+1|bc`-RC
+        RELEASE=${MAJOR_NUM}.${MINOR_NUM}.${PATCH_NUM}
     fi;
 
-# get XML versions of the change logs
+    # get XML versions of the change logs
     BASE_LOGGER_REVNUM=`echo $LOGGER_REVNUM - 1000 | bc`
     NEXT_LOGGER_REVNUM=`echo $LOGGER_REVNUM + 1 | bc`
     echo Getting the mercurial change logs for revisions $NEXT_LOGGER_REVNUM:$REVISION
@@ -147,20 +135,14 @@ makedocs ()
     echo Getting the mercurial change logs for revisions $BASE_LOGGER_REVNUM:$LOGGER_REVNUM
     hg log -v ../dlib ../examples ../tools ../python_examples --style=xml  -r$BASE_LOGGER_REVNUM:$LOGGER_REVNUM > docs/old_log.txt || report_failure 
 
-# grab a clean copy of the repository 
+    # grab a clean copy of the repository 
     rm -rf docs/cache
     rm -rf docs/web
     rm -rf docs/chm/docs
-    rm -rf cache.$$
-    hg archive cache.$$ || report_failure
-# put the stuff we need into the docs/cache folder
-    mkdir docs/cache
-    mv cache.$$/dlib docs/cache/
-    mv cache.$$/examples docs/cache/
-    mv cache.$$/python_examples docs/cache/
-    mv cache.$$/tools docs/cache/
-    rm -rf cache.$$
-
+    hg archive docs/cache || report_failure
+    # Don't need the docs folder in the cache, moreover, deleting it here avoids letting the makerel script include it in the dlib tar balls.
+    rm -rf docs/cache/docs
+    rm docs/cache/README.txt
 
     echo "#ifndef DLIB_REVISION_H"           > docs/cache/dlib/revision.h
     echo "// Version: " $RELEASE            >> docs/cache/dlib/revision.h
@@ -168,6 +150,7 @@ makedocs ()
     echo "// Mercurial Revision ID: " $CHANGESET_ID >> docs/cache/dlib/revision.h
     echo "#define DLIB_MAJOR_VERSION " $MAJOR_NUM >> docs/cache/dlib/revision.h
     echo "#define DLIB_MINOR_VERSION " $MINOR_NUM >> docs/cache/dlib/revision.h
+    echo "#define DLIB_PATCH_VERSION " $PATCH_NUM >> docs/cache/dlib/revision.h
     echo "#endif"                           >> docs/cache/dlib/revision.h
 
 
diff --git a/docs/makerel b/docs/makerel
index 5a4b282c1..a9137027b 100755
--- a/docs/makerel
+++ b/docs/makerel
@@ -1,7 +1,8 @@
 #!/bin/bash
+. bash_helper_functions
 
-# if the first argument to this script is the word major then the 
-# major version number is updated and the minor is set back to 0
+# If the first argument to this script is the word major then the 
+# major version number is updated and the minor is set back to 0.
 
 report_failure ()
 {
@@ -15,44 +16,41 @@ report_failure ()
 
 
 REVNUM_FILE=.logger_revnum
-COUNTER_FILE=.current_release_number
-MINOR_COUTNER_FILE=.current_minor_release_number
-
-
-RELEASE=`cat $COUNTER_FILE | awk '{ print $1 + 1}'` 
-
-if [ "$1" = "major" ] 
-    then
-    MAJOR_NUM=`cat $COUNTER_FILE | awk '{print $1 + 1}'` 
-    MINOR_NUM=0 
-    echo $MAJOR_NUM > $COUNTER_FILE
-    echo $MINOR_NUM > $MINOR_COUTNER_FILE
-else 
-    MAJOR_NUM=`cat $COUNTER_FILE` 
-    MINOR_NUM=`cat $MINOR_COUTNER_FILE | awk '{print $1 + 1}'` 
-    echo $MINOR_NUM > $MINOR_COUTNER_FILE
-fi;
-
-./makedocs makerel || exit 1
+CHANGESET_ID=`hg id -i | sed -e 's/\+//'`
 
 rm -rf release || report_failure
 mkdir release || report_failure
 
+
+if [ "$1" = "major" ] 
+    then
+    MAJOR_NUM=`echo $MAJOR_NUM+1|bc`
+    MINOR_NUM=0 
+else 
+    MINOR_NUM=`echo $MINOR_NUM+1|bc`
+fi;
+set_dlib_version MAJOR $MAJOR_NUM
+set_dlib_version MINOR $MINOR_NUM
+set_dlib_version PATCH 0 
+
 RELEASE=${MAJOR_NUM}.${MINOR_NUM} 
+# Commit changes to the version numbers so that the makedocs script will use them.
+echo Create Mercurial tags and commit release
+hg tag v$RELEASE || report_failure
+hg commit -m "Created release v$RELEASE" || report_failure
 
+./makedocs makerel || exit 1
 
-
-CHANGESET_ID=`hg id -i | sed -e 's/\+//'`
 echo $CHANGESET_ID > $REVNUM_FILE
+set_dlib_version PATCH 99 
+hg commit -m "Record last changeset and set PATCH version to 99"
+
 
 cd release || report_failure
 RELDIR=`echo dlib-$RELEASE`
 mkdir $RELDIR
 cd $RELDIR || report_failure
-cp -r ../../docs/cache/dlib . || report_failure
-cp -r ../../docs/cache/examples . || report_failure
-cp -r ../../docs/cache/python_examples . || report_failure
-cp -r ../../docs/cache/tools . || report_failure
+cp -r ../../docs/cache/* . || report_failure
 
 echo Version: $RELEASE >> dlib/README.txt
 echo "Date:    `date`" >> dlib/README.txt
@@ -89,9 +87,5 @@ mv $SOURCE_TAR.bz2 v$RELEASE
 mv $SOURCE_ZIP v$RELEASE
 
 
-echo Create Mercurial tags and commit release
-cd ..
-hg tag v$RELEASE || report_failure
-hg commit -m "Created release v$RELEASE"
 
 
diff --git a/setup.py b/setup.py
index 503446c6f..ffd729f6b 100644
--- a/setup.py
+++ b/setup.py
@@ -43,6 +43,7 @@ from subprocess import Popen, PIPE, STDOUT
 import signal
 from threading import Thread
 import time
+import re
 
 
 # change directory to this module path
@@ -340,9 +341,10 @@ def readme(fname):
 def read_version():
     """Read version information
     """
-    major = readme('./docs/.current_release_number').strip()
-    minor = readme('./docs/.current_minor_release_number').strip()
-    return major + '.' + minor
+    major = re.findall("set\(CPACK_PACKAGE_VERSION_MAJOR.*\"(.*)\"", open('dlib/CMakeLists.txt').read())[0]
+    minor = re.findall("set\(CPACK_PACKAGE_VERSION_MINOR.*\"(.*)\"", open('dlib/CMakeLists.txt').read())[0]
+    patch = re.findall("set\(CPACK_PACKAGE_VERSION_PATCH.*\"(.*)\"", open('dlib/CMakeLists.txt').read())[0]
+    return major + '.' + minor + '.' + patch 
 
 
 def rmtree(name):
@@ -546,7 +548,7 @@ setup(
     version=read_version(),
     keywords=['dlib', 'Computer Vision', 'Machine Learning'],
     description='A toolkit for making real world machine learning and data analysis applications',
-    long_description=readme('./README.txt'),
+    long_description=readme('dlib/README.txt'),
     author='Davis King',
     author_email='davis@dlib.net',
     url='https://github.com/davisking/dlib',