Skip to content
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

Add think-cell-library #23777

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions recipes/think-cell-library/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"cci.20240426":
url: "https://github.com/think-cell/think-cell-library/archive/9b334a494d66c76352e66d6440c0116be7bce8a1.tar.gz"
sha256: "886e0a49f5ff7c978362511ca3d3123d8f98478aad2445950842d3e1388e5c7b"
73 changes: 73 additions & 0 deletions recipes/think-cell-library/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout
from conan.tools.scm import Version
import os


required_conan_version = ">=1.53.0"


class PackageConan(ConanFile):
name = "think-cell-library"
description = "This library consists of several core C++ utilities that we at think-cell Software have developed and consider to be useful."
license = "BSL-1.0 license"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/think-cell/think-cell-library"
topics = ("ranges", "header-only")
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
def _min_cppstd(self):
return 20

@property
def _compilers_minimum_version(self):
return {
"apple-clang": "13",
"clang": "7",
"gcc": "12",
"msvc": "191",
"Visual Studio": "15",
}

def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("boost/1.84.0")
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved

def package_id(self):
self.info.clear()

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)

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

def build(self):
pass

def package(self):
copy(self, "LICENSE_1_0.txt", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(
self,
"*.h",
os.path.join(self.source_folder, "tc"),
os.path.join(self.package_folder, "include", "tc"),
)

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
11 changes: 11 additions & 0 deletions recipes/think-cell-library/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX) # if the project is pure C
# project(test_package LANGUAGES CXX) # if the project uses c++

find_package(think-cell-library REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
# don't link to ${CONAN_LIBS} or CONAN_PKG::package
target_link_libraries(${PROJECT_NAME} PRIVATE think-cell-library::think-cell-library)
# In case the target project need a specific C++ standard
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
27 changes: 27 additions & 0 deletions recipes/think-cell-library/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


# It will become the standard on Conan 2.x
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

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")
28 changes: 28 additions & 0 deletions recipes/think-cell-library/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "tc/range/meta.h"
#include "tc/range/filter_adaptor.h"
#include "tc/string/format.h"
#include "tc/string/make_c_str.h"

#include <vector>
#include <cstdio>
#include <cstdlib>

namespace {

template <typename... Args>
void print(Args&&... args) noexcept {
std::printf("%s", tc::implicit_cast<char const*>(tc::make_c_str<char>(std::forward<Args>(args)...)));
}

int main(void) {
std::vector<int> v = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};

tc::for_each(
tc::filter(v, [](const int& n){ return (n%2==0);}),
[&](auto const& n) {
print(tc::as_dec(n), ", ");
}
);
print("\n");
return EXIT_SUCCESS;
}
4 changes: 4 additions & 0 deletions recipes/think-cell-library/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
versions:
# Newer versions at the top
"cci.20240426":
folder: all
Loading