Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 631976e0 authored by Théotime Grohens's avatar Théotime Grohens
Browse files

Merge branch 'print-commit' into 'aevol_7'

[aevol] Print compile commit branch, hash and date

See merge request aevol/aevol!30
parents 59b907ed ee8f2200
No related branches found
No related tags found
No related merge requests found
set(AEVOL_REVISION "unknown")
if(EXISTS ${AEVOL_SOURCE_DIR}/.git)
execute_process(COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${AEVOL_SOURCE_DIR}
OUTPUT_VARIABLE AEVOL_REVISION_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND
git status -s ${AEVOL_SOURCE_DIR}
WORKING_DIRECTORY ${AEVOL_SOURCE_DIR}
OUTPUT_VARIABLE AEVOL_SOURCE_MODIFIED
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT AEVOL_SOURCE_MODIFIED STREQUAL "")
set(AEVOL_REVISION_HASH "${AEVOL_REVISION_HASH}-dirty")
endif()
execute_process(COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${AEVOL_SOURCE_DIR}
OUTPUT_VARIABLE AEVOL_BRANCH_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND git log -n 1 --pretty=%cD #--date=short
WORKING_DIRECTORY ${AEVOL_SOURCE_DIR}
OUTPUT_VARIABLE AEVOL_REVISION_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
# If we wanted to use the compile date instead
# However, this makes the build non-reproducible
#string(TIMESTAMP AEVOL_COMPILE_DATE "%Y-%m-%d %H:%M:%S")
set(AEVOL_REVISION "${AEVOL_BRANCH_NAME}, ${AEVOL_REVISION_HASH}, ${AEVOL_REVISION_DATE}")
endif()
if(NOT "${AEVOL_BINARY_DIR}" STREQUAL "")
configure_file(${AEVOL_BINARY_DIR}/src/libaevol/aevol_version.cpp.in
${AEVOL_BINARY_DIR}/src/libaevol/aevol_version.cpp)
endif()
......@@ -49,6 +49,7 @@ const char* DEFAULT_PARAM_FILE_NAME = "param.in";
#include "ExpManager.h"
#include "ParamLoader.h"
#include "aevol_version.h"
using namespace aevol;
......@@ -69,6 +70,9 @@ static IOJson* my_iojson = nullptr;
int main(int argc, char* argv[]) {
interpret_cmd_line_options(argc, argv);
// Print the hash and date of the commit used to compile this executable
printf("Running aevol version %s\n", version_string);
if(param_file_name != nullptr) {
// Create a param loader for the parameter file
my_param_loader = new ParamLoader(param_file_name);
......
......@@ -58,6 +58,8 @@
#include "ExpManager_7.h"
#include "macros.h"
#include "aevol_version.h"
using namespace aevol;
#ifndef __NO_X
......@@ -101,8 +103,12 @@ int main(int argc, char* argv[]) {
printf("aevol is being run in DEBUG mode\n");
#endif
interpret_cmd_line_options(argc, argv);
// Print the hash and date of the commit used to compile this executable
printf("Running aevol version %s\n", version_string);
// =================================================================
// Load the simulation
// =================================================================
......
......@@ -14,6 +14,8 @@ set(aevol_sources
aevol.h
macros.h
aevol_version.h
biochemistry/ae_string.cpp
biochemistry/ae_string.h
biochemistry/Alignment.cpp
......@@ -202,11 +204,31 @@ if ( ${with-raevol} )
raevol/Protein_R.h
raevol/Protein_R.cpp
raevol/Rna_R.h
raevol/Rna_R.cpp
raevol/Rna_R.cpp
#"SIMD_Abstract Metadata.cpp" "SIMD_Abstract Metadata.h" SIMD_Map_Metadata.cpp SIMD_Map_Metadata.h
raevol/SIMD_PhenotypicTargetHandler_R.cpp raevol/SIMD_PhenotypicTargetHandler_R.h)
endif ()
# ============================================================================
# Generate version file aevol_version.cpp
# ============================================================================
configure_file(aevol_version.cpp.in ${CMAKE_BINARY_DIR}/src/libaevol/aevol_version.cpp.in @ONLY)
# configure further at build time (always built as run_always.txt is never actually created)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/src/libaevol/aevol_version.cpp run_always.txt
COMMAND ${CMAKE_COMMAND}
-DAEVOL_DIR=${PROJECT_SOURCE_DIR}
-DAEVOL_SOURCE_DIR=${CMAKE_SOURCE_DIR}
-DAEVOL_BINARY_DIR=${CMAKE_BINARY_DIR}
-P ${CMAKE_SOURCE_DIR}/CMakeScripts/aevol_version.cmake
COMMENT "Generating aevol_version.cpp"
)
list(APPEND aevol_sources
${CMAKE_BINARY_DIR}/src/libaevol/aevol_version.cpp)
add_library(aevol ${aevol_sources})
# ============================================================================
......
namespace aevol {
char const *version_string = "@PROJECT_VERSION@" " " "(${AEVOL_REVISION})";
}
\ No newline at end of file
namespace aevol {
extern char const *version_string;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment