Skip to content

Commit

Permalink
(#4858) [utf8.h] Add library and packages
Browse files Browse the repository at this point in the history
* [utf8.h] Add library and packages

* no conan version limitation

* Apply suggestions from code review

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>
  • Loading branch information
jgsogo and SpaceIm committed Mar 13, 2021
1 parent 3ee8a20 commit f4707cf
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 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"
29 changes: 29 additions & 0 deletions recipes/utf8.h/all/conanfile.py
@@ -0,0 +1,29 @@
import os
import glob
from conans import ConanFile, tools


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])
extracted_dir = glob.glob("utf8.h-*")[0]
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()
10 changes: 10 additions & 0 deletions 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)
17 changes: 17 additions & 0 deletions 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)
13 changes: 13 additions & 0 deletions 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;
}
3 changes: 3 additions & 0 deletions recipes/utf8.h/config.yml
@@ -0,0 +1,3 @@
versions:
"cci.20210310":
folder: all

0 comments on commit f4707cf

Please sign in to comment.