From 6571cad5ff9dbf6885b047a246cd39acaf521c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Tue, 1 Jul 2025 10:44:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=80=D0=BE=D0=B4=D0=B5=20=D1=83=D1=81?= =?UTF-8?q?=D0=BF=D0=B5=D1=88=D0=BD=D0=B0=D1=8F=20=D1=83=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BA=D0=B0=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7?= =?UTF-8?q?=20Conan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + conanfile.py | 2 +- .../libmysqlclient_fix/conandata.yml | 4 + .../libmysqlclient_fix/conanfile.py | 96 +++++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 custom_recipes/libmysqlclient_fix/conandata.yml create mode 100644 custom_recipes/libmysqlclient_fix/conanfile.py diff --git a/README.md b/README.md index 5c3d4ae..6d7a011 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ conan export custom_recipes/openssl_fix/ --user=up_and_down --channel=stable conan export custom_recipes/lz4_fix/ --user=up_and_down --channel=stable conan export custom_recipes/zlib_fix/ --user=up_and_down --channel=stable conan export custom_recipes/zstd_fix/ --user=up_and_down --channel=stable +conan export custom_recipes/libmysqlclient_fix/ --user=up_and_down --channel=stable // Запуск дебага conan install . -pr ./profiles/debug_profile --output-folder=cmake-build-debug --build=missing diff --git a/conanfile.py b/conanfile.py index b249585..41f16ae 100644 --- a/conanfile.py +++ b/conanfile.py @@ -9,7 +9,7 @@ class UpAndDown(ConanFile): def requirements(self): self.requires("boost/1.87.0@up_and_down/stable") - self.requires("libmysqlclient/8.1.0") + self.requires("libmysqlclient/8.1.0@up_and_down/stable", override=True) self.requires("lz4/1.10.0@up_and_down/stable", override=True) self.requires("openssl/3.5.0@up_and_down/stable", force=True) self.requires("zlib/1.3.1@up_and_down/stable", override=True) diff --git a/custom_recipes/libmysqlclient_fix/conandata.yml b/custom_recipes/libmysqlclient_fix/conandata.yml new file mode 100644 index 0000000..9dd23d2 --- /dev/null +++ b/custom_recipes/libmysqlclient_fix/conandata.yml @@ -0,0 +1,4 @@ +sources: + "8.1.0": + url: "https://dev.mysql.com/get/Downloads/MySQL-8.1/mysql-8.1.0.tar.gz" + sha256: "3dd017a940734aa90796a4c65e125e6712f64bbbbe3388d36469deaa87b599eb" diff --git a/custom_recipes/libmysqlclient_fix/conanfile.py b/custom_recipes/libmysqlclient_fix/conanfile.py new file mode 100644 index 0000000..c28a0f6 --- /dev/null +++ b/custom_recipes/libmysqlclient_fix/conanfile.py @@ -0,0 +1,96 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import get, copy, rmdir +import os + +class LibmysqlclientConan(ConanFile): + name = "libmysqlclient" + version = "8.1.0" + description = "MySQL client library" + license = "GPL-2.0" + url = "https://dev.mysql.com/" + homepage = "https://www.mysql.com" + topics = ("mysql", "database", "sql") + settings = "os", "compiler", "build_type", "arch" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + + # Критически важные настройки + tc.variables["WITHOUT_SERVER"] = "ON" + tc.variables["WITH_UNIT_TESTS"] = "OFF" + tc.variables["DISABLE_SHARED"] = "OFF" if self.options.shared else "ON" + tc.variables["DISABLE_STATIC"] = "ON" if self.options.shared else "OFF" + + # Настройки для Windows + if self.settings.os == "Windows": + tc.variables["WITH_SSL"] = "schannel" + tc.variables["WITH_ZLIB"] = "bundled" + if "MD" in str(self.settings.compiler.runtime): + tc.variables["WINDOWS_RUNTIME_MD"] = "ON" + else: + tc.variables["WITH_SSL"] = "system" + tc.variables["WITH_ZLIB"] = "system" + + tc.generate() + + def build(self): + cmake = CMake(self) + self.run("cmake --version") + self.run("cmake -E chdir . ls -la", shell=True) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + # Копируем только необходимые файлы + copy(self, "*.h", + src=os.path.join(self.source_folder, "include"), + dst=os.path.join(self.package_folder, "include")) + + copy(self, "*.lib", + src=os.path.join(self.build_folder, "library_output_directory"), + dst=os.path.join(self.package_folder, "lib")) + + copy(self, "*.dll", + src=os.path.join(self.build_folder, "library_output_directory"), + dst=os.path.join(self.package_folder, "bin")) + + # Удаляем ненужные файлы + rmdir(self, os.path.join(self.package_folder, "docs")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "bin", "Debug")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.libs = ["mysqlclient"] + self.cpp_info.includedirs = ["include", "include/mysql"] + + if self.settings.os == "Windows": + self.cpp_info.system_libs = ["ws2_32", "crypt32", "secur32", "shlwapi", "advapi32"] + if self.options.shared: + self.cpp_info.defines = ["LIBMYSQL_DYNAMIC"] \ No newline at end of file