Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-state-manager', |
| 3 | 'cpp', |
| 4 | default_options: [ |
| 5 | 'warning_level=3', |
| 6 | 'werror=true', |
Andrew Geissler | 429100a | 2021-09-09 12:50:24 -0500 | [diff] [blame] | 7 | 'cpp_std=c++20' |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 8 | ], |
Andrew Geissler | 429100a | 2021-09-09 12:50:24 -0500 | [diff] [blame] | 9 | meson_version: '>= 0.57.0', |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 10 | license: 'Apache-2.0', |
| 11 | version: '0.1', |
| 12 | ) |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 13 | cpp = meson.get_compiler('cpp') |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 14 | |
Thang Tran | ba2241c | 2021-10-26 17:47:09 +0700 | [diff] [blame] | 15 | build_host_gpios = get_option('host-gpios') |
| 16 | |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 17 | conf = configuration_data() |
| 18 | conf.set_quoted( |
| 19 | 'HOST_BUSNAME', get_option('host-busname')) |
| 20 | conf.set_quoted( |
| 21 | 'HOST_OBJPATH', get_option('host-objpath')) |
| 22 | conf.set_quoted( |
Andrew Geissler | fe270d3 | 2021-01-27 14:06:46 -0600 | [diff] [blame] | 23 | 'HYPERVISOR_BUSNAME', get_option('hypervisor-busname')) |
| 24 | conf.set_quoted( |
| 25 | 'HYPERVISOR_OBJPATH', get_option('hypervisor-objpath')) |
| 26 | conf.set_quoted( |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 27 | 'CHASSIS_BUSNAME', get_option('chassis-busname')) |
| 28 | conf.set_quoted( |
| 29 | 'CHASSIS_OBJPATH', get_option('chassis-objpath')) |
| 30 | conf.set_quoted( |
| 31 | 'BMC_BUSNAME', get_option('bmc-busname')) |
| 32 | conf.set_quoted( |
| 33 | 'BMC_OBJPATH', get_option('bmc-objpath')) |
| 34 | conf.set_quoted( |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 35 | 'HOST_STATE_PERSIST_PATH', get_option('host-state-persist-path')) |
| 36 | conf.set_quoted( |
| 37 | 'POH_COUNTER_PERSIST_PATH', get_option('poh-counter-persist-path')) |
| 38 | conf.set_quoted( |
| 39 | 'CHASSIS_STATE_CHANGE_PERSIST_PATH', get_option('chassis-state-change-persist-path')) |
Carol Wang | 71230ef | 2020-02-18 17:39:49 +0800 | [diff] [blame] | 40 | conf.set_quoted( |
Carol Wang | 1dbbef4 | 2020-03-09 11:51:23 +0800 | [diff] [blame] | 41 | 'SCHEDULED_HOST_TRANSITION_PERSIST_PATH', get_option('scheduled-host-transition-persist-path')) |
| 42 | conf.set_quoted( |
Carol Wang | 71230ef | 2020-02-18 17:39:49 +0800 | [diff] [blame] | 43 | 'SCHEDULED_HOST_TRANSITION_BUSNAME', get_option('scheduled-host-transition-busname')) |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 44 | conf.set( |
| 45 | 'BOOT_COUNT_MAX_ALLOWED', get_option('boot-count-max-allowed')) |
| 46 | conf.set( |
| 47 | 'CLASS_VERSION', get_option('class-version')) |
Thang Tran | ba2241c | 2021-10-26 17:47:09 +0700 | [diff] [blame] | 48 | if build_host_gpios.enabled() |
| 49 | conf.set_quoted( |
| 50 | 'HOST_GPIOS_BUSNAME', get_option('host-gpios-busname')) |
| 51 | conf.set_quoted( |
| 52 | 'HOST_GPIOS_OBJPATH', get_option('host-gpios-objpath')) |
| 53 | endif |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 54 | |
Andrew Geissler | 343dbf8 | 2021-03-16 16:56:09 -0500 | [diff] [blame] | 55 | # globals shared across applications |
| 56 | conf.set_quoted( |
| 57 | 'HOST_RUNNING_FILE', '/run/openbmc/host@%d-on') |
| 58 | |
Andrew Geissler | 5259f97 | 2021-08-30 15:46:55 -0500 | [diff] [blame] | 59 | conf.set_quoted( |
| 60 | 'CHASSIS_ON_FILE', '/run/openbmc/chassis@%d-on') |
| 61 | |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 62 | configure_file(output: 'config.h', configuration: conf) |
| 63 | |
Andrew Geissler | 7fdad60 | 2020-06-22 13:46:16 -0500 | [diff] [blame] | 64 | if(get_option('warm-reboot').enabled()) |
| 65 | add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp') |
| 66 | endif |
| 67 | |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 68 | sdbusplus = dependency('sdbusplus') |
| 69 | sdeventplus = dependency('sdeventplus') |
| 70 | phosphorlogging = dependency('phosphor-logging') |
| 71 | phosphordbusinterfaces = dependency('phosphor-dbus-interfaces') |
Ben Tyner | 2c36e5a | 2021-07-12 14:56:49 -0500 | [diff] [blame] | 72 | libgpiod = dependency('libgpiod', version : '>=1.4.1') |
Allen.Wang | 79b4500 | 2022-02-10 17:59:20 +0800 | [diff] [blame] | 73 | fmt = dependency('fmt') |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 74 | |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 75 | if cpp.has_header('nlohmann/json.hpp') |
| 76 | nlohmann_json = declare_dependency() |
| 77 | else |
| 78 | subproject('nlohmann-json') |
| 79 | nlohmann_json = declare_dependency( |
| 80 | include_directories: [ |
| 81 | 'subprojects/nlohmann-json/single_include', |
| 82 | 'subprojects/nlohmann-json/single_include/nlohmann', |
| 83 | ] |
| 84 | ) |
| 85 | endif |
| 86 | |
| 87 | if cpp.has_header('CLI/CLI.hpp') |
| 88 | CLI11 = declare_dependency() |
| 89 | else |
| 90 | CLI11 = dependency('CLI11') |
| 91 | endif |
| 92 | |
| 93 | # Get Cereal dependency. |
| 94 | cereal = dependency('cereal', required: false) |
| 95 | has_cereal = cpp.has_header_symbol( |
| 96 | 'cereal/cereal.hpp', |
| 97 | 'cereal::specialize', |
| 98 | dependencies: cereal, |
| 99 | required: false) |
| 100 | if not has_cereal |
| 101 | cereal_opts = import('cmake').subproject_options() |
| 102 | cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) |
| 103 | cereal_proj = import('cmake').subproject( |
| 104 | 'cereal', |
| 105 | options: cereal_opts, |
| 106 | required: false) |
| 107 | assert(cereal_proj.found(), 'cereal is required') |
| 108 | cereal = cereal_proj.dependency('cereal') |
| 109 | endif |
| 110 | |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 111 | executable('phosphor-host-state-manager', |
| 112 | 'host_state_manager.cpp', |
| 113 | 'host_state_manager_main.cpp', |
| 114 | 'settings.cpp', |
Andrew Geissler | 0d1c3f1 | 2021-07-27 16:21:01 -0400 | [diff] [blame] | 115 | 'host_check.cpp', |
Andrew Geissler | 1ab2b6c | 2022-03-10 16:16:15 -0600 | [diff] [blame] | 116 | 'utils.cpp', |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 117 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 118 | cereal, |
| 119 | fmt, |
| 120 | libgpiod, |
| 121 | phosphordbusinterfaces, |
| 122 | phosphorlogging, |
| 123 | sdbusplus, |
| 124 | sdeventplus, |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 125 | ], |
| 126 | implicit_include_directories: true, |
| 127 | install: true |
| 128 | ) |
| 129 | |
Andrew Geissler | fe270d3 | 2021-01-27 14:06:46 -0600 | [diff] [blame] | 130 | executable('phosphor-hypervisor-state-manager', |
| 131 | 'hypervisor_state_manager.cpp', |
| 132 | 'hypervisor_state_manager_main.cpp', |
| 133 | 'settings.cpp', |
| 134 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 135 | phosphordbusinterfaces, |
| 136 | phosphorlogging, |
| 137 | sdbusplus, |
| 138 | sdeventplus, |
Andrew Geissler | fe270d3 | 2021-01-27 14:06:46 -0600 | [diff] [blame] | 139 | ], |
| 140 | implicit_include_directories: true, |
| 141 | install: true |
| 142 | ) |
| 143 | |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 144 | executable('phosphor-chassis-state-manager', |
| 145 | 'chassis_state_manager.cpp', |
| 146 | 'chassis_state_manager_main.cpp', |
Andrew Geissler | f8ae6a0 | 2022-01-21 17:00:20 -0600 | [diff] [blame] | 147 | 'utils.cpp', |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 148 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 149 | cereal, |
| 150 | fmt, |
| 151 | libgpiod, |
| 152 | nlohmann_json, |
| 153 | phosphordbusinterfaces, |
| 154 | phosphorlogging, |
| 155 | sdbusplus, |
| 156 | sdeventplus, |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 157 | ], |
| 158 | implicit_include_directories: true, |
| 159 | install: true |
| 160 | ) |
| 161 | |
Andrew Geissler | 378fe11 | 2022-02-03 16:39:44 -0600 | [diff] [blame] | 162 | executable('phosphor-chassis-check-power-status', |
| 163 | 'chassis_check_power_status.cpp', |
| 164 | 'utils.cpp', |
| 165 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 166 | libgpiod, |
| 167 | phosphordbusinterfaces, |
| 168 | phosphorlogging, |
| 169 | sdbusplus, |
Andrew Geissler | 378fe11 | 2022-02-03 16:39:44 -0600 | [diff] [blame] | 170 | ], |
| 171 | implicit_include_directories: true, |
| 172 | install: true |
| 173 | ) |
| 174 | |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 175 | executable('phosphor-bmc-state-manager', |
| 176 | 'bmc_state_manager.cpp', |
| 177 | 'bmc_state_manager_main.cpp', |
Andrew Geissler | 98e64e6 | 2022-01-25 16:02:56 -0600 | [diff] [blame] | 178 | 'utils.cpp', |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 179 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 180 | libgpiod, |
| 181 | phosphordbusinterfaces, |
| 182 | phosphorlogging, |
| 183 | sdbusplus, |
| 184 | sdeventplus, |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 185 | ], |
| 186 | implicit_include_directories: true, |
| 187 | install: true |
| 188 | ) |
| 189 | |
| 190 | executable('phosphor-discover-system-state', |
| 191 | 'discover_system_state.cpp', |
| 192 | 'settings.cpp', |
Andrew Geissler | 49e6713 | 2022-01-26 14:27:52 -0600 | [diff] [blame] | 193 | 'utils.cpp', |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 194 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 195 | cereal, |
| 196 | libgpiod, |
| 197 | phosphorlogging, |
| 198 | sdbusplus, |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 199 | ], |
| 200 | implicit_include_directories: true, |
| 201 | install: true |
| 202 | ) |
| 203 | |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 204 | executable('phosphor-systemd-target-monitor', |
Andrew Geissler | 9e3afdf | 2022-02-10 15:06:16 -0600 | [diff] [blame] | 205 | 'systemd_service_parser.cpp', |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 206 | 'systemd_target_monitor.cpp', |
| 207 | 'systemd_target_parser.cpp', |
| 208 | 'systemd_target_signal.cpp', |
| 209 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 210 | CLI11, |
| 211 | nlohmann_json, |
| 212 | phosphorlogging, |
| 213 | sdbusplus, |
| 214 | sdeventplus, |
Andrew Geissler | f245410 | 2019-12-06 15:14:08 -0600 | [diff] [blame] | 215 | ], |
| 216 | implicit_include_directories: true, |
| 217 | install: true |
| 218 | ) |
Andrew Geissler | 3f12563 | 2019-12-11 17:08:19 -0600 | [diff] [blame] | 219 | |
Carol Wang | 71230ef | 2020-02-18 17:39:49 +0800 | [diff] [blame] | 220 | executable('phosphor-scheduled-host-transition', |
| 221 | 'scheduled_host_transition_main.cpp', |
| 222 | 'scheduled_host_transition.cpp', |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 223 | 'utils.cpp', |
Carol Wang | 71230ef | 2020-02-18 17:39:49 +0800 | [diff] [blame] | 224 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 225 | cereal, |
| 226 | libgpiod, |
| 227 | phosphorlogging, |
| 228 | sdbusplus, |
| 229 | sdeventplus, |
Carol Wang | 71230ef | 2020-02-18 17:39:49 +0800 | [diff] [blame] | 230 | ], |
| 231 | implicit_include_directories: true, |
| 232 | install: true |
| 233 | ) |
| 234 | |
Andrew Geissler | ba0163a | 2021-08-11 15:09:50 -0400 | [diff] [blame] | 235 | executable('phosphor-host-reset-recovery', |
| 236 | 'host_reset_recovery.cpp', |
| 237 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 238 | phosphorlogging, |
| 239 | sdbusplus, |
Andrew Geissler | ba0163a | 2021-08-11 15:09:50 -0400 | [diff] [blame] | 240 | ], |
| 241 | implicit_include_directories: true, |
| 242 | install: true |
| 243 | ) |
| 244 | |
Andrew Geissler | dfa75fc | 2019-12-11 17:26:42 -0600 | [diff] [blame] | 245 | install_data('obmcutil', |
| 246 | install_mode: 'rwxr-xr-x', |
| 247 | install_dir: get_option('bindir') |
| 248 | ) |
| 249 | |
Andrew Geissler | 179d38c | 2019-12-10 15:05:23 -0600 | [diff] [blame] | 250 | systemd = dependency('systemd') |
Andrew Geissler | 429100a | 2021-09-09 12:50:24 -0500 | [diff] [blame] | 251 | systemd_system_unit_dir = systemd.get_variable( |
| 252 | pkgconfig : 'systemdsystemunitdir') |
Andrew Geissler | 179d38c | 2019-12-10 15:05:23 -0600 | [diff] [blame] | 253 | subdir('service_files') |
Andrew Geissler | c101157 | 2020-01-27 15:09:50 -0600 | [diff] [blame] | 254 | subdir('target_files') |
Andrew Geissler | 179d38c | 2019-12-10 15:05:23 -0600 | [diff] [blame] | 255 | |
Thang Tran | ba2241c | 2021-10-26 17:47:09 +0700 | [diff] [blame] | 256 | if build_host_gpios.enabled() |
| 257 | subdir('host_condition_gpio') |
| 258 | endif |
| 259 | |
Andrew Geissler | efef970 | 2019-12-10 16:56:57 -0600 | [diff] [blame] | 260 | datadir = join_paths( |
| 261 | get_option('sysconfdir'), |
| 262 | 'phosphor-systemd-target-monitor' |
| 263 | ) |
| 264 | subdir('data') |
| 265 | |
Andrew Geissler | 3f12563 | 2019-12-11 17:08:19 -0600 | [diff] [blame] | 266 | build_tests = get_option('tests') |
| 267 | |
| 268 | # If test coverage of source files within the root directory are wanted, |
| 269 | # need to define and build the tests from here |
| 270 | if not build_tests.disabled() |
| 271 | gtest = dependency('gtest', main: true, disabler: true, required: build_tests) |
Carol Wang | 4ca6f3f | 2020-02-19 16:28:59 +0800 | [diff] [blame] | 272 | gmock = dependency('gmock', disabler: true, required: build_tests) |
Andrew Geissler | 3f12563 | 2019-12-11 17:08:19 -0600 | [diff] [blame] | 273 | test( |
| 274 | 'test_systemd_parser', |
| 275 | executable('test_systemd_parser', |
| 276 | './test/systemd_parser.cpp', |
| 277 | 'systemd_target_parser.cpp', |
| 278 | dependencies: [ |
| 279 | gtest, |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 280 | nlohmann_json, |
Andrew Geissler | 3f12563 | 2019-12-11 17:08:19 -0600 | [diff] [blame] | 281 | ], |
| 282 | implicit_include_directories: true, |
| 283 | include_directories: '../' |
| 284 | ) |
| 285 | ) |
| 286 | |
| 287 | test( |
| 288 | 'test_systemd_signal', |
| 289 | executable('test_systemd_signal', |
| 290 | './test/systemd_signal.cpp', |
| 291 | 'systemd_target_signal.cpp', |
| 292 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 293 | gtest, |
| 294 | nlohmann_json, |
| 295 | phosphorlogging, |
| 296 | sdbusplus, |
| 297 | sdeventplus, |
Andrew Geissler | 3f12563 | 2019-12-11 17:08:19 -0600 | [diff] [blame] | 298 | ], |
| 299 | implicit_include_directories: true, |
| 300 | include_directories: '../' |
| 301 | ) |
| 302 | ) |
Carol Wang | 4ca6f3f | 2020-02-19 16:28:59 +0800 | [diff] [blame] | 303 | |
| 304 | test( |
| 305 | 'test_scheduled_host_transition', |
| 306 | executable('test_scheduled_host_transition', |
| 307 | './test/test_scheduled_host_transition.cpp', |
| 308 | 'scheduled_host_transition.cpp', |
Carol Wang | dc05939 | 2020-03-13 17:39:17 +0800 | [diff] [blame] | 309 | 'utils.cpp', |
Carol Wang | 4ca6f3f | 2020-02-19 16:28:59 +0800 | [diff] [blame] | 310 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 311 | cereal, |
| 312 | gmock, |
| 313 | gtest, |
| 314 | libgpiod, |
| 315 | phosphorlogging, |
| 316 | sdbusplus, |
| 317 | sdeventplus, |
Carol Wang | 4ca6f3f | 2020-02-19 16:28:59 +0800 | [diff] [blame] | 318 | ], |
| 319 | implicit_include_directories: true, |
| 320 | include_directories: '../' |
| 321 | ) |
| 322 | ) |
Andrew Geissler | c74716e | 2021-02-09 15:11:10 -0600 | [diff] [blame] | 323 | |
| 324 | test( |
| 325 | 'test_hypervisor_state', |
| 326 | executable('test_hypervisor_state', |
| 327 | './test/hypervisor_state.cpp', |
| 328 | 'hypervisor_state_manager.cpp', |
| 329 | dependencies: [ |
Patrick Williams | f8d5f3e | 2022-04-05 15:51:15 -0500 | [diff] [blame] | 330 | gtest, |
| 331 | phosphorlogging, |
| 332 | sdbusplus, |
| 333 | sdeventplus, |
Andrew Geissler | c74716e | 2021-02-09 15:11:10 -0600 | [diff] [blame] | 334 | ], |
| 335 | implicit_include_directories: true, |
| 336 | include_directories: '../' |
| 337 | ) |
| 338 | ) |
Andrew Geissler | 3f12563 | 2019-12-11 17:08:19 -0600 | [diff] [blame] | 339 | endif |