From dc908dd9fad195f60fda472b87622d8689c81420 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 18 Oct 2022 01:22:37 +0200 Subject: [PATCH 01/14] restbed: add restbed/4.8 recipe --- recipes/restbed/all/conandata.yml | 9 ++ recipes/restbed/all/conanfile.py | 101 ++++++++++++++++++ .../all/patches/4.8-0001-cmake-conan.patch | 71 ++++++++++++ .../restbed/all/test_package/CMakeLists.txt | 7 ++ recipes/restbed/all/test_package/conanfile.py | 30 ++++++ .../restbed/all/test_package/test_package.cpp | 38 +++++++ recipes/restbed/config.yml | 3 + 7 files changed, 259 insertions(+) create mode 100644 recipes/restbed/all/conandata.yml create mode 100644 recipes/restbed/all/conanfile.py create mode 100644 recipes/restbed/all/patches/4.8-0001-cmake-conan.patch create mode 100644 recipes/restbed/all/test_package/CMakeLists.txt create mode 100644 recipes/restbed/all/test_package/conanfile.py create mode 100644 recipes/restbed/all/test_package/test_package.cpp create mode 100644 recipes/restbed/config.yml diff --git a/recipes/restbed/all/conandata.yml b/recipes/restbed/all/conandata.yml new file mode 100644 index 0000000000000..7cd5670048e26 --- /dev/null +++ b/recipes/restbed/all/conandata.yml @@ -0,0 +1,9 @@ +sources: + "4.8": + url: "https://github.com/Corvusoft/restbed/archive/refs/tags/4.8.tar.gz" + sha256: "4801833f86a67b8a123c2c01203e259eb81157e1e9ef144a3b6395cb2d838a42" +patches: + "4.8": + - patch_file: "patches/4.8-0001-cmake-conan.patch" + patch_description: "Use CMake targets + separate static/shared" + patch_type: "conan" diff --git a/recipes/restbed/all/conanfile.py b/recipes/restbed/all/conanfile.py new file mode 100644 index 0000000000000..f81748e8721c1 --- /dev/null +++ b/recipes/restbed/all/conanfile.py @@ -0,0 +1,101 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm +import os +import textwrap + +required_conan_version = ">=1.52.0" + + +class RestbedConan(ConanFile): + name = "restbed" + homepage = "https://github.com/Corvusoft/restbed" + description = "Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications." + topics = ("restbed", "restful", "server", "client", "json", "http", "ssl", "tls") + url = "https://github.com/conan-io/conan-center-index" + license = "AGPL-3.0-or-later", "CPL" # Corvusoft Permissive License (CPL) + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "ssl": [True, False], + "ipc": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "ssl": True, + "ipc": False, + } + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + try: + del self.options.fPIC + except Exception: + pass + if self.settings.os in ("Windows", ): + del self.options.ipc + + def validate(self): + if self.settings.os in ("Windows", ) and not self.options.shared: + # The headers don't allow to avoid __declspec(dllimport)/__declsped(dllexport) + raise ConanInvalidConfiguration("Static libraries for Windows are not supported") + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("asio/1.24.0") + if self.options.ssl: + self.requires("openssl/3.0.5") + + def source(self): + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTS"] = False + tc.variables["BUILD_SSL"] = self.options.ssl + tc.variables["BUILD_IPC"] = self.options.get_safe("ipc", False) + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + + @property + def _libzmq_target(self): + return "libzmq" if self.options.shared else "libzmq-static" + + def package_info(self): + libname = "restbed" + if self.settings.os in ("Windows", ) and self.options.shared: + libname += "-shared" + self.cpp_info.libs = [libname] + + if self.settings.os in ("FreeBSD", "Linux", ): + self.cpp_info.system_libs.append("dl") diff --git a/recipes/restbed/all/patches/4.8-0001-cmake-conan.patch b/recipes/restbed/all/patches/4.8-0001-cmake-conan.patch new file mode 100644 index 0000000000000..b1cadf6559c77 --- /dev/null +++ b/recipes/restbed/all/patches/4.8-0001-cmake-conan.patch @@ -0,0 +1,71 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -19,7 +19,7 @@ message( " " ) + option( BUILD_TESTS "Build unit tests." ON ) + option( BUILD_SSL "Build secure socket layer support." ON ) + option( BUILD_IPC "Build unix domain socket layer support." OFF ) +- ++set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + # + # Configuration + # +@@ -57,7 +57,7 @@ find_package( asio REQUIRED ) + + if ( BUILD_SSL ) + add_definitions( "-DBUILD_SSL" ) +- find_package( openssl REQUIRED ) ++ find_package( OpenSSL REQUIRED ) + endif ( ) + + include_directories( ${INCLUDE_DIR} SYSTEM ${asio_INCLUDE} ${ssl_INCLUDE} ) +@@ -75,13 +75,14 @@ endif ( ) + # Build + # + file( GLOB_RECURSE MANIFEST "${SOURCE_DIR}/*.cpp" ) +- ++if(NOT BUILD_SHARED_LIBS) + set( STATIC_LIBRARY_NAME "${PROJECT_NAME}-static" ) + add_library( ${STATIC_LIBRARY_NAME} STATIC ${MANIFEST} ) + set_property( TARGET ${STATIC_LIBRARY_NAME} PROPERTY CXX_STANDARD 14 ) + set_property( TARGET ${STATIC_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON ) + set_target_properties( ${STATIC_LIBRARY_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME} ) +- ++target_link_libraries( ${STATIC_LIBRARY_NAME} LINK_PRIVATE asio::asio ) ++else() + set( SHARED_LIBRARY_NAME "${PROJECT_NAME}-shared" ) + add_library( ${SHARED_LIBRARY_NAME} SHARED ${MANIFEST} ) + set_property( TARGET ${SHARED_LIBRARY_NAME} PROPERTY CXX_STANDARD 14 ) +@@ -93,13 +94,20 @@ else ( ) + set_target_properties( ${SHARED_LIBRARY_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME} ) + endif ( ) + set_target_properties( ${SHARED_LIBRARY_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} ) +- ++target_link_libraries( ${SHARED_LIBRARY_NAME} LINK_PRIVATE asio::asio ) ++endif() + if ( BUILD_SSL ) +- target_link_libraries( ${SHARED_LIBRARY_NAME} LINK_PRIVATE ${ssl_LIBRARY_SHARED} ${crypto_LIBRARY_SHARED} ) +- target_link_libraries( ${STATIC_LIBRARY_NAME} LINK_PRIVATE ${ssl_LIBRARY_STATIC} ${crypto_LIBRARY_STATIC} ${CMAKE_DL_LIBS} ) ++if(BUILD_SHARED_LIBS) ++ target_link_libraries( ${SHARED_LIBRARY_NAME} LINK_PRIVATE OpenSSL::SSL ) ++else() ++ target_link_libraries( ${STATIC_LIBRARY_NAME} LINK_PRIVATE OpenSSL::SSL ${CMAKE_DL_LIBS} ) ++endif() + else ( ) ++if(BUILD_SHARED_LIBS) + target_link_libraries( ${SHARED_LIBRARY_NAME} ) ++else() + target_link_libraries( ${STATIC_LIBRARY_NAME} ${CMAKE_DL_LIBS} ) ++endif() + endif ( ) + + if ( BUILD_TESTS ) +@@ -119,5 +127,8 @@ file( GLOB ARTIFACTS "${SOURCE_DIR}/*.hpp" ) + + install( FILES "${INCLUDE_DIR}/${PROJECT_NAME}" DESTINATION "${CMAKE_INSTALL_PREFIX}/include" ) + install( FILES ${ARTIFACTS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/corvusoft/${PROJECT_NAME}" ) ++if(NOT BUILD_SHARED_LIBS) + install( TARGETS ${STATIC_LIBRARY_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library ) ++else() +-install( TARGETS ${SHARED_LIBRARY_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library ) ++install( TARGETS ${SHARED_LIBRARY_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT library ) ++endif() diff --git a/recipes/restbed/all/test_package/CMakeLists.txt b/recipes/restbed/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..edbc5b2ce0f6c --- /dev/null +++ b/recipes/restbed/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +find_package(restbed REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE restbed::restbed) diff --git a/recipes/restbed/all/test_package/conanfile.py b/recipes/restbed/all/test_package/conanfile.py new file mode 100644 index 0000000000000..f72d1f660e19f --- /dev/null +++ b/recipes/restbed/all/test_package/conanfile.py @@ -0,0 +1,30 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/restbed/all/test_package/test_package.cpp b/recipes/restbed/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..7fee18c959b38 --- /dev/null +++ b/recipes/restbed/all/test_package/test_package.cpp @@ -0,0 +1,38 @@ +#include + +#include +#include +#include + +static void post_method_handler( const std::shared_ptr< restbed::Session > session ) +{ + const auto request = session->get_request( ); + + int content_length = request->get_header( "Content-Length", 0 ); + + session->fetch( content_length, [ ]( const std::shared_ptr< restbed::Session > session, const restbed::Bytes & body ) + { + fprintf( stdout, "%.*s\n", ( int ) body.size( ), body.data( ) ); + session->close( restbed::OK, "Hello, World!", { { "Content-Length", "13" } } ); + } ); +} + +int main(void) +{ + auto resource = std::make_shared< restbed::Resource >( ); + resource->set_path( "/resource" ); + resource->set_method_handler( "POST", post_method_handler ); + + auto settings = std::make_shared< restbed::Settings >( ); + settings->set_port( 1984 ); + settings->set_default_header( "Connection", "close" ); + + restbed::Service service; + service.publish( resource ); +#if 0 + // Don't start the service to avoid blocking + service.start( settings ); +#endif + + return EXIT_SUCCESS; +} diff --git a/recipes/restbed/config.yml b/recipes/restbed/config.yml new file mode 100644 index 0000000000000..5a6e56bf2599d --- /dev/null +++ b/recipes/restbed/config.yml @@ -0,0 +1,3 @@ +versions: + "4.8": + folder: all From 74d5bc02e5c4ab1c31f360c0b52e70db364fb34f Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 18 Oct 2022 01:38:03 +0200 Subject: [PATCH 02/14] restbed: add old-school test package --- .../restbed/all/test_v1_package/CMakeLists.txt | 10 ++++++++++ .../restbed/all/test_v1_package/conanfile.py | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 recipes/restbed/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/restbed/all/test_v1_package/conanfile.py diff --git a/recipes/restbed/all/test_v1_package/CMakeLists.txt b/recipes/restbed/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..4c405aa3bfdca --- /dev/null +++ b/recipes/restbed/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package LANGUAGES CXX) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup(TARGETS) + +find_package(restbed REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE restbed::restbed) diff --git a/recipes/restbed/all/test_v1_package/conanfile.py b/recipes/restbed/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..38f4483872d47 --- /dev/null +++ b/recipes/restbed/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) From 7e2aac46a247d7cd91aa7e8c65cd6f914ae3527c Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 18 Oct 2022 16:45:43 +0200 Subject: [PATCH 03/14] restbed: allow static Windows build + address feedback --- recipes/restbed/all/conandata.yml | 3 ++ recipes/restbed/all/conanfile.py | 25 ++++++++-------- .../all/patches/4.8-0001-cmake-conan.patch | 29 ++++++++++++++----- .../4.8-0002-mingw-deprecated-fix.patch | 12 ++++++++ 4 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 recipes/restbed/all/patches/4.8-0002-mingw-deprecated-fix.patch diff --git a/recipes/restbed/all/conandata.yml b/recipes/restbed/all/conandata.yml index 7cd5670048e26..2439bdc25240d 100644 --- a/recipes/restbed/all/conandata.yml +++ b/recipes/restbed/all/conandata.yml @@ -7,3 +7,6 @@ patches: - patch_file: "patches/4.8-0001-cmake-conan.patch" patch_description: "Use CMake targets + separate static/shared" patch_type: "conan" + - patch_file: "patches/4.8-0002-mingw-deprecated-fix.patch" + patch_description: "MinGW apparently does not support deprecated and __declspec in the same line" + patch_type: "upstreamable" diff --git a/recipes/restbed/all/conanfile.py b/recipes/restbed/all/conanfile.py index f81748e8721c1..fc4161ec512d0 100644 --- a/recipes/restbed/all/conanfile.py +++ b/recipes/restbed/all/conanfile.py @@ -1,9 +1,8 @@ from conan import ConanFile -from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, load, rm, save import os -import textwrap +import re required_conan_version = ">=1.52.0" @@ -46,11 +45,6 @@ def configure(self): if self.settings.os in ("Windows", ): del self.options.ipc - def validate(self): - if self.settings.os in ("Windows", ) and not self.options.shared: - # The headers don't allow to avoid __declspec(dllimport)/__declsped(dllexport) - raise ConanInvalidConfiguration("Static libraries for Windows are not supported") - def layout(self): cmake_layout(self, src_folder="src") @@ -74,6 +68,15 @@ def generate(self): def _patch_sources(self): apply_conandata_patches(self) + if not self.options.shared: + # Remove __declspec(dllexport) and __declspec(dllimport) + for root, _, files in os.walk(self.source_folder): + for file in files: + if os.path.splitext(file)[1] in (".hpp", ".h"): + full_path = os.path.join(root, file) + data = load(self, full_path) + data, _ = re.subn(r"__declspec\((dllexport|dllimport)\)", "", data) + save(self, full_path, data) def build(self): self._patch_sources() @@ -87,10 +90,6 @@ def package(self): cmake.install() rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) - @property - def _libzmq_target(self): - return "libzmq" if self.options.shared else "libzmq-static" - def package_info(self): libname = "restbed" if self.settings.os in ("Windows", ) and self.options.shared: @@ -99,3 +98,5 @@ def package_info(self): if self.settings.os in ("FreeBSD", "Linux", ): self.cpp_info.system_libs.append("dl") + elif self.settings.os in ("Windows", ): + self.cpp_info.system_libs.append("mswsock") diff --git a/recipes/restbed/all/patches/4.8-0001-cmake-conan.patch b/recipes/restbed/all/patches/4.8-0001-cmake-conan.patch index b1cadf6559c77..e239976a0dfce 100644 --- a/recipes/restbed/all/patches/4.8-0001-cmake-conan.patch +++ b/recipes/restbed/all/patches/4.8-0001-cmake-conan.patch @@ -1,6 +1,6 @@ --- CMakeLists.txt +++ CMakeLists.txt -@@ -19,7 +19,7 @@ message( " " ) +@@ -19,7 +19,7 @@ option( BUILD_TESTS "Build unit tests." ON ) option( BUILD_SSL "Build secure socket layer support." ON ) option( BUILD_IPC "Build unix domain socket layer support." OFF ) @@ -18,7 +18,18 @@ endif ( ) include_directories( ${INCLUDE_DIR} SYSTEM ${asio_INCLUDE} ${ssl_INCLUDE} ) -@@ -75,13 +75,14 @@ endif ( ) +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -68,7 +68,7 @@ + + if ( WIN32 ) + add_definitions( -DWIN_DLL_EXPORT ) +- set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251" ) ++ #set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251" ) + endif ( ) + + # +@@ -75,13 +75,14 @@ # Build # file( GLOB_RECURSE MANIFEST "${SOURCE_DIR}/*.cpp" ) @@ -35,7 +46,7 @@ set( SHARED_LIBRARY_NAME "${PROJECT_NAME}-shared" ) add_library( ${SHARED_LIBRARY_NAME} SHARED ${MANIFEST} ) set_property( TARGET ${SHARED_LIBRARY_NAME} PROPERTY CXX_STANDARD 14 ) -@@ -93,13 +94,20 @@ else ( ) +@@ -93,13 +94,20 @@ set_target_properties( ${SHARED_LIBRARY_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME} ) endif ( ) set_target_properties( ${SHARED_LIBRARY_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} ) @@ -46,20 +57,22 @@ - target_link_libraries( ${SHARED_LIBRARY_NAME} LINK_PRIVATE ${ssl_LIBRARY_SHARED} ${crypto_LIBRARY_SHARED} ) - target_link_libraries( ${STATIC_LIBRARY_NAME} LINK_PRIVATE ${ssl_LIBRARY_STATIC} ${crypto_LIBRARY_STATIC} ${CMAKE_DL_LIBS} ) +if(BUILD_SHARED_LIBS) -+ target_link_libraries( ${SHARED_LIBRARY_NAME} LINK_PRIVATE OpenSSL::SSL ) ++ target_link_libraries( ${SHARED_LIBRARY_NAME} LINK_PRIVATE OpenSSL::SSL $<$:mswsock>) +else() -+ target_link_libraries( ${STATIC_LIBRARY_NAME} LINK_PRIVATE OpenSSL::SSL ${CMAKE_DL_LIBS} ) ++ target_link_libraries( ${STATIC_LIBRARY_NAME} LINK_PRIVATE OpenSSL::SSL ${CMAKE_DL_LIBS} $<$:mswsock>) +endif() else ( ) +if(BUILD_SHARED_LIBS) - target_link_libraries( ${SHARED_LIBRARY_NAME} ) +- target_link_libraries( ${SHARED_LIBRARY_NAME} ) ++ target_link_libraries( ${SHARED_LIBRARY_NAME} OpenSSL::SSL $<$:mswsock>) +else() - target_link_libraries( ${STATIC_LIBRARY_NAME} ${CMAKE_DL_LIBS} ) +- target_link_libraries( ${STATIC_LIBRARY_NAME} ${CMAKE_DL_LIBS} ) ++ target_link_libraries( ${STATIC_LIBRARY_NAME} ${CMAKE_DL_LIBS} OpenSSL::SSL $<$:mswsock>) +endif() endif ( ) if ( BUILD_TESTS ) -@@ -119,5 +127,8 @@ file( GLOB ARTIFACTS "${SOURCE_DIR}/*.hpp" ) +@@ -119,5 +127,8 @@ install( FILES "${INCLUDE_DIR}/${PROJECT_NAME}" DESTINATION "${CMAKE_INSTALL_PREFIX}/include" ) install( FILES ${ARTIFACTS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/corvusoft/${PROJECT_NAME}" ) diff --git a/recipes/restbed/all/patches/4.8-0002-mingw-deprecated-fix.patch b/recipes/restbed/all/patches/4.8-0002-mingw-deprecated-fix.patch new file mode 100644 index 0000000000000..98f35027afdd1 --- /dev/null +++ b/recipes/restbed/all/patches/4.8-0002-mingw-deprecated-fix.patch @@ -0,0 +1,12 @@ +--- source/corvusoft/restbed/http.hpp ++++ source/corvusoft/restbed/http.hpp +@@ -40,7 +40,7 @@ + class Response; + class Settings; +- +- class [[deprecated("HTTP client is deprecated; we will release a complimentary client framework at a future date.")]] HTTP_EXPORT Http ++ class HTTP_EXPORT Http; ++ class [[deprecated("HTTP client is deprecated; we will release a complimentary client framework at a future date.")]] Http + { + public: + //Friends From 61c8f8c07024de9f34520dfca4799b088a21813c Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 18 Oct 2022 20:48:11 +0200 Subject: [PATCH 04/14] restbed: require at least gcc 5 --- recipes/restbed/all/conanfile.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/recipes/restbed/all/conanfile.py b/recipes/restbed/all/conanfile.py index fc4161ec512d0..81848baee85ac 100644 --- a/recipes/restbed/all/conanfile.py +++ b/recipes/restbed/all/conanfile.py @@ -1,6 +1,8 @@ -from conan import ConanFile +from conan import ConanFile, Version +from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, load, rm, save +from conan.tools.build.cppstd import check_min_cppstd import os import re @@ -45,6 +47,14 @@ def configure(self): if self.settings.os in ("Windows", ): del self.options.ipc + def validate(self): + if getattr(self.info.settings.compiler, "cppstd"): + check_min_cppstd(self, 14) + if self.settings.compiler == "gcc": + if self.settings.compiler.version < Version(5): + raise ConanInvalidConfiguration("gcc 5+ is required for c++14 support") + + def layout(self): cmake_layout(self, src_folder="src") From b52a40b9e2d9c717079bc77a8326acbedc0c1105 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 18 Oct 2022 20:52:04 +0200 Subject: [PATCH 05/14] restbed: fix conan v2 warning --- recipes/restbed/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/restbed/all/conanfile.py b/recipes/restbed/all/conanfile.py index 81848baee85ac..e352496693dc5 100644 --- a/recipes/restbed/all/conanfile.py +++ b/recipes/restbed/all/conanfile.py @@ -2,7 +2,7 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, load, rm, save -from conan.tools.build.cppstd import check_min_cppstd +from conan.tools.build import check_min_cppstd import os import re From 77fc83eb58c963810f8e0a824d466cb6a95ae47a Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 18 Oct 2022 20:53:36 +0200 Subject: [PATCH 06/14] restbed: use self.info in validate --- recipes/restbed/all/conanfile.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/recipes/restbed/all/conanfile.py b/recipes/restbed/all/conanfile.py index e352496693dc5..65b655b0bc29a 100644 --- a/recipes/restbed/all/conanfile.py +++ b/recipes/restbed/all/conanfile.py @@ -50,11 +50,10 @@ def configure(self): def validate(self): if getattr(self.info.settings.compiler, "cppstd"): check_min_cppstd(self, 14) - if self.settings.compiler == "gcc": - if self.settings.compiler.version < Version(5): + if self.info.settings.compiler == "gcc": + if self.info.settings.compiler.version < Version(5): raise ConanInvalidConfiguration("gcc 5+ is required for c++14 support") - def layout(self): cmake_layout(self, src_folder="src") From 79383a0e0beba64aa9a75f72cbf0a73f7a1fcf6b Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 18 Oct 2022 21:53:02 +0200 Subject: [PATCH 07/14] restbed: set CMAKE_CXX_STANDARD if not already set --- recipes/restbed/all/test_package/CMakeLists.txt | 4 ++++ recipes/restbed/all/test_v1_package/CMakeLists.txt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/recipes/restbed/all/test_package/CMakeLists.txt b/recipes/restbed/all/test_package/CMakeLists.txt index edbc5b2ce0f6c..e82fe31166c40 100644 --- a/recipes/restbed/all/test_package/CMakeLists.txt +++ b/recipes/restbed/all/test_package/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.1) project(test_package LANGUAGES CXX) +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() + find_package(restbed REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) diff --git a/recipes/restbed/all/test_v1_package/CMakeLists.txt b/recipes/restbed/all/test_v1_package/CMakeLists.txt index 4c405aa3bfdca..416feeeb24201 100644 --- a/recipes/restbed/all/test_v1_package/CMakeLists.txt +++ b/recipes/restbed/all/test_v1_package/CMakeLists.txt @@ -4,6 +4,10 @@ project(test_package LANGUAGES CXX) include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup(TARGETS) +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() + find_package(restbed REQUIRED CONFIG) add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) From 6b17cd57d906a51898c9ea524509c5bcc0d78b4c Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 19 Oct 2022 11:24:28 +0200 Subject: [PATCH 08/14] Apply suggestions from code review --- recipes/restbed/all/conandata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/restbed/all/conandata.yml b/recipes/restbed/all/conandata.yml index 2439bdc25240d..6e0b42fcccc44 100644 --- a/recipes/restbed/all/conandata.yml +++ b/recipes/restbed/all/conandata.yml @@ -9,4 +9,4 @@ patches: patch_type: "conan" - patch_file: "patches/4.8-0002-mingw-deprecated-fix.patch" patch_description: "MinGW apparently does not support deprecated and __declspec in the same line" - patch_type: "upstreamable" + patch_type: "portability" From 549ababd4958d63822c86315f651c40dc383a02e Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 19 Oct 2022 12:27:24 +0200 Subject: [PATCH 09/14] Add 'm' tot system libraries --- recipes/restbed/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/restbed/all/conanfile.py b/recipes/restbed/all/conanfile.py index 65b655b0bc29a..149e882bc4264 100644 --- a/recipes/restbed/all/conanfile.py +++ b/recipes/restbed/all/conanfile.py @@ -106,6 +106,6 @@ def package_info(self): self.cpp_info.libs = [libname] if self.settings.os in ("FreeBSD", "Linux", ): - self.cpp_info.system_libs.append("dl") + self.cpp_info.system_libs.extend(["dl", "m"]) elif self.settings.os in ("Windows", ): self.cpp_info.system_libs.append("mswsock") From 24d56752ab05287952c9f426be7c53dcc4fd6556 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Wed, 19 Oct 2022 16:15:13 +0200 Subject: [PATCH 10/14] Update recipes/restbed/all/conanfile.py Co-authored-by: Uilian Ries --- recipes/restbed/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/restbed/all/conanfile.py b/recipes/restbed/all/conanfile.py index 149e882bc4264..1d56d30e3b34b 100644 --- a/recipes/restbed/all/conanfile.py +++ b/recipes/restbed/all/conanfile.py @@ -1,4 +1,5 @@ -from conan import ConanFile, Version +from conan import ConanFile +from conan.tools.scm import Version from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, load, rm, save From 12afe0dc85f5f7c297345218e8f05fed4eaedc54 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 20 Oct 2022 15:41:01 +0200 Subject: [PATCH 11/14] Address feedback --- recipes/restbed/all/conanfile.py | 8 ++++---- recipes/restbed/all/test_package/CMakeLists.txt | 7 ++----- recipes/restbed/all/test_package/test_package.cpp | 12 +++++++----- recipes/restbed/all/test_v1_package/CMakeLists.txt | 7 ++----- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/recipes/restbed/all/conanfile.py b/recipes/restbed/all/conanfile.py index 1d56d30e3b34b..cd985de94ad1c 100644 --- a/recipes/restbed/all/conanfile.py +++ b/recipes/restbed/all/conanfile.py @@ -22,14 +22,14 @@ class RestbedConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], - "ssl": [True, False], "ipc": [True, False], + "with_openssl": [True, False], } default_options = { "shared": False, "fPIC": True, - "ssl": True, "ipc": False, + "with_openssl": True, } def export_sources(self): @@ -60,7 +60,7 @@ def layout(self): def requirements(self): self.requires("asio/1.24.0") - if self.options.ssl: + if self.options.with_openssl: self.requires("openssl/3.0.5") def source(self): @@ -70,7 +70,7 @@ def source(self): def generate(self): tc = CMakeToolchain(self) tc.variables["BUILD_TESTS"] = False - tc.variables["BUILD_SSL"] = self.options.ssl + tc.variables["BUILD_SSL"] = self.options.with_openssl tc.variables["BUILD_IPC"] = self.options.get_safe("ipc", False) tc.generate() deps = CMakeDeps(self) diff --git a/recipes/restbed/all/test_package/CMakeLists.txt b/recipes/restbed/all/test_package/CMakeLists.txt index e82fe31166c40..3bad6b5f5053d 100644 --- a/recipes/restbed/all/test_package/CMakeLists.txt +++ b/recipes/restbed/all/test_package/CMakeLists.txt @@ -1,11 +1,8 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package LANGUAGES CXX) -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) -endif() - find_package(restbed REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} PRIVATE restbed::restbed) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/restbed/all/test_package/test_package.cpp b/recipes/restbed/all/test_package/test_package.cpp index 7fee18c959b38..d4731f4f97f74 100644 --- a/recipes/restbed/all/test_package/test_package.cpp +++ b/recipes/restbed/all/test_package/test_package.cpp @@ -3,6 +3,7 @@ #include #include #include +#include static void post_method_handler( const std::shared_ptr< restbed::Session > session ) { @@ -17,7 +18,7 @@ static void post_method_handler( const std::shared_ptr< restbed::Session > sessi } ); } -int main(void) +int main(int argc, char *argv[]) { auto resource = std::make_shared< restbed::Resource >( ); resource->set_path( "/resource" ); @@ -29,10 +30,11 @@ int main(void) restbed::Service service; service.publish( resource ); -#if 0 - // Don't start the service to avoid blocking - service.start( settings ); -#endif + + if (argc > 1 && strcmp(argv[1], "run") == 0) { + // Don't start the service to avoid blocking + service.start( settings ); + } return EXIT_SUCCESS; } diff --git a/recipes/restbed/all/test_v1_package/CMakeLists.txt b/recipes/restbed/all/test_v1_package/CMakeLists.txt index 416feeeb24201..87b1318ff1676 100644 --- a/recipes/restbed/all/test_v1_package/CMakeLists.txt +++ b/recipes/restbed/all/test_v1_package/CMakeLists.txt @@ -1,14 +1,11 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.8) project(test_package LANGUAGES CXX) include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup(TARGETS) -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) -endif() - find_package(restbed REQUIRED CONFIG) add_executable(${PROJECT_NAME} ../test_package/test_package.cpp) target_link_libraries(${PROJECT_NAME} PRIVATE restbed::restbed) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) From 57082bea17efac9b83879a6bdf89afd5285a77e4 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 20 Oct 2022 15:41:01 +0200 Subject: [PATCH 12/14] Address feedback --- recipes/restbed/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/restbed/all/conanfile.py b/recipes/restbed/all/conanfile.py index cd985de94ad1c..39c68465e4f79 100644 --- a/recipes/restbed/all/conanfile.py +++ b/recipes/restbed/all/conanfile.py @@ -14,7 +14,7 @@ class RestbedConan(ConanFile): name = "restbed" homepage = "https://github.com/Corvusoft/restbed" description = "Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications." - topics = ("restbed", "restful", "server", "client", "json", "http", "ssl", "tls") + topics = ("restful", "server", "client", "json", "http", "ssl", "tls") url = "https://github.com/conan-io/conan-center-index" license = "AGPL-3.0-or-later", "CPL" # Corvusoft Permissive License (CPL) From 8e47eb1070384e962b62211bd892f07f765e70bf Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 21 Oct 2022 15:57:17 +0200 Subject: [PATCH 13/14] restbed: expand minimum compiler conformance testing --- recipes/restbed/all/conanfile.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/recipes/restbed/all/conanfile.py b/recipes/restbed/all/conanfile.py index 39c68465e4f79..876950994bc0a 100644 --- a/recipes/restbed/all/conanfile.py +++ b/recipes/restbed/all/conanfile.py @@ -1,9 +1,10 @@ from conan import ConanFile -from conan.tools.scm import Version from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, load, rm, save -from conan.tools.build import check_min_cppstd +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os import re @@ -32,6 +33,18 @@ class RestbedConan(ConanFile): "with_openssl": True, } + @property + def _minimum_cpp_standard(self): + return 14 + + @property + def _compilers_minimum_version(self): + return { + "gcc": "5", + "clang": "7", + "apple-clang": "10", + } + def export_sources(self): export_conandata_patches(self) @@ -50,10 +63,13 @@ def configure(self): def validate(self): if getattr(self.info.settings.compiler, "cppstd"): - check_min_cppstd(self, 14) - if self.info.settings.compiler == "gcc": - if self.info.settings.compiler.version < Version(5): - raise ConanInvalidConfiguration("gcc 5+ is required for c++14 support") + check_min_cppstd(self, self._minimum_cpp_standard) + if not is_msvc(self): + minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False) + if minimum_version and Version(self.info.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._minimum_cpp_standard}, which your compiler does not support." + ) def layout(self): cmake_layout(self, src_folder="src") From c43a129deac171521d4b522ca213ffee429c282b Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 22 Oct 2022 11:40:55 +0200 Subject: [PATCH 14/14] Use LicenseRef- prefix for license file --- recipes/restbed/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/restbed/all/conanfile.py b/recipes/restbed/all/conanfile.py index 876950994bc0a..0a5e2d6cfc925 100644 --- a/recipes/restbed/all/conanfile.py +++ b/recipes/restbed/all/conanfile.py @@ -17,7 +17,7 @@ class RestbedConan(ConanFile): description = "Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications." topics = ("restful", "server", "client", "json", "http", "ssl", "tls") url = "https://github.com/conan-io/conan-center-index" - license = "AGPL-3.0-or-later", "CPL" # Corvusoft Permissive License (CPL) + license = "AGPL-3.0-or-later", "LicenseRef-CPL" # Corvusoft Permissive License (CPL) settings = "os", "arch", "compiler", "build_type" options = {