xref: /openbmc/telemetry/meson.build (revision 53fb7855)
1project(
2    'Telemetry',
3    'cpp',
4    meson_version: '>=1.1.1',
5    default_options: [
6        'buildtype=debugoptimized',
7        'cpp_std=c++23',
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
35nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
36phosphor_logging = dependency('phosphor-logging')
37sdbusplus = dependency('sdbusplus')
38systemd = dependency('systemd')
39
40add_project_arguments(
41    '-DTELEMETRY_MAX_REPORTS=' + get_option('max-reports').to_string(),
42    '-DTELEMETRY_MAX_READING_PARAMS=' +
43        get_option('max-reading-parameters').to_string(),
44    '-DTELEMETRY_MIN_INTERVAL=' + get_option('min-interval').to_string(),
45    '-DTELEMETRY_MAX_TRIGGERS=' + get_option('max-triggers').to_string(),
46    '-DTELEMETRY_MAX_DBUS_PATH_LENGTH=' +
47        get_option('max-dbus-path-length').to_string(),
48    '-DTELEMETRY_MAX_APPEND_LIMIT=' +
49        get_option('max-append-limit').to_string(),
50    '-DTELEMETRY_MAX_ID_NAME_LENGTH=' + get_option('max-id-name-length').to_string(),
51    '-DTELEMETRY_MAX_PREFIX_LENGTH=' + get_option('max-prefix-length').to_string(),
52    language: 'cpp'
53)
54
55executable(
56    'telemetry',
57    [
58        'src/discrete_threshold.cpp',
59        'src/main.cpp',
60        'src/metric.cpp',
61        'src/errors.cpp',
62        'src/metrics/collection_data.cpp',
63        'src/metrics/collection_function.cpp',
64        'src/numeric_threshold.cpp',
65        'src/on_change_threshold.cpp',
66        'src/persistent_json_storage.cpp',
67        'src/report.cpp',
68        'src/report_factory.cpp',
69        'src/report_manager.cpp',
70        'src/sensor.cpp',
71        'src/sensor_cache.cpp',
72        'src/trigger.cpp',
73        'src/trigger_actions.cpp',
74        'src/trigger_factory.cpp',
75        'src/trigger_manager.cpp',
76        'src/types/readings.cpp',
77        'src/types/report_types.cpp',
78        'src/utils/conversion_trigger.cpp',
79        'src/utils/dbus_path_utils.cpp',
80        'src/utils/make_id_name.cpp',
81        'src/utils/messanger_service.cpp',
82    ],
83    dependencies: [
84        boost,
85        nlohmann_json_dep,
86        sdbusplus,
87        phosphor_logging,
88    ],
89    include_directories: 'src',
90    install: true,
91    install_dir: get_option('prefix') / get_option('bindir'),
92    pie: true,
93)
94
95service_wants = ''
96if get_option('service-wants').length() > 0
97    service_wants = '\nWants=' + ' '.join(get_option('service-wants'))
98endif
99
100service_requires = ''
101if get_option('service-requires').length() > 0
102    service_requires = '\nRequires=' + ' '.join(get_option('service-requires'))
103endif
104
105service_before = ''
106if get_option('service-before').length() > 0
107    service_before = '\nBefore=' + ' '.join(get_option('service-before'))
108endif
109
110service_after = ''
111if get_option('service-after').length() > 0
112    service_after = ' ' + ' '.join(get_option('service-after'))
113endif
114
115configure_file(
116    input: 'xyz.openbmc_project.Telemetry.service.in',
117    output: 'xyz.openbmc_project.Telemetry.service',
118    configuration: {
119        'bindir': get_option('prefix') / get_option('bindir'),
120        'wants': service_wants,
121        'requires': service_requires,
122        'before': service_before,
123        'after': service_after
124    },
125    install: true,
126    install_dir: systemd.get_variable('systemdsystemunitdir'),
127)
128
129if get_option('buildtest')
130    subdir('tests')
131endif
132