George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-ledmanager', 'cpp', |
| 3 | version : '1.0.0', |
Patrick Williams | 959b482 | 2023-07-12 11:15:13 -0500 | [diff] [blame] | 4 | meson_version: '>=1.1.1', |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 5 | default_options: [ |
| 6 | 'warning_level=3', |
| 7 | 'werror=true', |
Patrick Williams | 959b482 | 2023-07-12 11:15:13 -0500 | [diff] [blame] | 8 | 'cpp_std=c++23', |
George Liu | db6d763 | 2021-12-27 14:11:01 +0800 | [diff] [blame] | 9 | 'buildtype=debugoptimized', |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 10 | ] |
| 11 | ) |
| 12 | |
| 13 | conf_data = configuration_data() |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 14 | conf_data.set_quoted('LED_JSON_FILE', '/usr/share/phosphor-led-manager/led-group-config.json') |
| 15 | conf_data.set_quoted('SAVED_GROUPS_FILE', '/var/lib/phosphor-led-manager/savedGroups') |
| 16 | conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout') |
| 17 | conf_data.set_quoted('CALLOUT_REV_ASSOCIATION', 'fault') |
| 18 | conf_data.set_quoted('ELOG_ENTRY', 'entry') |
| 19 | conf_data.set_quoted('LED_FAULT', 'fault') |
| 20 | |
| 21 | conf_data.set('CLASS_VERSION', 1) |
Patrick Williams | 95b0db9 | 2023-11-29 06:43:59 -0600 | [diff] [blame^] | 22 | conf_data.set('LED_USE_JSON', get_option('use-json').allowed()) |
| 23 | conf_data.set('USE_LAMP_TEST', get_option('use-lamp-test').allowed()) |
| 24 | conf_data.set('MONITOR_OPERATIONAL_STATUS', get_option('monitor-operational-status').allowed()) |
| 25 | conf_data.set('PERSISTENT_LED_ASSERTED', get_option('persistent-led-asserted').allowed()) |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 26 | |
Patrick Williams | 9bd334f | 2022-03-16 11:28:26 -0500 | [diff] [blame] | 27 | sdbusplus_dep = dependency('sdbusplus') |
Patrick Williams | a821dea | 2022-03-21 09:43:07 -0500 | [diff] [blame] | 28 | sdeventplus_dep = dependency('sdeventplus') |
| 29 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 30 | phosphor_logging_dep = dependency('phosphor-logging') |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 31 | |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 32 | prog_python = find_program('python3', required: true) |
| 33 | realpath_prog = find_program('realpath') |
| 34 | |
| 35 | cpp = meson.get_compiler('cpp') |
| 36 | if cpp.has_header('nlohmann/json.hpp') |
Patrick Williams | d1c1f0e | 2022-03-16 10:46:47 -0500 | [diff] [blame] | 37 | nlohmann_json_dep = declare_dependency() |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 38 | else |
| 39 | subproject('nlohmann', required: false) |
Patrick Williams | d1c1f0e | 2022-03-16 10:46:47 -0500 | [diff] [blame] | 40 | nlohmann_json_dep = declare_dependency( |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 41 | include_directories: [ |
| 42 | 'subprojects/nlohmann/single_include', |
| 43 | 'subprojects/nlohmann/single_include/nlohmann', |
| 44 | ] |
| 45 | ) |
| 46 | endif |
| 47 | |
Patrick Williams | 7217c03 | 2022-03-16 16:26:09 -0500 | [diff] [blame] | 48 | if cpp.has_header('CLI/CLI.hpp') |
| 49 | CLI11_dep = declare_dependency() |
| 50 | else |
Patrick Williams | a821dea | 2022-03-21 09:43:07 -0500 | [diff] [blame] | 51 | CLI11_dep = dependency('CLI11') |
Patrick Williams | 7217c03 | 2022-03-16 16:26:09 -0500 | [diff] [blame] | 52 | endif |
| 53 | |
Patrick Williams | d1c1f0e | 2022-03-16 10:46:47 -0500 | [diff] [blame] | 54 | # Get Cereal dependency. |
| 55 | cereal_dep = dependency('cereal', required: false) |
| 56 | has_cereal = cpp.has_header_symbol( |
| 57 | 'cereal/cereal.hpp', |
| 58 | 'cereal::specialize', |
| 59 | dependencies: cereal_dep, |
| 60 | required: false) |
| 61 | if not has_cereal |
| 62 | cereal_opts = import('cmake').subproject_options() |
| 63 | cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) |
| 64 | cereal_proj = import('cmake').subproject( |
| 65 | 'cereal', |
| 66 | options: cereal_opts, |
| 67 | required: false) |
| 68 | assert(cereal_proj.found(), 'cereal is required') |
| 69 | cereal_dep = cereal_proj.dependency('cereal') |
| 70 | endif |
| 71 | |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 72 | deps = [ |
Patrick Williams | 7217c03 | 2022-03-16 16:26:09 -0500 | [diff] [blame] | 73 | CLI11_dep, |
| 74 | cereal_dep, |
| 75 | nlohmann_json_dep, |
| 76 | phosphor_dbus_interfaces_dep, |
| 77 | phosphor_logging_dep, |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 78 | sdbusplus_dep, |
George Liu | 687fe07 | 2021-05-04 16:16:43 +0800 | [diff] [blame] | 79 | sdeventplus_dep, |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 80 | ] |
| 81 | |
Patrick Williams | 953315d | 2022-03-16 14:30:39 -0500 | [diff] [blame] | 82 | subdir('manager') |
| 83 | subdir('fault-monitor') |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 84 | |
| 85 | configure_file(output: 'config.h', |
| 86 | configuration: conf_data |
| 87 | ) |
| 88 | |
| 89 | install_data( |
| 90 | 'scripts/led-set-all-groups-asserted.sh', |
| 91 | install_dir: get_option('bindir') |
| 92 | ) |
| 93 | |
George Liu | 049700c | 2023-08-07 17:28:30 +0800 | [diff] [blame] | 94 | if get_option('tests').allowed() |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 95 | subdir('test') |
| 96 | endif |
George Liu | 629f4a3 | 2021-04-14 17:42:08 +0800 | [diff] [blame] | 97 | |
| 98 | install_subdir('configs', |
| 99 | install_dir: get_option('datadir') / 'phosphor-led-manager', |
| 100 | strip_directory: true) |