forked from DEGoodmanWilson/conan-gnutls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
132 lines (106 loc) · 6.28 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
from conans import ConanFile
import os, shutil
from conans.tools import download, unzip, replace_in_file, check_md5
from conans import CMake
class GnutlsConan(ConanFile):
name = "gnutls"
version = "3.4.16"
branch = "master"
ZIP_FOLDER_NAME = "gnutls-%s" % version
generators = "cmake"
settings = "os", "compiler", "arch", "build_type"
options = {"shared": [True, False],
"enable_m_guard": [True, False],
"disable_asm": [True, False],
"enable_ld_version_script": [True, False],
"disable_endian_check": [True, False],
"enable_random_daemon": [True, False],
"enable_hmac_binary_check": [True, False],
"disable_padlock_support": [True, False],
"disable_aesni_support": [True, False],
"disable_O_flag_munging": [True, False]}
#TODO add in non-binary flags
requires = 'libiconv/1.14@lasote/stable', 'nettle/3.3@DEGoodmanWilson/testing', 'gmp/6.1.1@DEGoodmanWilson/testing', 'zlib/1.2.8@lasote/stable'
# TODO add p11-kit http://p11-glue.freedesktop.org/p11-kit.html and libidn and libdane
url = "http://github.com/DEGoodmanWilson/conan-gnutls"
default_options = "shared=False", "enable_m_guard=False", "disable_asm=False", \
"enable_ld_version_script=False", "disable_endian_check=False", \
"enable_random_daemon=False", "disable_aesni_support=False", \
"enable_hmac_binary_check=False", "disable_padlock_support=False", "disable_O_flag_munging=False"
def source(self):
zip_name = "gnutls-%s.tar.gz" % self.version
# download("http://ftp.heanet.ie/mirrors/ftp.gnupg.org/gcrypt/gnutls/v3.4/%s" % zip_name, zip_name)
download("https://www.dropbox.com/s/7h0a0b0gfmkjp42/%s?dl=1" % zip_name, zip_name)
check_md5(zip_name, "093777651b9cb41f66122991c5bf3d42")
unzip(zip_name)
os.unlink(zip_name)
def config(self):
del self.settings.compiler.libcxx
def generic_env_configure_vars(self, verbose=False):
"""Reusable in any lib with configure!!"""
# find nettle and hogweed paths
nettle_lib_path = ""
nettle_include_path = ""
gmp_lib_path = ""
gmp_include_path = ""
for path in self.deps_cpp_info.lib_paths:
if "nettle" in path:
nettle_lib_path = path
elif "gmp" in path:
gmp_lib_path = path
for path in self.deps_cpp_info.include_paths:
if "nettle" in path:
nettle_include_path = path
elif "gmp" in path:
gmp_include_path = path
if self.settings.os == "Linux" or self.settings.os == "Macos":
libs = 'LIBS="%s"' % " ".join(["-l%s" % lib for lib in self.deps_cpp_info.libs])
ldflags = 'LDFLAGS="%s -liconv"' % " ".join(["-L%s" % lib for lib in self.deps_cpp_info.lib_paths])
archflag = "-m32" if self.settings.arch == "x86" else ""
cflags = 'CFLAGS="-fPIC %s %s %s"' % (archflag, " ".join(self.deps_cpp_info.cflags), " ".join(['-I"%s"' % lib for lib in self.deps_cpp_info.include_paths]))
cpp_flags = 'CPPFLAGS="%s %s %s"' % (archflag, " ".join(self.deps_cpp_info.cppflags), " ".join(['-I"%s"' % lib for lib in self.deps_cpp_info.include_paths]))
package_flags = 'NETTLE_CFLAGS="-I%s" NETTLE_LIBS="-L%s -lnettle" HOGWEED_CFLAGS="-I%s" HOGWEED_LIBS="-L%s -lhogweed" GMP_CFLAGS="-I%s" GMP_LIBS="-L%s -lgmp"' % (nettle_include_path, nettle_lib_path, nettle_include_path, nettle_lib_path, gmp_include_path, gmp_lib_path)
command = "env %s %s %s %s %s" % (libs, ldflags, cflags, cpp_flags, package_flags)
elif self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
cl_args = " ".join(['/I"%s"' % lib for lib in self.deps_cpp_info.include_paths])
lib_paths= ";".join(['"%s"' % lib for lib in self.deps_cpp_info.lib_paths])
command = "SET LIB=%s;%%LIB%% && SET CL=%s" % (lib_paths, cl_args)
if verbose:
command += " && SET LINK=/VERBOSE"
return command
def build(self):
if self.settings.os == "Windows":
self.output.fatal("Cannot build on Windows, sorry!")
return # no can do boss!
self.build_with_configure()
def build_with_configure(self):
config_options_string = ""
for option_name in self.options.values.fields:
activated = getattr(self.options, option_name)
if activated:
self.output.info("Activated option! %s" % option_name)
config_options_string += " --%s" % option_name.replace("_", "-")
iconv_prefix = ""
for path in self.deps_cpp_info.lib_paths:
if "iconv" in path:
iconv_prefix = '/lib'.join(path.split("/lib")[0:-1]) #remove the final /lib. There are probably better ways to do this.
break
# TODO remove --without-p11-kit
configure_command = "cd %s && %s ./configure --enable-static --enable-shared --without-p11-kit --without-idn --with-included-libtasn1 --enable-local-libopts --with-libiconv-prefix=%s %s" % (self.ZIP_FOLDER_NAME, self.generic_env_configure_vars(), iconv_prefix, config_options_string)
self.output.warn(configure_command)
self.run(configure_command)
self.run("cd %s && make" % self.ZIP_FOLDER_NAME)
def package(self):
if self.settings.os == "Windows":
self.output.fatal("Cannot build on Windows, sorry!")
return
self.copy("*.h", dst="include", src="%s/src" % (self.ZIP_FOLDER_NAME), keep_path=True)
self.copy("*.h", dst="include", src="%s/lib/includes" % (self.ZIP_FOLDER_NAME), keep_path=True)
if self.options.shared:
self.copy(pattern="*.so*", dst="lib", src=self.ZIP_FOLDER_NAME, keep_path=False)
self.copy(pattern="*.dll*", dst="bin", src=self.ZIP_FOLDER_NAME, keep_path=False)
else:
self.copy(pattern="*.a", dst="lib", src="%s" % self.ZIP_FOLDER_NAME, keep_path=False)
self.copy(pattern="*.lib", dst="lib", src="%s" % self.ZIP_FOLDER_NAME, keep_path=False)
def package_info(self):
self.cpp_info.libs = ['gnutls']