Skip to content

Commit

Permalink
scnlib: add version 4.0.1, 3.0.2 (#25814)
Browse files Browse the repository at this point in the history
Co-authored-by: Luis Caro Campos <[email protected]>
Co-authored-by: Abril Rincón Blanco <[email protected]>
  • Loading branch information
3 people authored Nov 4, 2024
1 parent 10c6933 commit 3ddb2da
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 322 deletions.
67 changes: 6 additions & 61 deletions recipes/scnlib/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,13 @@
sources:
"4.0.1":
url: "https://github.com/eliaskosunen/scnlib/archive/refs/tags/v4.0.1.tar.gz"
sha256: "ece17b26840894cc57a7127138fe4540929adcb297524dec02c490c233ff46a7"
"3.0.2":
url: "https://github.com/eliaskosunen/scnlib/archive/refs/tags/v3.0.2.tar.gz"
sha256: "27f17420ddad6971339e6d5db0d915204181c31f5cb0e92a63b9998d98e2852b"
"3.0.1":
url: "https://github.com/eliaskosunen/scnlib/archive/refs/tags/v3.0.1.tar.gz"
sha256: "bc8a668873601d00cce6841c2d0f2c93f836f63f0fbc77997834dea12e951eb1"
"2.0.3":
url: "https://github.com/eliaskosunen/scnlib/archive/refs/tags/v2.0.3.tar.gz"
sha256: "507ed0e988f1d9460a9c921fc21f5a5244185a4015942f235522fbe5c21e6a51"
"2.0.2":
url: "https://github.com/eliaskosunen/scnlib/archive/refs/tags/v2.0.2.tar.gz"
sha256: "a485076b8710576cf05fbc086d39499d16804575c0660b0dfaeeaf7823660a17"
"2.0.1":
url: "https://github.com/eliaskosunen/scnlib/archive/refs/tags/v2.0.1.tar.gz"
sha256: "f399d1b1f36f5d53a2d63fd2974797ab8f3f7e69c424d9661253830cb793b72e"
"2.0.0":
url: "https://github.com/eliaskosunen/scnlib/archive/refs/tags/v2.0.0.tar.gz"
sha256: "2a35356a3a7485fdf97f28cfbea52db077cf4e7bab0a5a0fc3b04e89630334cd"
"1.1.3":
url: "https://github.com/eliaskosunen/scnlib/archive/refs/tags/v1.1.3.tar.gz"
sha256: "32ca1baed2da5d86aa03273c87580ef32e95925697d252138507ec0545d86ab2"
"1.1.2":
url: "https://github.com/eliaskosunen/scnlib/archive/refs/tags/v1.1.2.tar.gz"
sha256: "5ed3ec742302c7304bf188bde9c4012a65dc8124ff4e1a69b598480d664250e6"
"1.0":
url: "https://github.com/eliaskosunen/scnlib/archive/refs/tags/v1.0.tar.gz"
sha256: "5b8333e522206c2a74e57a9c9544c4fe4e7858cfe93e216905b463eaf91af5fe"
patches:
"2.0.2":
- patch_file: "patches/2.0.0-0001-remove-re2-version.patch"
patch_description: "remove re2 version on find_package"
patch_type: "portability"
"2.0.1":
- patch_file: "patches/2.0.0-0001-remove-re2-version.patch"
patch_description: "remove re2 version on find_package"
patch_type: "portability"
"2.0.0":
- patch_file: "patches/2.0.0-0001-remove-re2-version.patch"
patch_description: "remove re2 version on find_package"
patch_type: "portability"
"1.1.3":
- patch_file: "patches/1.1.3-0001-install-dll-windows.patch"
patch_description: "add runtime destination path on install"
patch_type: "portability"
- patch_file: "patches/1.1.3-0002-remove-header-only-target.patch"
patch_description: "prevent to generate header only target for conan package"
patch_type: "conan"
- patch_file: "patches/1.1.3-0003-fix-link-keyword.patch"
patch_description: "use PRIVATE instead of INTERFACE"
patch_type: "conan"
"1.1.2":
- patch_file: "patches/1.1.2-0001-install-dll-windows.patch"
patch_description: "add runtime destination path on install"
patch_type: "portability"
- patch_file: "patches/1.1.2-0002-remove-header-only-target.patch"
patch_description: "prevent to generate header only target for conan package"
patch_type: "conan"
- patch_file: "patches/1.1.2-0003-fix-link-keyword.patch"
patch_description: "use PRIVATE instead of INTERFACE"
patch_type: "conan"
"1.0":
- patch_file: "patches/1.0-0001-install-dll-windows.patch"
patch_description: "add runtime destination path on install"
patch_type: "portability"
- patch_file: "patches/1.0-0002-remove-header-only-target.patch"
patch_description: "prevent to generate header only target for conan package"
patch_type: "conan"
- patch_file: "patches/1.0-0003-use-conan-package.patch"
patch_description: "use conan package of fast-float"
patch_type: "conan"
92 changes: 27 additions & 65 deletions recipes/scnlib/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conan import ConanFile
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir
from conan.tools.files import get, copy, rm, rmdir
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.layout import basic_layout
Expand All @@ -9,7 +9,7 @@

import os

required_conan_version = ">=1.53.0"
required_conan_version = ">=2.0"

class ScnlibConan(ConanFile):
name = "scnlib"
Expand All @@ -35,38 +35,15 @@ class ScnlibConan(ConanFile):

@property
def _min_cppstd(self):
if Version(self.version) < "2.0.0":
return "11"
else:
# scn/2.0.0 has complation error on MSVC c++17
# we have to use versions which support c++20
# https://github.com/eliaskosunen/scnlib/issues/97
# https://github.com/conan-io/conan-center-index/pull/22455#issuecomment-1924444193
return "20" if is_msvc(self) else "17"

@property
def _compilers_minimum_version(self):
return {
"17": {
"gcc": "8",
"clang": "7",
# scn/2.0.0 requires std::regex_constants::multiline
"apple-clang": "14",
},
"20": {
"Visual Studio": "17",
"msvc": "193",
}
}.get(self._min_cppstd, {})

def export_sources(self):
export_conandata_patches(self)
# scn/2.0.0 has complation error on MSVC c++17
# we have to use versions which support c++20
# https://github.com/eliaskosunen/scnlib/issues/97
# https://github.com/conan-io/conan-center-index/pull/22455#issuecomment-1924444193
return "20" if is_msvc(self) else "17"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if Version(self.version) < "2.0":
del self.options.regex_backend

def configure(self):
if self.options.get_safe("header_only") or self.options.shared:
Expand All @@ -83,7 +60,7 @@ def layout(self):

def requirements(self):
self.requires("fast_float/6.1.0")
if "2.0" <= Version(self.version) < "3.0":
if Version(self.version) < "3.0":
self.requires("simdutf/4.0.5")
if self.options.get_safe("regex_backend") in ["boost", "boost_icu"]:
self.requires("boost/1.83.0")
Expand All @@ -95,21 +72,17 @@ def package_id(self):
self.info.clear()

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)
check_min_cppstd(self, self._min_cppstd)

