This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconanfile.py
94 lines (75 loc) · 2.97 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
from conans import CMake, ConanFile, tools
from conans.errors import ConanException
class GrpcConan(ConanFile):
""" gRPC Conan package """
name = "gRPC"
version = "1.3.7"
description = "Conan package for gRPC"
license = "MIT"
url = "https://github.com/osechet/conan-grpc"
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
requires = "Protobuf/3.3.1@memsharded/testing"
exports = "FindgRPC.cmake", "FindProtobuf.cmake"
exports_sources = "zlib.patch"
def config_options(self):
if self.settings.compiler == 'gcc':
if self.settings.compiler.libcxx != 'libstdc++11':
raise ConanException("You must use the setting compiler.libcxx=libstdc++11")
def configure(self):
self.options["Protobuf"].shared = False
def source(self):
self.run("git clone --depth 1 -b v%s https://github.com/grpc/grpc.git" % self.version)
self.run("cd grpc && git submodule update --init")
#self.copy("zlib.patch", ".", ".")
# patch zlib's CMakeLists.txt
tools.patch(base_path="grpc/third_party/zlib",
patch_string="""
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,7 +83,7 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
-include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
#============================================================================""")
def patch_prefix(self):
""" patch Makefile to set the install prefix """
tools.patch(base_path="grpc",
patch_string="""
--- a/Makefile
+++ b/Makefile
@@ -233,7 +233,7 @@ DEFINES_counters = NDEBUG
# General settings.
# You may want to change these depending on your system.
-prefix ?= /usr/local
+prefix ?= %s
PROTOC ?= protoc
DTRACE ?= dtrace""" % self.package_folder)
def build_unix(self):
""" Build on Unix systems """
self.patch_prefix()
self.run("cd grpc && make")
self.run("cd grpc && make install")
if self.settings.os == "Linux":
self.run("ldconfig -n %s/lib" % self.package_folder)
def build_windows(self):
""" Build on Windows systems """
cmake = CMake(self)
cmake.definitions["CMAKE_INSTALL_PREFIX"] = self.package_folder
cmake.configure(source_dir="grpc")
cmake.build()
cmake.build(target="install")
def build(self):
if self.settings.os == "Windows":
self.build_windows()
else:
self.build_unix()
def package(self):
self.copy("FindProtobuf.cmake", ".", ".")
self.copy("FindgRPC.cmake", ".", ".")
def package_info(self):
self.cpp_info.libs = ["grpc"]
self.cpp_info.libs = ["grpc++_unsecure"]
self.cpp_info.libs = ["gpr"]