diff --git a/base/timer.cpp b/base/timer.cpp index 0b632eda1e..50d4394c82 100644 --- a/base/timer.cpp +++ b/base/timer.cpp @@ -52,4 +52,11 @@ string FormatCurrentTime() return s; } +uint32_t TodayAsYYMMDD() +{ + time_t rawTime = time(NULL); + tm * pTm = gmtime(&rawTime); + return (pTm->tm_year - 100) * 10000 + (pTm->tm_mon + 1) * 100 + pTm->tm_mday; +} + } diff --git a/base/timer.hpp b/base/timer.hpp index 79b2c923fb..f53f17ef4c 100644 --- a/base/timer.hpp +++ b/base/timer.hpp @@ -20,5 +20,6 @@ public: }; string FormatCurrentTime(); +uint32_t TodayAsYYMMDD(); } diff --git a/defines.hpp b/defines.hpp index 72a8760eda..53a38c8910 100644 --- a/defines.hpp +++ b/defines.hpp @@ -6,6 +6,7 @@ #define TRIANGLE_FILE_TAG "trg" #define INDEX_FILE_TAG "idx" #define HEADER_FILE_TAG "header" +#define VERSION_FILE_TAG "version" #define COUNTRIES_FILE "countries.txt" #define DATA_UPDATE_FILE "maps.update" diff --git a/generator/feature_sorter.cpp b/generator/feature_sorter.cpp index 0d05670a66..46df3741b2 100644 --- a/generator/feature_sorter.cpp +++ b/generator/feature_sorter.cpp @@ -15,13 +15,13 @@ #include "../platform/platform.hpp" +#include "../version/version.hpp" + #include "../coding/file_container.hpp" #include "../base/string_utils.hpp" #include "../base/logging.hpp" - -#include "../base/start_mem_debug.hpp" - +#include "../base/timer.hpp" namespace { @@ -103,9 +103,23 @@ namespace feature { // write own mwm header (now it's a base point only) m_header.SetBounds(m_bounds); - FileWriter w = m_writer.GetWriter(HEADER_FILE_TAG); - m_header.Save(w); - w.Flush(); + { + FileWriter w = m_writer.GetWriter(HEADER_FILE_TAG); + m_header.Save(w); + w.Flush(); + } + + // write version information + { + static uint32_t generatorStartTime = my::TodayAsYYMMDD(); + + FileWriter w = m_writer.GetWriter(VERSION_FILE_TAG); + + WriteVarUint(w, Version::BUILD); + WriteVarUint(w, Version::GIT_HASH); + // actual date of data generation + WriteVarUint(w, generatorStartTime); + } // assume like we close files m_datFile.Flush(); diff --git a/storage/country.cpp b/storage/country.cpp index 4aa3861334..9158f70bf0 100644 --- a/storage/country.cpp +++ b/storage/country.cpp @@ -14,9 +14,9 @@ #include "../base/logging.hpp" #include "../base/std_serialization.hpp" #include "../base/string_utils.hpp" +#include "../base/timer.hpp" #include "../std/fstream.hpp" -#include "../std/ctime.hpp" namespace storage { @@ -166,10 +166,7 @@ namespace storage stream::SinkWriterStream wStream(writer); // save version - it's equal to current date in GMT - time_t rawTime = time(NULL); - tm * pTm = gmtime(&rawTime); - uint32_t const version = (pTm->tm_year - 100) * 10000 + (pTm->tm_mon + 1) * 100 + pTm->tm_mday; - wStream << static_cast(version); + wStream << my::TodayAsYYMMDD(); wStream << level; wStream << cellFiles; wStream << commonFiles; diff --git a/tools/unix/generate_version.sh b/tools/unix/generate_version.sh index a9dfcc3f9c..353cab6206 100755 --- a/tools/unix/generate_version.sh +++ b/tools/unix/generate_version.sh @@ -33,7 +33,7 @@ else fi fi -BUILD_TIMESTAMP=`date -u +%y%m%d` +BUILD_TIMESTAMP=`date -u +%y%m%d%H%M` BUILD_TIMESTAMP_FULL=`date -u` GIT_CMD="git --git-dir=$GIT_WORKING_DIR_PATH/.git --work-tree=$GIT_WORKING_DIR_PATH" @@ -66,6 +66,7 @@ if [ $# -eq 4 ]; then echo " static unsigned int const MAJOR = $MAJOR;" >> $OUT_FILE echo " static unsigned int const MINOR = $MINOR;" >> $OUT_FILE echo " static unsigned int const BUILD = $BUILD_TIMESTAMP;" >> $OUT_FILE + echo " static unsigned int const GIT_HASH = 0x$GIT_COMMIT_HASH;" >> $OUT_FILE echo " #define VERSION_STRING \"$STRING_VER\"" >> $OUT_FILE echo " #define VERSION_DATE_STRING \"$BUILD_TIMESTAMP_FULL\"" >> $OUT_FILE echo "}" >> $OUT_FILE