xref: /openbmc/telemetry/meson.build (revision 1b03c8d6)
1project(
2    'Telemetry',
3    'cpp',
4    meson_version: '>=0.57.0',
5    default_options: [
6        'buildtype=debugoptimized',
7        'cpp_std=c++20',
8        'warning_level=3',
9        'werror=true',
10        'b_lto=true',
11    ],
12    license: 'Apache-2.0',
13)
14
15cxx = meson.get_compiler('cpp')
16add_project_arguments(
17    cxx.get_supported_arguments([
18        '-DBOOST_ASIO_DISABLE_THREADS',
19        '-DBOOST_ALL_NO_LIB',
20        '-DBOOST_SYSTEM_NO_DEPRECATED',
21        '-DBOOST_ASIO_NO_DEPRECATED',
22        '-DBOOST_NO_RTTI',
23        '-DBOOST_NO_TYPEID',
24        '-Wno-unused-parameter',
25    ]),
26    language: 'cpp'
27)
28
29boost_version = '>=1.79.0'
30boost_modules = ['coroutine', 'context']
31boost = dependency('boost',
32    version: boost_version,
33    modules: boost_modules)
34
35phosphor_logging = dependency('phosphor-logging')
36sdbusplus = dependency('sdbusplus')
37systemd = dependency('systemd')
38
39if cxx.has_header('nlohmann/json.hpp')
40    nlohmann_json = declare_dependency()
41else
42    nlohmann_json = dependency('nlohmann_json')
43endif
44
45add_project_arguments(
46    '-DTELEMETRY_MAX_REPORTS=' + get_option('max-reports').to_string(),
47    '-DTELEMETRY_MAX_READING_PARAMS=' +
48        get_option('max-reading-parameters').to_string(),
49    '-DTELEMETRY_MIN_INTERVAL=' + get_option('min-interval').to_string(),
50    '-DTELEMETRY_MAX_TRIGGERS=' + get_option('max-triggers').to_string(),
51    '-DTELEMETRY_MAX_DBUS_PATH_LENGTH=' +
52        get_option('max-dbus-path-length').to_string(),
53    '-DTELEMETRY_MAX_APPEND_LIMIT=' +
54        get_option('max-append-limit').to_string(),
55    '-DTELEMETRY_MAX_ID_NAME_LENGTH=' + get_option('max-id-name-length').to_string(),
56    '-DTELEMETRY_MAX_PREFIX_LENGTH=' + get_option('max-prefix-length').to_string(),
57    language: 'cpp'
58)
59
60executable(
61    'telemetry',
62    [
63        'src/discrete_threshold.cpp',
64        'src/main.cpp',
65        'src/metric.cpp',
66        'src/metrics/collection_data.cpp',
67        'src/metrics/collection_function.cpp',
68        'src/numeric_threshold.cpp',
69        'src/on_change_threshold.cpp',
70        'src/persistent_json_storage.cpp',
71        'src/report.cpp',
72        'src/report_factory.cpp',
73        'src/report_manager.cpp',
74        'src/sensor.cpp',
75        'src/sensor_cache.cpp',
76        'src/trigger.cpp',
77        'src/trigger_actions.cpp',
78        'src/trigger_factory.cpp',
79        'src/trigger_manager.cpp',
80        'src/types/readings.cpp',
81        'src/types/report_types.cpp',
82        'src/utils/conversion_trigger.cpp',
83        'src/utils/dbus_path_utils.cpp',
84        'src/utils/make_id_name.cpp',
85        'src/utils/messanger_service.cpp',
86    ],
87    dependencies: [
88        boost,
89        nlohmann_json,
90        sdbusplus,
91        phosphor_logging,
92    ],
93    include_directories: 'src',
94    install: true,
95    install_dir: get_option('prefix') / get_option('bindir'),
96    pie: true,
97)
98
99service_wants = ''
100if get_option('service-wants').length() > 0
101    service_wants = '\nWants=' + ' '.join(get_option('service-wants'))
102endif
103
104service_requires = ''
105if get_option('service-requires').length() > 0
106    service_requires = '\nRequires=' + ' '.join(get_option('service-requires'))
107endif
108
109service_before = ''
110if get_option('service-before').length() > 0
111    service_before = '\nBefore=' + ' '.join(get_option('service-before'))
112endif
113
114service_after = ''
115if get_option('service-after').length() > 0
116    service_after = ' ' + ' '.join(get_option('service-after'))
117endif
118
119configure_file(
120    input: 'xyz.openbmc_project.Telemetry.service.in',
121    output: 'xyz.openbmc_project.Telemetry.service',
122    configuration: {
123        'bindir': get_option('prefix') / get_option('bindir'),
124        'wants': service_wants,
125        'requires': service_requires,
126        'before': service_before,
127        'after': service_after
128    },
129    install: true,
130    install_dir: systemd.get_variable(pkgconfig: 'systemdsystemunitdir'),
131)
132
133if get_option('buildtest')
134    subdir('tests')
135endif
136