From a1e4120eb2b55e498036084ffbf684833608326c Mon Sep 17 00:00:00 2001 From: jgsogo Date: Fri, 12 Mar 2021 11:13:37 +0100 Subject: [PATCH 1/3] [utf8.h] Add library and packages --- recipes/utf8.h/all/conandata.yml | 4 +++ recipes/utf8.h/all/conanfile.py | 32 +++++++++++++++++++ .../utf8.h/all/test_package/CMakeLists.txt | 10 ++++++ recipes/utf8.h/all/test_package/conanfile.py | 17 ++++++++++ .../utf8.h/all/test_package/test_package.cpp | 13 ++++++++ recipes/utf8.h/config.yml | 3 ++ 6 files changed, 79 insertions(+) create mode 100644 recipes/utf8.h/all/conandata.yml create mode 100644 recipes/utf8.h/all/conanfile.py create mode 100644 recipes/utf8.h/all/test_package/CMakeLists.txt create mode 100644 recipes/utf8.h/all/test_package/conanfile.py create mode 100644 recipes/utf8.h/all/test_package/test_package.cpp create mode 100644 recipes/utf8.h/config.yml diff --git a/recipes/utf8.h/all/conandata.yml b/recipes/utf8.h/all/conandata.yml new file mode 100644 index 0000000000000..8841db197744f --- /dev/null +++ b/recipes/utf8.h/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20210310": + url: "https://github.com/sheredom/utf8.h/archive/ee5a7d4beb7755da13e4d4ec3eccfb65a0530456.tar.gz" + sha256: "d7c9ad480b640c76292a1c4b9735497fd635cb8828e95beabb7db91ea4cecf55" diff --git a/recipes/utf8.h/all/conanfile.py b/recipes/utf8.h/all/conanfile.py new file mode 100644 index 0000000000000..c04583f13ef0b --- /dev/null +++ b/recipes/utf8.h/all/conanfile.py @@ -0,0 +1,32 @@ +import os +import re +from conans import ConanFile, tools + +required_conan_version = ">=1.28.0" + +class Utf8HConan(ConanFile): + name = "utf8.h" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/sheredom/utf8.h" + description = "Single header utf8 string functions for C and C++" + topics = ("utf8", "unicode", "text") + license = "Unlicense" + no_copy_source = True + + @property + def _source_subfolder(self): + return "source_subfolder" + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + url = self.conan_data["sources"][self.version]['url'] + m = re.match(r'.*/([0-9a-f]+)\.tar.gz', url) + extracted_dir = self.name + "-" + m[1] + os.rename(extracted_dir, self._source_subfolder) + + def package(self): + self.copy("utf8.h", dst="include", src=self._source_subfolder) + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + + def package_id(self): + self.info.header_only() diff --git a/recipes/utf8.h/all/test_package/CMakeLists.txt b/recipes/utf8.h/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..6fec0df294d0a --- /dev/null +++ b/recipes/utf8.h/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +find_package(utf8.h REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} utf8.h::utf8.h) diff --git a/recipes/utf8.h/all/test_package/conanfile.py b/recipes/utf8.h/all/test_package/conanfile.py new file mode 100644 index 0000000000000..abcaeed3f89b6 --- /dev/null +++ b/recipes/utf8.h/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + 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.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/utf8.h/all/test_package/test_package.cpp b/recipes/utf8.h/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..fd1eef99eafd8 --- /dev/null +++ b/recipes/utf8.h/all/test_package/test_package.cpp @@ -0,0 +1,13 @@ +#include "utf8.h" + +int main() +{ + const char ref[] = {'\xcf', '\xb4', '\xce', '\x98', '\xce', + '\x98', '\xce', '\x98', '\0'}; + char str[] = {'\xcf', '\xb4', '\xce', '\xb8', '\xce', + '\x98', '\xcf', '\x91', '\0'}; + + int r = utf8ncasecmp(ref, str, 8); + + return 0; +} diff --git a/recipes/utf8.h/config.yml b/recipes/utf8.h/config.yml new file mode 100644 index 0000000000000..dc79ecf2dafac --- /dev/null +++ b/recipes/utf8.h/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20210310": + folder: all From a2723df58ccb04b232238d8b40d81d4d66d6115b Mon Sep 17 00:00:00 2001 From: jgsogo Date: Fri, 12 Mar 2021 14:03:15 +0100 Subject: [PATCH 2/3] no conan version limitation --- recipes/utf8.h/all/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/utf8.h/all/conanfile.py b/recipes/utf8.h/all/conanfile.py index c04583f13ef0b..dc1d9fdf3047d 100644 --- a/recipes/utf8.h/all/conanfile.py +++ b/recipes/utf8.h/all/conanfile.py @@ -2,7 +2,6 @@ import re from conans import ConanFile, tools -required_conan_version = ">=1.28.0" class Utf8HConan(ConanFile): name = "utf8.h" From c614283828f6286a507217858c10f0effb0c2f20 Mon Sep 17 00:00:00 2001 From: "Javier G. Sogo" Date: Fri, 12 Mar 2021 16:50:04 +0100 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> --- recipes/utf8.h/all/conanfile.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/recipes/utf8.h/all/conanfile.py b/recipes/utf8.h/all/conanfile.py index dc1d9fdf3047d..635e886398dd2 100644 --- a/recipes/utf8.h/all/conanfile.py +++ b/recipes/utf8.h/all/conanfile.py @@ -1,5 +1,5 @@ import os -import re +import glob from conans import ConanFile, tools @@ -18,9 +18,7 @@ def _source_subfolder(self): def source(self): tools.get(**self.conan_data["sources"][self.version]) - url = self.conan_data["sources"][self.version]['url'] - m = re.match(r'.*/([0-9a-f]+)\.tar.gz', url) - extracted_dir = self.name + "-" + m[1] + extracted_dir = glob.glob("utf8.h-*")[0] os.rename(extracted_dir, self._source_subfolder) def package(self):