Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
JPScore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JuPedSim
JPScore
Commits
78d84cb6
Commit
78d84cb6
authored
May 18, 2018
by
Mohcine Chraibi
Browse files
Options
Downloads
Patches
Plain Diff
add git logging to jpscore
parent
9fd03ad6
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!26
Develop
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+555
-508
555 additions, 508 deletions
CMakeLists.txt
IO/IniFileParser.cpp
+54
-7
54 additions, 7 deletions
IO/IniFileParser.cpp
Simulation.cpp
+2
-2
2 additions, 2 deletions
Simulation.cpp
general/ArgumentParser.cpp
+12
-7
12 additions, 7 deletions
general/ArgumentParser.cpp
with
623 additions
and
524 deletions
CMakeLists.txt
+
555
−
508
View file @
78d84cb6
...
@@ -27,7 +27,7 @@ set(JPSCORE_PATCH_VERSION 3)
...
@@ -27,7 +27,7 @@ set(JPSCORE_PATCH_VERSION 3)
set
(
JPSCORE_VERSION
set
(
JPSCORE_VERSION
${
JPSCORE_MAJOR_VERSION
}
.
${
JPSCORE_MINOR_VERSION
}
.
${
JPSCORE_PATCH_VERSION
}
)
${
JPSCORE_MAJOR_VERSION
}
.
${
JPSCORE_MINOR_VERSION
}
.
${
JPSCORE_PATCH_VERSION
}
)
message
(
STATUS
"JPSCORE_VERSION: "
${
JPSCORE_VERSION
}
)
message
(
STATUS
"JPSCORE_VERSION: "
${
JPSCORE_VERSION
}
)
add_definitions
(
"-DJPSCORE_VERSION=
\"
${
JPSCORE_VERSION
}
\"
"
)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
OR
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
OR
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"Clang"
)
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"Clang"
)
set
(
warnings
"-Wall -Wextra"
)
set
(
warnings
"-Wall -Wextra"
)
...
@@ -113,6 +113,7 @@ message(STATUS " CMake generator: " ${CMAKE_GENERATOR})
...
@@ -113,6 +113,7 @@ message(STATUS " CMake generator: " ${CMAKE_GENERATOR})
message
(
STATUS
" CMake build tool: "
${
CMAKE_BUILD_TOOL
}
)
message
(
STATUS
" CMake build tool: "
${
CMAKE_BUILD_TOOL
}
)
if
(
MSVC
)
if
(
MSVC
)
message
(
STATUS
" MSVC: "
${
MSVC_VERSION
}
)
message
(
STATUS
" MSVC: "
${
MSVC_VERSION
}
)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ZLIB_WINAPI)
endif
()
endif
()
if
(
CMAKE_GENERATOR MATCHES Xcode
)
if
(
CMAKE_GENERATOR MATCHES Xcode
)
message
(
STATUS
" Xcode: "
${
XCODE_VERSION
}
)
message
(
STATUS
" Xcode: "
${
XCODE_VERSION
}
)
...
@@ -127,6 +128,52 @@ message(STATUS "")
...
@@ -127,6 +128,52 @@ message(STATUS "")
# message( STATUS "EXECUTABLE_OUTPUT_PATH: " ${EXECUTABLE_OUTPUT_PATH} )
# message( STATUS "EXECUTABLE_OUTPUT_PATH: " ${EXECUTABLE_OUTPUT_PATH} )
# message( STATUS "CMAKE_VERBOSE_MAKEFILE: " ${CMAKE_VERBOSE_MAKEFILE} )
# message( STATUS "CMAKE_VERBOSE_MAKEFILE: " ${CMAKE_VERBOSE_MAKEFILE} )
find_package
(
Git REQUIRED
)
# no need for this msg. It comes from cmake.findgit()
find_program
(
GIT_SCM git DOC
"Git version control"
)
mark_as_advanced
(
GIT_SCM
)
find_file
(
GITDIR NAMES .git PATHS
${
CMAKE_SOURCE_DIR
}
NO_DEFAULT_PATH
)
if
(
GIT_SCM AND GITDIR
)
# the commit's SHA1, and whether the building workspace was dirty or not
# describe --match=NeVeRmAtCh --always --tags --abbrev=40 --dirty
execute_process
(
COMMAND
"
${
GIT_EXECUTABLE
}
"
--no-pager describe --tags --always --dirty
WORKING_DIRECTORY
"
${
CMAKE_SOURCE_DIR
}
"
OUTPUT_VARIABLE GIT_SHA1
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
# branch
execute_process
(
COMMAND
"
${
GIT_EXECUTABLE
}
"
rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY
"
${
CMAKE_SOURCE_DIR
}
"
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# the date of the commit
execute_process
(
COMMAND
"
${
GIT_EXECUTABLE
}
"
log -1 --format=%ad --date=local
WORKING_DIRECTORY
"
${
CMAKE_SOURCE_DIR
}
"
OUTPUT_VARIABLE GIT_DATE
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
# the subject of the commit
execute_process
(
COMMAND
"
${
GIT_EXECUTABLE
}
"
log -1 --format=%s
WORKING_DIRECTORY
"
${
CMAKE_SOURCE_DIR
}
"
OUTPUT_VARIABLE GIT_COMMIT_SUBJECT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_definitions
(
"-DGIT_COMMIT_HASH=
\"
${
GIT_SHA1
}
\"
"
)
add_definitions
(
"-DGIT_COMMIT_DATE=
\"
${
GIT_DATE
}
\"
"
)
add_definitions
(
"-DGIT_COMMIT_SUBJECT=
\"
${
GIT_COMMIT_SUBJECT
}
\"
"
)
add_definitions
(
"-DGIT_BRANCH=
\"
${
GIT_BRANCH
}
\"
"
)
else
()
message
(
STATUS
"Not in a git repo"
)
endif
()
# add a target to generate API documentation with Doxygen
# add a target to generate API documentation with Doxygen
find_package
(
Doxygen
)
find_package
(
Doxygen
)
if
(
DOXYGEN_FOUND
)
if
(
DOXYGEN_FOUND
)
...
...
This diff is collapsed.
Click to expand it.
IO/IniFileParser.cpp
+
54
−
7
View file @
78d84cb6
...
@@ -45,6 +45,41 @@
...
@@ -45,6 +45,41 @@
#include
"../routing/ai_router/AIRouter.h"
#include
"../routing/ai_router/AIRouter.h"
#include
"../routing/ff_router/ffRouter.h"
#include
"../routing/ff_router/ffRouter.h"
/* https://stackoverflow.com/questions/38530981/output-compiler-version-in-a-c-program#38531037 */
std
::
string
ver_string
(
int
a
,
int
b
,
int
c
)
{
std
::
ostringstream
ss
;
ss
<<
a
<<
'.'
<<
b
<<
'.'
<<
c
;
return
ss
.
str
();
}
//https://sourceforge.net/p/predef/wiki/Compilers/
std
::
string
true_cxx
=
#ifdef __clang__
"clang++"
;
#elif defined(__GNU__)
"g++"
;
#elif defined(__MINGW32__)
"MinGW"
;
#elif defined(_MSC_VER)
"Visual Studio"
;
#else
"Compiler not identified"
;
#endif
std
::
string
true_cxx_ver
=
#ifdef __clang__
ver_string
(
__clang_major__
,
__clang_minor__
,
__clang_patchlevel__
);
#elif defined(__GNU__)
ver_string
(
__GNUC__
,
__GNUC_MINOR__
,
__GNUC_PATCHLEVEL__
);
#elif defined(__MINGW32__)
ver_string
(
__MINGW32__
,
__MINGW32_MAJOR_VERSION
,
__MINGW32_MINOR_VERSION
);
#elif defined( _MSC_VER)
ver_string
(
_MSC_VER
,
_MSC_FULL_VER
,
_MSC_BUILD
);
#else
""
;
#endif
IniFileParser
::
IniFileParser
(
Configuration
*
config
)
IniFileParser
::
IniFileParser
(
Configuration
*
config
)
{
{
_config
=
config
;
_config
=
config
;
...
@@ -97,6 +132,25 @@ bool IniFileParser::Parse(std::string iniFile)
...
@@ -97,6 +132,25 @@ bool IniFileParser::Parse(std::string iniFile)
Log
->
Write
(
"ERROR:
\t
Wrong header version. Only version greater than %s is supported."
,
JPS_OLD_VERSION
);
Log
->
Write
(
"ERROR:
\t
Wrong header version. Only version greater than %s is supported."
,
JPS_OLD_VERSION
);
return
false
;
return
false
;
}
}
//logfile
if
(
xMainNode
->
FirstChild
(
"logfile"
))
{
_config
->
SetErrorLogFile
(
_config
->
GetProjectRootDir
()
+
xMainNode
->
FirstChild
(
"logfile"
)
->
FirstChild
()
->
Value
());
_config
->
SetLog
(
2
);
Log
->
Write
(
"INFO:
\t
logfile <%s>"
,
_config
->
GetErrorLogFile
().
c_str
());
}
Log
->
Write
(
"----
\n
JuPedSim - JPScore
\n
"
);
Log
->
Write
(
"Current date : %s %s"
,
__DATE__
,
__TIME__
);
Log
->
Write
(
"Version : %s"
,
JPSCORE_VERSION
);
Log
->
Write
(
"Compiler : %s (%s)"
,
true_cxx
.
c_str
(),
true_cxx_ver
.
c_str
());
Log
->
Write
(
"Commit hash : %s"
,
GIT_COMMIT_HASH
);
Log
->
Write
(
"Commit date : %s"
,
GIT_COMMIT_DATE
);
Log
->
Write
(
"Branch : %s
\n
----
\n
"
,
GIT_BRANCH
);
//seed
//seed
if
(
xMainNode
->
FirstChild
(
"seed"
))
{
if
(
xMainNode
->
FirstChild
(
"seed"
))
{
TiXmlNode
*
seedNode
=
xMainNode
->
FirstChild
(
"seed"
)
->
FirstChild
();
TiXmlNode
*
seedNode
=
xMainNode
->
FirstChild
(
"seed"
)
->
FirstChild
();
...
@@ -149,13 +203,6 @@ bool IniFileParser::Parse(std::string iniFile)
...
@@ -149,13 +203,6 @@ bool IniFileParser::Parse(std::string iniFile)
_config
->
SetMaxOpenMPThreads
(
omp_get_max_threads
());
_config
->
SetMaxOpenMPThreads
(
omp_get_max_threads
());
Log
->
Write
(
"INFO:
\t
Using num_threads <%d> threads (%d available)"
,
_config
->
GetMaxOpenMPThreads
(),
max_threads
);
Log
->
Write
(
"INFO:
\t
Using num_threads <%d> threads (%d available)"
,
_config
->
GetMaxOpenMPThreads
(),
max_threads
);
//logfile
if
(
xMainNode
->
FirstChild
(
"logfile"
))
{
_config
->
SetErrorLogFile
(
_config
->
GetProjectRootDir
()
+
xMainNode
->
FirstChild
(
"logfile"
)
->
FirstChild
()
->
Value
());
_config
->
SetLog
(
2
);
Log
->
Write
(
"INFO:
\t
logfile <%s>"
,
_config
->
GetErrorLogFile
().
c_str
());
}
//display statistics
//display statistics
if
(
xMainNode
->
FirstChild
(
"show_statistics"
))
{
if
(
xMainNode
->
FirstChild
(
"show_statistics"
))
{
std
::
string
value
=
xMainNode
->
FirstChild
(
"show_statistics"
)
->
FirstChild
()
->
Value
();
std
::
string
value
=
xMainNode
->
FirstChild
(
"show_statistics"
)
->
FirstChild
()
->
Value
();
...
...
This diff is collapsed.
Click to expand it.
Simulation.cpp
+
2
−
2
View file @
78d84cb6
...
@@ -95,7 +95,7 @@ bool Simulation::InitArgs()
...
@@ -95,7 +95,7 @@ bool Simulation::InitArgs()
}
}
case
2
:
{
case
2
:
{
char
name
[
CLENGTH
]
=
""
;
char
name
[
CLENGTH
]
=
""
;
sprintf
(
name
,
"%s.
P0.da
t"
,
_config
->
GetErrorLogFile
().
c_str
());
sprintf
(
name
,
"%s.
tx
t"
,
_config
->
GetErrorLogFile
().
c_str
());
if
(
Log
)
if
(
Log
)
delete
Log
;
delete
Log
;
Log
=
new
FileHandler
(
name
);
Log
=
new
FileHandler
(
name
);
...
@@ -346,7 +346,7 @@ void Simulation::UpdateRoutesAndLocations()
...
@@ -346,7 +346,7 @@ void Simulation::UpdateRoutesAndLocations()
//exit(EXIT_FAILURE);
//exit(EXIT_FAILURE);
#pragma omp critical(Simulation_Update_pedsToRemove)
#pragma omp critical(Simulation_Update_pedsToRemove)
{
{
pedsToRemove
.
push_back
(
ped
);
pedsToRemove
.
insert
(
ped
);
Log
->
incrementDeletedAgents
();
Log
->
incrementDeletedAgents
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
general/ArgumentParser.cpp
+
12
−
7
View file @
78d84cb6
...
@@ -49,14 +49,15 @@
...
@@ -49,14 +49,15 @@
using
namespace
std
;
using
namespace
std
;
void
ArgumentParser
::
Usage
(
const
std
::
string
file
)
void
ArgumentParser
::
Usage
(
const
std
::
string
file
)
{
{
fprintf
(
stderr
,
"
\n\n
You are actually using JuPedsim version %s
\n\n
"
,
JPS_VERSION
);
fprintf
(
stderr
,
"Usages:
\n
"
);
fprintf
(
stderr
,
"Usages:
\n
"
);
fprintf
(
stderr
,
" %s <path to file> start the simulation with the specified file.
\n
"
,
file
.
c_str
());
fprintf
(
stderr
,
" %s <path to file> start the simulation with the specified file.
\n
"
,
file
.
c_str
());
fprintf
(
stderr
,
" %s search and use the file ini.xml in the current directory.
\n
"
,
fprintf
(
stderr
,
" %s search and use the file ini.xml in the current directory.
\n
"
,
file
.
c_str
());
file
.
c_str
());
fprintf
(
stderr
,
" %s -v/--version display the current version.
\n
"
,
file
.
c_str
());
fprintf
(
stderr
,
" %s -h/--help display this text.
\n
"
,
file
.
c_str
());
fprintf
(
stderr
,
" %s -h/--help display this text.
\n
"
,
file
.
c_str
());
#ifdef _JPS_AS_A_SERVICE
#ifdef _JPS_AS_A_SERVICE
fprintf
(
stderr
,
" %s --as-a-service -p <port nr> runs jps as a service at port <port nr>.
\n
"
,
file
.
c_str
());
fprintf
(
stderr
,
" %s --as-a-service -p <port nr> runs jps as a service at port <port nr>.
\n
"
,
file
.
c_str
());
...
@@ -77,6 +78,15 @@ bool ArgumentParser::ParseArgs(int argc, char** argv)
...
@@ -77,6 +78,15 @@ bool ArgumentParser::ParseArgs(int argc, char** argv)
if
(
argc
==
1
)
{
if
(
argc
==
1
)
{
Log
->
Write
(
Log
->
Write
(
"INFO:
\t
Trying to load the default configuration from the file <ini.xml>"
);
"INFO:
\t
Trying to load the default configuration from the file <ini.xml>"
);
// first logs will go to stdout
Log
->
Write
(
"----
\n
JuPedSim - JPScore
\n
"
);
Log
->
Write
(
"Current date : %s %s"
,
__DATE__
,
__TIME__
);
Log
->
Write
(
"Version : %s"
,
JPSCORE_VERSION
);
// Log->Write("Compiler : %s (%s)", true_cxx.c_str(), true_cxx_ver.c_str());
Log
->
Write
(
"Commit hash : %s"
,
GIT_COMMIT_HASH
);
Log
->
Write
(
"Commit date : %s"
,
GIT_COMMIT_DATE
);
Log
->
Write
(
"Branch : %s
\n
----
\n
"
,
GIT_BRANCH
);
IniFileParser
*
p
=
new
IniFileParser
(
_config
);
IniFileParser
*
p
=
new
IniFileParser
(
_config
);
if
(
!
p
->
Parse
(
"ini.xml"
))
{
if
(
!
p
->
Parse
(
"ini.xml"
))
{
Usage
(
argv
[
0
]);
Usage
(
argv
[
0
]);
...
@@ -90,10 +100,6 @@ bool ArgumentParser::ParseArgs(int argc, char** argv)
...
@@ -90,10 +100,6 @@ bool ArgumentParser::ParseArgs(int argc, char** argv)
Usage
(
argv
[
0
]);
Usage
(
argv
[
0
]);
return
false
;
return
false
;
}
}
else
if
(
argument
==
"-v"
||
argument
==
"--version"
)
{
fprintf
(
stderr
,
"You are actually using JuPedsim/jpscore version %s
\n\n
"
,
JPS_VERSION
);
return
false
;
}
// other special case where a single configuration file is submitted
// other special case where a single configuration file is submitted
//check if inifile options are given
//check if inifile options are given
...
@@ -161,4 +167,3 @@ bool ArgumentParser::ParseArgs(int argc, char** argv)
...
@@ -161,4 +167,3 @@ bool ArgumentParser::ParseArgs(int argc, char** argv)
Usage
(
argv
[
0
]);
Usage
(
argv
[
0
]);
return
false
;
return
false
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment