-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
97 lines (86 loc) · 4.44 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, AutoToolsBuildEnvironment, tools
from conans.errors import ConanInvalidConfiguration
import os
class LibpqConan(ConanFile):
name = "libpq"
version = "10.4"
description = "The library used by all the standard PostgreSQL tools."
topics = ("conan", "libpq", "postgresql", "database", "db")
url = "https://github.com/zinnion/conan-libpq"
homepage = "https://www.postgresql.org/docs/current/static/libpq.html"
author = "Zinnion <mauro@zinnion.com>"
license = "PostgreSQL"
exports = ["LICENSE.md"]
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_zlib": [True, False],
"with_openssl": [True, False]}
default_options = {'shared': False, 'fPIC': True, 'with_zlib': True, 'with_openssl': True}
_source_subfolder = "source_subfolder"
_build_subfolder = None
_autotools = None
generators = ["cmake_find_package","cmake"]
def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC
del self.options.shared
def configure(self):
if self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
raise ConanInvalidConfiguration("Visual Studio is not supported yet.")
del self.settings.compiler.libcxx
def requirements(self):
if self.options.with_zlib:
self.requires.add("zlib/1.2.11@zinnion/stable")
if self.options.with_openssl:
self.requires.add("OpenSSL/1.1.1d@zinnion/stable")
def source(self):
source_url = "https://ftp.postgresql.org/pub/source"
sha256 = "60192bc75cd73e688500e8350ea065cca032e21abe57e72d4f556e0bf84fcf17"
tools.get("{0}/v{1}/postgresql-{2}.tar.gz".format(source_url, self.version, self.version), sha256=sha256)
extracted_dir = "postgresql-" + self.version
os.rename(extracted_dir, self._source_subfolder)
def _configure_autotools(self):
if not self._autotools:
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
self._build_subfolder = os.path.join(self.build_folder, "output")
args = ['--without-readline']
args.append('--with-zlib' if self.options.with_zlib else '--without-zlib')
args.append('--with-openssl' if self.options.with_openssl else '--without-openssl')
with tools.chdir(self._source_subfolder):
self._autotools.configure(args=args)
return self._autotools
def build(self):
autotools = self._configure_autotools()
with tools.chdir(os.path.join(self._source_subfolder, "src", "common")):
autotools.make()
with tools.chdir(os.path.join(self._source_subfolder, "src", "interfaces", "libpq")):
autotools.make()
def package(self):
self.copy(pattern="COPYRIGHT", dst="licenses", src=self._source_subfolder)
autotools = self._configure_autotools()
with tools.chdir(os.path.join(self._source_subfolder, "src", "common")):
autotools.install()
with tools.chdir(os.path.join(self._source_subfolder, "src", "interfaces", "libpq")):
autotools.install()
self.copy(pattern="*.h", dst="include", src=os.path.join(self._build_subfolder, "include"),keep_path=False)
self.copy(pattern="postgres_ext.h", dst="include", src=os.path.join(self._source_subfolder, "src", "include"),keep_path=False)
self.copy(pattern="pg_config_ext.h", dst="include", src=os.path.join(self._source_subfolder, "src", "include"),keep_path=False)
if self.settings.os == "Linux":
pattern = "*.so*" if self.options.shared else "*.a"
elif self.settings.os == "Macos":
pattern = "*.dylib" if self.options.shared else "*.a"
elif self.settings.os == "Windows":
pattern = "*.a"
self.copy(pattern="*.dll", dst="bin", src=os.path.join(self._build_subfolder, "bin"),keep_path=False)
self.copy(pattern=pattern, dst="lib", src=os.path.join(self._build_subfolder, "lib"),keep_path=False)
def package_info(self):
#self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.libs = ["pq"]
if self.settings.os == "Linux":
self.cpp_info.libs.append("pthread")
elif self.settings.os == "Windows":
self.cpp_info.libs.append("ws2_32")