Skip to content

Commit

Permalink
Build dates now follow SOURCE_DATE_EPOCH specs
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Feb 6, 2016
1 parent dcd6c18 commit 03b2ecd
Show file tree
Hide file tree
Showing 35 changed files with 111 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -5,4 +5,4 @@ install*
*.layout
CMakeFiles/
CMakeLists.txt.user

SOURCE_DATE_EPOCH
2 changes: 1 addition & 1 deletion apps/2d-slam-demo/CAboutBox.cpp
Expand Up @@ -148,7 +148,7 @@ void CAboutBox::OnInit(wxInitDialogEvent& event)
cout << "For bug reports or to collaborate: <joseluisblancoc@gmail.com>\n";

cout << "MRPT version: " << MRPT_getVersion() << endl;
cout << "MRPT compilation date: " << MRPT_getCompilationDate() << endl;
cout << "MRPT source timestamp: " << MRPT_getCompilationDate() << endl;
cout << "Eigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << endl;
cout << "wxWidgets version: " <<std::string(wxVer.mb_str()) << endl;
cout << "OpenCV version: ";
Expand Down
2 changes: 1 addition & 1 deletion apps/GridmapNavSimul/CAboutBox.cpp
Expand Up @@ -146,7 +146,7 @@ void CAboutBox::OnInit(wxInitDialogEvent& event)

cout << "Version: " << GRIDMAPSIMUL_VERSION << endl;
cout << "MRPT version: " << MRPT_getVersion() << endl;
cout << "MRPT compilation date: " << MRPT_getCompilationDate() << endl;
cout << "MRPT source timestamp: " << MRPT_getCompilationDate() << endl;
cout << "Eigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << endl;
cout << "wxWidgets version: " <<std::string(wxVer.mb_str()) << endl;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/RawLogViewer/CAboutBox.cpp
Expand Up @@ -145,7 +145,7 @@ void CAboutBox::OnInit(wxInitDialogEvent& event)
cout << "http://www.isa.uma.es/jlblanco\n\n";

cout << "MRPT version: " << MRPT_getVersion() << endl;
cout << "MRPT compilation date: " << MRPT_getCompilationDate() << endl;
cout << "MRPT source timestamp: " << MRPT_getCompilationDate() << endl;
cout << "Eigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << endl;
cout << "wxWidgets version: " <<std::string(wxVer.mb_str()) << endl;
cout << "wxMathPlot version: 0.1.2\n";
Expand Down
2 changes: 1 addition & 1 deletion apps/SceneViewer3D/CAboutBox.cpp
Expand Up @@ -153,7 +153,7 @@ void CAboutBox::OnInit(wxInitDialogEvent& event)
cout << "http://www.isa.uma.es/jlblanco\n\n";

cout << "MRPT version: " << MRPT_getVersion() << endl;
cout << "MRPT compilation date: " << MRPT_getCompilationDate() << endl;
cout << "MRPT source timestamp: " << MRPT_getCompilationDate() << endl;
cout << "Eigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << endl;
cout << "wxWidgets version: " <<std::string(wxVer.mb_str()) << endl;
cout << "wxMathPlot version: 0.03\n";
Expand Down
2 changes: 1 addition & 1 deletion apps/camera-calib/CAboutBox.cpp
Expand Up @@ -146,7 +146,7 @@ void CAboutBox::OnInit(wxInitDialogEvent& event)

