Skip to content

Commit

Permalink
(conan-io#16872) drogon: add version 1.8.4, update dependencies
Browse files Browse the repository at this point in the history
* drogon: add version 1.8.4, update dependencies

* update openssl

* update openssl, sqlite3

* make trantor transitive_libs

* Added jsoncpp transitive_libs=True param

* Added package_type and with_yaml_cpp option (optional requirement)

* support C++14 build on msvc

* make boost transitive_headers=True

* add /Zc:__cplusplus on MSVC

* add /EHsc flag for msvc

---------

Co-authored-by: Francisco Ramirez de Anton <[email protected]>
Co-authored-by: Uilian Ries <[email protected]>
Co-authored-by: Rubén Rincón Blanco <[email protected]>
  • Loading branch information
4 people authored Jul 3, 2023
1 parent b92ff4e commit bd635eb
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 21 deletions.
25 changes: 22 additions & 3 deletions recipes/drogon/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"1.8.4":
url: "https://github.com/drogonframework/drogon/archive/v1.8.4.tar.gz"
sha256: "6f2f59ead0f0c37b0aac4bc889cbaedf3c2540f3020e892596c72f0a4d887a18"
"1.8.3":
url: "https://github.com/drogonframework/drogon/archive/v1.8.3.tar.gz"
sha256: "db6d92a0c40ec52d5704fb4128860b9eecdc284653e8d85113b4219b96dc7129"
Expand All @@ -12,6 +15,19 @@ sources:
url: "https://github.com/drogonframework/drogon/archive/refs/tags/v1.7.5.tar.gz"
sha256: "e2af7c55dcabafef16f26f5b3242692f5a2b54c19b7b626840bf9132d24766f6"
patches:
"1.8.4":
- patch_file: "patches/1.8.4-0001-remove-shared-libs.patch"
patch_description: "remove shared libs option"
patch_type: "conan"
- patch_file: "patches/1.8.4-0002-find-package-jsoncpp.patch"
patch_description: "Fix jsoncpp cmake target name"
patch_type: "conan"
- patch_file: "patches/1.8.4-0003-find-package-sqlite.patch"
patch_description: "Fix sqlite cmake target name"
patch_type: "conan"
- patch_file: "patches/1.8.4-0004-find-package-yaml-cpp.patch"
patch_description: "Fix yaml-cpp cmake target name"
patch_type: "conan"
"1.8.3":
- patch_file: "patches/1.8.0-0001-disable-unused-data.patch"
patch_description: "Consume Trantor package from Conan instead of using the\
Expand All @@ -23,7 +39,6 @@ patches:
- patch_file: "patches/1.8.3-0003-find-package-sqlite.patch"
patch_description: "Fix sqlite cmake target name"
patch_type: "conan"

"1.8.2":
- patch_file: "patches/1.8.0-0001-disable-unused-data.patch"
patch_description: "Consume Trantor package from Conan instead of using the\
Expand All @@ -35,7 +50,6 @@ patches:
- patch_file: "patches/1.8.2-0003-find-package-sqlite.patch"
patch_description: "Fix sqlite cmake target name"
patch_type: "conan"

"1.8.0":
- patch_file: "patches/1.8.0-0001-disable-unused-data.patch"
patch_description: "Consume Trantor package from Conan instead of using the subproject"
Expand All @@ -46,7 +60,9 @@ patches:
- patch_file: "patches/1.8.0-0003-find-package-sqlite.patch"
patch_description: "Fix sqlite cmake target name"
patch_type: "conan"

- patch_file: "patches/1.8.0-0004-remove-msvc-check.patch"
patch_description: "remove msvc check for C++17 support"
patch_type: "portability"
"1.7.5":
- patch_file: "patches/1.7.5-0001-disable_trantor.patch"
patch_description: "Consume Trantor package from Conan instead of using the subproject"
Expand All @@ -60,3 +76,6 @@ patches:
- patch_file: "patches/1.7.5-0004-find-package-jsoncpp.patch"
patch_description: "Fix jsoncpp cmake target name"
patch_type: "conan"
- patch_file: "patches/1.7.5-0005-remove-msvc-check.patch"
patch_description: "remove msvc check for C++17 support"
patch_type: "portability"
51 changes: 33 additions & 18 deletions recipes/drogon/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import os

from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import cmake_layout, CMakeToolchain, CMakeDeps, CMake
from conan.tools.files import copy, get, apply_conandata_patches, export_conandata_patches, rmdir
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
import os
from conan.tools.microsoft import is_msvc

required_conan_version = ">=1.53.0"


class DrogonConan(ConanFile):
name = "drogon"
description = "A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows"
Expand All @@ -24,6 +27,7 @@ class DrogonConan(ConanFile):
"with_orm": [True, False],
"with_profile": [True, False],
"with_brotli": [True, False],
"with_yaml_cpp": [True, False],
"with_postgres": [True, False],
"with_postgres_batch": [True, False],
"with_mysql": [True, False],
Expand All @@ -38,12 +42,14 @@ class DrogonConan(ConanFile):
"with_orm": True,
"with_profile": False,
"with_brotli": False,
"with_yaml_cpp": False,
"with_postgres": False,
"with_postgres_batch": False,
"with_mysql": False,
"with_sqlite": False,
"with_redis": False,
}
package_type = "library"