if self.options.get_safe("regex_backend") == "boost_icu" and \
not self.dependencies["boost"].options.get_safe("i18n_backend_icu"):
raise ConanInvalidConfiguration(
f"{self.ref} with regex_backend=Boost_icu option requires boost::i18n_backend_icu to be enabled."
)
if Version(self.version) >= "2.0.0" and self.options.header_only:
# TODO: This should probably be a del self.options.header_only in config_options once the CI supports it
if self.options.header_only:
raise ConanInvalidConfiguration(f"{self.ref} doesn't support header only mode.")
if Version(self.version) >= "2.0.0" and self.settings.compiler == "gcc" and Version(self.settings.compiler.version).major == "11":
if self.settings.compiler == "gcc" and Version(self.settings.compiler.version).major == "11":
raise ConanInvalidConfiguration(f"{self.ref} doesn't support gcc 11.x due to std::regex_constants::multiline is not defined.")

def build_requirements(self):
Expand All @@ -129,24 +102,21 @@ def generate(self):
tc.variables["SCN_DOCS"] = False
tc.variables["SCN_INSTALL"] = True
tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
if Version(self.version) < "2.0":
tc.variables["SCN_USE_BUNDLED_FAST_FLOAT"] = False
else:
tc.variables["SCN_USE_EXTERNAL_SIMDUTF"] = True
tc.variables["SCN_USE_EXTERNAL_FAST_FLOAT"] = True
tc.variables["SCN_BENCHMARKS_BUILDTIME"] = False
tc.variables["SCN_BENCHMARKS_BINARYSIZE"] = False
tc.variables["SCN_DISABLE_REGEX"] = self.options.regex_backend is None
if self.options.regex_backend is not None:
tc.variables["SCN_REGEX_BACKEND"] = self.options.regex_backend
tc.variables["SCN_USE_EXTERNAL_REGEX_BACKEND"] = True

