-
Notifications
You must be signed in to change notification settings - Fork 2k
Add reduct-cpp #27398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
victor1234
wants to merge
15
commits into
conan-io:master
Choose a base branch
from
victor1234:add-reduct-cpp-recipe
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add reduct-cpp #27398
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
623d352
feat(reduct-cpp): add recipe
victor1234 3ba4a33
fix(conanfile): fix attributes, requirements(), layout(), add require…
victor1234 bdfc6f4
feat(test_package): add test_package
victor1234 49d687a
fix(conanfile): add validate() with c++20 check
victor1234 0363d69
fix(conanfile): remove license
victor1234 0c10b27
fix(conanfile): add rmfiles in package()
victor1234 ff2bc3a
fix(conanfile): add license copy
victor1234 1eda515
fix(conanfile): add packages options check to validate()
victor1234 58b9f56
fix(coanfile): set cmake_file_name, target name in package_info()
victor1234 ab51967
fix(conanfile): add gcc version + with_chrono validation, remove conf…
victor1234 6ed9100
chore(conanfile): format
victor1234 63f6f5a
fix(coanfile): improve validate()
victor1234 095db0d
Changes
AbrilRBS b94c9ff
Typo
AbrilRBS 052bcf1
Add missing transitive headers and libs
AbrilRBS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,8 @@ | ||
sources: | ||
"1.15.0": | ||
url: "https://github.com/reductstore/reduct-cpp/archive/refs/tags/v1.15.0.tar.gz" | ||
sha256: "120caa687389b6a0f9d05b1d1b8670640e63aaeaf2463714427d7cd353220b86" | ||
patches: | ||
"1.15.0": | ||
- patch_file: "patches/0001-1.15.0-disable-conan-lookup.patch" | ||
patch_type: "conan" |
This file contains hidden or 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,121 @@ | ||
import os | ||
from os.path import join | ||
|
||
from conan import ConanFile | ||
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 copy, get, rmdir, export_conandata_patches, apply_conandata_patches | ||
|
||
required_conan_version = ">=2" | ||
|
||
|
||
class ReductCppConan(ConanFile): | ||
name = "reduct-cpp" | ||
description = "Reduct Storage Client SDK for C++" | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://www.reduct.store/docs/getting-started/with-cpp" | ||
topics = ("reduct-storage", "http-client", "http-api") | ||
package_type = "library" | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"with_chrono": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"with_chrono": False, | ||
} | ||
|
||
implements = ["auto_shared_fpic"] | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def requirements(self): | ||
self.requires("fmt/11.0.2", transitive_headers=True, transitive_libs=True) | ||
self.requires("cpp-httplib/0.14.1") | ||
self.requires("nlohmann_json/3.11.3") | ||
self.requires("openssl/[>=1.1 <4]", transitive_headers=True, transitive_libs=True) | ||
self.requires("concurrentqueue/1.0.4") | ||
if not self.options.with_chrono: | ||
self.requires("date/3.0.1") | ||
|
||
def validate(self): | ||
check_min_cppstd(self, 20) | ||
|
||
httplib = self.dependencies["cpp-httplib"] | ||
|
||
if not httplib.options.with_openssl: | ||
raise ConanInvalidConfiguration("cpp-httplib must be built with OpenSSL") | ||
|
||
if not httplib.options.with_zlib: | ||
raise ConanInvalidConfiguration("cpp-httplib must be built with zlib") | ||
|
||
if self.options.with_chrono: | ||
date = self.dependencies["date"] | ||
if not date.options.header_only: | ||
raise ConanInvalidConfiguration("date must be built as header-only") | ||
|
||
if self.settings.get_safe("os") == "Windows" and not self.options.with_chrono: | ||
raise ConanInvalidConfiguration("ReductCpp requires chrono on Windows.") | ||
|
||
elif self.settings.get_safe("compiler") == "gcc": | ||
if ( | ||
self.settings.get_safe("compiler.version") < "14" | ||
and self.options.with_chrono | ||
): | ||
raise ConanInvalidConfiguration( | ||
"ReductCpp with chrono requires GCC 14 or higher. " | ||
) | ||
elif ( | ||
self.settings.get_safe("compiler.version") >= "14" | ||
and not self.options.with_chrono | ||
): | ||
raise ConanInvalidConfiguration( | ||
"ReductCpp requires chrono with GCC 14 or higher. " | ||
) | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
apply_conandata_patches(self) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
if self.options.with_chrono: | ||
tc.cache_variables["REDUCT_CPP_USE_STD_CHRONO"] = True | ||
tc.cache_variables["REDUCT_CPP_USE_CONAN"] = True | ||
tc.generate() | ||
|
||
deps = CMakeDeps(self) | ||
deps.generate() | ||
|
||
def build(self): | ||
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() | ||
|
||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) | ||
rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) | ||
rmdir(self, os.path.join(self.package_folder, "share")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["reductcpp"] | ||
self.cpp_info.set_property("cmake_file_name", "ReductCpp") | ||
self.cpp_info.set_property("cmake_target_name", "reductcpp") |
17 changes: 17 additions & 0 deletions
17
recipes/reduct-cpp/all/patches/0001-1.15.0-disable-conan-lookup.patch
This file contains hidden or 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,17 @@ | ||
diff --git a/cmake/InstallDependencies.cmake b/cmake/InstallDependencies.cmake | ||
index 8171db3..33b0a00 100644 | ||
--- a/cmake/InstallDependencies.cmake | ||
+++ b/cmake/InstallDependencies.cmake | ||
@@ -1,12 +1,4 @@ | ||
if(REDUCT_CPP_USE_CONAN) | ||
- message(STATUS "Using Conan to fetch dependencies") | ||
- find_program(CONAN conan) | ||
- if(NOT CONAN) | ||
- message( | ||
- FATAL_ERROR | ||
- "Conan not found. Please install Conan and run cmake again" | ||
- ) | ||
- endif() | ||
|
||
find_package(fmt REQUIRED) | ||
find_package(nlohmann_json REQUIRED) |
This file contains hidden or 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.15) | ||
project(test_package LANGUAGES CXX) | ||
|
||
find_package(ReductCpp REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE reductcpp) |
This file contains hidden or 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,25 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain" | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
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.bindir, "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains hidden or 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,12 @@ | ||
#include "reduct/client.h" | ||
|
||
#include <iostream> | ||
|
||
using reduct::IBucket; | ||
using reduct::IClient; | ||
|
||
/* It's a constructor with no network calls, so it's safe to use in test */ | ||
int main() { | ||
auto client = IClient::Build("http://127.0.0.1:8383"); | ||
return EXIT_SUCCESS; | ||
} |
This file contains hidden or 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.15.0": | ||
folder: all |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.