diff --git a/recipes/statistic/all/conandata.yml b/recipes/statistic/all/conandata.yml new file mode 100644 index 0000000000000..c9f570c26cbed --- /dev/null +++ b/recipes/statistic/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.8": + url: "https://github.com/RobTillaart/Statistic/archive/refs/tags/1.0.8.tar.gz" + sha256: "44ed39d05fb9280ad88e88d732805a228a69110fac6d1377bcf64cc84a363241" diff --git a/recipes/statistic/all/conanfile.py b/recipes/statistic/all/conanfile.py new file mode 100644 index 0000000000000..612fd3e02ff8c --- /dev/null +++ b/recipes/statistic/all/conanfile.py @@ -0,0 +1,52 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.files import copy, get +from conan.tools.layout import basic_layout +from conan.tools.build import check_min_cppstd +from conan.tools.microsoft import is_msvc +import os + +required_conan_version = ">=1.52.0" + +class StatisticConan(ConanFile): + name = "statistic" + description = "Statistic library for Arduino includes sum, average, variance and std deviation" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/RobTillaart/Statistic" + topics = ("arduino", "statistics", "header-only") + package_type = "header-library" + settings = "os", "arch", "compiler", "build_type" + no_copy_source = True + + @property + def _min_cppstd(self): + return 11 + + def layout(self): + basic_layout(self, src_folder="src") + + def package_id(self): + self.info.clear() + + def validate(self): + if is_msvc(self): + raise ConanInvalidConfiguration(f"{self.ref} does not support Visual Studio") + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def package(self): + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + copy( + self, + "Statistic.h", + self.source_folder, + os.path.join(self.package_folder, "include"), + ) + + def package_info(self): + self.cpp_info.bindirs = [] + self.cpp_info.libdirs = [] diff --git a/recipes/statistic/all/test_package/CMakeLists.txt b/recipes/statistic/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..9b9900a401fc1 --- /dev/null +++ b/recipes/statistic/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(statistic REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE statistic::statistic) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/statistic/all/test_package/conanfile.py b/recipes/statistic/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3a91c9439218e --- /dev/null +++ b/recipes/statistic/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +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", "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") diff --git a/recipes/statistic/all/test_package/test_package.cpp b/recipes/statistic/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..185ea7dc94706 --- /dev/null +++ b/recipes/statistic/all/test_package/test_package.cpp @@ -0,0 +1,20 @@ +#include +#if defined __has_include && __has_include() +# define HAVE_STDCXX_LIMITS 1 +#endif +#include "Statistic.h" + +int main(void) { + statistic::Statistic myStats; + + for (int i = 0; i < 10; i++) { + myStats.add(i); + } + std::cout << myStats.count() << std::endl; + std::cout << myStats.average() << std::endl; + std::cout << myStats.variance() << std::endl; + std::cout << myStats.minimum() << std::endl; + std::cout << myStats.maximum() << std::endl; + + return 0; +} diff --git a/recipes/statistic/config.yml b/recipes/statistic/config.yml new file mode 100644 index 0000000000000..28e3ee22ca8ac --- /dev/null +++ b/recipes/statistic/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.8": + folder: all