def export_sources(self):
export_conandata_patches(self)
Expand Down Expand Up @@ -71,58 +77,62 @@ def _min_cppstd(self):

@property
def _compilers_minimum_version(self):
if Version(self.version) < "1.8.2":
return {
return {
"14": {
"Visual Studio": "15",
"msvc": "191",
"gcc": "6",
"clang": "5",
"apple-clang": "10",
}
else:
return {
},
"17": {
"Visual Studio": "16",
"msvc": "192",
"gcc": "8",
"clang": "7",
"apple-clang": "12",
}
}.get(str(self._min_cppstd), {})

def validate(self):
if self.info.settings.compiler.cppstd:
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)

minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False)
if minimum_version:
if Version(self.info.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.")
else:
self.output.warn(f"{self.ref} requires C++{self._min_cppstd}. Your compiler is unknown. Assuming it supports C++{self._min_cppstd}.")

if self.settings.compiler.get_safe("cppstd") == "14" and not self.options.with_boost:
raise ConanInvalidConfiguration(f"{self.ref} requires boost on C++14")

def requirements(self):
self.requires("trantor/1.5.8")
self.requires("jsoncpp/1.9.5")
self.requires("openssl/1.1.1s")
self.requires("trantor/1.5.11", transitive_headers=True, transitive_libs=True)
self.requires("jsoncpp/1.9.5", transitive_headers=True, transitive_libs=True)
self.requires("openssl/[>=1.1 <4]")
self.requires("zlib/1.2.13")
if self.settings.os == "Linux":
self.requires("libuuid/1.0.3")
if self.options.with_profile:
self.requires("coz/cci.20210322")
if self.options.with_boost:
self.requires("boost/1.81.0")
self.requires("boost/1.82.0", transitive_headers=True)
if self.options.with_brotli:
self.requires("brotli/1.0.9")
if self.options.get_safe("with_postgres"):
self.requires("libpq/14.5")
self.requires("libpq/14.7")
if self.options.get_safe("with_mysql"):
self.requires("libmysqlclient/8.0.30")
self.requires("libmysqlclient/8.0.31")
if self.options.get_safe("with_sqlite"):
self.requires("sqlite3/3.40.0")
self.requires("sqlite3/3.42.0")
if self.options.get_safe("with_redis"):
self.requires("hiredis/1.1.0")
if self.options.with_yaml_cpp:
self.requires("yaml-cpp/0.7.0")

def source(self):
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def layout(self):
cmake_layout(self, src_folder="src")
Expand All @@ -136,11 +146,16 @@ def generate(self):
tc.variables["BUILD_DROGON_SHARED"] = self.options.shared
tc.variables["BUILD_DOC"] = False
tc.variables["BUILD_BROTLI"] = self.options.with_brotli
tc.variables["BUILD_YAML_CONFIG"] = self.options.with_yaml_cpp
tc.variables["BUILD_POSTGRESQL"] = self.options.get_safe("with_postgres", False)
tc.variables["BUILD_POSTGRESQL_BATCH"] = self.options.get_safe("with_postgres_batch", False)
tc.variables["BUILD_MYSQL"] = self.options.get_safe("with_mysql", False)
tc.variables["BUILD_SQLITE"] = self.options.get_safe("with_sqlite", False)
tc.variables["BUILD_REDIS"] = self.options.get_safe("with_redis", False)
if is_msvc(self):
tc.variables["CMAKE_CXX_FLAGS"] = "/Zc:__cplusplus /EHsc"
if Version(self.version) >= "1.8.4":
tc.variables["USE_SUBMODULE"] = False
tc.generate()
tc = CMakeDeps(self)
tc.generate()
Expand Down
92 changes: 92 additions & 0 deletions recipes/drogon/all/patches/1.7.5-0005-remove-msvc-check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
diff --git a/lib/inc/drogon/utils/any.h b/lib/inc/drogon/utils/any.h
index 63abd2e..8ac74d8 100644
--- a/lib/inc/drogon/utils/any.h
+++ b/lib/inc/drogon/utils/any.h
@@ -13,7 +13,7 @@
*/

#pragma once
-#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
+#if __cplusplus >= 201703L
#include <any>
#else
#include <boost/any.hpp>
@@ -21,7 +21,7 @@

namespace drogon
{
-#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
+#if __cplusplus >= 201703L
using std::any;
using std::any_cast;
#else
diff --git a/lib/inc/drogon/utils/optional.h b/lib/inc/drogon/utils/optional.h
index 2dde172..297a819 100644
--- a/lib/inc/drogon/utils/optional.h
+++ b/lib/inc/drogon/utils/optional.h
@@ -13,7 +13,7 @@
*/

#pragma once
-#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
+#if __cplusplus >= 201703L
#include <optional>
#else
#include <boost/optional.hpp>
@@ -21,9 +21,9 @@

namespace drogon
{
-#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
+#if __cplusplus >= 201703L
using std::optional;
#else
using boost::optional;
#endif
-} // namespace drogon
\ No newline at end of file
+} // namespace drogon
diff --git a/lib/inc/drogon/utils/string_view.h b/lib/inc/drogon/utils/string_view.h
index a2362b7..074d05f 100644
--- a/lib/inc/drogon/utils/string_view.h
+++ b/lib/inc/drogon/utils/string_view.h
@@ -13,7 +13,7 @@
*/

#pragma once
-#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
+#if __cplusplus >= 201703L
#include <string_view>
#else
#include <stdint.h>
@@ -25,7 +25,7 @@

namespace drogon
{
-#if __cplusplus >= 201703L || (defined _MSC_VER && _MSC_VER > 1900)
+#if __cplusplus >= 201703L
using std::string_view;
#else
using boost::string_view;
@@ -40,10 +40,10 @@ inline LogStream &operator<<(LogStream &ls, const drogon::string_view &v)
}
} // namespace trantor

-#if __cplusplus < 201703L && !(defined _MSC_VER && _MSC_VER > 1900)
+#if __cplusplus < 201703L
namespace drogon
{
-#ifndef _MSC_VER
+#if 1
template <size_t N>
struct StringViewHasher;

@@ -319,7 +319,7 @@ struct hash<drogon::string_view>
size_t operator()(const drogon::string_view &__str) const noexcept
{
// MSVC is having problems with non-aligned strings
-#ifndef _MSC_VER
+#if 1
return drogon::StringViewHasher<sizeof(size_t)>()(__str);
#else
return drogon::ShortStringViewHasher(__str);
Loading

0 comments on commit bd635eb

Please sign in to comment.