xref: /openbmc/telemetry/meson.build (revision 1cdd7e4f)
1project(
2    'Telemetry',
3    'cpp',
4    meson_version: '>=0.57.0',
5    default_options: [
6        'buildtype=debugoptimized',
7        'cpp_std=c++20',
8        # TODO: Without RTTI telemetry does not build using Boost 1.74.0
9        # https://github.com/chriskohlhoff/asio/issues/533
10        #'cpp_rtti=false',
11        'warning_level=3',
12        'werror=true',
13        'b_lto=true',
14    ],
15    license: 'Apache-2.0',
16)
17
18summary({'Fast build with link-time optimizer disabled':
19            not get_option('b_lto')}, section: 'General')
20
21cpp = meson.get_compiler('cpp')
22add_project_arguments(
23    cpp.get_supported_arguments([
24        '-DBOOST_ASIO_DISABLE_THREADS',
25        '-DBOOST_ALL_NO_LIB',
26        '-DBOOST_SYSTEM_NO_DEPRECATED',
27        '-DBOOST_ASIO_NO_DEPRECATED',
28        '-DBOOST_NO_RTTI',
29        '-DBOOST_NO_TYPEID',
30        # TODO: Removed below arg after upgrade to Boost 1.75
31        '-DBOOST_ALLOW_DEPRECATED_HEADERS',
32        '-Wno-unused-parameter',
33    ]),
34    language: 'cpp'
35)
36
37boost = dependency(
38    'boost',
39    version: '>=1.74.0',
40    required: false,
41    modules: ['coroutine'])
42assert(boost.found(),
43       'Missing Boost 1.74.0 or higher, as WA you can set BOOST_ROOT ' +
44       'environemt to point at boost build. To build a boost you can use ' +
45       'script ./scripts/boost_build_1.74.0.sh')
46
47phosphor_logging = dependency('phosphor-logging')
48sdbusplus = dependency('sdbusplus')
49systemd = dependency('systemd')
50
51if cpp.has_header('nlohmann/json.hpp')
52    nlohmann_json = declare_dependency()
53else
54    nlohmann_json = dependency('nlohmann_json')
55endif
56
57add_project_arguments(
58    '-DTELEMETRY_MAX_REPORTS=' + get_option('max-reports').to_string(),
59    '-DTELEMETRY_MAX_READING_PARAMS=' +
60        get_option('max-reading-parameters').to_string(),
61    '-DTELEMETRY_MIN_INTERVAL=' + get_option('min-interval').to_string(),
62    '-DTELEMETRY_MAX_TRIGGERS=' + get_option('max-triggers').to_string(),
63    '-DTELEMETRY_MAX_DBUS_PATH_LENGTH=' +
64        get_option('max-dbus-path-length').to_string(),
65    '-DTELEMETRY_MAX_APPEND_LIMIT=' +
66        get_option('max-append-limit').to_string(),
67    language: 'cpp'
68)
69
70executable(
71    'telemetry',
72    [
73        'src/discrete_threshold.cpp',
74        'src/main.cpp',
75        'src/metric.cpp',
76        'src/metrics/collection_data.cpp',
77        'src/metrics/collection_function.cpp',
78        'src/numeric_threshold.cpp',
79        'src/on_change_threshold.cpp',
80        'src/persistent_json_storage.cpp',
81        'src/report.cpp',
82        'src/report_factory.cpp',
83        'src/report_manager.cpp',
84        'src/sensor.cpp',
85        'src/sensor_cache.cpp',
86        'src/trigger.cpp',
87        'src/trigger_actions.cpp',
88        'src/trigger_factory.cpp',
89        'src/trigger_manager.cpp',
90        'src/types/readings.cpp',
91        'src/types/report_types.cpp',
92        'src/utils/conversion_trigger.cpp',
93        'src/utils/dbus_path_utils.cpp',
94        'src/utils/generate_id.cpp',
95        'src/utils/messanger_service.cpp',
96    ],
97    dependencies: [
98        boost,
99        nlohmann_json,
100        sdbusplus,
101        phosphor_logging,
102    ],
103    include_directories: 'src',
104    install: true,
105    install_dir: get_option('prefix') / get_option('bindir'),
106    pie: true,
107)
108
109configure_file(
110    input: 'xyz.openbmc_project.Telemetry.service.in',
111    output: 'xyz.openbmc_project.Telemetry.service',
112    configuration: {
113        'bindir': get_option('prefix') / get_option('bindir'),
114    },
115    install: true,
116    install_dir: systemd.get_variable(pkgconfig: 'systemdsystemunitdir'),
117)
118
119if get_option('buildtest')
120    subdir('tests')
121endif
122