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 | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 9 | 'buildtype=debugoptimized' |
| 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 | |
| 28 | sdbusplus_dep = dependency('sdbusplus', required: false) |
| 29 | if sdbusplus_dep.found() |
| 30 | sdbusplusplus_prog = find_program('sdbus++') |
| 31 | sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson') |
| 32 | else |
| 33 | sdbusplus_proj = subproject('sdbusplus', required: true) |
| 34 | sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') |
| 35 | sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog') |
| 36 | sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable( |
| 37 | 'sdbuspp_gen_meson_prog' |
| 38 | ) |
| 39 | endif |
| 40 | |
George Liu | 687fe07 | 2021-05-04 16:16:43 +0800 | [diff] [blame] | 41 | sdeventplus_dep = dependency( |
| 42 | 'sdeventplus', |
| 43 | fallback: [ |
| 44 | 'sdeventplus', |
| 45 | 'sdeventplus_dep' |
| 46 | ], |
| 47 | ) |
| 48 | phosphor_logging_dep = dependency( |
| 49 | 'phosphor-logging', |
| 50 | fallback: [ |
| 51 | 'phosphor-logging', |
| 52 | 'phosphor_logging_dep' |
| 53 | ], |
| 54 | ) |
| 55 | phosphor_dbus_interfaces_dep = dependency( |
| 56 | 'phosphor-dbus-interfaces', |
| 57 | fallback: [ |
| 58 | 'phosphor-dbus-interfaces', |
| 59 | 'phosphor_dbus_interfaces_dep' |
| 60 | ], |
| 61 | ) |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 62 | prog_python = find_program('python3', required: true) |
| 63 | realpath_prog = find_program('realpath') |
| 64 | |
| 65 | cpp = meson.get_compiler('cpp') |
| 66 | if cpp.has_header('nlohmann/json.hpp') |
| 67 | nlohmann_json = declare_dependency() |
| 68 | else |
| 69 | subproject('nlohmann', required: false) |
| 70 | nlohmann_json = declare_dependency( |
| 71 | include_directories: [ |
| 72 | 'subprojects/nlohmann/single_include', |
| 73 | 'subprojects/nlohmann/single_include/nlohmann', |
| 74 | ] |
| 75 | ) |
| 76 | endif |
| 77 | |
| 78 | selected_subdirs = [] |
| 79 | selected_subdirs += 'xyz/openbmc_project' |
| 80 | |
| 81 | generated_root = meson.current_build_dir() / 'gen' |
| 82 | generated_others = [] |
| 83 | generated_sources = [] |
| 84 | |
| 85 | # Source the generated meson files. |
| 86 | subdir('gen') |
| 87 | foreach d : selected_subdirs |
| 88 | subdir('gen' / d) |
| 89 | endforeach |
| 90 | |
| 91 | # Parse through the list from sdbus++-gendir and put into sets. |
| 92 | generated_headers = [] |
| 93 | generated_cpp = [] |
| 94 | generated_others_files = [] |
| 95 | |
| 96 | foreach g : generated_sources generated_others |
| 97 | foreach f : g.to_list() |
| 98 | rel_path = run_command( |
| 99 | realpath_prog, |
| 100 | '--relative-to', generated_root, |
| 101 | f.full_path(), |
| 102 | ).stdout().strip().split('\n')[-1] |
| 103 | |
| 104 | if rel_path.endswith('.hpp') |
| 105 | generated_headers += rel_path |
| 106 | elif rel_path.endswith('.cpp') |
| 107 | generated_cpp += rel_path |
| 108 | else |
| 109 | generated_others_files += rel_path |
| 110 | endif |
| 111 | endforeach |
| 112 | endforeach |
| 113 | |
| 114 | deps = [ |
| 115 | sdbusplus_dep, |
George Liu | 687fe07 | 2021-05-04 16:16:43 +0800 | [diff] [blame] | 116 | sdeventplus_dep, |
| 117 | phosphor_logging_dep, |
| 118 | phosphor_dbus_interfaces_dep, |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 119 | nlohmann_json |
| 120 | ] |
| 121 | |
| 122 | sources = [ |
| 123 | 'group.cpp', |
| 124 | 'led-main.cpp', |
| 125 | 'manager.cpp', |
| 126 | 'serialize.cpp', |
| 127 | 'utils.cpp', |
| 128 | ] |
| 129 | |
| 130 | if get_option('use-json').disabled() |
| 131 | led_gen_hpp = custom_target( |
| 132 | 'led-gen.hpp', |
| 133 | command : [ |
| 134 | prog_python, |
George Liu | e367cea | 2021-05-04 10:25:43 +0800 | [diff] [blame] | 135 | meson.project_source_root() + '/parse_led.py', |
| 136 | '-i', meson.project_source_root(), |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 137 | '-o', meson.current_build_dir(), |
| 138 | ], |
| 139 | output : 'led-gen.hpp') |
| 140 | sources += [led_gen_hpp] |
| 141 | endif |
| 142 | |
| 143 | if get_option('use-lamp-test').enabled() |
| 144 | conf_data.set_quoted('LAMP_TEST_OBJECT', '/xyz/openbmc_project/led/groups/lamp_test') |
| 145 | conf_data.set_quoted('HOST_LAMP_TEST_OBJECT', '/xyz/openbmc_project/led/groups/host_lamp_test') |
| 146 | conf_data.set_quoted('LAMP_TEST_LED_OVERRIDES_JSON', '/usr/share/phosphor-led-manager/lamp-test-led-overrides.json') |
| 147 | conf_data.set('LAMP_TEST_TIMEOUT_IN_SECS', 240) |
| 148 | |
| 149 | sources += ['lamptest.cpp'] |
| 150 | endif |
| 151 | |
| 152 | configure_file(output: 'config.h', |
| 153 | configuration: conf_data |
| 154 | ) |
| 155 | |
| 156 | install_data( |
| 157 | 'scripts/led-set-all-groups-asserted.sh', |
| 158 | install_dir: get_option('bindir') |
| 159 | ) |
| 160 | |
| 161 | executable( |
| 162 | 'phosphor-ledmanager', |
| 163 | sources, |
| 164 | generated_sources, |
| 165 | include_directories: include_directories('gen'), |
| 166 | dependencies: sdbusplus_dep, |
| 167 | implicit_include_directories: true, |
| 168 | dependencies: deps, |
| 169 | install: true, |
| 170 | install_dir: get_option('bindir') |
| 171 | ) |
| 172 | subdir('fault-monitor') |
| 173 | |
| 174 | build_tests = get_option('tests') |
| 175 | if not build_tests.disabled() |
| 176 | subdir('test') |
| 177 | endif |
George Liu | 629f4a3 | 2021-04-14 17:42:08 +0800 | [diff] [blame] | 178 | |
| 179 | install_subdir('configs', |
| 180 | install_dir: get_option('datadir') / 'phosphor-led-manager', |
| 181 | strip_directory: true) |