-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
121 lines (109 loc) · 3.17 KB
/
meson.build
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
110
111
112
113
114
115
116
117
118
119
120
121
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
project(
'metrics-ipmi-blobs',
['cpp', 'c'],
version: '0.1',
default_options: [
'warning_level=3',
'werror=true',
'cpp_std=c++23',
'c_std=c18',
'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
],
)
nanopb = find_program('nanopb_generator.py', native: true, required: false)
if not nanopb.found()
nanopb_opts = import('cmake').subproject_options()
nanopb_opts.add_cmake_defines({'BUILD_SHARED_LIBS': 'ON'})
nanopb_proj = import('cmake').subproject('nanopb', options: nanopb_opts)
nanopb = find_program(
meson.global_source_root() + '/subprojects/nanopb/generator/nanopb_generator.py',
native: true,
)
nanopb_dep = nanopb_proj.dependency('protobuf_nanopb')
else
nanopb_dep = meson.get_compiler('cpp').find_library('protobuf-nanopb')
endif
nanopb_kwargs = {
'output': ['@[email protected]', '@[email protected]'],
'command': [
nanopb,
'-q',
'-s',
'packed_struct:0',
'-H.n.h',
'-S.n.c',
'-I' + import('fs').relative_to(
meson.current_source_dir(),
meson.global_build_root(),
),
'-D' + import('fs').relative_to(
meson.current_build_dir(),
meson.global_build_root(),
),
'@INPUT@',
],
}
tgt = custom_target(
'metricblob.pb.n.hc',
input: 'metricblob.proto',
kwargs: nanopb_kwargs,
)
metrics_nanopb_hdr = tgt[0]
metrics_nanopb_src = tgt[1]
metrics_nanopb_pre = declare_dependency(
include_directories: include_directories('.'),
sources: metrics_nanopb_hdr,
dependencies: [nanopb_dep],
)
metrics_nanopb_lib = static_library(
'metrics_nanopb',
metrics_nanopb_src,
implicit_include_directories: false,
dependencies: metrics_nanopb_pre,
)
metrics_nanopb_dep = declare_dependency(
dependencies: metrics_nanopb_pre,
link_with: metrics_nanopb_lib,
)
pre = declare_dependency(
include_directories: include_directories('.'),
dependencies: [
metrics_nanopb_dep,
dependency('phosphor-logging'),
dependency('phosphor-ipmi-blobs'),
dependency('sdbusplus'),
],
)
lib = static_library(
'metricsblob',
'util.cpp',
'handler.cpp',
'metric.cpp',
implicit_include_directories: false,
dependencies: pre,
)
dep = declare_dependency(dependencies: pre, link_with: lib)
shared_module(
'metricsblob',
'main.cpp',
dependencies: dep,
implicit_include_directories: false,
install: true,
install_dir: get_option('libdir') / 'blob-ipmid',
)
if get_option('tests').allowed()
subdir('test')
endif