blob: 993f100054399627a9030e3a9beb33d9914eed6e [file] [log] [blame]
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +02001project(
2 'Telemetry',
3 'cpp',
Patrick Williams934201f2021-10-06 15:41:36 -05004 meson_version: '>=0.57.0',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +02005 default_options: [
6 'buildtype=debugoptimized',
Patrick Williams934201f2021-10-06 15:41:36 -05007 'cpp_std=c++20',
Wludzik, Jozefa4bf7402020-10-21 15:08:58 +02008 # TODO: Without RTTI telemetry does not build using Boost 1.74.0
9 # https://github.com/chriskohlhoff/asio/issues/533
10 #'cpp_rtti=false',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020011 'warning_level=3',
12 'werror=true',
13 'b_lto=true',
14 ],
15 license: 'Apache-2.0',
16)
17
Lukasz Kazmierczaka74e44f2021-07-23 15:02:20 +020018summary({'Fast build with link-time optimizer disabled':
19 not get_option('b_lto')}, section: 'General')
20
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020021cpp = 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',
Wludzik, Jozef596a9942021-01-27 12:28:59 +010030 # TODO: Removed below arg after upgrade to Boost 1.75
31 '-DBOOST_ALLOW_DEPRECATED_HEADERS',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020032 '-Wno-unused-parameter',
33 ]),
34 language: 'cpp'
35)
36
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020037boost = dependency(
Wludzik, Jozef596a9942021-01-27 12:28:59 +010038 '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')
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020046
Patrick Williamsf8ae65c2022-03-21 10:21:36 -050047phosphor_logging = dependency('phosphor-logging')
48sdbusplus = dependency('sdbusplus')
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020049systemd = dependency('systemd')
50
Krzysztof Grobelny73da6902020-09-24 13:42:04 +020051if cpp.has_header('nlohmann/json.hpp')
52 nlohmann_json = declare_dependency()
53else
Patrick Williamsf8ae65c2022-03-21 10:21:36 -050054 nlohmann_json = dependency('nlohmann_json')
Krzysztof Grobelny73da6902020-09-24 13:42:04 +020055endif
56
Wludzik, Jozef503c1582020-12-11 14:48:01 +010057add_project_arguments(
58 '-DTELEMETRY_MAX_REPORTS=' + get_option('max-reports').to_string(),
Wludzik, Jozef596a9942021-01-27 12:28:59 +010059 '-DTELEMETRY_MAX_READING_PARAMS=' +
60 get_option('max-reading-parameters').to_string(),
Wludzik, Jozef503c1582020-12-11 14:48:01 +010061 '-DTELEMETRY_MIN_INTERVAL=' + get_option('min-interval').to_string(),
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010062 '-DTELEMETRY_MAX_TRIGGERS=' + get_option('max-triggers').to_string(),
Szymon Dompkee28aa532021-10-27 12:33:12 +020063 '-DTELEMETRY_MAX_DBUS_PATH_LENGTH=' +
64 get_option('max-dbus-path-length').to_string(),
Ankita Vilas Gawadecd5b0b72022-01-20 20:55:04 +000065 '-DTELEMETRY_MAX_APPEND_LIMIT=' +
66 get_option('max-append-limit').to_string(),
Szymon Dompke32305f12022-07-05 15:37:21 +020067 '-DTELEMETRY_MAX_ID_NAME_LENGTH=' + get_option('max-id-name-length').to_string(),
68 '-DTELEMETRY_MAX_PREFIX_LENGTH=' + get_option('max-prefix-length').to_string(),
Wludzik, Jozef503c1582020-12-11 14:48:01 +010069 language: 'cpp'
70)
71
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020072executable(
73 'telemetry',
74 [
Szymon Dompkef763c9e2021-03-12 09:19:22 +010075 'src/discrete_threshold.cpp',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020076 'src/main.cpp',
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020077 'src/metric.cpp',
Krzysztof Grobelnyf7ea2992022-01-27 11:04:58 +010078 'src/metrics/collection_data.cpp',
79 'src/metrics/collection_function.cpp',
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010080 'src/numeric_threshold.cpp',
Szymon Dompkef763c9e2021-03-12 09:19:22 +010081 'src/on_change_threshold.cpp',
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020082 'src/persistent_json_storage.cpp',
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020083 'src/report.cpp',
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020084 'src/report_factory.cpp',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020085 'src/report_manager.cpp',
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020086 'src/sensor.cpp',
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020087 'src/sensor_cache.cpp',
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010088 'src/trigger.cpp',
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010089 'src/trigger_actions.cpp',
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010090 'src/trigger_factory.cpp',
91 'src/trigger_manager.cpp',
Krzysztof Grobelny493e62e2022-02-14 10:55:50 +010092 'src/types/readings.cpp',
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000093 'src/types/report_types.cpp',
Cezary Zwolak4416fce2021-03-17 03:21:06 +010094 'src/utils/conversion_trigger.cpp',
Szymon Dompke1cdd7e42022-06-08 14:43:13 +020095 'src/utils/dbus_path_utils.cpp',
Szymon Dompke32305f12022-07-05 15:37:21 +020096 'src/utils/make_id_name.cpp',
Krzysztof Grobelnye6d48872022-02-08 13:41:30 +010097 'src/utils/messanger_service.cpp',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020098 ],
99 dependencies: [
100 boost,
Krzysztof Grobelny73da6902020-09-24 13:42:04 +0200101 nlohmann_json,
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +0200102 sdbusplus,
103 phosphor_logging,
104 ],
105 include_directories: 'src',
106 install: true,
107 install_dir: get_option('prefix') / get_option('bindir'),
108 pie: true,
109)
110
Szymon Dompke458a37d2022-08-05 10:16:39 +0200111service_wants = ''
112if get_option('service-wants').length() > 0
113 service_wants = '\nWants=' + ' '.join(get_option('service-wants'))
114endif
115
116service_requires = ''
117if get_option('service-requires').length() > 0
118 service_requires = '\nRequires=' + ' '.join(get_option('service-requires'))
119endif
120
121service_before = ''
122if get_option('service-before').length() > 0
123 service_before = '\nBefore=' + ' '.join(get_option('service-before'))
124endif
125
126service_after = ''
127if get_option('service-after').length() > 0
128 service_after = ' ' + ' '.join(get_option('service-after'))
129endif
130
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +0200131configure_file(
132 input: 'xyz.openbmc_project.Telemetry.service.in',
133 output: 'xyz.openbmc_project.Telemetry.service',
134 configuration: {
135 'bindir': get_option('prefix') / get_option('bindir'),
Szymon Dompke458a37d2022-08-05 10:16:39 +0200136 'wants': service_wants,
137 'requires': service_requires,
138 'before': service_before,
139 'after': service_after
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +0200140 },
141 install: true,
Patrick Williamsbdf87192021-12-03 10:08:57 -0600142 install_dir: systemd.get_variable(pkgconfig: 'systemdsystemunitdir'),
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +0200143)
Krzysztof Grobelny73da6902020-09-24 13:42:04 +0200144
145if get_option('buildtest')
146 subdir('tests')
147endif