From 7b275bcd15e4acd92a59f4fa1c0172c41b56c404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Burtin?= Date: Sun, 22 Nov 2020 11:41:59 +0100 Subject: [PATCH 1/3] Add the possibility to specify regex backend --- recipes/libgit2/all/conanfile.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/recipes/libgit2/all/conanfile.py b/recipes/libgit2/all/conanfile.py index 3d9b06ac0ece3..e3c7b3a34dd52 100644 --- a/recipes/libgit2/all/conanfile.py +++ b/recipes/libgit2/all/conanfile.py @@ -22,6 +22,7 @@ class LibGit2Conan(ConanFile): "with_https": [False, "openssl", "mbedtls", "winhttp", "security"], "with_sha1": ["collisiondetection", "commoncrypto", "openssl", "mbedtls", "generic", "win32"], "with_ntlmclient": [True, False], + "with_regex": ["default", "builtin", "pcre", "pcre2"], } default_options = { "shared": False, @@ -32,6 +33,7 @@ class LibGit2Conan(ConanFile): "with_https": "openssl", "with_sha1": "collisiondetection", "with_ntlmclient": True, + "with_regex": "default", } @property @@ -84,6 +86,10 @@ def requirements(self): self.requires("mbedtls/2.16.3-gpl") if tools.is_apple_os(self.settings.os) and self.options.with_iconv: self.requires("libiconv/1.16") + if self.options.with_regex == "pcre": + self.requires("pcre/8.44") + elif self.options.with_regex == "pcre2": + self.requires("pcre2/10.35") def source(self): tools.get(**self.conan_data["sources"][self.version]) @@ -124,6 +130,9 @@ def _configure_cmake(self): cmake.definitions["BUILD_EXAMPLES"] = False cmake.definitions["USE_HTTP_PARSER"] = "system" + if self.options.with_regex != "default": + cmake.definitions["REGEX_BACKEND"] = self.options.with_regex + if self.settings.compiler == "Visual Studio": cmake.definitions["STATIC_CRT"] = "MT" in str(self.settings.compiler.runtime) From 199191bceb69d48d329730e25f625da0d0488443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Burtin?= Date: Wed, 2 Dec 2020 18:17:13 +0100 Subject: [PATCH 2/3] Handle auto with_regex option --- recipes/libgit2/all/conanfile.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/recipes/libgit2/all/conanfile.py b/recipes/libgit2/all/conanfile.py index e3c7b3a34dd52..d63fc426f4618 100644 --- a/recipes/libgit2/all/conanfile.py +++ b/recipes/libgit2/all/conanfile.py @@ -22,7 +22,7 @@ class LibGit2Conan(ConanFile): "with_https": [False, "openssl", "mbedtls", "winhttp", "security"], "with_sha1": ["collisiondetection", "commoncrypto", "openssl", "mbedtls", "generic", "win32"], "with_ntlmclient": [True, False], - "with_regex": ["default", "builtin", "pcre", "pcre2"], + "with_regex": ["auto", "builtin", "pcre", "pcre2", "regcomp_l", "regcomp"], } default_options = { "shared": False, @@ -33,7 +33,7 @@ class LibGit2Conan(ConanFile): "with_https": "openssl", "with_sha1": "collisiondetection", "with_ntlmclient": True, - "with_regex": "default", + "with_regex": "auto", } @property @@ -67,6 +67,10 @@ def configure(self): if self.settings.os != "Windows": raise ConanInvalidConfiguration("win32 is only valid on Windows") + if self.options.with_regex == "regcomp" or self.options.with_regex == "regcomp_l": + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration("{} isn't supported by Visual Studio".format(self.options.with_regex)) + @property def _need_openssl(self): return "openssl" in (self.options.with_https, self.options.with_sha1) @@ -75,6 +79,15 @@ def _need_openssl(self): def _need_mbedtls(self): return "mbedtls" in (self.options.with_https, self.options.with_sha1) + @property + def _with_regex(self): + if self.options.with_regex == "auto": + if tools.is_apple_os(self.settings.os): + return "regcomp_l" + else: + return "builtin" + return self.options.with_regex + def requirements(self): self.requires("zlib/1.2.11") self.requires("http_parser/2.9.4") @@ -130,8 +143,7 @@ def _configure_cmake(self): cmake.definitions["BUILD_EXAMPLES"] = False cmake.definitions["USE_HTTP_PARSER"] = "system" - if self.options.with_regex != "default": - cmake.definitions["REGEX_BACKEND"] = self.options.with_regex + cmake.definitions["REGEX_BACKEND"] = self._with_regex if self.settings.compiler == "Visual Studio": cmake.definitions["STATIC_CRT"] = "MT" in str(self.settings.compiler.runtime) From 6a732b533d96b7c08ad6fdcedd9f595854827518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Burtin?= Date: Thu, 3 Dec 2020 14:12:23 +0100 Subject: [PATCH 3/3] Update the regex option with the chosen backend when set to auto --- recipes/libgit2/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/libgit2/all/conanfile.py b/recipes/libgit2/all/conanfile.py index d63fc426f4618..f2aa621f12cf4 100644 --- a/recipes/libgit2/all/conanfile.py +++ b/recipes/libgit2/all/conanfile.py @@ -67,6 +67,7 @@ def configure(self): if self.settings.os != "Windows": raise ConanInvalidConfiguration("win32 is only valid on Windows") + self.options.with_regex = self._with_regex if self.options.with_regex == "regcomp" or self.options.with_regex == "regcomp_l": if self.settings.compiler == "Visual Studio": raise ConanInvalidConfiguration("{} isn't supported by Visual Studio".format(self.options.with_regex)) @@ -143,7 +144,7 @@ def _configure_cmake(self): cmake.definitions["BUILD_EXAMPLES"] = False cmake.definitions["USE_HTTP_PARSER"] = "system" - cmake.definitions["REGEX_BACKEND"] = self._with_regex + cmake.definitions["REGEX_BACKEND"] = self.options.with_regex if self.settings.compiler == "Visual Studio": cmake.definitions["STATIC_CRT"] = "MT" in str(self.settings.compiler.runtime)