Skip to content

Commit 38a15d3

Browse files
committed
fix issue #834: enable minitrace
1 parent bcceae7 commit 38a15d3

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ endif()
8080

8181
add_subdirectory(3rdparty/lexy)
8282

83+
add_library(minitrace STATIC 3rdparty/minitrace/minitrace.cpp)
84+
target_compile_definitions(minitrace PRIVATE MTR_ENABLED=True)
85+
set_property(TARGET minitrace PROPERTY POSITION_INDEPENDENT_CODE ON)
86+
8387
list(APPEND BT_SOURCE
8488
src/action_node.cpp
8589
src/basic_types.cpp
@@ -124,7 +128,6 @@ list(APPEND BT_SOURCE
124128
src/loggers/bt_observer.cpp
125129

126130
3rdparty/tinyxml2/tinyxml2.cpp
127-
3rdparty/minitrace/minitrace.cpp
128131
)
129132

130133

@@ -163,6 +166,7 @@ target_link_libraries(${BTCPP_LIBRARY}
163166
Threads::Threads
164167
${CMAKE_DL_LIBS}
165168
$<BUILD_INTERFACE:foonathan::lexy>
169+
minitrace
166170
PUBLIC
167171
${BTCPP_EXTRA_LIBRARIES}
168172
)

examples/t11_groot_howto.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "behaviortree_cpp/loggers/groot2_publisher.h"
55
#include "behaviortree_cpp/xml_parsing.h"
66
#include "behaviortree_cpp/json_export.h"
7+
#include "behaviortree_cpp/loggers/bt_minitrace_logger.h"
78

89
/** We are using the same example in Tutorial 5,
910
* But this time we also show how to connect
@@ -120,6 +121,7 @@ int main()
120121

121122
// Logging with lightweight serialization
122123
BT::FileLogger2 logger2(tree, "t12_logger2.btlog");
124+
BT::MinitraceLogger minilog(tree, "minitrace.json");
123125

124126
while(1)
125127
{

include/behaviortree_cpp/loggers/bt_minitrace_logger.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#ifndef BT_MINITRACE_LOGGER_H
2-
#define BT_MINITRACE_LOGGER_H
1+
#pragma once
32

4-
#include <cstring>
53
#include "behaviortree_cpp/loggers/abstract_logger.h"
64

75
namespace BT
@@ -23,5 +21,3 @@ class MinitraceLogger : public StatusChangeLogger
2321
};
2422

2523
} // namespace BT
26-
27-
#endif // BT_MINITRACE_LOGGER_H

src/loggers/bt_minitrace_logger.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ void MinitraceLogger::callback(Duration /*timestamp*/, const TreeNode& node,
6060
{
6161
MTR_END(category, name);
6262
}
63+
mtr_flush();
6364
}
6465

6566
void MinitraceLogger::flush()

0 commit comments

Comments
 (0)