-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* drogon: add recipe * fix LANGUAGE * add boost * fix boost component check failed * drop gcc5 support * force use boost * link stdc++fs on gcc/8.x * try to fix trantor link error * force C++17 when MSVC > 1900 * link rpcrt4 on shared and static * move deleting code for orm to configure()
- Loading branch information
Showing
9 changed files
with
272 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(conan_wrapper CXX) | ||
|
||
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") | ||
conan_basic_setup(KEEP_RPATHS) | ||
|
||
add_subdirectory("source_subfolder") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sources: | ||
"1.7.5": | ||
url: "https://github.com/drogonframework/drogon/archive/refs/tags/v1.7.5.tar.gz" | ||
sha256: "e2af7c55dcabafef16f26f5b3242692f5a2b54c19b7b626840bf9132d24766f6" | ||
patches: | ||
"1.7.5": | ||
- base_path: "source_subfolder" | ||
patch_file: "patches/1.7.5-0001-disable_trantor.patch" | ||
- base_path: "source_subfolder" | ||
patch_file: "patches/1.7.5-0002-remove-boost-components.patch" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
from conans import ConanFile, CMake, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
import os | ||
import functools | ||
|
||
required_conan_version = ">=1.43.0" | ||
|
||
class DrogonConan(ConanFile): | ||
name = "drogon" | ||
description = "A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows" | ||
topics = ("http-server", "non-blocking-io", "http-framework", "asynchronous-programming") | ||
license = "MIT" | ||
homepage = "https://github.com/drogonframework/drogon" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "cmake", "cmake_find_package_multi" | ||
options = { | ||
"shared": [False, True], | ||
"fPIC": [True, False], | ||
"with_ctl": [True, False], | ||
"with_orm": [True, False], | ||
"with_profile": [True, False], | ||
"with_brotli": [True, False], | ||
"with_postgres": [True, False], | ||
"with_postgres_batch": [True, False], | ||
"with_mysql": [True, False], | ||
"with_sqlite": [True, False], | ||
"with_redis": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"with_ctl": False, | ||
"with_orm": True, | ||
"with_profile": False, | ||
"with_brotli": False, | ||
"with_postgres": False, | ||
"with_postgres_batch": False, | ||
"with_mysql": False, | ||
"with_sqlite": False, | ||
"with_redis": False, | ||
} | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def export_sources(self): | ||
self.copy("CMakeLists.txt") | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
self.copy(patch["patch_file"]) | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
del self.options.fPIC | ||
self.options["trantor"].shared = True | ||
if not self.options.with_orm: | ||
del self.options.with_postgres | ||
del self.options.with_postgres_batch | ||
del self.options.with_mysql | ||
del self.options.with_sqlite | ||
del self.options.with_redis | ||
elif not self.options.with_postgres: | ||
del self.options.with_postgres_batch | ||
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"gcc": "6", | ||
"Visual Studio": "15.0", | ||
"clang": "5", | ||
"apple-clang": "10", | ||
} | ||
|
||
def validate(self): | ||
if self.settings.compiler.get_safe("cppstd"): | ||
tools.check_min_cppstd(self, "14") | ||
|
||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) | ||
if minimum_version: | ||
if tools.Version(self.settings.compiler.version) < minimum_version: | ||
raise ConanInvalidConfiguration("{} requires C++14, which your compiler does not support.".format(self.name)) | ||
else: | ||
self.output.warn("{} requires C++14. Your compiler is unknown. Assuming it supports C++14.".format(self.name)) | ||
|
||
def requirements(self): | ||
self.requires("trantor/1.5.5") | ||
self.requires("boost/1.79.0") | ||
self.requires("jsoncpp/1.9.5") | ||
self.requires("openssl/1.1.1o") | ||
self.requires("zlib/1.2.12") | ||
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_brotli: | ||
self.requires("brotli/1.0.9") | ||
if self.options.get_safe("with_postgres"): | ||
self.requires("libpq/14.2") | ||
if self.options.get_safe("with_mysql"): | ||
self.requires("libmysqlclient/8.0.25") | ||
if self.options.get_safe("with_sqlite"): | ||
self.requires("sqlite3/3.38.5") | ||
if self.options.get_safe("with_redis"): | ||
self.requires("hiredis/1.0.2") | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True) | ||
|
||
@functools.lru_cache(1) | ||
def _configure_cmake(self): | ||
cmake = CMake(self) | ||
cmake.definitions["BUILD_CTL"] = self.options.with_ctl | ||
cmake.definitions["BUILD_EXAMPLES"] = False | ||
cmake.definitions["BUILD_ORM"] = self.options.with_orm | ||
cmake.definitions["COZ_PROFILING"] = self.options.with_profile | ||
cmake.definitions["BUILD_DROGON_SHARED"] = self.options.shared | ||
cmake.definitions["BUILD_DOC"] = False | ||
cmake.definitions["BUILD_BROTLI"] = self.options.with_brotli | ||
cmake.definitions["BUILD_POSTGRESQL"] = self.options.get_safe("with_postgres", False) | ||
cmake.definitions["BUILD_POSTGRESQL_BATCH"] = self.options.get_safe("with_postgres_batch", False) | ||
cmake.definitions["BUILD_MYSQL"] = self.options.get_safe("with_mysql", False) | ||
cmake.definitions["BUILD_SQLITE"] = self.options.get_safe("with_sqlite", False) | ||
cmake.definitions["BUILD_REDIS"] = self.options.get_safe("with_redis", False) | ||
cmake.configure() | ||
return cmake | ||
|
||
def build(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
self.copy("LICENSE", "licenses", self._source_subfolder) | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["drogon"] | ||
if self.settings.os == "Windows": | ||
self.cpp_info.system_libs.extend(["rpcrt4", "ws2_32", "crypt32", "advapi32"]) | ||
if self.settings.compiler == "gcc" and tools.Version(self.settings.compiler.version).major == "8": | ||
self.cpp_info.system_libs.append("stdc++fs") | ||
|
||
if self.options.with_ctl: | ||
bin_path = os.path.join(self.package_folder, "bin") | ||
self.output.info("Appending PATH environment variable: {}".format(bin_path)) | ||
self.env_info.PATH.append(bin_path) | ||
|
||
self.cpp_info.set_property("cmake_file_name", "Drogon") | ||
self.cpp_info.set_property("cmake_target_name", "Drogon::Drogon") | ||
|
||
self.cpp_info.filenames["cmake_find_package"] = "Drogon" | ||
self.cpp_info.filenames["cmake_find_package_multi"] = "Drogon" | ||
self.cpp_info.names["cmake_find_package"] = "Drogon" | ||
self.cpp_info.names["cmake_find_package_multi"] = "Drogon" |
29 changes: 29 additions & 0 deletions
29
recipes/drogon/all/patches/1.7.5-0001-disable_trantor.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 146d2b8..f83e119 100755 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -52,7 +52,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") | ||
endif () | ||
|
||
if (BUILD_DROGON_SHARED) | ||
- set(BUILD_TRANTOR_SHARED TRUE) | ||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) | ||
find_package(Threads) | ||
# set(BUILD_EXAMPLES FALSE) | ||
@@ -110,7 +109,6 @@ target_include_directories( | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/orm_lib/inc> | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/nosql_lib/redis/inc> | ||
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}> | ||
- $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/trantor> | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/exports> | ||
$<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}>) | ||
|
||
@@ -120,8 +118,6 @@ if (WIN32) | ||
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/mman-win32>) | ||
endif (WIN32) | ||
|
||
-add_subdirectory(trantor) | ||
- | ||
target_link_libraries(${PROJECT_NAME} PUBLIC trantor) | ||
|
||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Haiku") |
14 changes: 14 additions & 0 deletions
14
recipes/drogon/all/patches/1.7.5-0002-remove-boost-components.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index f83e119..46a23fd 100755 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -177,7 +177,8 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Android") | ||
endif () | ||
|
||
if(NEED_BOOST_FS) | ||
- find_package(Boost 1.49.0 COMPONENTS filesystem system REQUIRED) | ||
+ # TODO: component specified find_package is always failed. Need to fix it. | ||
+ find_package(Boost 1.49.0 REQUIRED) | ||
message(STATUS "Using Boost filesytem::path") | ||
message(STATUS "Boost include dir: " ${Boost_INCLUDE_DIR}) | ||
include_directories(${BOOST_INCLUDE_DIRS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(Drogon CONFIG REQUIRED) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} Drogon::Drogon) | ||
|
||
# drogon uses string_view when MSVC_VERSION is greater than 1900. | ||
# https://github.com/drogonframework/drogon/blob/v1.7.5/lib/inc/drogon/utils/string_view.h#L16 | ||
if(DEFINED MSVC_VERSION AND MSVC_VERSION GREATER 1900) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) | ||
else() | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
|
||
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): | ||
self.run(os.path.join("bin", "test_package"), run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "drogon/drogon.h" | ||
|
||
int main() { | ||
trantor::Logger::setLogLevel(trantor::Logger::kTrace); | ||
|
||
auto client = drogon::HttpClient::newHttpClient("http://www.example.com"); | ||
auto req = drogon::HttpRequest::newHttpRequest(); | ||
req->setMethod(drogon::Get); | ||
req->setPath("/s"); | ||
req->setParameter("wd", "wx"); | ||
req->setParameter("oq", "wx"); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"1.7.5": | ||
folder: "all" |