Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql-connector-cpp:8.3.0 #17594

Closed
wants to merge 78 commits into from
Closed
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
c73e448
add mysql connector cpp
samuaz May 17, 2023
e677ff6
Merge branch 'master' into master
samuaz May 17, 2023
cc55bca
fix topic
samuaz May 17, 2023
359e741
fix topic
samuaz May 17, 2023
c10f75c
clean
samuaz May 17, 2023
cc9ac82
Update recipes/mysql-connector-cpp/all/conanfile.py
samuaz May 17, 2023
c1b519e
apply suggestions
samuaz May 17, 2023
35ebf16
Merge branch 'master' into master
samuaz May 17, 2023
5824edf
apply suggestions
samuaz May 17, 2023
a79b652
Merge branch 'master' into master
samuaz May 20, 2023
979d848
Merge branch 'master' into master
samuaz May 24, 2023
d9bd970
update minimal gcc version
samuaz May 25, 2023
a3118df
update minimal gcc version
samuaz May 25, 2023
b5c5e24
Merge branch 'master' into master
samuaz May 25, 2023
3b99960
remove protobuf dep
samuaz May 25, 2023
9302cda
fix mac build
samuaz May 25, 2023
e3c36a3
fix mac build
samuaz May 25, 2023
6a20bad
Merge branch 'master' into master
samuaz May 25, 2023
67baac8
fix mac build
samuaz May 25, 2023
37cf658
Merge branch 'master' of github-samuaz:samuaz/conan-center-index
samuaz May 25, 2023
2dbfc42
fix mac build
samuaz May 25, 2023
7987a44
Merge branch 'master' into master
samuaz Jun 15, 2023
f75015e
Update recipes/mysql-connector-cpp/all/conanfile.py
samuaz Aug 15, 2023
b0b24ca
Update recipes/mysql-connector-cpp/all/conanfile.py
samuaz Aug 15, 2023
ad19c6f
Update recipes/mysql-connector-cpp/all/conanfile.py
samuaz Aug 15, 2023
391ebc3
Update recipes/mysql-connector-cpp/all/conanfile.py
samuaz Aug 15, 2023
df6cff8
Merge branch 'master' into master
samuaz Aug 16, 2023
fc5ee7e
Update conanfile.py
samuaz Aug 16, 2023
4414110
Merge branch 'master' into master
samuaz Aug 16, 2023
6fb64fd
force to use openssl 1.1.1u for mac due to conan ci fails
samuaz Aug 16, 2023
d47f42d
Update recipes/mysql-connector-cpp/all/conanfile.py
samuaz Aug 27, 2023
1843fbe
Update recipes/mysql-connector-cpp/all/conanfile.py
samuaz Aug 27, 2023
a498fa7
Merge branch 'master' into master
samuaz Aug 27, 2023
bada841
Improve recipe support
uilianries Sep 4, 2023
b35b8ce
Merge pull request #2 from uilianries/mysql-connector
samuaz Feb 7, 2024
43b2859
Merge branch 'master' into master
samuaz Feb 7, 2024
4dd8ac7
Merge branch 'master' into master
samuaz Feb 7, 2024
ab680bc
Solve comments and update to 8.3.0 and mac support
samuaz Feb 15, 2024
d83ebac
Solve comments and update to 8.3.0 and mac support
samuaz Feb 15, 2024
461540f
Solve comments and update to 8.3.0 and mac support
samuaz Feb 15, 2024
8db4c5c
Solve comments and update to 8.3.0 and mac support
samuaz Feb 15, 2024
2864a1c
Merge branch 'master' into master
samuaz Feb 15, 2024
9f58017
Update libmysql dep to 8.1.0
samuaz Feb 15, 2024
72e6a94
Solve comments
samuaz Feb 16, 2024
cede1ff
Merge branch 'master' of github-samuaz:samuaz/conan-center-index
samuaz Feb 17, 2024
fd33645
fix tests
samuaz Feb 17, 2024
4c88722
Merge branch 'master' into master
samuaz Feb 17, 2024
ba130a8
mysql-connector-cpp add licenses to package
samuaz Feb 23, 2024
6575909
FIX license
samuaz Mar 3, 2024
811958b
Merge branch 'master' into master
samuaz Mar 3, 2024
294ae18
FIX IMPORT
samuaz Mar 3, 2024
d8fe9de
Merge branch 'master' of github-samuaz:samuaz/conan-center-index
samuaz Mar 3, 2024
f7f9385
clean up test
samuaz Mar 3, 2024
1049b14
fix build clean cmake config
samuaz Mar 3, 2024
2014f03
fix test withjdbc
samuaz Mar 3, 2024
f2c6f41
Update recipes/mysql-connector-cpp/all/test_package/conanfile.py
samuaz Mar 7, 2024
495e6d3
Update recipes/mysql-connector-cpp/all/conanfile.py
samuaz Mar 7, 2024
9dc26b6
Update recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt
samuaz Mar 7, 2024
057ae9c
Update recipes/mysql-connector-cpp/all/conanfile.py
samuaz Mar 7, 2024
a1bd617
Update recipes/mysql-connector-cpp/all/conanfile.py
samuaz Mar 7, 2024
4095a04
Updates
samuaz Mar 7, 2024
19f769b
Fix string check
uilianries Mar 11, 2024
d88c42d
mysql-connector-cpp remove oldest versions
samuaz Mar 11, 2024
b6efc0a
Merge branch 'master' of github-samuaz:samuaz/conan-center-index
samuaz Mar 11, 2024
f0b993d
Merge branch 'master' into master
samuaz Mar 11, 2024
0ae0935
mysql-connector-cpp remove oldest versions
samuaz Mar 12, 2024
17b55d6
mysql-connector-cpp remove oldest versions
samuaz Mar 12, 2024
a3b7502
mysql-connector-cpp remove oldest versions
samuaz Mar 12, 2024
e0e885a
mysql-connector-cpp remove oldest versions
samuaz Mar 12, 2024
cecbd17
mysql-connector-cpp remove oldest versions
samuaz Mar 12, 2024
f261d2c
Merge branch 'master' into master
samuaz Apr 20, 2024
0aa219c
add openssl
samuaz Apr 20, 2024
25487cf
add openssl
samuaz Apr 20, 2024
e51018c
Merge branch 'master' into master
samuaz May 26, 2024
09e8071
Merge branch 'master' into master
samuaz Jun 7, 2024
2863b27
mysql-connector-cpp just restart the build
samuaz Aug 1, 2024
64ad1d7
avoid duplicated symbols on ssl
samuaz Aug 1, 2024
86a5df4
mysql-connector-cpp try to avoid duplicated symbols in libcrypto
samuaz Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions recipes/mysql-connector-cpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sources:
"8.3.0":
samuaz marked this conversation as resolved.
Show resolved Hide resolved
url: "https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-8.3.0-src.tar.gz"
sha256: "a17bf1fad12b1ab17f5f6c7766289fb87200e919453234c3ec1664d7734be8f8"
"8.2.0":
url: "https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-8.2.0-src.tar.gz"
sha256: "9424668225c5a73f7b7805cd36d75d8502c9a8e20ca11c952653155ef6e909da"
"8.1.0":
url: "https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-8.1.0-src.tar.gz"
sha256: "2ee3c7d0d031ce581deeed747d9561d140172373592bed5d0630a790e6053dc1"
"8.0.33":
url: "https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-8.0.33-src.tar.gz"
sha256: "160cf6881fbde9bd46cd11aaf12930b676bc6e27589ac5c7ba49c196b97e053b"
165 changes: 165 additions & 0 deletions recipes/mysql-connector-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, CMakeDeps, cmake_layout
from conan.tools.files import get, replace_in_file, rm
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
from conan.tools.microsoft import check_min_vs, is_msvc
from conan.tools.build import check_min_cppstd
from conan.tools.env import VirtualBuildEnv
import os


