blob: 6f81261d2df40eb3d2ffd6b05a80c3966c5592bc [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
47phosphor_logging = dependency('phosphor-logging', required: false)
48if not phosphor_logging.found()
49 subproject('phosphor-logging', required: false)
50 phosphor_logging = declare_dependency(
51 include_directories: 'subprojects/phosphor-logging'
52 )
53endif
54
Wludzik, Jozef596a9942021-01-27 12:28:59 +010055sdbusplus = dependency('sdbusplus', fallback: ['sdbusplus', 'sdbusplus_dep'])
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020056systemd = dependency('systemd')
57
Krzysztof Grobelny73da6902020-09-24 13:42:04 +020058if cpp.has_header('nlohmann/json.hpp')
59 nlohmann_json = declare_dependency()
60else
Wludzik, Jozef596a9942021-01-27 12:28:59 +010061 nlohmann_json = dependency('nlohmann_json',
62 fallback: ['nlohmann', 'nlohmann_json_dep'])
Krzysztof Grobelny73da6902020-09-24 13:42:04 +020063endif
64
Wludzik, Jozef503c1582020-12-11 14:48:01 +010065add_project_arguments(
66 '-DTELEMETRY_MAX_REPORTS=' + get_option('max-reports').to_string(),
Wludzik, Jozef596a9942021-01-27 12:28:59 +010067 '-DTELEMETRY_MAX_READING_PARAMS=' +
68 get_option('max-reading-parameters').to_string(),
Wludzik, Jozef503c1582020-12-11 14:48:01 +010069 '-DTELEMETRY_MIN_INTERVAL=' + get_option('min-interval').to_string(),
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010070 '-DTELEMETRY_MAX_TRIGGERS=' + get_option('max-triggers').to_string(),
Szymon Dompkee28aa532021-10-27 12:33:12 +020071 '-DTELEMETRY_MAX_DBUS_PATH_LENGTH=' +
72 get_option('max-dbus-path-length').to_string(),
Wludzik, Jozef503c1582020-12-11 14:48:01 +010073 language: 'cpp'
74)
75
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020076executable(
77 'telemetry',
78 [
Krzysztof Grobelny80697712021-03-04 09:49:27 +000079 'src/details/collection_function.cpp',
Szymon Dompkef763c9e2021-03-12 09:19:22 +010080 'src/discrete_threshold.cpp',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020081 'src/main.cpp',
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020082 'src/metric.cpp',
Wludzik, Jozef1477fe62021-01-02 11:56:10 +010083 'src/numeric_threshold.cpp',
Szymon Dompkef763c9e2021-03-12 09:19:22 +010084 'src/on_change_threshold.cpp',
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020085 'src/persistent_json_storage.cpp',
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020086 'src/report.cpp',
Wludzik, Jozef2f9f9b82020-10-13 09:07:45 +020087 'src/report_factory.cpp',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020088 'src/report_manager.cpp',
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020089 'src/sensor.cpp',
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020090 'src/sensor_cache.cpp',
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010091 'src/trigger.cpp',
Wludzik, Jozefd960e1f2021-01-08 09:25:59 +010092 'src/trigger_actions.cpp',
Wludzik, Jozef76833cb2020-12-21 14:42:41 +010093 'src/trigger_factory.cpp',
94 'src/trigger_manager.cpp',
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000095 'src/types/report_types.cpp',
Cezary Zwolak4416fce2021-03-17 03:21:06 +010096 'src/utils/conversion_trigger.cpp',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020097 ],
98 dependencies: [
99 boost,
Krzysztof Grobelny73da6902020-09-24 13:42:04 +0200100 nlohmann_json,
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +0200101 sdbusplus,
102 phosphor_logging,
103 ],
104 include_directories: 'src',
105 install: true,
106 install_dir: get_option('prefix') / get_option('bindir'),
107 pie: true,
108)
109
110configure_file(
111 input: 'xyz.openbmc_project.Telemetry.service.in',
112 output: 'xyz.openbmc_project.Telemetry.service',
113 configuration: {
114 'bindir': get_option('prefix') / get_option('bindir'),
115 },
116 install: true,
Patrick Williamsbdf87192021-12-03 10:08:57 -0600117 install_dir: systemd.get_variable(pkgconfig: 'systemdsystemunitdir'),
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +0200118)
Krzysztof Grobelny73da6902020-09-24 13:42:04 +0200119
120if get_option('buildtest')
121 subdir('tests')
122endif