From 6b173fd061c77e5eb51990f372d9c138f14bd7fa Mon Sep 17 00:00:00 2001 From: bennyhuo Date: Tue, 13 Dec 2022 06:45:56 +0800 Subject: [PATCH 01/10] add tinycthreadpool --- recipes/tinycthreadpool/all/conandata.yml | 4 + recipes/tinycthreadpool/all/conanfile.py | 79 +++++++++++++++++++ .../all/test_package/CMakeLists.txt | 8 ++ .../all/test_package/conanfile.py | 26 ++++++ .../all/test_package/example.c | 14 ++++ .../all/test_v1_package/CMakeLists.txt | 8 ++ .../all/test_v1_package/conanfile.py | 19 +++++ recipes/tinycthreadpool/config.yml | 4 + 8 files changed, 162 insertions(+) create mode 100644 recipes/tinycthreadpool/all/conandata.yml create mode 100644 recipes/tinycthreadpool/all/conanfile.py create mode 100644 recipes/tinycthreadpool/all/test_package/CMakeLists.txt create mode 100644 recipes/tinycthreadpool/all/test_package/conanfile.py create mode 100644 recipes/tinycthreadpool/all/test_package/example.c create mode 100644 recipes/tinycthreadpool/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/tinycthreadpool/all/test_v1_package/conanfile.py create mode 100644 recipes/tinycthreadpool/config.yml diff --git a/recipes/tinycthreadpool/all/conandata.yml b/recipes/tinycthreadpool/all/conandata.yml new file mode 100644 index 0000000000000..f17fd3022427f --- /dev/null +++ b/recipes/tinycthreadpool/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0": + url: "https://github.com/bennyhuo/tinycthreadpool/archive/refs/tags/1.0.tar.gz" + sha256: "2a144e883251dc63179990e671b5a9ce3ebaf42186471baee00ecad322dd2fd9" diff --git a/recipes/tinycthreadpool/all/conanfile.py b/recipes/tinycthreadpool/all/conanfile.py new file mode 100644 index 0000000000000..6e8655bacb3cf --- /dev/null +++ b/recipes/tinycthreadpool/all/conanfile.py @@ -0,0 +1,79 @@ +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import is_msvc_static_runtime, is_msvc +from conan.tools.scm import Version +from conan.tools.files import get, copy +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout + +required_conan_version = ">=1.53.0" + + +class TinyCThreadPoolConan(ConanFile): + name = "tinycthreadpool" + description = "Portable C thread pool" + license = "BSD-2-Clause" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/bennyhuo/tinycthreadpool" + topics = ("thread-pool", "threading", "pure-c") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def layout(self): + cmake_layout(self, src_folder="src") + + def generate(self): + tc = CMakeToolchain(self) + if is_msvc(self): + tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) + + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + tc = CMakeDeps(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "tinycthreadpool") + self.cpp_info.set_property("cmake_target_name", "tinycthreadpool::tinycthreadpool") + self.cpp_info.set_property("pkg_config_name", "tinycthreadpool") + + self.cpp_info.libs = ["tinycthreadpool"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.append("pthread") + + # TODO: to remove in conan v2 + self.cpp_info.names["cmake_find_package"] = "tinycthreadpool" + self.cpp_info.names["cmake_find_package_multi"] = "tinycthreadpool" + diff --git a/recipes/tinycthreadpool/all/test_package/CMakeLists.txt b/recipes/tinycthreadpool/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..873506d1a8b31 --- /dev/null +++ b/recipes/tinycthreadpool/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(PackageTest C) + +find_package(tinycthreadpool REQUIRED CONFIG) + +add_executable(example example.c) +target_link_libraries(example tinycthreadpool::tinycthreadpool) +target_compile_features(example PRIVATE c_std_11) diff --git a/recipes/tinycthreadpool/all/test_package/conanfile.py b/recipes/tinycthreadpool/all/test_package/conanfile.py new file mode 100644 index 0000000000000..5ebee977f3e4e --- /dev/null +++ b/recipes/tinycthreadpool/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +import os + +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout + + +class ThreadpoolTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps","CMakeToolchain","VirtualRunEnv" + + 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): + cmd = os.path.join(self.cpp.build.bindir, "example") + self.run(cmd, env="conanrun") diff --git a/recipes/tinycthreadpool/all/test_package/example.c b/recipes/tinycthreadpool/all/test_package/example.c new file mode 100644 index 0000000000000..af998ecc461c4 --- /dev/null +++ b/recipes/tinycthreadpool/all/test_package/example.c @@ -0,0 +1,14 @@ +#include +#include +#include + +int main(void) { + puts("Start Testing!"); + threadpool_t *threadpool = threadpool_create(3, 5, 0); + printf("Create thread pool: %#x.\n", threadpool); + if (threadpool){ + int result = threadpool_destroy(threadpool, 0); + printf("End Testing! result: %d\n", result); + } + return 0; +} diff --git a/recipes/tinycthreadpool/all/test_v1_package/CMakeLists.txt b/recipes/tinycthreadpool/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..925ecbe19e448 --- /dev/null +++ b/recipes/tinycthreadpool/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/tinycthreadpool/all/test_v1_package/conanfile.py b/recipes/tinycthreadpool/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..2a41ea908ed28 --- /dev/null +++ b/recipes/tinycthreadpool/all/test_v1_package/conanfile.py @@ -0,0 +1,19 @@ +from conans import ConanFile, CMake +from conan.tools.build import cross_building +import os + + +# legacy validation with Conan 1.x +class TestPackageV1Conan(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 cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/tinycthreadpool/config.yml b/recipes/tinycthreadpool/config.yml new file mode 100644 index 0000000000000..739bad18cc6dc --- /dev/null +++ b/recipes/tinycthreadpool/config.yml @@ -0,0 +1,4 @@ +versions: + # Newer versions at the top + "1.0": + folder: all From b0b981f26a693ae04ed796087215c9780791308f Mon Sep 17 00:00:00 2001 From: Benny Huo Date: Sat, 8 Apr 2023 21:44:10 +0800 Subject: [PATCH 02/10] Update recipes/tinycthreadpool/all/conanfile.py Co-authored-by: Chris Mc --- recipes/tinycthreadpool/all/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/tinycthreadpool/all/conanfile.py b/recipes/tinycthreadpool/all/conanfile.py index 6e8655bacb3cf..2d435feac02f6 100644 --- a/recipes/tinycthreadpool/all/conanfile.py +++ b/recipes/tinycthreadpool/all/conanfile.py @@ -1,7 +1,6 @@ import os from conan import ConanFile -from conan.errors import ConanInvalidConfiguration from conan.tools.microsoft import is_msvc_static_runtime, is_msvc from conan.tools.scm import Version from conan.tools.files import get, copy From 62cc640bbb5dcb97cea38566f8d4851fd8869d47 Mon Sep 17 00:00:00 2001 From: Benny Huo Date: Sat, 8 Apr 2023 21:44:25 +0800 Subject: [PATCH 03/10] Update recipes/tinycthreadpool/all/conanfile.py Co-authored-by: Chris Mc --- recipes/tinycthreadpool/all/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/tinycthreadpool/all/conanfile.py b/recipes/tinycthreadpool/all/conanfile.py index 2d435feac02f6..5a043d8fbbee5 100644 --- a/recipes/tinycthreadpool/all/conanfile.py +++ b/recipes/tinycthreadpool/all/conanfile.py @@ -2,7 +2,6 @@ from conan import ConanFile from conan.tools.microsoft import is_msvc_static_runtime, is_msvc -from conan.tools.scm import Version from conan.tools.files import get, copy from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout From cab3af5bfd1994291dfb8df30f2750d7b8f89ffc Mon Sep 17 00:00:00 2001 From: Benny Huo Date: Sat, 8 Apr 2023 21:44:39 +0800 Subject: [PATCH 04/10] Update recipes/tinycthreadpool/all/conanfile.py Co-authored-by: Chris Mc --- recipes/tinycthreadpool/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/tinycthreadpool/all/conanfile.py b/recipes/tinycthreadpool/all/conanfile.py index 5a043d8fbbee5..61d603d1a1cab 100644 --- a/recipes/tinycthreadpool/all/conanfile.py +++ b/recipes/tinycthreadpool/all/conanfile.py @@ -36,7 +36,7 @@ def config_options(self): del self.options.fPIC 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") From dc5a2ee0ef2c96724fc022421dacc4855c7e96f7 Mon Sep 17 00:00:00 2001 From: Benny Huo Date: Sat, 8 Apr 2023 21:44:57 +0800 Subject: [PATCH 05/10] Update recipes/tinycthreadpool/all/conanfile.py Co-authored-by: Chris Mc --- recipes/tinycthreadpool/all/conanfile.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/tinycthreadpool/all/conanfile.py b/recipes/tinycthreadpool/all/conanfile.py index 61d603d1a1cab..469a451d3c531 100644 --- a/recipes/tinycthreadpool/all/conanfile.py +++ b/recipes/tinycthreadpool/all/conanfile.py @@ -45,8 +45,6 @@ def generate(self): tc = CMakeToolchain(self) if is_msvc(self): tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) - - tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" tc.generate() tc = CMakeDeps(self) From 36778e6c8aa9cf5a321fc064853457da88d3c2f6 Mon Sep 17 00:00:00 2001 From: Benny Huo Date: Sat, 8 Apr 2023 21:45:13 +0800 Subject: [PATCH 06/10] Update recipes/tinycthreadpool/all/conanfile.py Co-authored-by: Chris Mc --- recipes/tinycthreadpool/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/tinycthreadpool/all/conanfile.py b/recipes/tinycthreadpool/all/conanfile.py index 469a451d3c531..d8edb3b0a2b0f 100644 --- a/recipes/tinycthreadpool/all/conanfile.py +++ b/recipes/tinycthreadpool/all/conanfile.py @@ -5,7 +5,7 @@ from conan.tools.files import get, copy from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -required_conan_version = ">=1.53.0" +required_conan_version = ">=1.54.0" class TinyCThreadPoolConan(ConanFile): From 57ebec75cfbdd149536d02c505e472b93a43db0e Mon Sep 17 00:00:00 2001 From: Benny Huo Date: Sat, 8 Apr 2023 21:45:46 +0800 Subject: [PATCH 07/10] Update recipes/tinycthreadpool/all/conanfile.py Co-authored-by: Chris Mc --- recipes/tinycthreadpool/all/conanfile.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/recipes/tinycthreadpool/all/conanfile.py b/recipes/tinycthreadpool/all/conanfile.py index d8edb3b0a2b0f..ca983123892fa 100644 --- a/recipes/tinycthreadpool/all/conanfile.py +++ b/recipes/tinycthreadpool/all/conanfile.py @@ -61,15 +61,6 @@ def package(self): cmake.install() def package_info(self): - self.cpp_info.set_property("cmake_file_name", "tinycthreadpool") - self.cpp_info.set_property("cmake_target_name", "tinycthreadpool::tinycthreadpool") - self.cpp_info.set_property("pkg_config_name", "tinycthreadpool") - self.cpp_info.libs = ["tinycthreadpool"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.append("pthread") - - # TODO: to remove in conan v2 - self.cpp_info.names["cmake_find_package"] = "tinycthreadpool" - self.cpp_info.names["cmake_find_package_multi"] = "tinycthreadpool" - From 15a34845a485c62667cd48ba4dd6c3b7b5738364 Mon Sep 17 00:00:00 2001 From: bennyhuo Date: Sat, 15 Apr 2023 23:12:56 +0800 Subject: [PATCH 08/10] depends on tinycthread as a library not source. --- recipes/tinycthreadpool/all/conandata.yml | 4 ++-- recipes/tinycthreadpool/all/conanfile.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/recipes/tinycthreadpool/all/conandata.yml b/recipes/tinycthreadpool/all/conandata.yml index f17fd3022427f..a6b63fae3cefb 100644 --- a/recipes/tinycthreadpool/all/conandata.yml +++ b/recipes/tinycthreadpool/all/conandata.yml @@ -1,4 +1,4 @@ sources: "1.0": - url: "https://github.com/bennyhuo/tinycthreadpool/archive/refs/tags/1.0.tar.gz" - sha256: "2a144e883251dc63179990e671b5a9ce3ebaf42186471baee00ecad322dd2fd9" + url: "https://github.com/bennyhuo/tinycthreadpool/archive/refs/tags/v1.0.tar.gz" + sha256: "a3e9876d3e3008cffed96216d026504b57ab6be6ee3df62d5916fecd4106ede5" diff --git a/recipes/tinycthreadpool/all/conanfile.py b/recipes/tinycthreadpool/all/conanfile.py index ca983123892fa..81054ed5bf8c2 100644 --- a/recipes/tinycthreadpool/all/conanfile.py +++ b/recipes/tinycthreadpool/all/conanfile.py @@ -41,6 +41,9 @@ def source(self): def layout(self): cmake_layout(self, src_folder="src") + def requirements(self): + self.requires("tinycthread/cci.20161001", transitive_headers=True) + def generate(self): tc = CMakeToolchain(self) if is_msvc(self): From 6375de4a2b7c590efe76ca6d42497333f1dce3b1 Mon Sep 17 00:00:00 2001 From: Benny Huo Date: Mon, 17 Apr 2023 15:09:03 +0800 Subject: [PATCH 09/10] Update recipes/tinycthreadpool/all/conanfile.py Co-authored-by: Chris Mc --- recipes/tinycthreadpool/all/conanfile.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/tinycthreadpool/all/conanfile.py b/recipes/tinycthreadpool/all/conanfile.py index 81054ed5bf8c2..1a856df7a1f20 100644 --- a/recipes/tinycthreadpool/all/conanfile.py +++ b/recipes/tinycthreadpool/all/conanfile.py @@ -46,8 +46,6 @@ def requirements(self): def generate(self): tc = CMakeToolchain(self) - if is_msvc(self): - tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self) tc.generate() tc = CMakeDeps(self) From e665fc9bb4ce0aaec6c935f83a6453819afac55a Mon Sep 17 00:00:00 2001 From: Benny Huo Date: Mon, 17 Apr 2023 15:09:21 +0800 Subject: [PATCH 10/10] Update recipes/tinycthreadpool/all/conanfile.py Co-authored-by: Chris Mc --- recipes/tinycthreadpool/all/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/tinycthreadpool/all/conanfile.py b/recipes/tinycthreadpool/all/conanfile.py index 1a856df7a1f20..1cc771a3807a5 100644 --- a/recipes/tinycthreadpool/all/conanfile.py +++ b/recipes/tinycthreadpool/all/conanfile.py @@ -1,7 +1,6 @@ import os from conan import ConanFile -from conan.tools.microsoft import is_msvc_static_runtime, is_msvc from conan.tools.files import get, copy from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout