-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconanfile.py
99 lines (86 loc) · 2.83 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
import os
from conans import ConanFile, CMake, tools
def get_version():
with open(os.path.join(os.path.dirname(__file__), 'version'), 'r') as f:
content = f.read()
try:
content = content.decode()
except AttributeError:
pass
return content.strip()
class HttbConan(ConanFile):
name = "httb"
version = get_version()
license = "MIT"
author = "Eduard Maximovich [email protected]"
url = "https://github.com/edwardstock/httb"
description = "Lightweight C++ HTTP Client based on Boost.Beast"
topics = ("boost", "http", "cpp-http", "cpp-http-client", "http-client", "boost-http", "boost-beast")
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = {
"shared": False,
"OpenSSL:shared": False,
"boost:shared": False,
}
exports = (
"version",
)
exports_sources = (
"cfg/*",
"modules/*",
"include/*",
"tests/*",
"src/*",
"CMakeLists.txt",
"conanfile.py",
"conanfile.txt",
"LICENSE",
"README.md"
)
generators = "cmake"
default_user = "scatter"
default_channel = "latest"
requires = (
"OpenSSL/1.1.1b@conan/stable",
"toolbox/3.1.1@edwardstock/latest",
"boost/1.70.0@conan/stable",
)
build_requires = (
"gtest/1.8.1@bincrafters/stable"
)
def source(self):
if "CONAN_LOCAL" not in os.environ:
self.run("rm -rf *")
self.run("git clone https://github.com/edwardstock/httb.git .")
def configure(self):
if self.settings.compiler == "Visual Studio":
del self.settings.compiler.runtime
def build(self):
cmake = CMake(self)
opts = {
'CMAKE_BUILD_TYPE': self.settings.build_type,
'ENABLE_TEST': "Off",
'ENABLE_SHARED': 'Off'
}
if self.options.shared:
opts['ENABLE_SHARED'] = 'On'
cmake.configure(defs=opts)
cmake.build()
def package(self):
self.copy("*", dst="include", src="include", keep_path=True)
dir_types = ['bin', 'lib', 'Debug', 'Release', 'RelWithDebInfo', 'MinSizeRel']
file_types = ['lib', 'dll', 'dll.a', 'a', 'so', 'exp', 'pdb', 'ilk', 'dylib']
for dirname in dir_types:
for ftype in file_types:
self.copy("*." + ftype, src=dirname, dst="lib", keep_path=False)
def package_info(self):
self.cpp_info.libs = self.collect_libs()
def test(self):
cmake = CMake(self)
cmake.configure(defs={'ENABLE_TEST': 'On'})
cmake.build(target="httb-test")
if self.settings.compiler == "Visual Studio":
self.run("bin/httb-test.exe")
else:
self.run("bin/httb-test")