requird_conan_version = ">=1.54.0"


class MysqlConnectorCPPRecipe(ConanFile):
name = "mysql-connector-cpp"
license = "GPL-2.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://dev.mysql.com/doc/connector-cpp/8.1/en/"
description = "A MySQL database connector for C++ applications that connect to MySQL servers"
topics = ("mysql", "connector", "libmysqlclient", "jdbc")
settings = "os", "compiler", "build_type", "arch"
samuaz marked this conversation as resolved.
Show resolved Hide resolved
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}

@property
def _min_cppstd(self):
return "17"
samuaz marked this conversation as resolved.
Show resolved Hide resolved

@property
def _compilers_minimum_version(self):
return {
"Visual Studio": "16",
"msvc": "192",
"gcc": "9" if Version(self.version) >= "8.0.27" else "5.3",
"clang": "6",
}

def layout(self):
cmake_layout(self, src_folder="src")

def build_requirements(self):
self.tool_requires("protobuf/3.21.12")

def requirements(self):
self.requires("zlib/1.2.13")
samuaz marked this conversation as resolved.
Show resolved Hide resolved
self.requires("lz4/1.9.4")
self.requires("zstd/1.5.5")
self.requires("protobuf/3.21.12")
self.requires("boost/1.83.0")
samuaz marked this conversation as resolved.
Show resolved Hide resolved
self.requires("openssl/[>=1.1.1 <4]")
self.requires("libmysqlclient/8.0.31")
samuaz marked this conversation as resolved.
Show resolved Hide resolved

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True, destination=self.source_folder)

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
check_min_vs(self, 192)
samuaz marked this conversation as resolved.
Show resolved Hide resolved
if not is_msvc(self):
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.")

