Skip to content

Commit

Permalink
Merge pull request #117 from bincrafters/pcre
Browse files Browse the repository at this point in the history
add pcre/8.41
  • Loading branch information
lasote committed Sep 27, 2019
2 parents 2f976d0 + bfe6fd3 commit 619e8eb
Show file tree
Hide file tree
Showing 7 changed files with 552 additions and 0 deletions.
7 changes: 7 additions & 0 deletions recipes/pcre/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project(cmake_wrapper)

message(STATUS "Conan CMake Wrapper")
include(conanbuildinfo.cmake)
conan_basic_setup()

add_subdirectory("source_subfolder")
4 changes: 4 additions & 0 deletions recipes/pcre/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"8.41":
url: "https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz"
sha256: "244838e1f1d14f7e2fa7681b857b3a8566b74215f28133f14a8f5e59241b682c"
93 changes: 93 additions & 0 deletions recipes/pcre/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
from conans import ConanFile, CMake, tools
import os


class PCREConan(ConanFile):
name = "pcre"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://www.pcre.org"
author = "Bincrafters <bincrafters@gmail.com>"
description = "Perl Compatible Regular Expressions"
license = "BSD-3-Clause"
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_bzip2": [True, False],
"with_zlib": [True, False],
"with_jit": [True, False],
"build_pcrecpp": [True, False],
"build_pcregrep": [True, False],
"with_utf": [True, False],
"with_unicode_properties": [True, False]
}
default_options = {'shared': False, 'fPIC': True, 'with_bzip2': True, 'with_zlib': True, 'with_jit': False, 'build_pcrecpp': False, 'build_pcregrep': False, 'with_utf': False, 'with_unicode_properties': False}
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"

def config_options(self):
if self.settings.os == "Windows":
self.options.remove("fPIC")

def configure(self):
if not self.options.build_pcrecpp:
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
if self.options.with_unicode_properties:
self.options.with_utf = True

def patch_cmake(self):
"""Patch CMake file to avoid man and share during install stage
"""
cmake_file = os.path.join(self._source_subfolder, "CMakeLists.txt")
tools.replace_in_file(cmake_file, "INSTALL(FILES ${man1} DESTINATION man/man1)", "")
tools.replace_in_file(cmake_file, "INSTALL(FILES ${man3} DESTINATION man/man3)", "")
tools.replace_in_file(cmake_file, "INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)", "")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
self.patch_cmake()

def requirements(self):
if self.options.with_bzip2:
self.requires.add("bzip2/1.0.8")
if self.options.with_zlib:
self.requires.add("zlib/1.2.11")

def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["PCRE_BUILD_TESTS"] = False
cmake.definitions["PCRE_BUILD_PCREGREP"] = self.options.build_pcregrep
cmake.definitions["PCRE_BUILD_PCRECPP"] = self.options.build_pcrecpp
cmake.definitions["PCRE_SUPPORT_LIBZ"] = self.options.with_zlib
cmake.definitions["PCRE_SUPPORT_LIBBZ2"] = self.options.with_bzip2
cmake.definitions["PCRE_SUPPORT_JIT"] = self.options.with_jit
cmake.definitions["PCRE_SUPPORT_UTF"] = self.options.with_utf
cmake.definitions["PCRE_SUPPORT_UNICODE_PROPERTIES"] = self.options.with_unicode_properties
cmake.definitions["PCRE_SUPPORT_LIBREADLINE"] = False
cmake.definitions["PCRE_SUPPORT_LIBEDIT"] = False
if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
cmake.definitions["PCRE_STATIC_RUNTIME"] = not self.options.shared and "MT" in self.settings.compiler.runtime
cmake.configure(build_folder=self._build_subfolder)
return cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy(pattern="LICENCE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
if self.settings.os == "Windows" and self.settings.build_type == 'Debug':
self.cpp_info.libs = ['pcreposixd', 'pcred']
else:
self.cpp_info.libs = ['pcreposix', 'pcre']
if not self.options.shared:
self.cpp_info.defines.append("PCRE_STATIC=1")
15 changes: 15 additions & 0 deletions recipes/pcre/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
project(test_package)
cmake_minimum_required(VERSION 2.8.11)

set(CMAKE_VERBOSE_MAKEFILE TRUE)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

file(GLOB SOURCE_FILES *.c)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
if (PCRE_STATIC)
target_compile_definitions(${PROJECT_NAME} PRIVATE PCRE_STATIC=1)
endif (PCRE_STATIC)
24 changes: 24 additions & 0 deletions recipes/pcre/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from conans import ConanFile, CMake, tools, RunEnvironment
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
with tools.environment_append(RunEnvironment(self).vars):
bin_path = os.path.join("bin", "test_package")
arguments = "%sw+ Bincrafters" % ("\\" if self.settings.os == "Windows" else "\\\\")
if self.settings.os == "Windows":
self.run("%s %s" % (bin_path, arguments))
elif self.settings.os == "Macos":
self.run("DYLD_LIBRARY_PATH=%s %s %s" % (os.environ.get('DYLD_LIBRARY_PATH', ''), bin_path, arguments))
else:
self.run("LD_LIBRARY_PATH=%s %s %s" % (os.environ.get('LD_LIBRARY_PATH', ''), bin_path, arguments))
Loading

0 comments on commit 619e8eb

Please sign in to comment.