forked from jupp0r/prometheus-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrakefile
More file actions
89 lines (82 loc) · 2.82 KB
/
drakefile
File metadata and controls
89 lines (82 loc) · 2.82 KB
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
import drake
import drake.cmake
import drake.cxx
import drake.git
import os
prometheus_libs = None
sources = None
config = None
def configure(
cxx_toolkit,
cxx_config,
protoc,
protobuf_config,
protobuf_lib,
cmake_vars = {},
curl_include_dir = None,
curl_library = None,
zlib_include_dir = None,
zlib_library = None,
):
global prometheus_libs, sources
prometheus_libs = [drake.cxx.DynLib(p, tk = cxx_toolkit) for p in [
'core/prometheus-cpp-core',
'pull/prometheus-cpp-pull',
]]
# Prometheus git repo.
git = drake.git.Git()
# The files we depend upon.
files = git.ls_files('include', 'lib', 'CMakeLists.txt')
print(zlib_library)
srcs = [protoc, protobuf_lib, curl_library, zlib_library] + drake.nodes(*files)
# Makefile target to run.
targets = [
'all',
]
class PrometheusCMakeBuilder(drake.cmake.CMakeBuilder):
def execute(self):
if not super().execute():
return False
for l in prometheus_libs:
self.cmd(
'Fix rpath for {}'.format(l),
cxx_toolkit.rpath_set_command(l, '.'))
drake.cxx.set_lib_id(l.path())
return True
cmake_vars.update({
'BUILD_SHARED_LIBS': 'ON',
'PROTOBUF_INCLUDE_DIR': protobuf_config.protobuf_include_dir,
'PROTOBUF_LIBRARY': protobuf_lib.path(absolute = True),
'PROTOBUF_PROTOC_EXECUTABLE': protoc.path(absolute = True),
# CivetWeb, a small HTTP in C and C++, is used an a "object"
# library (aka "convenience library" in Libtool parlance) in
# libprometheus-cpp. But compiling the latter as a shared library
# does not make the former PIC. So force -fPIC.
# https://cmake.org/pipermail/cmake/2012-June/050941.html
'CURL_INCLUDE_DIR': str(curl_include_dir),
'CURL_LIBRARY': str(curl_library.path(absolute = True)),
'ZLIB_INCLUDE_DIR': str(zlib_include_dir),
'ZLIB_LIBRARY': str(zlib_library.path(absolute = True)),
'CMAKE_C_FLAGS': '-fPIC',
'CMAKE_CXX_FLAGS': (('-stdlib=libc++' if cxx_toolkit.os == drake.os.macos else '')
+ ' -fPIC'),
})
if drake.path_source().absolute():
cmake_source = drake.path_source() / drake.Drake.current.prefix
else:
cmake_source = drake.node('CMakeLists.txt').path(absolute = True).dirname()
cmake = PrometheusCMakeBuilder(cxx_toolkit, srcs, prometheus_libs, cmake_vars,
targets = targets,
path_to_cmake_source = cmake_source)
global config
config = drake.cxx.Config(cxx_config)
config += protobuf_config
# libprometheus-cpp's header.
config.add_local_include_path('core/include')
config.add_local_include_path('pull/include')
# prometheus_client_model, a submodule, that contains the protobuf
# support: metrics.pb.h.
config.add_local_include_path('lib/cpp')
# Local Variables:
# mode: python
# End: