George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-ledmanager', 'cpp', |
| 3 | version : '1.0.0', |
George Liu | e367cea | 2021-05-04 10:25:43 +0800 | [diff] [blame] | 4 | meson_version: '>=0.57.0', |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 5 | default_options: [ |
| 6 | 'warning_level=3', |
| 7 | 'werror=true', |
George Liu | e367cea | 2021-05-04 10:25:43 +0800 | [diff] [blame] | 8 | 'cpp_std=c++20', |
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() |
| 14 | conf_data.set_quoted('BUSNAME', 'xyz.openbmc_project.LED.GroupManager') |
| 15 | conf_data.set_quoted('OBJPATH', '/xyz/openbmc_project/led/groups') |
| 16 | conf_data.set_quoted('LED_JSON_FILE', '/usr/share/phosphor-led-manager/led-group-config.json') |
| 17 | conf_data.set_quoted('SAVED_GROUPS_FILE', '/var/lib/phosphor-led-manager/savedGroups') |
| 18 | conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout') |
| 19 | conf_data.set_quoted('CALLOUT_REV_ASSOCIATION', 'fault') |
| 20 | conf_data.set_quoted('ELOG_ENTRY', 'entry') |
| 21 | conf_data.set_quoted('LED_FAULT', 'fault') |
| 22 | |
| 23 | conf_data.set('CLASS_VERSION', 1) |
| 24 | conf_data.set('LED_USE_JSON', get_option('use-json').enabled()) |
| 25 | conf_data.set('USE_LAMP_TEST', get_option('use-lamp-test').enabled()) |
George Liu | d76c074 | 2021-04-15 17:56:03 +0800 | [diff] [blame] | 26 | conf_data.set('MONITOR_OPERATIONAL_STATUS', get_option('monitor-operational-status').enabled()) |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 27 | |
Patrick Williams | 9bd334f | 2022-03-16 11:28:26 -0500 | [diff] [blame] | 28 | sdbusplus_dep = dependency('sdbusplus') |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 29 | |
George Liu | 687fe07 | 2021-05-04 16:16:43 +0800 | [diff] [blame] | 30 | sdeventplus_dep = dependency( |
| 31 | 'sdeventplus', |
| 32 | fallback: [ |
| 33 | 'sdeventplus', |
| 34 | 'sdeventplus_dep' |
| 35 | ], |
| 36 | ) |
| 37 | phosphor_logging_dep = dependency( |
| 38 | 'phosphor-logging', |
| 39 | fallback: [ |
| 40 | 'phosphor-logging', |
| 41 | 'phosphor_logging_dep' |
| 42 | ], |
| 43 | ) |
| 44 | phosphor_dbus_interfaces_dep = dependency( |
| 45 | 'phosphor-dbus-interfaces', |
| 46 | fallback: [ |
| 47 | 'phosphor-dbus-interfaces', |
| 48 | 'phosphor_dbus_interfaces_dep' |
| 49 | ], |
| 50 | ) |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 51 | prog_python = find_program('python3', required: true) |
| 52 | realpath_prog = find_program('realpath') |
| 53 | |
| 54 | cpp = meson.get_compiler('cpp') |
| 55 | if cpp.has_header('nlohmann/json.hpp') |
Patrick Williams | d1c1f0e | 2022-03-16 10:46:47 -0500 | [diff] [blame] | 56 | nlohmann_json_dep = declare_dependency() |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 57 | else |
| 58 | subproject('nlohmann', required: false) |
Patrick Williams | d1c1f0e | 2022-03-16 10:46:47 -0500 | [diff] [blame] | 59 | nlohmann_json_dep = declare_dependency( |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 60 | include_directories: [ |
| 61 | 'subprojects/nlohmann/single_include', |
| 62 | 'subprojects/nlohmann/single_include/nlohmann', |
| 63 | ] |
| 64 | ) |
| 65 | endif |
| 66 | |
Patrick Williams | d1c1f0e | 2022-03-16 10:46:47 -0500 | [diff] [blame] | 67 | # Get Cereal dependency. |
| 68 | cereal_dep = dependency('cereal', required: false) |
| 69 | has_cereal = cpp.has_header_symbol( |
| 70 | 'cereal/cereal.hpp', |
| 71 | 'cereal::specialize', |
| 72 | dependencies: cereal_dep, |
| 73 | required: false) |
| 74 | if not has_cereal |
| 75 | cereal_opts = import('cmake').subproject_options() |
| 76 | cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) |
| 77 | cereal_proj = import('cmake').subproject( |
| 78 | 'cereal', |
| 79 | options: cereal_opts, |
| 80 | required: false) |
| 81 | assert(cereal_proj.found(), 'cereal is required') |
| 82 | cereal_dep = cereal_proj.dependency('cereal') |
| 83 | endif |
| 84 | |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 85 | deps = [ |
| 86 | sdbusplus_dep, |
George Liu | 687fe07 | 2021-05-04 16:16:43 +0800 | [diff] [blame] | 87 | sdeventplus_dep, |
| 88 | phosphor_logging_dep, |
| 89 | phosphor_dbus_interfaces_dep, |
Patrick Williams | d1c1f0e | 2022-03-16 10:46:47 -0500 | [diff] [blame] | 90 | nlohmann_json_dep, |
| 91 | cereal_dep, |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 92 | ] |
| 93 | |
| 94 | sources = [ |
| 95 | 'group.cpp', |
| 96 | 'led-main.cpp', |
| 97 | 'manager.cpp', |
| 98 | 'serialize.cpp', |
| 99 | 'utils.cpp', |
| 100 | ] |
| 101 | |
| 102 | if get_option('use-json').disabled() |
| 103 | led_gen_hpp = custom_target( |
| 104 | 'led-gen.hpp', |
| 105 | command : [ |
| 106 | prog_python, |
Patrick Williams | 79d7245 | 2022-03-16 14:19:39 -0500 | [diff] [blame^] | 107 | meson.project_source_root() + '/scripts/parse_led.py', |
Seires Li | ad73885 | 2021-06-24 07:00:37 +0800 | [diff] [blame] | 108 | '-i', meson.project_source_root(), |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 109 | '-o', meson.current_build_dir(), |
| 110 | ], |
| 111 | output : 'led-gen.hpp') |
| 112 | sources += [led_gen_hpp] |
| 113 | endif |
| 114 | |
| 115 | if get_option('use-lamp-test').enabled() |
| 116 | conf_data.set_quoted('LAMP_TEST_OBJECT', '/xyz/openbmc_project/led/groups/lamp_test') |
| 117 | conf_data.set_quoted('HOST_LAMP_TEST_OBJECT', '/xyz/openbmc_project/led/groups/host_lamp_test') |
| 118 | conf_data.set_quoted('LAMP_TEST_LED_OVERRIDES_JSON', '/usr/share/phosphor-led-manager/lamp-test-led-overrides.json') |
| 119 | conf_data.set('LAMP_TEST_TIMEOUT_IN_SECS', 240) |
| 120 | |
| 121 | sources += ['lamptest.cpp'] |
| 122 | endif |
| 123 | |
| 124 | configure_file(output: 'config.h', |
| 125 | configuration: conf_data |
| 126 | ) |
| 127 | |
| 128 | install_data( |
| 129 | 'scripts/led-set-all-groups-asserted.sh', |
| 130 | install_dir: get_option('bindir') |
| 131 | ) |
| 132 | |
| 133 | executable( |
| 134 | 'phosphor-ledmanager', |
| 135 | sources, |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 136 | implicit_include_directories: true, |
| 137 | dependencies: deps, |
| 138 | install: true, |
| 139 | install_dir: get_option('bindir') |
| 140 | ) |
| 141 | subdir('fault-monitor') |
| 142 | |
| 143 | build_tests = get_option('tests') |
| 144 | if not build_tests.disabled() |
| 145 | subdir('test') |
| 146 | endif |
George Liu | 629f4a3 | 2021-04-14 17:42:08 +0800 | [diff] [blame] | 147 | |
| 148 | install_subdir('configs', |
| 149 | install_dir: get_option('datadir') / 'phosphor-led-manager', |
| 150 | strip_directory: true) |