Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 1 | project( |
| 2 | 'Telemetry', |
| 3 | 'cpp', |
Wludzik, Jozef | 0e29f43 | 2020-11-17 08:22:33 +0100 | [diff] [blame] | 4 | meson_version: '>=0.54.3', |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 5 | default_options: [ |
| 6 | 'buildtype=debugoptimized', |
| 7 | 'cpp_std=c++17', |
Wludzik, Jozef | a4bf740 | 2020-10-21 15:08:58 +0200 | [diff] [blame] | 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', |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 11 | 'warning_level=3', |
| 12 | 'werror=true', |
| 13 | 'b_lto=true', |
| 14 | ], |
| 15 | license: 'Apache-2.0', |
| 16 | ) |
| 17 | |
| 18 | cpp = meson.get_compiler('cpp') |
| 19 | add_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 | '-Wno-unused-parameter', |
| 28 | ]), |
| 29 | language: 'cpp' |
| 30 | ) |
| 31 | |
Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame] | 32 | boost = dependency( |
| 33 | 'boost', |
| 34 | version: '>=1.74.0', |
| 35 | required: false, |
| 36 | modules: ['coroutine']) |
| 37 | |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 38 | if not boost.found() |
| 39 | subproject('boost', required: false) |
Wludzik, Jozef | a4bf740 | 2020-10-21 15:08:58 +0200 | [diff] [blame] | 40 | boost = declare_dependency(include_directories: 'subprojects/boost_1_74_0') |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 41 | endif |
| 42 | |
| 43 | phosphor_logging = dependency('phosphor-logging', required: false) |
| 44 | if not phosphor_logging.found() |
| 45 | subproject('phosphor-logging', required: false) |
| 46 | phosphor_logging = declare_dependency( |
| 47 | include_directories: 'subprojects/phosphor-logging' |
| 48 | ) |
| 49 | endif |
| 50 | |
| 51 | sdbusplus = dependency('sdbusplus',required : false) |
| 52 | if not sdbusplus.found() |
| 53 | sdbusplus_proj = subproject('sdbusplus', required: true) |
| 54 | sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') |
| 55 | endif |
| 56 | |
| 57 | systemd = dependency('systemd') |
| 58 | |
Krzysztof Grobelny | 73da690 | 2020-09-24 13:42:04 +0200 | [diff] [blame] | 59 | if cpp.has_header('nlohmann/json.hpp') |
| 60 | nlohmann_json = declare_dependency() |
| 61 | else |
| 62 | subproject('nlohmann', required: false) |
| 63 | nlohmann_json = declare_dependency( |
| 64 | include_directories: [ |
| 65 | 'subprojects/nlohmann/single_include', |
| 66 | 'subprojects/nlohmann/single_include/nlohmann', |
| 67 | ] |
| 68 | ) |
| 69 | endif |
| 70 | |
Wludzik, Jozef | 503c158 | 2020-12-11 14:48:01 +0100 | [diff] [blame] | 71 | add_project_arguments( |
| 72 | '-DTELEMETRY_MAX_REPORTS=' + get_option('max-reports').to_string(), |
| 73 | '-DTELEMETRY_MAX_READING_PARAMS=' + get_option('max-reading-parameters').to_string(), |
| 74 | '-DTELEMETRY_MIN_INTERVAL=' + get_option('min-interval').to_string(), |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame^] | 75 | '-DTELEMETRY_MAX_TRIGGERS=' + get_option('max-triggers').to_string(), |
Wludzik, Jozef | 503c158 | 2020-12-11 14:48:01 +0100 | [diff] [blame] | 76 | language: 'cpp' |
| 77 | ) |
| 78 | |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 79 | executable( |
| 80 | 'telemetry', |
| 81 | [ |
| 82 | 'src/main.cpp', |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 83 | 'src/metric.cpp', |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 84 | 'src/persistent_json_storage.cpp', |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 85 | 'src/report.cpp', |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 86 | 'src/report_factory.cpp', |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 87 | 'src/report_manager.cpp', |
Krzysztof Grobelny | b564594 | 2020-09-29 11:52:45 +0200 | [diff] [blame] | 88 | 'src/sensor.cpp', |
Krzysztof Grobelny | 7f06f61 | 2020-09-24 13:42:10 +0200 | [diff] [blame] | 89 | 'src/sensor_cache.cpp', |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame^] | 90 | 'src/trigger.cpp', |
| 91 | 'src/trigger_factory.cpp', |
| 92 | 'src/trigger_manager.cpp', |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 93 | ], |
| 94 | dependencies: [ |
| 95 | boost, |
Krzysztof Grobelny | 73da690 | 2020-09-24 13:42:04 +0200 | [diff] [blame] | 96 | nlohmann_json, |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 97 | sdbusplus, |
| 98 | phosphor_logging, |
| 99 | ], |
| 100 | include_directories: 'src', |
| 101 | install: true, |
| 102 | install_dir: get_option('prefix') / get_option('bindir'), |
| 103 | pie: true, |
| 104 | ) |
| 105 | |
| 106 | configure_file( |
| 107 | input: 'xyz.openbmc_project.Telemetry.service.in', |
| 108 | output: 'xyz.openbmc_project.Telemetry.service', |
| 109 | configuration: { |
| 110 | 'bindir': get_option('prefix') / get_option('bindir'), |
| 111 | }, |
| 112 | install: true, |
| 113 | install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir'), |
| 114 | ) |
Krzysztof Grobelny | 73da690 | 2020-09-24 13:42:04 +0200 | [diff] [blame] | 115 | |
| 116 | if get_option('buildtest') |
| 117 | subdir('tests') |
| 118 | endif |