cout << "Program version: " << CAMERA_CALIB_GUI_VERSION << endl;
cout << "MRPT version: " << MRPT_getVersion() << endl;
cout << "MRPT compilation date: " << MRPT_getCompilationDate() << endl;
cout << "MRPT source timestamp: " << MRPT_getCompilationDate() << endl;
cout << "Eigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << endl;
cout << "wxWidgets version: " <<std::string(wxVer.mb_str()) << endl;
cout << "OpenCV version: ";
Expand Down
2 changes: 1 addition & 1 deletion apps/grid-matching/grid-matching_main.cpp
Expand Up @@ -717,7 +717,7 @@ int main(int argc, char **argv)
if (!arg_nologo.getValue())
{
printf(" grid-matching - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", mrpt::system::MRPT_getVersion().c_str(), mrpt::system::MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", mrpt::system::MRPT_getVersion().c_str(), mrpt::system::MRPT_getCompilationDate().c_str());
}

SKIP_ICP_STAGE = arg_skip_icp.getValue();
Expand Down
2 changes: 1 addition & 1 deletion apps/hmt-slam-gui/CAboutBox.cpp
Expand Up @@ -144,7 +144,7 @@ void CAboutBox::OnInit(wxInitDialogEvent& event)
cout << "For bug reports or to collaborate: <joseluisblancoc@gmail.com>\n";

cout << "MRPT version: " << MRPT_getVersion() << endl;
cout << "MRPT compilation date: " << MRPT_getCompilationDate() << endl;
cout << "MRPT source timestamp: " << MRPT_getCompilationDate() << endl;
cout << "Eigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << endl;
cout << "wxWidgets version: " <<std::string(wxVer.mb_str()) << endl;
cout << "OpenCV version: ";
Expand Down
2 changes: 1 addition & 1 deletion apps/hmt-slam/hmt-slam_main.cpp
Expand Up @@ -51,7 +51,7 @@ int main(int argc, char **argv)
CConsoleRedirector dbg_out_file("./DEBUG_log_streaming.txt",true, true,false,0 );

printf(" HMT-SLAM version 0.2 - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str() );
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str() );
printf("-------------------------------------------------------------------\n");

// Process arguments:
Expand Down
2 changes: 1 addition & 1 deletion apps/holonomic-navigator-demo/CAboutBox.cpp
Expand Up @@ -146,7 +146,7 @@ void CAboutBox::OnInit(wxInitDialogEvent& event)
cout << " http://www.mrpt.org/ \n\n";

cout << "MRPT version: " << MRPT_getVersion() << endl;
cout << "MRPT compilation date: " << MRPT_getCompilationDate() << endl;
cout << "MRPT source timestamp: " << MRPT_getCompilationDate() << endl;
cout << "Eigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << endl;
cout << "wxWidgets version: " <<std::string(wxVer.mb_str()) << endl;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/icp-slam-live/icp-slam-live_main.cpp
Expand Up @@ -53,7 +53,7 @@ int main(int argc, char **argv)
bool showVersion = argc>1 && !os::_strcmp(argv[1],"--version");

printf(" icp-slam-live - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
if (showVersion)
return 0; // Program end
printf("-------------------------------------------------------------------\n");
Expand Down
2 changes: 1 addition & 1 deletion apps/icp-slam/icp-slam_main.cpp
Expand Up @@ -57,7 +57,7 @@ int main(int argc, char **argv)
bool showVersion = argc>1 && !os::_strcmp(argv[1],"--version");

printf(" icp-slam - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());

if (showVersion)
return 0; // Program end
Expand Down
2 changes: 1 addition & 1 deletion apps/kf-slam/kf-slam_main.cpp
Expand Up @@ -59,7 +59,7 @@ int main(int argc, char **argv)
try
{
printf(" kf-slam - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf("-------------------------------------------------------------------\n");

// Process arguments:
Expand Down
2 changes: 1 addition & 1 deletion apps/kinect-stereo-calib/CAboutBox.cpp
Expand Up @@ -147,7 +147,7 @@ void CAboutBox::OnInit(wxInitDialogEvent& event)
cout << "For bug reports or to collaborate: <joseluisblancoc@gmail.com>\n";

cout << "MRPT version: " << MRPT_getVersion() << endl;
cout << "MRPT compilation date: " << MRPT_getCompilationDate() << endl;
cout << "MRPT source timestamp: " << MRPT_getCompilationDate() << endl;
cout << "Eigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << endl;
cout << "wxWidgets version: " <<std::string(wxVer.mb_str()) << endl;
cout << "OpenCV version: ";
Expand Down
2 changes: 1 addition & 1 deletion apps/map-partition/map-partition.cpp
Expand Up @@ -318,7 +318,7 @@ int main(int argc, char **argv)
try
{
printf(" map-partition version 0.2 - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf("-------------------------------------------------------------------\n");

// Process arguments:
Expand Down
2 changes: 1 addition & 1 deletion apps/navlog-viewer/CAboutBox.cpp
Expand Up @@ -149,7 +149,7 @@ void CAboutBox::OnInit(wxInitDialogEvent& event)

cout << "Program version: " << NAVLOGVIEWER_VERSION << endl;
cout << "MRPT version: " << MRPT_getVersion() << endl;
cout << "MRPT compilation date: " << MRPT_getCompilationDate() << endl;
cout << "MRPT source timestamp: " << MRPT_getCompilationDate() << endl;
cout << "Eigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << endl;
cout << "wxWidgets version: " <<std::string(wxVer.mb_str()) << endl;
cout << "OpenCV version: ";
Expand Down
2 changes: 1 addition & 1 deletion apps/observations2map/observations2map_main.cpp
Expand Up @@ -43,7 +43,7 @@ int main(int argc, char **argv)
try
{
printf(" observations2map - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf("-------------------------------------------------------------------\n");

// Process arguments:
Expand Down
2 changes: 1 addition & 1 deletion apps/pf-localization/pf_localization_main.cpp
Expand Up @@ -75,7 +75,7 @@ int main(int argc, char **argv)
try
{
printf(" pf-localization\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf("-------------------------------------------------------------------\n");

// Process arguments:
Expand Down
2 changes: 1 addition & 1 deletion apps/rawlog-grabber/rawloggrabber_main.cpp
Expand Up @@ -72,7 +72,7 @@ int main(int argc, char **argv)
try
{
printf(" rawlog-grabber - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf("-------------------------------------------------------------------\n");

// Process arguments:
Expand Down
2 changes: 1 addition & 1 deletion apps/rbpf-slam/rbpf-slam.cpp
Expand Up @@ -80,7 +80,7 @@ int main(int argc, char **argv)
try
{
printf(" rbpf-slam - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf("-------------------------------------------------------------------\n");

// Process arguments:
Expand Down
2 changes: 1 addition & 1 deletion apps/ro-localization/ro-localization_main.cpp
Expand Up @@ -892,7 +892,7 @@ int main(int argc, char **argv)
try
{
printf(" ro-localization - Version 0.1 - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf("-------------------------------------------------------------------\n");

// Process arguments:
Expand Down
2 changes: 1 addition & 1 deletion apps/robotic-arm-kinematics/CAboutBox.cpp
Expand Up @@ -147,7 +147,7 @@ void CAboutBox::OnInit(wxInitDialogEvent& event)
cout << " http://www.mrpt.org/ \n\n";

cout << "MRPT version: " << MRPT_getVersion() << endl;
cout << "MRPT compilation date: " << MRPT_getCompilationDate() << endl;
cout << "MRPT source timestamp: " << MRPT_getCompilationDate() << endl;
cout << "Eigen version: " << EIGEN_WORLD_VERSION << "." << EIGEN_MAJOR_VERSION << "." << EIGEN_MINOR_VERSION << endl;
cout << "wxWidgets version: " <<std::string(wxVer.mb_str()) << endl;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/simul-beacons/simul-beacons-main.cpp
Expand Up @@ -38,7 +38,7 @@ int main(int argc, char ** argv)
bool showVersion = argc>1 && !os::_strcmp(argv[1],"--version");

printf(" simul-beacons - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());

if (showVersion)
return 0; // Program end
Expand Down
2 changes: 1 addition & 1 deletion apps/simul-gridmap/simul-gridmap_main.cpp
Expand Up @@ -76,7 +76,7 @@ int main(int argc, char ** argv)
if (arg_nologo.getValue())
{
printf(" simul-gridmap - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
}

// Invoke method:
Expand Down
2 changes: 1 addition & 1 deletion apps/simul-landmarks/simul-landmarks-main.cpp
Expand Up @@ -47,7 +47,7 @@ int main(int argc, char ** argv)
bool showVersion = argc>1 && !os::_strcmp(argv[1],"--version");

printf(" simul-landmarks - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());

if (showVersion)
return 0; // Program end
Expand Down
2 changes: 1 addition & 1 deletion apps/track-video-features/track-video-feats_main.cpp
Expand Up @@ -369,7 +369,7 @@ int main(int argc, char **argv)
try
{
printf(" track-video-features - Part of MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", mrpt::system::MRPT_getVersion().c_str(), mrpt::system::MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", mrpt::system::MRPT_getVersion().c_str(), mrpt::system::MRPT_getCompilationDate().c_str());
printf("-------------------------------------------------------------------\n");

// The video source:
Expand Down
2 changes: 1 addition & 1 deletion apps/velodyne-view/velodyne-view_main.cpp
Expand Up @@ -146,7 +146,7 @@ int VelodyneView(int argc, char **argv)
if (!arg_nologo.isSet())
{
printf(" velodyne-view - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", mrpt::system::MRPT_getVersion().c_str(), mrpt::system::MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", mrpt::system::MRPT_getVersion().c_str(), mrpt::system::MRPT_getCompilationDate().c_str());
}

// Launch grabbing thread:
Expand Down
37 changes: 32 additions & 5 deletions cmakemodules/script_create_version_h.cmake
Expand Up @@ -7,11 +7,38 @@ SET(CMAKE_MRPT_COMPLETE_NAME "MRPT ${CMAKE_MRPT_VERSION_NUMBER_MAJOR}.${CMAKE_MR
# Build a three digits version code, eg. 0.5.1 -> 051, 1.2.0 -> 120
SET(CMAKE_MRPT_VERSION_CODE "0x${CMAKE_MRPT_VERSION_NUMBER_MAJOR}${CMAKE_MRPT_VERSION_NUMBER_MINOR}${CMAKE_MRPT_VERSION_NUMBER_PATCH}")

IF (CMAKE_VERSION VERSION_GREATER 2.8.10)
STRING(TIMESTAMP CMAKE_MRPT_BUILD_DATE "%Y-%m-%d")
ELSE()
SET(CMAKE_MRPT_BUILD_DATE "")
ENDIF()
# SOURCE_DATE_EPOCH: See Specs in https://reproducible-builds.org/specs/source-date-epoch/
# Take its value from:
# 1) The file SRC/SOURCE_DATE_EPOCH (generated by scripts creating Windows/Debian packages)
# 2) The env var "SOURCE_DATE_EPOCH"
# 3) The output from "git log -1 --pretty=%ct"
# 4) As a last resort, leave it blank, so the C++ source code will use current time.

SET(CMAKE_SOURCE_DATE_EPOCH "")
# 1: SRC/SOURCE_DATE_EPOCH
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/SOURCE_DATE_EPOCH")
FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/SOURCE_DATE_EPOCH" CMAKE_SOURCE_DATE_EPOCH LIMIT_COUNT 1) # Read only the first line
endif()
if ("" STREQUAL "${CMAKE_SOURCE_DATE_EPOCH}")
# If empty:
# 2) The env var "SOURCE_DATE_EPOCH"
if (DEFINED ENV{SOURCE_DATE_EPOCH})
set(CMAKE_SOURCE_DATE_EPOCH "$ENV{SOURCE_DATE_EPOCH}")
else()
# 3) The output from "git log -1 --pretty=%ct"
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(
COMMAND "${GIT_EXECUTABLE}" "log" "-1" "--pretty=%ct"
OUTPUT_VARIABLE CMAKE_SOURCE_DATE_EPOCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
IF ($ENV{VERBOSE})
MESSAGE(STATUS "SOURCE_DATE_EPOCH from git log: ${CMAKE_SOURCE_DATE_EPOCH}")
ENDIF()
endif()
endif()
endif()


CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/parse-files/version.h.in" "${MRPT_CONFIG_FILE_INCLUDE_DIR}/mrpt/version.h")

Expand Down
5 changes: 5 additions & 0 deletions cmakemodules/script_show_final_summary.cmake
Expand Up @@ -62,6 +62,11 @@ MESSAGE(STATUS " Word size (32/64 bit) : ${CMAKE_MRPT_WORD_SIZE}")
MESSAGE(STATUS " CMake version : " ${CMAKE_VERSION})
MESSAGE(STATUS " CMake generator : " ${CMAKE_GENERATOR})
MESSAGE(STATUS " CMake build tool : " ${CMAKE_BUILD_TOOL})
if (UNIX)
execute_process(COMMAND "date" "-u" "-d" "@${CMAKE_SOURCE_DATE_EPOCH}" "+%Y-%m-%d" OUTPUT_VARIABLE MRPT_BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
endif(UNIX)
MESSAGE(STATUS " MRPT SOURCE_DATE_EPOCH : " ${CMAKE_SOURCE_DATE_EPOCH} " (${MRPT_BUILD_DATE})")

MESSAGE(STATUS " Compiler : " ${CMAKE_CXX_COMPILER_ID})
if(MSVC)
MESSAGE(STATUS " MSVC : " ${MSVC_VERSION})
Expand Down
9 changes: 3 additions & 6 deletions libs/base/include/mrpt/system/os.h
Expand Up @@ -141,19 +141,16 @@ namespace mrpt
/** \addtogroup mrpt_system_os
* @{ */

/** Shows the message "Press any key to continue" (or other custom message) to the current standard output and returns when a key is pressed.
*/
/** Shows the message "Press any key to continue" (or other custom message) to the current standard output and returns when a key is pressed */
void BASE_IMPEXP pause(const std::string &msg = std::string("Press any key to continue...") ) MRPT_NO_THROWS;

/** Clears the console window */
void BASE_IMPEXP clearConsole();

/** Returns the MRPT compilation date
*/
/** Returns the MRPT source code timestamp, according to the Reproducible-Builds specifications: https://reproducible-builds.org/specs/source-date-epoch/ */
std::string BASE_IMPEXP MRPT_getCompilationDate();

/** Returns a string describing the MRPT version including the SVN number.
*/
/** Returns a string describing the MRPT version */
std::string BASE_IMPEXP MRPT_getVersion();

/** Returns a const ref to a text with the same text that appears at the beginning of each MRPT file (useful for displaying the License text in GUIs) */
Expand Down
24 changes: 23 additions & 1 deletion libs/base/src/system/os.cpp
Expand Up @@ -154,9 +154,31 @@ void mrpt::system::registerFatalExceptionHandlers()
mrpt::system::MRPT_getCompilationDate
---------------------------------------------------------------*/
#include <mrpt/version.h>
#include <errno.h>
#include <limits.h>
#include <ctime>

string mrpt::system::MRPT_getCompilationDate()
{
return string( MRPT_build_date_str );
time_t now;
char *endptr;
const char *source_date_epoch = MRPT_SOURCE_DATE_EPOCH;

errno = 0;
unsigned long long epoch = strtoull(source_date_epoch, &endptr, 10);
if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0)) || (errno != 0 && epoch == 0)) {
// Last resort:
now = time(NULL);
}
else {
now = epoch;
}
struct tm *build_time = gmtime(&now);
const int year = build_time->tm_year + 1900;
const int month = build_time->tm_mon + 1;
const int day = build_time->tm_mday;

return mrpt::format("%i-%02i-%02i",year,month,day);
}

/*---------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions mex/apps/mex-grabber/mexgrabber.cpp
Expand Up @@ -80,7 +80,7 @@ namespace {
MEX_DEFINE(new) (int nlhs, mxArray* plhs[],
int nrhs, const mxArray* prhs[]) {
printf(" mex-grabber - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf("-------------------------------------------------------------------\n");

mexplus::InputArguments input(nrhs, prhs, 1);
Expand Down Expand Up @@ -297,7 +297,7 @@ int main(int argc, const char* argv[] )
try
{
printf(" MEX-grabber - Part of the MRPT\n");
printf(" MRPT C++ Library: %s - BUILD DATE %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf(" MRPT C++ Library: %s - Sources timestamp: %s\n", MRPT_getVersion().c_str(), MRPT_getCompilationDate().c_str());
printf("-------------------------------------------------------------------\n");
printf(" This is a test for Matlab MEX functionalities\n");
printf("-------------------------------------------------------------------\n");
Expand Down
5 changes: 3 additions & 2 deletions parse-files/version.h.in
Expand Up @@ -6,10 +6,11 @@
#define MRPT_VERSION_H

const char MRPT_version_str[] = "${CMAKE_MRPT_COMPLETE_NAME}";
const char MRPT_build_date_str[] = "${CMAKE_MRPT_BUILD_DATE}";

/** Version number of package in hexadecimal:
* A three digits version code, eg. 0.5.1 -> 0x051, 1.2.0 -> 0x120 */
#define MRPT_VERSION ${CMAKE_MRPT_VERSION_CODE}

// See specs: https://reproducible-builds.org/specs/source-date-epoch/
const char MRPT_SOURCE_DATE_EPOCH[] = "${CMAKE_SOURCE_DATE_EPOCH}";

#endif

0 comments on commit 03b2ecd

Please sign in to comment.