diff --git a/recipes/oniguruma/all/CMakeLists.txt b/recipes/oniguruma/all/CMakeLists.txt new file mode 100644 index 00000000000000..361b35d4c17d9a --- /dev/null +++ b/recipes/oniguruma/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.11) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/oniguruma/all/conandata.yml b/recipes/oniguruma/all/conandata.yml new file mode 100644 index 00000000000000..53529bbc4e6519 --- /dev/null +++ b/recipes/oniguruma/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "6.9.7.1": + url: "https://github.com/kkos/oniguruma/releases/download/v6.9.7.1/onig-6.9.7.1.tar.gz" + sha256: "6444204b9c34e6eb6c0b23021ce89a0370dad2b2f5c00cd44c342753e0b204d9" diff --git a/recipes/oniguruma/all/conanfile.py b/recipes/oniguruma/all/conanfile.py new file mode 100644 index 00000000000000..0990f38bec2d04 --- /dev/null +++ b/recipes/oniguruma/all/conanfile.py @@ -0,0 +1,79 @@ +from conans import ConanFile, CMake, tools +import os + +required_conan_version = ">=1.33.0" + + +class OnigurumaConan(ConanFile): + name = "oniguruma" + description = "Oniguruma is a modern and flexible regular expressions library." + license = "BSD-2-Clause" + topics = ("conan", "oniguruma", "regex") + homepage = "https://github.com/kkos/oniguruma" + url = "https://github.com/conan-io/conan-center-index" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "posix_api": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "posix_api": True, + } + + exports_sources = "CMakeLists.txt" + generators = "cmake" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["ENABLE_POSIX_API"] = self.options.posix_api + self._cmake.definitions["ENABLE_BINARY_COMPATIBLE_POSIX_API"] = self.options.posix_api + self._cmake.configure() + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("COPYING", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "oniguruma" + self.cpp_info.names["cmake_find_package_multi"] = "oniguruma" + self.cpp_info.names["pkg_config"] = "oniguruma" + self.cpp_info.components["onig"].names["cmake_find_package"] = "onig" + self.cpp_info.components["onig"].names["cmake_find_package_multi"] = "onig" + self.cpp_info.components["onig"].names["pkg_config"] = "oniguruma" + self.cpp_info.components["onig"].libs = ["onig"] + if not self.options.shared: + self.cpp_info.components["onig"].defines.append("ONIG_STATIC") diff --git a/recipes/oniguruma/all/test_package/CMakeLists.txt b/recipes/oniguruma/all/test_package/CMakeLists.txt new file mode 100644 index 00000000000000..fd982ccec97d02 --- /dev/null +++ b/recipes/oniguruma/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(oniguruma REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} oniguruma::onig) diff --git a/recipes/oniguruma/all/test_package/conanfile.py b/recipes/oniguruma/all/test_package/conanfile.py new file mode 100644 index 00000000000000..a9f777f7680ff1 --- /dev/null +++ b/recipes/oniguruma/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(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 tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/oniguruma/all/test_package/test_package.c b/recipes/oniguruma/all/test_package/test_package.c new file mode 100644 index 00000000000000..84f01cc855f98c --- /dev/null +++ b/recipes/oniguruma/all/test_package/test_package.c @@ -0,0 +1,58 @@ +#include + +#include +#include + +int main(void) { + int r; + unsigned char *start, *range, *end; + regex_t* reg; + OnigErrorInfo einfo; + OnigRegion *region; + OnigEncoding use_encs[1]; + + static UChar* pattern = (UChar* )"a(.*)b|[e-f]+"; + static UChar* str = (UChar* )"zzzzaffffffffb"; + + use_encs[0] = ONIG_ENCODING_ASCII; + onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0])); + + r = onig_new(®, pattern, pattern + strlen((char* )pattern), + ONIG_OPTION_DEFAULT, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo); + if (r != ONIG_NORMAL) { + char s[ONIG_MAX_ERROR_MESSAGE_LEN]; + onig_error_code_to_str((UChar* )s, r, &einfo); + fprintf(stderr, "ERROR: %s\n", s); + return -1; + } + + region = onig_region_new(); + + end = str + strlen((char* )str); + start = str; + range = end; + r = onig_search(reg, str, end, start, range, region, ONIG_OPTION_NONE); + if (r >= 0) { + int i; + + fprintf(stderr, "match at %d\n", r); + for (i = 0; i < region->num_regs; i++) { + fprintf(stderr, "%d: (%d-%d)\n", i, region->beg[i], region->end[i]); + } + } else if (r == ONIG_MISMATCH) { + fprintf(stderr, "search fail\n"); + } else { /* error */ + char s[ONIG_MAX_ERROR_MESSAGE_LEN]; + onig_error_code_to_str((UChar* )s, r); + fprintf(stderr, "ERROR: %s\n", s); + onig_region_free(region, 1 /* 1:free self, 0:free contents only */); + onig_free(reg); + onig_end(); + return -1; + } + + onig_region_free(region, 1 /* 1:free self, 0:free contents only */); + onig_free(reg); + onig_end(); + return 0; +} diff --git a/recipes/oniguruma/config.yml b/recipes/oniguruma/config.yml new file mode 100644 index 00000000000000..102a597795299a --- /dev/null +++ b/recipes/oniguruma/config.yml @@ -0,0 +1,3 @@ +versions: + "6.9.7.1": + folder: all