tc.variables["SCN_USE_EXTERNAL_SIMDUTF"] = True
tc.variables["SCN_USE_EXTERNAL_FAST_FLOAT"] = True
tc.variables["SCN_BENCHMARKS_BUILDTIME"] = False
tc.variables["SCN_BENCHMARKS_BINARYSIZE"] = False
tc.variables["SCN_DISABLE_REGEX"] = self.options.regex_backend is None
if self.options.regex_backend is not None:
tc.variables["SCN_REGEX_BACKEND"] = self.options.regex_backend
tc.variables["SCN_USE_EXTERNAL_REGEX_BACKEND"] = True
tc.generate()

deps = CMakeDeps(self)
deps.generate()

def build(self):
apply_conandata_patches(self)
if not self.options.get_safe("header_only"):
cmake = CMake(self)
cmake.configure()
Expand All @@ -157,13 +127,10 @@ def package(self):
if self.options.get_safe("header_only"):
copy(self, "*", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include"))
src_folder = os.path.join(self.source_folder, "src")
if Version(self.version) >= "1.0":
copy(self, "reader_*.cpp", src=src_folder, dst=os.path.join(self.package_folder, "include", "scn", "reader"))
copy(self, "vscan.cpp", src=src_folder, dst=os.path.join(self.package_folder, "include", "scn", "scan"))
copy(self, "locale.cpp", src=src_folder, dst=os.path.join(self.package_folder, "include", "scn", "detail"))
copy(self, "file.cpp", src=src_folder, dst=os.path.join(self.package_folder, "include", "scn", "detail"))
else:
copy(self, "*.cpp", src=src_folder, dst=os.path.join(self.package_folder, "include", "scn", "detail"))
copy(self, "reader_*.cpp", src=src_folder, dst=os.path.join(self.package_folder, "include", "scn", "reader"))
copy(self, "vscan.cpp", src=src_folder, dst=os.path.join(self.package_folder, "include", "scn", "scan"))
copy(self, "locale.cpp", src=src_folder, dst=os.path.join(self.package_folder, "include", "scn", "detail"))
copy(self, "file.cpp", src=src_folder, dst=os.path.join(self.package_folder, "include", "scn", "detail"))
else:
cmake = CMake(self)
cmake.install()
Expand All @@ -184,13 +151,8 @@ def package_info(self):
self.cpp_info.components["_scnlib"].defines = ["SCN_HEADER_ONLY=0"]
self.cpp_info.components["_scnlib"].libs = ["scn"]
self.cpp_info.components["_scnlib"].requires.append("fast_float::fast_float")
if "2.0" <= Version(self.version) < "3.0":
if Version(self.version) < "3.0":
self.cpp_info.components["_scnlib"].requires.append("simdutf::simdutf")
if Version(self.version) >= "2.0":
if self.options.get_safe("regex_backend") in ["boost", "boost_icu"]:
self.cpp_info.components["_scnlib"].requires.append("boost::regex")
elif self.options.get_safe("regex_backend") == "re2":
self.cpp_info.components["_scnlib"].requires.append("re2::re2")

if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["_scnlib"].system_libs.append("m")
Expand Down
12 changes: 0 additions & 12 deletions recipes/scnlib/all/patches/1.0-0001-install-dll-windows.patch

This file was deleted.

This file was deleted.

35 changes: 0 additions & 35 deletions recipes/scnlib/all/patches/1.0-0003-use-conan-package.patch

This file was deleted.

12 changes: 0 additions & 12 deletions recipes/scnlib/all/patches/1.1.2-0001-install-dll-windows.patch

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions recipes/scnlib/all/patches/1.1.2-0003-fix-link-keyword.patch

This file was deleted.

12 changes: 0 additions & 12 deletions recipes/scnlib/all/patches/1.1.3-0001-install-dll-windows.patch

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3ddb2da

Please sign in to comment.