1project( 2 'Telemetry', 3 'cpp', 4 meson_version: '>=0.54.3', 5 default_options: [ 6 'buildtype=debugoptimized', 7 'cpp_std=c++17', 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 18cpp = meson.get_compiler('cpp') 19add_project_arguments( 20 cpp.get_supported_arguments([ 21 '-DBOOST_ASIO_DISABLE_THREADS', 22 '-DBOOST_ALL_NO_LIB', 23 '-DBOOST_SYSTEM_NO_DEPRECATED', 24 '-DBOOST_ASIO_NO_DEPRECATED', 25 '-DBOOST_NO_RTTI', 26 '-DBOOST_NO_TYPEID', 27 # TODO: Removed below arg after upgrade to Boost 1.75 28 '-DBOOST_ALLOW_DEPRECATED_HEADERS', 29 '-Wno-unused-parameter', 30 ]), 31 language: 'cpp' 32) 33 34boost = dependency( 35 'boost', 36 version: '>=1.74.0', 37 required: false, 38 modules: ['coroutine']) 39assert(boost.found(), 40 'Missing Boost 1.74.0 or higher, as WA you can set BOOST_ROOT ' + 41 'environemt to point at boost build. To build a boost you can use ' + 42 'script ./scripts/boost_build_1.74.0.sh') 43 44phosphor_logging = dependency('phosphor-logging', required: false) 45if not phosphor_logging.found() 46 subproject('phosphor-logging', required: false) 47 phosphor_logging = declare_dependency( 48 include_directories: 'subprojects/phosphor-logging' 49 ) 50endif 51 52sdbusplus = dependency('sdbusplus', fallback: ['sdbusplus', 'sdbusplus_dep']) 53systemd = dependency('systemd') 54 55if cpp.has_header('nlohmann/json.hpp') 56 nlohmann_json = declare_dependency() 57else 58 nlohmann_json = dependency('nlohmann_json', 59 fallback: ['nlohmann', 'nlohmann_json_dep']) 60endif 61 62add_project_arguments( 63 '-DTELEMETRY_MAX_REPORTS=' + get_option('max-reports').to_string(), 64 '-DTELEMETRY_MAX_READING_PARAMS=' + 65 get_option('max-reading-parameters').to_string(), 66 '-DTELEMETRY_MIN_INTERVAL=' + get_option('min-interval').to_string(), 67 '-DTELEMETRY_MAX_TRIGGERS=' + get_option('max-triggers').to_string(), 68 language: 'cpp' 69) 70 71executable( 72 'telemetry', 73 [ 74 'src/main.cpp', 75 'src/metric.cpp', 76 'src/numeric_threshold.cpp', 77 'src/persistent_json_storage.cpp', 78 'src/report.cpp', 79 'src/report_factory.cpp', 80 'src/report_manager.cpp', 81 'src/sensor.cpp', 82 'src/sensor_cache.cpp', 83 'src/trigger.cpp', 84 'src/trigger_actions.cpp', 85 'src/trigger_factory.cpp', 86 'src/trigger_manager.cpp', 87 ], 88 dependencies: [ 89 boost, 90 nlohmann_json, 91 sdbusplus, 92 phosphor_logging, 93 ], 94 include_directories: 'src', 95 install: true, 96 install_dir: get_option('prefix') / get_option('bindir'), 97 pie: true, 98) 99 100configure_file( 101 input: 'xyz.openbmc_project.Telemetry.service.in', 102 output: 'xyz.openbmc_project.Telemetry.service', 103 configuration: { 104 'bindir': get_option('prefix') / get_option('bindir'), 105 }, 106 install: true, 107 install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir'), 108) 109 110if get_option('buildtest') 111 subdir('tests') 112endif 113