This repository has been archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconanfile.py
109 lines (98 loc) · 4.43 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
import os
from conans import ConanFile, CMake, tools
from conans.tools import Version
from conans.errors import ConanInvalidConfiguration
class FollyConan(ConanFile):
name = "folly"
version = "2019.09.02.00"
description = "An open-source C++ components library developed and used at Facebook"
topics = ("conan", "folly", "facebook", "components", "core", "efficiency")
url = "https://github.com/bincrafters/conan-folly"
homepage = "https://github.com/facebook/folly"
license = "Apache-2.0"
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
exports_sources = ["CMakeLists.txt", "*.patch"]
generators = "cmake"
requires = (
"boost/1.71.0",
"double-conversion/3.1.5",
"gflags/2.2.2",
"glog/0.4.0",
"libevent/2.1.11",
"lz4/1.9.2",
"openssl/1.0.2u",
"zlib/1.2.11",
"zstd/1.4.3",
"snappy/1.1.7",
"bzip2/1.0.8",
"libsodium/1.0.18",
"xz_utils/5.2.4",
"libdwarf/20191104"
)
@property
def _source_subfolder(self):
return "source_subfolder"
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
del self.options.shared
elif self.settings.os == "Macos":
del self.options.shared
def configure(self):
compiler_version = Version(self.settings.compiler.version.value)
if self.settings.os == "Windows" and \
self.settings.compiler == "Visual Studio" and \
compiler_version < "15":
raise ConanInvalidConfiguration("Folly could not be built by Visual Studio < 14")
elif self.settings.os == "Windows" and \
self.settings.arch != "x86_64":
raise ConanInvalidConfiguration("Folly requires a 64bit target architecture")
elif self.settings.os == "Windows" and \
self.settings.compiler == "Visual Studio" and \
"MT" in self.settings.compiler.runtime:
raise ConanInvalidConfiguration("Folly could not be build with runtime MT")
elif self.settings.os == "Linux" and \
self.settings.compiler == "clang" and \
compiler_version < "6.0":
raise ConanInvalidConfiguration("Folly could not be built by Clang < 6.0")
elif self.settings.os == "Linux" and \
self.settings.compiler == "gcc" and \
compiler_version < "5":
raise ConanInvalidConfiguration("Folly could not be built by GCC < 5")
elif self.settings.os == "Macos" and \
self.settings.compiler == "apple-clang" and \
compiler_version < "8.0":
raise ConanInvalidConfiguration("Folly could not be built by apple-clang < 8.0")
def requirements(self):
if self.settings.os == "Linux" or \
self.settings.compiler == "gcc":
self.requires("libiberty/9.1.0")
def source(self):
tools.get("{0}/archive/v{1}.tar.gz".format(self.homepage, self.version))
extracted_dir = self.name + '-' + self.version
os.rename(extracted_dir, self._source_subfolder)
def _configure_cmake(self):
cmake = CMake(self)
cmake.configure()
return cmake
def build(self):
tools.patch(base_path=self._source_subfolder, patch_file='0001-compiler-options.patch')
cmake = self._configure_cmake()
cmake.build()
def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self) + ["folly"]
if self.settings.os == "Linux":
self.cpp_info.libs.extend(["pthread", "dl"])
elif self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
self.cpp_info.libs.extend(["ws2_32", "Iphlpapi", "Crypt32"])
if (self.settings.os == "Linux" and self.settings.compiler == "clang" and
Version(self.settings.compiler.version.value) == "6" and self.settings.compiler.libcxx == "libstdc++") or \
(self.settings.os == "Macos" and self.settings.compiler == "apple-clang" and
Version(self.settings.compiler.version.value) == "9.0" and self.settings.compiler.libcxx == "libc++"):
self.cpp_info.libs.append("atomic")