# I dont have a windows computer to test it
samuaz marked this conversation as resolved.
Show resolved Hide resolved
if self.settings.os == "Windows":
raise ConanInvalidConfiguration(f"{self.ref} doesn't support windows for now")

# Sice 8.0.17 this doesn't support shared library on MacOS.
# https://github.com/mysql/mysql-server/blob/mysql-8.0.17/cmake/libutils.cmake#L333-L335
if self.settings.compiler == "apple-clang" and self.options.shared:
raise ConanInvalidConfiguration(f"{self.ref} doesn't support shared library on apple-clang")

# mysql < 8.0.29 uses `requires` in source code. It is the reserved keyword in C++20.
# https://github.com/mysql/mysql-server/blob/mysql-8.0.0/include/mysql/components/services/dynamic_loader.h#L270
if self.settings.compiler.get_safe("cppstd") == "20" and Version(self.version) < "8.0.29":
samuaz marked this conversation as resolved.
Show resolved Hide resolved
raise ConanInvalidConfiguration(f"{self.ref} doesn't support C++20")

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

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def _package_folder_dep(self, dep):
return self.dependencies[dep].package_folder.replace("\\", "/")

def _include_folder_dep(self, dep):
return self.dependencies[dep].cpp_info.includedirs[0].replace("\\", "/")

def _lib_folder_dep(self, dep):
return self.dependencies[dep].cpp_info.libdirs[0].replace("\\", "/")

