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