This repository has been archived by the owner on Oct 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
conanfile.py
82 lines (63 loc) · 3.02 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
import glob
import os
class MysqlConnectorCConan(ConanFile):
name = "mysql-connector-c"
version = "6.1.11"
url = "https://github.com/bincrafters/conan-mysql-connector-c"
description = "A MySQL client library for C development."
topics = ("conan", "mysql", "sql", "connector", "database")
homepage = "https://dev.mysql.com/downloads/connector/c/"
author = "Bincrafters <[email protected]>"
license = "GPL-2.0"
exports = ["LICENSE.md"]
exports_sources = ["CMakeLists.txt", "patches/*.patch"]
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False], "with_ssl": [True, False], "with_zlib": [True, False]}
default_options = {'shared': False, 'with_ssl': True, 'with_zlib': True}
_source_subfolder = "source_subfolder"
def requirements(self):
if self.options.with_ssl:
self.requires.add("OpenSSL/1.0.2s@conan/stable")
if self.options.with_zlib:
self.requires.add("zlib/1.2.11@conan/stable")
def source(self):
sha256 = "c8664851487200162b38b6f3c8db69850bd4f0e4c5ff5a6d161dbfb5cb76b6c4"
source_url = "http://dev.mysql.com/get/Downloads/Connector-C"
archive_name = self.name + "-" + self.version + "-src"
ext = "tar.gz"
tools.get("{0}/{1}.{2}".format(source_url, archive_name, ext), sha256=sha256)
os.rename(archive_name, self._source_subfolder)
sources_cmake = os.path.join(self._source_subfolder, "CMakeLists.txt")
sources_cmake_orig = os.path.join(self._source_subfolder, "CMakeListsOriginal.txt")
os.rename(sources_cmake, sources_cmake_orig)
os.rename("CMakeLists.txt", sources_cmake)
def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
def build(self):
for filename in glob.glob("patches/*.patch"):
self.output.info('applying patch "%s"' % filename)
tools.patch(base_path=self._source_subfolder, patch_file=filename)
cmake = CMake(self)
cmake.definitions["DISABLE_SHARED"] = not self.options.shared
cmake.definitions["DISABLE_STATIC"] = self.options.shared
cmake.definitions["STACK_DIRECTION"] = "-1" # stack grows downwards, on very few platforms stack grows upwards
if self.settings.compiler == "Visual Studio":
if self.settings.compiler.runtime == "MD" or self.settings.compiler.runtime == "MDd":
cmake.definitions["WINDOWS_RUNTIME_MD"] = True
if self.options.with_ssl:
cmake.definitions["WITH_SSL"] = "system"
if self.options.with_zlib:
cmake.definitions["WITH_ZLIB"] = "system"
cmake.configure(source_dir=self._source_subfolder)
cmake.build()
cmake.install()
def package(self):
pass
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.bindirs = ['lib']