Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#4858) [utf8.h] Add library and packages
* [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
Showing
6 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"cci.20210310": | ||
url: "https://github.com/sheredom/utf8.h/archive/ee5a7d4beb7755da13e4d4ec3eccfb65a0530456.tar.gz" | ||
sha256: "d7c9ad480b640c76292a1c4b9735497fd635cb8828e95beabb7db91ea4cecf55" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"cci.20210310": | ||
folder: all |