forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(conan-io#5780) add oniguruma/6.9.7.1
- Loading branch information
Showing
7 changed files
with
178 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,7 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_subdirectory(source_subfolder) |
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: | ||
"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" |
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,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") |
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 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) |
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 @@ | ||
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) |
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,58 @@ | ||
#include <oniguruma.h> | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
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; | ||
} |
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: | ||
"6.9.7.1": | ||
folder: all |