forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconanfile.py
101 lines (85 loc) · 3.48 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
from conans import ConanFile, AutoToolsBuildEnvironment, tools
from conans.errors import ConanInvalidConfiguration
from contextlib import contextmanager
import os
required_conan_version = ">=1.33.0"
class CityhashConan(ConanFile):
name = "cityhash"
description = "CityHash, a family of hash functions for strings."
license = "MIT"
topics = ("conan", "cityhash", "hash")
homepage = "https://github.com/google/cityhash"
url = "https://github.com/conan-io/conan-center-index"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
_autotools = None
@property
def _source_subfolder(self):
return "source_subfolder"
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
del self.options.fPIC
def validate(self):
if self.settings.compiler == "Visual Studio" and self.options.shared:
raise ConanInvalidConfiguration("cityhash does not support shared builds with Visual Studio")
def build_requirements(self):
self.build_requires("libtool/2.4.6")
if tools.os_info.is_windows and not tools.get_env("CONAN_BASH_PATH"):
self.build_requires("msys2/cci.latest")
def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)
@contextmanager
def _build_context(self):
if self.settings.compiler == "Visual Studio":
with tools.vcvars(self.settings):
env = {
"CC": "cl -nologo",
"CXX": "cl -nologo",
"LD": "link -nologo",
"AR": "{} lib".format(tools.unix_path(self.deps_user_info["automake"].ar_lib)),
}
with tools.environment_append(env):
yield
else:
yield
def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
self._autotools.libs = []
yes_no = lambda v: "yes" if v else "no"
args = [
"--enable-static={}".format(yes_no(not self.options.shared)),
"--enable-shared={}".format(yes_no(self.options.shared)),
]
if self.settings.compiler == "Visual Studio":
self._autotools.cxx_flags.append("-EHsc")
self._autotools.flags.append("-FS")
self._autotools.configure(configure_dir=self._source_subfolder, args=args)
return self._autotools
def build(self):
with tools.chdir(self._source_subfolder):
self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows)
with self._build_context():
autotools = self._configure_autotools()
autotools.make()
def package(self):
self.copy("COPYING", dst="licenses", src=self._source_subfolder)
with self._build_context():
autotools = self._configure_autotools()
autotools.install()
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la")
tools.rmdir(os.path.join(self.package_folder, "share"))
def package_info(self):
self.cpp_info.libs = ["cityhash"]