blob: 12daf3589472c5ec217cecc1c83ea1840ff56e4d [file] [log] [blame]
Andrew Geisslerf2454102019-12-06 15:14:08 -06001project(
2 'phosphor-state-manager',
3 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Patrick Williams9beba5a2023-07-12 11:15:24 -05007 'cpp_std=c++23'
Andrew Geisslerf2454102019-12-06 15:14:08 -06008 ],
Patrick Williams9beba5a2023-07-12 11:15:24 -05009 meson_version: '>=1.1.1',
Andrew Geisslerf2454102019-12-06 15:14:08 -060010 license: 'Apache-2.0',
11 version: '0.1',
12)
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -050013cpp = meson.get_compiler('cpp')
Andrew Geisslerf2454102019-12-06 15:14:08 -060014
Thang Tranba2241c2021-10-26 17:47:09 +070015build_host_gpios = get_option('host-gpios')
16
Andrew Geisslerf2454102019-12-06 15:14:08 -060017conf = configuration_data()
18conf.set_quoted(
19 'HOST_BUSNAME', get_option('host-busname'))
20conf.set_quoted(
21 'HOST_OBJPATH', get_option('host-objpath'))
22conf.set_quoted(
Andrew Geisslera0d7bb82023-03-01 12:50:14 -060023 'HOST_SCHED_OBJPATH', get_option('host-sched-objpath'))
24conf.set_quoted(
Andrew Geisslerfe270d32021-01-27 14:06:46 -060025 'HYPERVISOR_BUSNAME', get_option('hypervisor-busname'))
26conf.set_quoted(
27 'HYPERVISOR_OBJPATH', get_option('hypervisor-objpath'))
28conf.set_quoted(
Andrew Geisslerf2454102019-12-06 15:14:08 -060029 'CHASSIS_BUSNAME', get_option('chassis-busname'))
30conf.set_quoted(
31 'CHASSIS_OBJPATH', get_option('chassis-objpath'))
32conf.set_quoted(
33 'BMC_BUSNAME', get_option('bmc-busname'))
34conf.set_quoted(
35 'BMC_OBJPATH', get_option('bmc-objpath'))
36conf.set_quoted(
Andrew Geisslerf2454102019-12-06 15:14:08 -060037 'HOST_STATE_PERSIST_PATH', get_option('host-state-persist-path'))
38conf.set_quoted(
39 'POH_COUNTER_PERSIST_PATH', get_option('poh-counter-persist-path'))
40conf.set_quoted(
41 'CHASSIS_STATE_CHANGE_PERSIST_PATH', get_option('chassis-state-change-persist-path'))
Carol Wang71230ef2020-02-18 17:39:49 +080042conf.set_quoted(
Carol Wang1dbbef42020-03-09 11:51:23 +080043 'SCHEDULED_HOST_TRANSITION_PERSIST_PATH', get_option('scheduled-host-transition-persist-path'))
44conf.set_quoted(
Carol Wang71230ef2020-02-18 17:39:49 +080045 'SCHEDULED_HOST_TRANSITION_BUSNAME', get_option('scheduled-host-transition-busname'))
Andrew Geisslerf2454102019-12-06 15:14:08 -060046conf.set(
47 'BOOT_COUNT_MAX_ALLOWED', get_option('boot-count-max-allowed'))
48conf.set(
49 'CLASS_VERSION', get_option('class-version'))
Andrew Geissler8d8d7312022-03-04 14:42:26 -060050conf.set_quoted(
51 'SYSFS_SECURE_BOOT_PATH', get_option('sysfs-secure-boot-path'))
52conf.set_quoted(
53 'SYSFS_ABR_IMAGE_PATH', get_option('sysfs-abr-image-path'))
Patrick Williams5cd49f72023-11-29 06:44:17 -060054if build_host_gpios.allowed()
Thang Tranba2241c2021-10-26 17:47:09 +070055 conf.set_quoted(
56 'HOST_GPIOS_BUSNAME', get_option('host-gpios-busname'))
57 conf.set_quoted(
58 'HOST_GPIOS_OBJPATH', get_option('host-gpios-objpath'))
59endif
Andrew Geisslerf2454102019-12-06 15:14:08 -060060
NodeMan97bcbee4a2022-05-27 15:28:45 -050061conf.set10(
62 'ONLY_RUN_APR_ON_POWER_LOSS', get_option('only-run-apr-on-power-loss'))
63
Lakshmi Yadlapatib454d8b2023-03-27 16:11:41 -050064conf.set_quoted(
Lakshmi Yadlapati21d74d82023-07-20 17:37:22 -050065 'SYSFS_TPM_DEVICE_PATH', get_option('sysfs-tpm-device-path'))
66
67conf.set_quoted(
Lakshmi Yadlapatib454d8b2023-03-27 16:11:41 -050068 'SYSFS_TPM_MEASUREMENT_PATH', get_option('sysfs-tpm-measurement-path'))
69
Andrew Geissler629e3c42023-05-25 10:31:13 -040070conf.set10(
71 'ONLY_ALLOW_BOOT_WHEN_BMC_READY', get_option('only-allow-boot-when-bmc-ready'))
72
Andrew Geissler343dbf82021-03-16 16:56:09 -050073# globals shared across applications
74conf.set_quoted(
NodeMan97bcbee4a2022-05-27 15:28:45 -050075 'BASE_FILE_DIR', '/run/openbmc/')
76
77conf.set_quoted(
Patrick Williams78c066f2024-02-13 12:25:58 -060078 'CHASSIS_LOST_POWER_FILE', '/run/openbmc/chassis@{}-lost-power')
NodeMan97bcbee4a2022-05-27 15:28:45 -050079
80conf.set_quoted(
Patrick Williams78c066f2024-02-13 12:25:58 -060081 'HOST_RUNNING_FILE', '/run/openbmc/host@{}-on')
Andrew Geissler343dbf82021-03-16 16:56:09 -050082
Andrew Geissler5259f972021-08-30 15:46:55 -050083conf.set_quoted(
Thang Tran8be7ec42024-03-04 15:08:37 +070084 'CHASSIS_ON_FILE', '/run/openbmc/chassis@{}-on')
Andrew Geissler5259f972021-08-30 15:46:55 -050085
Andrew Geisslerf2454102019-12-06 15:14:08 -060086configure_file(output: 'config.h', configuration: conf)
87
Patrick Williams5cd49f72023-11-29 06:44:17 -060088if(get_option('warm-reboot').allowed())
Andrew Geissler7fdad602020-06-22 13:46:16 -050089 add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp')
90endif
91
Andrew Geissler31cddb72024-02-27 14:20:26 -060092if(get_option('force-warm-reboot').allowed())
93 add_project_arguments('-DENABLE_FORCE_WARM_REBOOT',language:'cpp')
94endif
95
Patrick Williamsf0865de2023-12-07 17:16:26 -060096nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Andrew Geisslerf2454102019-12-06 15:14:08 -060097sdbusplus = dependency('sdbusplus')
98sdeventplus = dependency('sdeventplus')
99phosphorlogging = dependency('phosphor-logging')
100phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Ben Tyner2c36e5a2021-07-12 14:56:49 -0500101libgpiod = dependency('libgpiod', version : '>=1.4.1')
Andrew Geisslerf2454102019-12-06 15:14:08 -0600102
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500103if cpp.has_header('CLI/CLI.hpp')
104 CLI11 = declare_dependency()
105else
106 CLI11 = dependency('CLI11')
107endif
108
109# Get Cereal dependency.
110cereal = dependency('cereal', required: false)
111has_cereal = cpp.has_header_symbol(
112 'cereal/cereal.hpp',
113 'cereal::specialize',
114 dependencies: cereal,
115 required: false)
116if not has_cereal
117 cereal_opts = import('cmake').subproject_options()
Konstantin Aladyshev8a373d52024-04-02 17:38:32 +0300118 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'})
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500119 cereal_proj = import('cmake').subproject(
120 'cereal',
121 options: cereal_opts,
122 required: false)
123 assert(cereal_proj.found(), 'cereal is required')
124 cereal = cereal_proj.dependency('cereal')
125endif
126
Andrew Geisslerf2454102019-12-06 15:14:08 -0600127executable('phosphor-host-state-manager',
128 'host_state_manager.cpp',
129 'host_state_manager_main.cpp',
130 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400131 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600132 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600133 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500134 cereal,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500135 libgpiod,
136 phosphordbusinterfaces,
137 phosphorlogging,
138 sdbusplus,
139 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600140 ],
141 implicit_include_directories: true,
142 install: true
143)
144
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600145executable('phosphor-hypervisor-state-manager',
146 'hypervisor_state_manager.cpp',
147 'hypervisor_state_manager_main.cpp',
148 'settings.cpp',
149 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500150 phosphordbusinterfaces,
151 phosphorlogging,
152 sdbusplus,
153 sdeventplus,
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600154 ],
155 implicit_include_directories: true,
156 install: true
157)
158
Andrew Geisslerf2454102019-12-06 15:14:08 -0600159executable('phosphor-chassis-state-manager',
160 'chassis_state_manager.cpp',
161 'chassis_state_manager_main.cpp',
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -0600162 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600163 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500164 cereal,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500165 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600166 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500167 phosphordbusinterfaces,
168 phosphorlogging,
169 sdbusplus,
170 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600171 ],
172 implicit_include_directories: true,
173 install: true
174)
175
Andrew Geissler378fe112022-02-03 16:39:44 -0600176executable('phosphor-chassis-check-power-status',
177 'chassis_check_power_status.cpp',
178 'utils.cpp',
179 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500180 libgpiod,
181 phosphordbusinterfaces,
182 phosphorlogging,
183 sdbusplus,
Andrew Geissler378fe112022-02-03 16:39:44 -0600184 ],
185 implicit_include_directories: true,
186 install: true
187)
188
Andrew Geisslerf2454102019-12-06 15:14:08 -0600189executable('phosphor-bmc-state-manager',
190 'bmc_state_manager.cpp',
191 'bmc_state_manager_main.cpp',
Andrew Geissler98e64e62022-01-25 16:02:56 -0600192 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600193 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500194 libgpiod,
195 phosphordbusinterfaces,
196 phosphorlogging,
197 sdbusplus,
198 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600199 ],
200 implicit_include_directories: true,
201 install: true
202)
203
204executable('phosphor-discover-system-state',
205 'discover_system_state.cpp',
206 'settings.cpp',
Andrew Geissler49e67132022-01-26 14:27:52 -0600207 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600208 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500209 cereal,
210 libgpiod,
211 phosphorlogging,
212 sdbusplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600213 ],
214 implicit_include_directories: true,
215 install: true
216)
217
Andrew Geisslerf2454102019-12-06 15:14:08 -0600218executable('phosphor-systemd-target-monitor',
Andrew Geissler9e3afdf2022-02-10 15:06:16 -0600219 'systemd_service_parser.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600220 'systemd_target_monitor.cpp',
221 'systemd_target_parser.cpp',
222 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400223 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600224 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500225 CLI11,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400226 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600227 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500228 phosphorlogging,
229 sdbusplus,
230 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600231 ],
232 implicit_include_directories: true,
233 install: true
234)
Andrew Geissler3f125632019-12-11 17:08:19 -0600235
Carol Wang71230ef2020-02-18 17:39:49 +0800236executable('phosphor-scheduled-host-transition',
237 'scheduled_host_transition_main.cpp',
238 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800239 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800240 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500241 cereal,
242 libgpiod,
243 phosphorlogging,
244 sdbusplus,
245 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800246 ],
247 implicit_include_directories: true,
248 install: true
249)
250
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400251executable('phosphor-host-reset-recovery',
252 'host_reset_recovery.cpp',
253 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500254 phosphorlogging,
255 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400256 ],
257 implicit_include_directories: true,
258 install: true
259)
260
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600261executable('phosphor-secure-boot-check',
262 'secure_boot_check.cpp',
263 'utils.cpp',
264 dependencies: [
Patrick Williams78c066f2024-02-13 12:25:58 -0600265 sdbusplus,
NodeMan9727d1e142022-07-27 15:10:07 -0500266 phosphorlogging, libgpiod
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600267 ],
268 implicit_include_directories: true,
269 install: true
270)
271
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600272install_data('obmcutil',
273 install_mode: 'rwxr-xr-x',
274 install_dir: get_option('bindir')
275)
276
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400277install_data('scripts/host-reboot',
278 install_mode: 'rwxr-xr-x',
Patrick Williams306c5ff2024-04-04 14:04:07 -0500279 install_dir: get_option('libexecdir')/'phosphor-state-manager'
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400280)
281
Andrew Geissler179d38c2019-12-10 15:05:23 -0600282systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500283systemd_system_unit_dir = systemd.get_variable(
Patrick Williamsc079c3f2023-04-12 08:01:05 -0500284 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600285subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600286subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600287
Patrick Williams5cd49f72023-11-29 06:44:17 -0600288if build_host_gpios.allowed()
Thang Tranba2241c2021-10-26 17:47:09 +0700289 subdir('host_condition_gpio')
290endif
291
Andrew Geisslerefef9702019-12-10 16:56:57 -0600292datadir = join_paths(
293 get_option('sysconfdir'),
294 'phosphor-systemd-target-monitor'
295)
296subdir('data')
297
Andrew Geissler3f125632019-12-11 17:08:19 -0600298build_tests = get_option('tests')
299
300# If test coverage of source files within the root directory are wanted,
301# need to define and build the tests from here
302if not build_tests.disabled()
303gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800304gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600305 test(
306 'test_systemd_parser',
307 executable('test_systemd_parser',
308 './test/systemd_parser.cpp',
309 'systemd_target_parser.cpp',
310 dependencies: [
311 gtest,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600312 nlohmann_json_dep,
Andrew Geissler3f125632019-12-11 17:08:19 -0600313 ],
314 implicit_include_directories: true,
315 include_directories: '../'
316 )
317 )
318
319 test(
320 'test_systemd_signal',
321 executable('test_systemd_signal',
322 './test/systemd_signal.cpp',
323 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400324 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600325 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500326 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400327 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600328 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500329 phosphorlogging,
330 sdbusplus,
331 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600332 ],
333 implicit_include_directories: true,
334 include_directories: '../'
335 )
336 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800337
338 test(
339 'test_scheduled_host_transition',
340 executable('test_scheduled_host_transition',
341 './test/test_scheduled_host_transition.cpp',
342 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800343 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800344 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500345 cereal,
346 gmock,
347 gtest,
348 libgpiod,
349 phosphorlogging,
350 sdbusplus,
351 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800352 ],
353 implicit_include_directories: true,
354 include_directories: '../'
355 )
356 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600357
358 test(
359 'test_hypervisor_state',
360 executable('test_hypervisor_state',
361 './test/hypervisor_state.cpp',
362 'hypervisor_state_manager.cpp',
363 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500364 gtest,
365 phosphorlogging,
366 sdbusplus,
367 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600368 ],
369 implicit_include_directories: true,
370 include_directories: '../'
371 )
372 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600373endif