This repository has been archived by the owner on Aug 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
71 lines (64 loc) · 3.58 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
from os import path
from conans import ConanFile, CMake, tools
class AzureUAMQPCConan(ConanFile):
name = "Azure-uAMQP-C"
version = "1.0.46"
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
url = "https://github.com/bincrafters/conan-azure-uamqp-c"
description = "AMQP library for C"
license = "https://github.com/Azure/azure-uamqp-c/blob/master/LICENSE"
options = {"shared": [True, False]}
default_options = {'shared': 'False'}
lib_short_name = "uamqp"
release_date = "2017-10-20"
release_name = "%s-%s" % (name.lower(), release_date)
requires = "Azure-C-Shared-Utility/1.0.46@bincrafters/stable"
def source(self):
source_url = "https://github.com/Azure/azure-uamqp-c"
tools.get("%s/archive/%s.tar.gz" % (source_url, self.release_date))
def configure(self):
del self.settings.compiler.libcxx
def build(self):
conan_magic_lines='''project(%s)
include(../conanbuildinfo.cmake)
conan_basic_setup()
''' % self.lib_short_name
cmake_file = "%s/CMakeLists.txt" % self.release_name
res_paths = self.deps_cpp_info["Azure-C-Shared-Utility"].res_paths[0]
if self.settings.os == "Windows":
res_paths = res_paths.replace("\\", "/")
tools.replace_in_file(cmake_file, "project(%s)" % self.lib_short_name, conan_magic_lines)
conan_magic_lines = "include(%s/deps/c-utility/configs/azure_iot_build_rules.cmake)" % res_paths
tools.replace_in_file(cmake_file, "include(deps/azure-c-shared-utility/configs/azure_iot_build_rules.cmake)", conan_magic_lines)
content = tools.load(cmake_file)
tools.save(cmake_file, content[0:content.find("if(${use_installed_dependencies})")])
conan_magic_lines = ''' find_package(azure_c_shared_utility REQUIRED CONFIG
HINTS %s/deps/c-utility/configs/)''' % res_paths
tools.replace_in_file("%s/dependencies.cmake" % self.release_name, " find_package(azure_c_shared_utility REQUIRED config)", conan_magic_lines)
if self.settings.os == "Windows":
conan_magic_lines = "target_link_libraries(uamqp aziotsharedutil ws2_32 secur32)"
tools.replace_in_file(cmake_file, "target_link_libraries(uamqp aziotsharedutil)", conan_magic_lines)
cmake = CMake(self)
cmake.definitions["skip_samples"] = True
cmake.definitions["use_installed_dependencies"] = True
if self.settings.os == "Windows" and self.options.shared:
cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
cmake.configure(source_dir=self.release_name)
cmake.build()
def package(self):
self.copy(pattern="LICENSE", dst=".", src=".")
self.copy(pattern="*", dst="include", src=path.join(self.release_name, "inc"))
self.copy(pattern="uamqpConfig.cmake", dst="res", src=path.join(self.release_name, "configs"))
self.copy(pattern="*.cmake", dst="res", src=path.join("CMakeFiles", "Export", "cmake"))
self.copy(pattern="*.lib", dst="lib", src="lib", keep_path=False)
self.copy(pattern="*.dll", dst="bin", src=".", keep_path=False)
self.copy(pattern="*.a", dst="lib", src="lib", keep_path=False)
self.copy(pattern="*.so*", dst="lib", src=".", keep_path=False)
self.copy(pattern="*.dylib", dst="lib", src=".", keep_path=False)
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Linux":
self.cpp_info.libs.append("pthread")
elif self.settings.os == "Windows":
self.cpp_info.libs.append("Ws2_32")