This repository has been archived by the owner on Oct 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconanfile.py
158 lines (134 loc) · 6.39 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, AutoToolsBuildEnvironment, tools
import os
import shutil
class Nghttp2Conan(ConanFile):
name = "nghttp2"
version = "1.38.0"
description = "HTTP/2 C Library and tools"
topics = ("conan", "http")
url = "https://github.com/bincrafters/conan-nghttp2"
homepage = "https://nghttp2.org"
author = "Bincrafters <bincrafters@gmail.com>"
license = "MIT"
exports = ["LICENSE.md"]
exports_sources = ["CMakeLists.txt"]
generators = "cmake", "pkg_config"
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False],
"fPIC": [True, False],
"with_app": [True, False],
"with_hpack": [True, False],
"with_asio": [True, False]}
default_options = {"shared": False,
"fPIC": True,
"with_app": True,
"with_hpack": True,
"with_asio": False}
_source_subfolder = "source_subfolder"
def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC
if self.options.with_asio and self.settings.compiler == "Visual Studio":
raise ConanInvalidConfiguration("Build with asio and MSVC is not supported yet, see upstream bug #589")
def requirements(self):
self.requires.add("zlib/1.2.11")
if self.options.with_app:
self.requires.add("openssl/1.0.2t")
self.requires.add("c-ares/1.15.0@conan/stable")
self.requires.add("libev/4.25@bincrafters/stable")
self.requires.add("libxml2/2.9.9@bincrafters/stable")
if self.options.with_hpack:
self.requires.add("jansson/2.12@bincrafters/stable")
if self.options.with_asio:
self.requires.add("boost/1.68.0@conan/stable")
# self.requires.add("boost_asio/1.69.0@bincrafters/stable")
# self.requires.add("boost_system/1.69.0@bincrafters/stable")
# self.requires.add("boost_thread/1.69.0@bincrafters/stable")
def source(self):
checksum = "8f306995b2805f9f62e9bc042bbf48eb64f6d30b25c04f76cb75d2977d1dd994"
source_url = "https://github.com/nghttp2/nghttp2"
tools.get("{0}/releases/download/v{1}/nghttp2-{1}.tar.bz2".format(source_url, self.version), sha256=checksum)
extracted_folder = "nghttp2-{0}".format(self.version)
os.rename(extracted_folder, self._source_subfolder)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["ENABLE_SHARED_LIB"] = "ON" if self.options.shared else "OFF"
cmake.definitions["ENABLE_STATIC_LIB"] = "OFF" if self.options.shared else "ON"
cmake.definitions["ENABLE_HPACK_TOOLS"] = "ON" if self.options.with_hpack else "OFF"
cmake.definitions["ENABLE_APP"] = "ON" if self.options.with_app else "OFF"
cmake.definitions["ENABLE_EXAMPLES"] = "OFF"
cmake.definitions["ENABLE_PYTHON_BINDINGS"] = "OFF"
cmake.definitions["ENABLE_FAILMALLOC"] = "OFF"
# disable unneeded auto-picked dependencies
cmake.definitions["WITH_LIBXML2"] = "OFF"
cmake.definitions["WITH_JEMALLOC"] = "OFF"
cmake.definitions["WITH_SPDYLAY"] = "OFF"
cmake.definitions["ENABLE_ASIO_LIB"] = "ON" if self.options.with_asio else "OFF"
if self.options.with_app:
cmake.definitions['OPENSSL_ROOT_DIR'] = self.deps_cpp_info['openssl'].rootpath
if self.options.with_asio:
cmake.definitions['BOOST_ROOT'] = self.deps_cpp_info['boost'].rootpath
cmake.definitions['ZLIB_ROOT'] = self.deps_cpp_info['zlib'].rootpath
cmake.configure()
return cmake
def _build_with_autotools(self):
if self.options.with_app:
os.rename('c-ares.pc', 'libcares.pc')
os.rename('OpenSSL.pc', 'openssl.pc')
prefix = os.path.abspath(self.package_folder)
with tools.chdir(self._source_subfolder):
env_build = AutoToolsBuildEnvironment(self)
if self.settings.os == 'Windows':
prefix = tools.unix_path(prefix)
args = ['--prefix=%s' % prefix]
if self.options.shared:
args.extend(['--disable-static', '--enable-shared'])
else:
args.extend(['--disable-shared', '--enable-static'])
if self.options.with_hpack:
args.append('--enable-hpack-tools')
else:
args.append('--disable-hpack-tools')
if self.options.with_app:
args.append('--enable-app')
else:
args.append('--disable-app')
args.append('--disable-examples')
args.append('--disable-python-bindings')
# disable unneeded auto-picked dependencies
args.append('--without-jemalloc')
args.append('--without-systemd')
args.append('--without-libxml2')
if self.options.with_asio:
args.append('--enable-asio-lib')
args.append('--with-boost=' + self.deps_cpp_info['boost'].rootpath)
else:
args.append('--without-boost')
env_build.configure(args=args)
env_build.make()
env_build.make(args=['install'])
def build(self):
if self.settings.compiler == "Visual Studio":
cmake = self._configure_cmake()
cmake.build()
else:
self._build_with_autotools()
def package(self):
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder)
if self.settings.compiler == "Visual Studio":
cmake = self._configure_cmake()
cmake.install()
cmake.patch_config_paths()
# remove unneeded directories
shutil.rmtree(os.path.join(self.package_folder, 'share', 'man'), ignore_errors=True)
shutil.rmtree(os.path.join(self.package_folder, 'share', 'doc'), ignore_errors=True)
for la_name in ('libnghttp2.la', 'libnghttp2_asio.la'):
la_file = os.path.join(self.package_folder, "lib", la_name)
if os.path.isfile(la_file):
os.unlink(la_file)
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.compiler == 'Visual Studio':
if not self.options.shared:
self.cpp_info.defines.append('NGHTTP2_STATICLIB')