fix(Build/Deps): Increase minimal Boost versions and remove old compatibilities (#20287)

* fix(Core/Common): remove conditions for unsupported boost versions

* fix Cmake version requiert acording to wiki
This commit is contained in:
Grimdhex 2024-11-11 20:54:32 +01:00 committed by GitHub
parent 9dbb8781b5
commit 156f634637
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 4 additions and 77 deletions

View File

@ -26,9 +26,9 @@ include (CheckCXXSourceCompiles)
if (WIN32) if (WIN32)
# On windows the requirements are higher according to the wiki. # On windows the requirements are higher according to the wiki.
set(BOOST_REQUIRED_VERSION 1.74) set(BOOST_REQUIRED_VERSION 1.78)
else() else()
set(BOOST_REQUIRED_VERSION 1.67) set(BOOST_REQUIRED_VERSION 1.74)
endif() endif()
find_package(Boost ${BOOST_REQUIRED_VERSION} REQUIRED system filesystem program_options iostreams regex) find_package(Boost ${BOOST_REQUIRED_VERSION} REQUIRED system filesystem program_options iostreams regex)

View File

@ -20,15 +20,7 @@
#include <boost/asio/deadline_timer.hpp> #include <boost/asio/deadline_timer.hpp>
#if BOOST_VERSION >= 107000 #define DeadlineTimerBase boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::io_context::executor_type>
#define BasicDeadlineTimerThirdTemplateArg , boost::asio::io_context::executor_type
#elif BOOST_VERSION >= 106600
#define BasicDeadlineTimerThirdTemplateArg
#else
#define BasicDeadlineTimerThirdTemplateArg , boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>>
#endif
#define DeadlineTimerBase boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> BasicDeadlineTimerThirdTemplateArg>
namespace Acore::Asio namespace Acore::Asio
{ {

View File

@ -20,16 +20,10 @@
#include <boost/version.hpp> #include <boost/version.hpp>
#if BOOST_VERSION >= 106600
#include <boost/asio/io_context.hpp> #include <boost/asio/io_context.hpp>
#include <boost/asio/post.hpp> #include <boost/asio/post.hpp>
#define IoContextBaseNamespace boost::asio #define IoContextBaseNamespace boost::asio
#define IoContextBase io_context #define IoContextBase io_context
#else
#include <boost/asio/io_service.hpp>
#define IoContextBaseNamespace boost::asio
#define IoContextBase io_service
#endif
namespace Acore::Asio namespace Acore::Asio
{ {
@ -45,9 +39,7 @@ namespace Acore::Asio
std::size_t run() { return _impl.run(); } std::size_t run() { return _impl.run(); }
void stop() { _impl.stop(); } void stop() { _impl.stop(); }
#if BOOST_VERSION >= 106600
boost::asio::io_context::executor_type get_executor() noexcept { return _impl.get_executor(); } boost::asio::io_context::executor_type get_executor() noexcept { return _impl.get_executor(); }
#endif
private: private:
IoContextBaseNamespace::IoContextBase _impl; IoContextBaseNamespace::IoContextBase _impl;
@ -56,21 +48,13 @@ namespace Acore::Asio
template<typename T> template<typename T>
inline decltype(auto) post(IoContextBaseNamespace::IoContextBase& ioContext, T&& t) inline decltype(auto) post(IoContextBaseNamespace::IoContextBase& ioContext, T&& t)
{ {
#if BOOST_VERSION >= 106600
return boost::asio::post(ioContext, std::forward<T>(t)); return boost::asio::post(ioContext, std::forward<T>(t));
#else
return ioContext.post(std::forward<T>(t));
#endif
} }
template<typename T> template<typename T>
inline decltype(auto) get_io_context(T&& ioObject) inline decltype(auto) get_io_context(T&& ioObject)
{ {
#if BOOST_VERSION >= 106600
return ioObject.get_executor().context(); return ioObject.get_executor().context();
#else
return ioObject.get_io_service();
#endif
} }
} }

View File

@ -23,21 +23,9 @@
namespace Acore::Net namespace Acore::Net
{ {
#if BOOST_VERSION >= 106600
using boost::asio::ip::make_address; using boost::asio::ip::make_address;
using boost::asio::ip::make_address_v4; using boost::asio::ip::make_address_v4;
inline uint32 address_to_uint(boost::asio::ip::address_v4 const& address) { return address.to_uint(); } inline uint32 address_to_uint(boost::asio::ip::address_v4 const& address) { return address.to_uint(); }
#else
inline boost::asio::ip::address make_address(char const* str) { return boost::asio::ip::address::from_string(str); }
inline boost::asio::ip::address make_address(char const* str, boost::system::error_code& ec) { return boost::asio::ip::address::from_string(str, ec); }
inline boost::asio::ip::address make_address(std::string const& str) { return boost::asio::ip::address::from_string(str); }
inline boost::asio::ip::address make_address(std::string const& str, boost::system::error_code& ec) { return boost::asio::ip::address::from_string(str, ec); }
inline boost::asio::ip::address_v4 make_address_v4(char const* str) { return boost::asio::ip::address_v4::from_string(str); }
inline boost::asio::ip::address_v4 make_address_v4(char const* str, boost::system::error_code& ec) { return boost::asio::ip::address_v4::from_string(str, ec); }
inline boost::asio::ip::address_v4 make_address_v4(std::string const& str) { return boost::asio::ip::address_v4::from_string(str); }
inline boost::asio::ip::address_v4 make_address_v4(std::string const& str, boost::system::error_code& ec) { return boost::asio::ip::address_v4::from_string(str, ec); }
inline uint32 address_to_uint(boost::asio::ip::address_v4 const& address) { return address.to_ulong(); }
#endif
} }
#endif // IpAddress_h__ #endif // IpAddress_h__

View File

@ -20,24 +20,16 @@
#include "Define.h" #include "Define.h"
#include "IpAddress.h" #include "IpAddress.h"
#include <boost/version.hpp>
#if BOOST_VERSION >= 106600
#include <boost/asio/ip/network_v4.hpp> #include <boost/asio/ip/network_v4.hpp>
#include <boost/asio/ip/network_v6.hpp> #include <boost/asio/ip/network_v6.hpp>
#endif
namespace Acore::Net namespace Acore::Net
{ {
inline bool IsInNetwork(boost::asio::ip::address_v4 const& networkAddress, boost::asio::ip::address_v4 const& mask, boost::asio::ip::address_v4 const& clientAddress) inline bool IsInNetwork(boost::asio::ip::address_v4 const& networkAddress, boost::asio::ip::address_v4 const& mask, boost::asio::ip::address_v4 const& clientAddress)
{ {
#if BOOST_VERSION >= 106600
boost::asio::ip::network_v4 network = boost::asio::ip::make_network_v4(networkAddress, mask); boost::asio::ip::network_v4 network = boost::asio::ip::make_network_v4(networkAddress, mask);
boost::asio::ip::address_v4_range hosts = network.hosts(); boost::asio::ip::address_v4_range hosts = network.hosts();
return hosts.find(clientAddress) != hosts.end(); return hosts.find(clientAddress) != hosts.end();
#else
return (clientAddress.to_ulong() & mask.to_ulong()) == (networkAddress.to_ulong() & mask.to_ulong());
#endif
} }
inline boost::asio::ip::address_v4 GetDefaultNetmaskV4(boost::asio::ip::address_v4 const& networkAddress) inline boost::asio::ip::address_v4 GetDefaultNetmaskV4(boost::asio::ip::address_v4 const& networkAddress)
@ -59,16 +51,9 @@ namespace Acore::Net
inline bool IsInNetwork(boost::asio::ip::address_v6 const& networkAddress, uint16 prefixLength, boost::asio::ip::address_v6 const& clientAddress) inline bool IsInNetwork(boost::asio::ip::address_v6 const& networkAddress, uint16 prefixLength, boost::asio::ip::address_v6 const& clientAddress)
{ {
#if BOOST_VERSION >= 106600
boost::asio::ip::network_v6 network = boost::asio::ip::make_network_v6(networkAddress, prefixLength); boost::asio::ip::network_v6 network = boost::asio::ip::make_network_v6(networkAddress, prefixLength);
boost::asio::ip::address_v6_range hosts = network.hosts(); boost::asio::ip::address_v6_range hosts = network.hosts();
return hosts.find(clientAddress) != hosts.end(); return hosts.find(clientAddress) != hosts.end();
#else
(void)networkAddress;
(void)prefixLength;
(void)clientAddress;
return false;
#endif
} }
} }

View File

@ -35,23 +35,12 @@ namespace Acore::Asio
Optional<boost::asio::ip::tcp::endpoint> Resolve(boost::asio::ip::tcp const& protocol, std::string const& host, std::string const& service) Optional<boost::asio::ip::tcp::endpoint> Resolve(boost::asio::ip::tcp const& protocol, std::string const& host, std::string const& service)
{ {
boost::system::error_code ec; boost::system::error_code ec;
#if BOOST_VERSION >= 106600
boost::asio::ip::resolver_base::flags flagsResolver = boost::asio::ip::resolver_base::all_matching; boost::asio::ip::resolver_base::flags flagsResolver = boost::asio::ip::resolver_base::all_matching;
boost::asio::ip::tcp::resolver::results_type results = _impl.resolve(protocol, host, service, flagsResolver, ec); boost::asio::ip::tcp::resolver::results_type results = _impl.resolve(protocol, host, service, flagsResolver, ec);
if (results.begin() == results.end() || ec) if (results.begin() == results.end() || ec)
return {}; return {};
return results.begin()->endpoint(); return results.begin()->endpoint();
#else
boost::asio::ip::resolver_query_base::flags flagsQuery = boost::asio::ip::tcp::resolver::query::all_matching;
boost::asio::ip::tcp::resolver::query query(std::move(protocol), std::move(host), std::move(service), flagsQuery);
boost::asio::ip::tcp::resolver::iterator itr = _impl.resolve(query, ec);
boost::asio::ip::tcp::resolver::iterator end;
if (itr == end || ec)
return {};
return itr->endpoint();
#endif
} }
private: private:

View File

@ -19,11 +19,8 @@
#define Strand_h__ #define Strand_h__
#include "IoContext.h" #include "IoContext.h"
#include <boost/asio/strand.hpp>
#if BOOST_VERSION >= 106600
#include <boost/asio/bind_executor.hpp> #include <boost/asio/bind_executor.hpp>
#endif #include <boost/asio/strand.hpp>
namespace Acore::Asio namespace Acore::Asio
{ {
@ -36,15 +33,7 @@ namespace Acore::Asio
Strand(IoContext& ioContext) : IoContextBaseNamespace::IoContextBase::strand(ioContext) { } Strand(IoContext& ioContext) : IoContextBaseNamespace::IoContextBase::strand(ioContext) { }
}; };
#if BOOST_VERSION >= 106600
using boost::asio::bind_executor; using boost::asio::bind_executor;
#else
template<typename T>
inline decltype(auto) bind_executor(Strand& strand, T&& t)
{
return strand.wrap(std::forward<T>(t));
}
#endif
} }
#endif // Strand_h__ #endif // Strand_h__