diff --git a/recipes-ros/mavros/libmavconn/0001-compile-also-with-boost-1.66.0.patch b/recipes-ros/mavros/libmavconn/0001-compile-also-with-boost-1.66.0.patch new file mode 100644 index 0000000..92133c0 --- /dev/null +++ b/recipes-ros/mavros/libmavconn/0001-compile-also-with-boost-1.66.0.patch @@ -0,0 +1,107 @@ +From 74e82fa924055edb84ed90d49b9bd45b078df5c4 Mon Sep 17 00:00:00 2001 +From: Lukas Bulwahn +Date: Sat, 17 Feb 2018 17:55:16 +0100 +Subject: [PATCH] compile also with boost >= 1.66.0 + +In boost 1.66.0, which includes boost-asio 1.12.0, the asio +interfaces have been changed to follow the "C++ Extensions for +Networking" Technical Specification [1]. As a consequence, +resolvers now produce ranges rather than iterators. + +In boost < 1.66.0, resolver.resolve returns an iterator that must +be passed to `std::for_each`. As this iterator in boost < 1.66.0 +does not provide begin() and end() member functions, it cannot be +simply turned into a proper range. +For boost >= 1.66.0, resolver.resolve returns a range, which +can be just iterated through with `for (auto v : _)` syntax. + +As it is not possible to have one way to iterate through the result +independent of the boost version, a preprocessing directive selects +the proper synactic iteration construction depending on the provided +boost-asio library version [2]. + +This way, this commit is backwards compatible with boost < 1.66.0 +and compiles properly with boost >= 1.66.0. + +The issue was identified in a build with the cross-compilation tool +chain provided in the meta-ros OpenEmbedded layer [3]. + +[1] http://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/net_ts.html +[2] https://github.com/boostorg/asio/commit/0c9cbdfbf217146c096265b5eb56089e8cebe608 +[3] http://github.com/bmwcarit/meta-ros + +Signed-off-by: Lukas Bulwahn + +Upstream-Status: Accepted [https://github.com/mavlink/mavros/commit/74e82fa92405] + +Signed-off-by: Lukas Bulwahn +--- + libmavconn/src/tcp.cpp | 20 +++++++++++++------- + libmavconn/src/udp.cpp | 20 +++++++++++++------- + 2 files changed, 26 insertions(+), 14 deletions(-) + +diff --git a/libmavconn/src/tcp.cpp b/libmavconn/src/tcp.cpp +index adec9fc..655f11c 100644 +--- a/libmavconn/src/tcp.cpp ++++ b/libmavconn/src/tcp.cpp +@@ -41,13 +41,19 @@ static bool resolve_address_tcp(io_service &io, size_t chan, std::string host, u + error_code ec; + + tcp::resolver::query query(host, ""); +- std::for_each(resolver.resolve(query, ec), tcp::resolver::iterator(), +- [&](const tcp::endpoint & q_ep) { +- ep = q_ep; +- ep.port(port); +- result = true; +- logDebug(PFXd "host %s resolved as %s", chan, host.c_str(), to_string_ss(ep).c_str()); +- }); ++ ++ auto fn = [&](const tcp::endpoint & q_ep) { ++ ep = q_ep; ++ ep.port(port); ++ result = true; ++ logDebug(PFXd "host %s resolved as %s", chan, host.c_str(), to_string_ss(ep).c_str()); ++ }; ++ ++#if BOOST_ASIO_VERSION >= 101200 ++ for (auto q_ep : resolver.resolve(query, ec)) fn(q_ep); ++#else ++ std::for_each(resolver.resolve(query, ec), tcp::resolver::iterator(), fn); ++#endif + + if (ec) { + logWarn(PFXd "resolve error: %s", chan, ec.message().c_str()); +diff --git a/libmavconn/src/udp.cpp b/libmavconn/src/udp.cpp +index d01b551..be0df47 100644 +--- a/libmavconn/src/udp.cpp ++++ b/libmavconn/src/udp.cpp +@@ -41,13 +41,19 @@ static bool resolve_address_udp(io_service &io, size_t chan, std::string host, u + error_code ec; + + udp::resolver::query query(host, ""); +- std::for_each(resolver.resolve(query, ec), udp::resolver::iterator(), +- [&](const udp::endpoint & q_ep) { +- ep = q_ep; +- ep.port(port); +- result = true; +- logDebug(PFXd "host %s resolved as %s", chan, host.c_str(), to_string_ss(ep).c_str()); +- }); ++ ++ auto fn = [&](const udp::endpoint & q_ep) { ++ ep = q_ep; ++ ep.port(port); ++ result = true; ++ logDebug(PFXd "host %s resolved as %s", chan, host.c_str(), to_string_ss(ep).c_str()); ++ }; ++ ++#if BOOST_ASIO_VERSION >= 101200 ++ for (auto q_ep : resolver.resolve(query, ec)) fn(q_ep); ++#else ++ std::for_each(resolver.resolve(query, ec), udp::resolver::iterator(), fn); ++#endif + + if (ec) { + logWarn(PFXd "resolve error: %s", chan, ec.message().c_str()); +-- +2.7.4 + diff --git a/recipes-ros/mavros/libmavconn_0.18.7.bb b/recipes-ros/mavros/libmavconn_0.18.7.bb index dfb5659..8e7cb2c 100644 --- a/recipes-ros/mavros/libmavconn_0.18.7.bb +++ b/recipes-ros/mavros/libmavconn_0.18.7.bb @@ -17,3 +17,5 @@ RDEPENDS_${PN} = " \ require mavros.inc ROS_PKG_SUBDIR = "libmavconn" + +SRC_URI += "file://0001-compile-also-with-boost-1.66.0.patch;striplevel=2" diff --git a/recipes-ros/ros-canopen/socketcan-interface/0001-compile-also-with-boost-1.66.0.patch b/recipes-ros/ros-canopen/socketcan-interface/0001-compile-also-with-boost-1.66.0.patch new file mode 100644 index 0000000..b2a82d4 --- /dev/null +++ b/recipes-ros/ros-canopen/socketcan-interface/0001-compile-also-with-boost-1.66.0.patch @@ -0,0 +1,45 @@ +From 89b29ca3a3c23ee07bb2df36b95ccfd60af98028 Mon Sep 17 00:00:00 2001 +From: Lukas Bulwahn +Date: Sat, 17 Feb 2018 20:15:12 +0100 +Subject: [PATCH] compile also with boost >= 1.66.0 + +In boost 1.66.0, which includes boost-asio 1.12.0, the asio +interfaces have been changed to follow the "C++ Extensions for +Networking" Technical Specification [1]. As a consequence, the type +boost::asio::strand has been moved to boost::asio::io_service::strand. + +A preprocessing directive ensures backwards compatibility using the +provided boost-asio version [2], and a comment to clarify the +minimum boost version that includes the boost-asio version. + +[1] http://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio/net_ts.html +[2] https://github.com/boostorg/asio/commit/0c9cbdfbf217146c096265b5eb56089e8cebe608 + +Signed-off-by: Lukas Bulwahn + +Upstream-Status: Accepted [https://github.com/ros-industrial/ros_canopen/commit/89b29ca3a3c23ee07bb2df36b95ccfd60af98028] + +Signed-off-by: Lukas Bulwahn +--- + socketcan_interface/include/socketcan_interface/asio_base.h | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/socketcan_interface/include/socketcan_interface/asio_base.h b/socketcan_interface/include/socketcan_interface/asio_base.h +index c54ff12..1a14480 100644 +--- a/socketcan_interface/include/socketcan_interface/asio_base.h ++++ b/socketcan_interface/include/socketcan_interface/asio_base.h +@@ -23,7 +23,11 @@ template class AsioDriver : public DriverInterface{ + + protected: + boost::asio::io_service io_service_; ++#if BOOST_ASIO_VERSION >= 101200 // Boost 1.66+ ++ boost::asio::io_context::strand strand_; ++#else + boost::asio::strand strand_; ++#endif + Socket socket_; + Frame input_; + +-- +2.7.4 + diff --git a/recipes-ros/ros-canopen/socketcan-interface_0.6.8.bb b/recipes-ros/ros-canopen/socketcan-interface_0.6.8.bb index cc8daad..0f080ca 100644 --- a/recipes-ros/ros-canopen/socketcan-interface_0.6.8.bb +++ b/recipes-ros/ros-canopen/socketcan-interface_0.6.8.bb @@ -9,3 +9,4 @@ require ros-canopen.inc SRC_URI += "file://0001-explicitly-include-iostream-to-compile-with-boost-1..patch;striplevel=2" SRC_URI += "file://0001-find-and-link-the-thread-library-properly.patch;striplevel=2" +SRC_URI += "file://0001-compile-also-with-boost-1.66.0.patch;striplevel=2"