def generate(self):
env = VirtualBuildEnv(self)
env.generate(scope="build")
tc = CMakeDeps(self)
tc.generate()
tc = CMakeToolchain(self)
tc.variables["WITH_JDBC"] = True
tc.variables["WITHOUT_SERVER"] = True
# INFO: mysql-connector-cpp caches all option values. Need to use cache_variables
tc.cache_variables["BUILD_STATIC"] = not self.options.shared
tc.cache_variables["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True)
samuaz marked this conversation as resolved.
Show resolved Hide resolved
# INFO: mysql-connector-cpp doesn't use find package for cmake. Need to pass manually folder paths
tc.variables["MYSQL_LIB_DIR"] = self._lib_folder_dep("libmysqlclient")
tc.variables["MYSQL_INCLUDE_DIR"] = self._include_folder_dep("libmysqlclient")
tc.variables["Boost_INCLUDE_DIRS"] = self._include_folder_dep("boost")
tc.variables["Boost_LIB_DIRS"] = self._lib_folder_dep("boost")
# INFO: Some dependencies can be found in mysql-connector-cpp source folder. Need to set to use Conan package
tc.cache_variables["WITH_SSL"] = self._package_folder_dep("openssl")
tc.cache_variables["WITH_BOOST"] = self._package_folder_dep("boost")
tc.cache_variables["WITH_ZLIB"] = self._package_folder_dep("zlib")
tc.cache_variables["WITH_LZ4"] = self._package_folder_dep("lz4")
tc.cache_variables["WITH_ZSTD"] = self._package_folder_dep("zstd")
tc.cache_variables["WITH_PROTOBUF"] = self._package_folder_dep("protobuf")
tc.generate()

def _patch_sources(self):
# INFO: Disable internal bootstrap to use Conan CMakeToolchain instead
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "bootstrap()", "")
# INFO: Manage fPIC from recipe options
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), "enable_pic()", "")
replace_in_file(self, os.path.join(self.source_folder, "cdk", "CMakeLists.txt"), "enable_pic()", "")
protobuf = "protobufd" if self.dependencies["protobuf"].settings.build_type == "Debug" else "protobuf"
# INFO: Disable protobuf-lite to use Conan protobuf targets instead
replace_in_file(self, os.path.join(self.source_folder, "cdk", "cmake", "DepFindProtobuf.cmake"), "LIBRARY protobuf-lite pb_libprotobuf-lite", "")
# INFO: Fix protobuf library name according to the build type
replace_in_file(self, os.path.join(self.source_folder, "cdk", "cmake", "DepFindProtobuf.cmake"), "LIBRARY protobuf", f"LIBRARY {protobuf}")
# INFO: Disable protobuf-lite to use Conan protobuf targets instead
replace_in_file(self, os.path.join(self.source_folder, "cdk", "protocol", "mysqlx", "CMakeLists.txt"), "ext::protobuf-lite", f"ext::{protobuf}")
# INFO: Disable protobuf-lite to use Conan protobuf targets instead
replace_in_file(self, os.path.join(self.source_folder, "cdk", "core", "CMakeLists.txt"), "ext::protobuf-lite", f"ext::{protobuf}")
if self.settings.os == "Windows":
# INFO: On Windows, libraries names change
zlib = "zdll" if self.dependencies["zlib"].options.shared else "zlib"
zstd = "zstd" if self.dependencies["zstd"].options.shared else "zstd_static"
replace_in_file(self, os.path.join(self.source_folder, "cdk", "cmake", "DepFindCompression.cmake"), "add_ext(zlib zlib.h z ext_zlib)", f"add_ext(zlib zlib.h {zlib} ext_zlib)")
replace_in_file(self, os.path.join(self.source_folder, "cdk", "protocol", "mysqlx", "CMakeLists.txt"), "ext::z ext::lz4 ext::zstd", f"ext::{zlib} ext::lz4 ext::{zstd}")
replace_in_file(self, os.path.join(self.source_folder, "cdk", "cmake", "DepFindCompression.cmake"), "add_ext(zstd zstd.h zstd ext_zstd)", f"add_ext(zstd zstd.h {zstd} ext_zstd)")

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

def package(self):
cmake = CMake(self)
cmake.install()
rm(self, "INFO_SRC", self.package_folder)
rm(self, "INFO_BIN", self.package_folder)

def package_info(self):
self.cpp_info.libdirs = ["lib64/debug","lib/debug"] if self.settings.build_type == "Debug" else ["lib64", "lib"]
suffix = "" if self.options.shared else "-static"
self.cpp_info.libs = [f"mysqlcppconn{suffix}", f"mysqlcppconn8{suffix}"]

if self.settings.os in ["Linux", "FreeBSD", "Macos"]:
self.cpp_info.system_libs = ["m", "resolv"]
elif self.settings.os == "Windows":
self.cpp_info.system_libs = ["ws2_32"]
8 changes: 8 additions & 0 deletions recipes/mysql-connector-cpp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(MySQLConnectorCPPTest CXX)

find_package(mysql-connector-cpp REQUIRED CONFIG)

add_executable(test_package test_package.cpp)
target_link_libraries(test_package mysql-connector-cpp::mysql-connector-cpp)
target_compile_features(test_package PRIVATE cxx_std_17)
26 changes: 26 additions & 0 deletions recipes/mysql-connector-cpp/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

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

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
11 changes: 11 additions & 0 deletions recipes/mysql-connector-cpp/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>
#include <mysql/jdbc.h>
#include <jdbc/mysql_driver.h>
#include <jdbc/cppconn/driver.h>
#include <jdbc/cppconn/exception.h>

int main() {
auto driver = sql::mysql::get_mysql_driver_instance();
std::cout << "MySQL connector cpp works" << std::endl;
return 0;
}
9 changes: 9 additions & 0 deletions recipes/mysql-connector-cpp/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
versions:
"8.3.0":
folder: all
"8.2.0":
folder: all
"8.1.0":
folder: all
"8.0.33":
folder: all
Loading