Skip to content

Commit 1203ab3

Browse files
committed
fix windows and mingw compilation (?)
1 parent e2c795d commit 1203ab3

File tree

10 files changed

+46
-33
lines changed

10 files changed

+46
-33
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ if(MSVC)
1212
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
1313
endif()
1414

15+
if( MINGW )
16+
add_definitions(-DBT_NO_COROUTINES)
17+
endif()
18+
1519
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1620

1721
set(CMAKE_CONFIG_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake")

examples/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ target_link_libraries(t07_wrap_legacy ${BEHAVIOR_TREE_LIBRARY} )
3535
add_executable(t08_additional_node_args t08_additional_node_args.cpp )
3636
target_link_libraries(t08_additional_node_args ${BEHAVIOR_TREE_LIBRARY} )
3737

38-
add_executable(t09_async_actions_coroutines t09_async_actions_coroutines.cpp )
39-
target_link_libraries(t09_async_actions_coroutines ${BEHAVIOR_TREE_LIBRARY} )
38+
if (NOT MINGW)
39+
add_executable(t09_async_actions_coroutines t09_async_actions_coroutines.cpp )
40+
target_link_libraries(t09_async_actions_coroutines ${BEHAVIOR_TREE_LIBRARY} )
41+
endif()
4042

4143
add_executable(t10_include_trees t10_include_trees.cpp )
4244
target_link_libraries(t10_include_trees ${BEHAVIOR_TREE_LIBRARY} dummy_nodes )

include/behaviortree_cpp/action_node.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ class AsyncActionNode : public ActionNodeBase
136136
std::thread thread_;
137137
};
138138

139+
#ifndef BT_NO_COROUTINES
140+
139141
/**
140142
* @brief The CoroActionNode class is an ideal candidate for asynchronous actions
141143
* which need to communicate with an external service using an asynch request/reply interface
@@ -174,9 +176,8 @@ class CoroActionNode : public ActionNodeBase
174176

175177
struct Pimpl; // The Pimpl idiom
176178
std::unique_ptr<Pimpl> _p;
177-
178179
};
179-
180+
#endif
180181

181182
} //end namespace
182183

include/behaviortree_cpp/control_node.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ class ControlNode : public TreeNode
3232
/// The method used to add nodes to the children vector
3333
void addChild(TreeNode* child);
3434

35-
unsigned childrenCount() const;
35+
size_t childrenCount() const;
3636

3737
const std::vector<TreeNode*>& children() const;
3838

39-
const TreeNode* child(unsigned index) const
39+
const TreeNode* child(size_t index) const
4040
{
4141
return children().at(index);
4242
}
4343

4444
virtual void halt() override;
4545

4646
/// call halt() for all the children in the range [i, childrenCount() )
47-
void haltChildren(unsigned i);
47+
void haltChildren(size_t i);
4848

4949
virtual NodeType type() const override final
5050
{

include/behaviortree_cpp/controls/fallback_node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class FallbackNode : public ControlNode
4040
virtual void halt() override;
4141

4242
private:
43-
unsigned int current_child_idx_;
43+
size_t current_child_idx_;
4444

4545
virtual BT::NodeStatus tick() override;
4646
};

include/behaviortree_cpp/controls/sequence_node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class SequenceNode : public ControlNode
4141
virtual void halt() override;
4242

4343
private:
44-
unsigned int current_child_idx_;
44+
size_t current_child_idx_;
4545

4646
virtual BT::NodeStatus tick() override;
4747
};

include/behaviortree_cpp/controls/sequence_star_node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class SequenceStarNode : public ControlNode
4343

4444
private:
4545

46-
unsigned int current_child_idx_;
46+
size_t current_child_idx_;
4747

4848
virtual BT::NodeStatus tick() override;
4949
};

src/action_node.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
*/
1313

1414
#include "behaviortree_cpp/action_node.h"
15-
#include "coroutine/coroutine.h"
1615

17-
namespace BT
18-
{
16+
using namespace BT;
17+
1918
ActionNodeBase::ActionNodeBase(const std::string& name, const NodeConfiguration& config)
2019
: LeafNode::LeafNode(name, config)
2120
{
@@ -146,7 +145,26 @@ void AsyncActionNode::stopAndJoinThread()
146145
}
147146
}
148147

148+
149+
SyncActionNode::SyncActionNode(const std::string &name, const NodeConfiguration& config):
150+
ActionNodeBase(name, config)
151+
{}
152+
153+
NodeStatus SyncActionNode::executeTick()
154+
{
155+
auto stat = ActionNodeBase::executeTick();
156+
if( stat == NodeStatus::RUNNING)
157+
{
158+
throw LogicError("SyncActionNode MUST never return RUNNING");
159+
}
160+
return stat;
161+
}
162+
163+
149164
//-------------------------------------
165+
#ifndef BT_NO_COROUTINES
166+
#include "coroutine/coroutine.h"
167+
150168
struct CoroActionNode::Pimpl
151169
{
152170
coroutine::routine_t coro;
@@ -212,21 +230,6 @@ void CoroActionNode::halt()
212230
{
213231
_p->pending_destroy = true;
214232
}
215-
216-
SyncActionNode::SyncActionNode(const std::string &name, const NodeConfiguration& config):
217-
ActionNodeBase(name, config)
218-
{}
219-
220-
NodeStatus SyncActionNode::executeTick()
221-
{
222-
auto stat = ActionNodeBase::executeTick();
223-
if( stat == NodeStatus::RUNNING)
224-
{
225-
throw LogicError("SyncActionNode MUST never return RUNNING");
226-
}
227-
return stat;
228-
}
229-
233+
#endif
230234

231235

232-
}

src/control_node.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ void ControlNode::addChild(TreeNode* child)
2525
children_nodes_.push_back(child);
2626
}
2727

28-
unsigned ControlNode::childrenCount() const
28+
size_t ControlNode::childrenCount() const
2929
{
30-
return unsigned(children_nodes_.size());
30+
return children_nodes_.size();
3131
}
3232

3333
void ControlNode::halt()
@@ -41,7 +41,7 @@ const std::vector<TreeNode*>& ControlNode::children() const
4141
return children_nodes_;
4242
}
4343

44-
void ControlNode::haltChildren(unsigned i)
44+
void ControlNode::haltChildren(size_t i)
4545
{
4646
for (size_t j = i; j < children_nodes_.size(); j++)
4747
{

tests/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ set(BT_TESTS
1313
gtest_factory.cpp
1414
gtest_decorator.cpp
1515
gtest_blackboard.cpp
16-
gtest_coroutines.cpp
1716
navigation_test.cpp
1817
gtest_subtree.cpp
1918
)
2019

20+
if (NOT MINGW)
21+
list(APPEND BT_TESTS gtest_coroutines.cpp)
22+
endif()
23+
2124
if(ament_cmake_FOUND AND BUILD_TESTING)
2225

2326
find_package(ament_cmake_gtest REQUIRED)

0 commit comments

Comments
 (0)