blob: 15eead986b53e5625a024099a3f9c74c5ce8264a [file] [log] [blame]
Brandon Kimdab96f12021-02-18 11:21:37 -08001# Copyright 2021 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Sui Chen03eba282021-02-11 11:35:56 -080015project(
16 'metrics-ipmi-blobs',
William A. Kennington III7f493702024-02-08 01:09:11 -080017 ['cpp', 'c'],
Sui Chen03eba282021-02-11 11:35:56 -080018 version: '0.1',
19 default_options: [
William A. Kennington III3f43b7e2021-02-16 16:54:40 -080020 'warning_level=3',
21 'werror=true',
Patrick Williams1dfe24e2023-07-12 11:16:02 -050022 'cpp_std=c++23',
William A. Kennington III7f493702024-02-08 01:09:11 -080023 'c_std=c18',
William A. Kennington III3f43b7e2021-02-16 16:54:40 -080024 'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
Sui Chen03eba282021-02-11 11:35:56 -080025 ],
26)
27
William A. Kennington III7f493702024-02-08 01:09:11 -080028nanopb = find_program('nanopb_generator.py', native: true, required: false)
29if not nanopb.found()
30 nanopb_opts = import('cmake').subproject_options()
31 nanopb_opts.add_cmake_defines({'BUILD_SHARED_LIBS': 'ON'})
32 nanopb_proj = import('cmake').subproject('nanopb', options: nanopb_opts)
33 nanopb = find_program(meson.global_source_root() + '/subprojects/nanopb/generator/nanopb_generator.py', native: true)
34 nanopb_dep = nanopb_proj.dependency('protobuf_nanopb')
35else
36 nanopb_dep = meson.get_compiler('cpp').find_library('protobuf-nanopb')
37endif
Sui Chen03eba282021-02-11 11:35:56 -080038
William A. Kennington III7f493702024-02-08 01:09:11 -080039nanopb_kwargs = {
40 'output': [
41 '@BASENAME@.pb.n.h',
42 '@BASENAME@.pb.n.c',
43 ],
44 'command': [
45 nanopb,
46 '-q',
47 '-s', 'packed_struct:0',
48 '-H.n.h',
49 '-S.n.c',
50 '-I' + import('fs').relative_to(meson.current_source_dir(), meson.global_build_root()),
51 '-D' + import('fs').relative_to(meson.current_build_dir(), meson.global_build_root()),
52 '@INPUT@',
53 ],
54}
Sui Chen03eba282021-02-11 11:35:56 -080055
William A. Kennington III7f493702024-02-08 01:09:11 -080056tgt = custom_target(
57 'metricblob.pb.n.hc',
58 input: 'metricblob.proto',
59 kwargs: nanopb_kwargs)
60metrics_nanopb_hdr = tgt[0]
61metrics_nanopb_src = tgt[1]
62
63metrics_nanopb_pre = declare_dependency(
64 include_directories: include_directories('.'),
65 sources: metrics_nanopb_hdr,
66 dependencies: [
67 nanopb_dep,
68 ])
69
70metrics_nanopb_lib = static_library(
71 'metrics_nanopb',
72 metrics_nanopb_src,
73 implicit_include_directories: false,
74 dependencies: metrics_nanopb_pre)
75
76metrics_nanopb_dep = declare_dependency(
77 dependencies: metrics_nanopb_pre,
78 link_with: metrics_nanopb_lib)
79
80pre = declare_dependency(
81 include_directories: include_directories('.'),
82 dependencies: [
83 metrics_nanopb_dep,
84 dependency('phosphor-logging'),
85 dependency('phosphor-ipmi-blobs'),
86 dependency('sdbusplus'),
87 ])
William A. Kennington IIIb056df62021-03-23 21:19:18 -070088
William A. Kennington III3f43b7e2021-02-16 16:54:40 -080089lib = static_library(
90 'metricsblob',
91 'util.cpp',
Sui Chen03eba282021-02-11 11:35:56 -080092 'handler.cpp',
93 'metric.cpp',
William A. Kennington III3f43b7e2021-02-16 16:54:40 -080094 implicit_include_directories: false,
William A. Kennington III7f493702024-02-08 01:09:11 -080095 dependencies: pre)
Sui Chen03eba282021-02-11 11:35:56 -080096
William A. Kennington III3f43b7e2021-02-16 16:54:40 -080097dep = declare_dependency(
William A. Kennington III7f493702024-02-08 01:09:11 -080098 dependencies: pre,
William A. Kennington III3f43b7e2021-02-16 16:54:40 -080099 link_with: lib)
100
101shared_module(
102 'metricsblob',
103 'main.cpp',
104 dependencies: dep,
105 implicit_include_directories: false,
106 install: true,
William A. Kennington III548f3ad2021-06-17 20:07:47 -0700107 install_dir: get_option('libdir') / 'blob-ipmid')
William A. Kennington III3f43b7e2021-02-16 16:54:40 -0800108
109if not get_option('tests').disabled()
110 subdir('test')
111endif