blob: cd01c3a45d50bf0f0d2dce5da5ecaa303fea546d [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(
84 'CHASSIS_ON_FILE', '/run/openbmc/chassis@%d-on')
85
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
Patrick Williamsf0865de2023-12-07 17:16:26 -060092nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Andrew Geisslerf2454102019-12-06 15:14:08 -060093sdbusplus = dependency('sdbusplus')
94sdeventplus = dependency('sdeventplus')
95phosphorlogging = dependency('phosphor-logging')
96phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Ben Tyner2c36e5a2021-07-12 14:56:49 -050097libgpiod = dependency('libgpiod', version : '>=1.4.1')
Andrew Geisslerf2454102019-12-06 15:14:08 -060098
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -050099if cpp.has_header('CLI/CLI.hpp')
100 CLI11 = declare_dependency()
101else
102 CLI11 = dependency('CLI11')
103endif
104
105# Get Cereal dependency.
106cereal = dependency('cereal', required: false)
107has_cereal = cpp.has_header_symbol(
108 'cereal/cereal.hpp',
109 'cereal::specialize',
110 dependencies: cereal,
111 required: false)
112if not has_cereal
113 cereal_opts = import('cmake').subproject_options()
114 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
115 cereal_proj = import('cmake').subproject(
116 'cereal',
117 options: cereal_opts,
118 required: false)
119 assert(cereal_proj.found(), 'cereal is required')
120 cereal = cereal_proj.dependency('cereal')
121endif
122
Andrew Geisslerf2454102019-12-06 15:14:08 -0600123executable('phosphor-host-state-manager',
124 'host_state_manager.cpp',
125 'host_state_manager_main.cpp',
126 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400127 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600128 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600129 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500130 cereal,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500131 libgpiod,
132 phosphordbusinterfaces,
133 phosphorlogging,
134 sdbusplus,
135 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600136 ],
137 implicit_include_directories: true,
138 install: true
139)
140
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600141executable('phosphor-hypervisor-state-manager',
142 'hypervisor_state_manager.cpp',
143 'hypervisor_state_manager_main.cpp',
144 'settings.cpp',
145 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500146 phosphordbusinterfaces,
147 phosphorlogging,
148 sdbusplus,
149 sdeventplus,
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600150 ],
151 implicit_include_directories: true,
152 install: true
153)
154
Andrew Geisslerf2454102019-12-06 15:14:08 -0600155executable('phosphor-chassis-state-manager',
156 'chassis_state_manager.cpp',
157 'chassis_state_manager_main.cpp',
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -0600158 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600159 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500160 cereal,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500161 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600162 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500163 phosphordbusinterfaces,
164 phosphorlogging,
165 sdbusplus,
166 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600167 ],
168 implicit_include_directories: true,
169 install: true
170)
171
Andrew Geissler378fe112022-02-03 16:39:44 -0600172executable('phosphor-chassis-check-power-status',
173 'chassis_check_power_status.cpp',
174 'utils.cpp',
175 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500176 libgpiod,
177 phosphordbusinterfaces,
178 phosphorlogging,
179 sdbusplus,
Andrew Geissler378fe112022-02-03 16:39:44 -0600180 ],
181 implicit_include_directories: true,
182 install: true
183)
184
Andrew Geisslerf2454102019-12-06 15:14:08 -0600185executable('phosphor-bmc-state-manager',
186 'bmc_state_manager.cpp',
187 'bmc_state_manager_main.cpp',
Andrew Geissler98e64e62022-01-25 16:02:56 -0600188 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600189 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500190 libgpiod,
191 phosphordbusinterfaces,
192 phosphorlogging,
193 sdbusplus,
194 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600195 ],
196 implicit_include_directories: true,
197 install: true
198)
199
200executable('phosphor-discover-system-state',
201 'discover_system_state.cpp',
202 'settings.cpp',
Andrew Geissler49e67132022-01-26 14:27:52 -0600203 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600204 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500205 cereal,
206 libgpiod,
207 phosphorlogging,
208 sdbusplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600209 ],
210 implicit_include_directories: true,
211 install: true
212)
213
Andrew Geisslerf2454102019-12-06 15:14:08 -0600214executable('phosphor-systemd-target-monitor',
Andrew Geissler9e3afdf2022-02-10 15:06:16 -0600215 'systemd_service_parser.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600216 'systemd_target_monitor.cpp',
217 'systemd_target_parser.cpp',
218 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400219 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600220 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500221 CLI11,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400222 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600223 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500224 phosphorlogging,
225 sdbusplus,
226 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600227 ],
228 implicit_include_directories: true,
229 install: true
230)
Andrew Geissler3f125632019-12-11 17:08:19 -0600231
Carol Wang71230ef2020-02-18 17:39:49 +0800232executable('phosphor-scheduled-host-transition',
233 'scheduled_host_transition_main.cpp',
234 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800235 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800236 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500237 cereal,
238 libgpiod,
239 phosphorlogging,
240 sdbusplus,
241 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800242 ],
243 implicit_include_directories: true,
244 install: true
245)
246
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400247executable('phosphor-host-reset-recovery',
248 'host_reset_recovery.cpp',
249 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500250 phosphorlogging,
251 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400252 ],
253 implicit_include_directories: true,
254 install: true
255)
256
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600257executable('phosphor-secure-boot-check',
258 'secure_boot_check.cpp',
259 'utils.cpp',
260 dependencies: [
Patrick Williams78c066f2024-02-13 12:25:58 -0600261 sdbusplus,
NodeMan9727d1e142022-07-27 15:10:07 -0500262 phosphorlogging, libgpiod
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600263 ],
264 implicit_include_directories: true,
265 install: true
266)
267
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600268install_data('obmcutil',
269 install_mode: 'rwxr-xr-x',
270 install_dir: get_option('bindir')
271)
272
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400273install_data('scripts/host-reboot',
274 install_mode: 'rwxr-xr-x',
275 install_dir: get_option('libexecdir')
276)
277
Andrew Geissler179d38c2019-12-10 15:05:23 -0600278systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500279systemd_system_unit_dir = systemd.get_variable(
Patrick Williamsc079c3f2023-04-12 08:01:05 -0500280 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600281subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600282subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600283
Patrick Williams5cd49f72023-11-29 06:44:17 -0600284if build_host_gpios.allowed()
Thang Tranba2241c2021-10-26 17:47:09 +0700285 subdir('host_condition_gpio')
286endif
287
Andrew Geisslerefef9702019-12-10 16:56:57 -0600288datadir = join_paths(
289 get_option('sysconfdir'),
290 'phosphor-systemd-target-monitor'
291)
292subdir('data')
293
Andrew Geissler3f125632019-12-11 17:08:19 -0600294build_tests = get_option('tests')
295
296# If test coverage of source files within the root directory are wanted,
297# need to define and build the tests from here
298if not build_tests.disabled()
299gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800300gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600301 test(
302 'test_systemd_parser',
303 executable('test_systemd_parser',
304 './test/systemd_parser.cpp',
305 'systemd_target_parser.cpp',
306 dependencies: [
307 gtest,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600308 nlohmann_json_dep,
Andrew Geissler3f125632019-12-11 17:08:19 -0600309 ],
310 implicit_include_directories: true,
311 include_directories: '../'
312 )
313 )
314
315 test(
316 'test_systemd_signal',
317 executable('test_systemd_signal',
318 './test/systemd_signal.cpp',
319 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400320 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600321 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500322 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400323 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600324 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500325 phosphorlogging,
326 sdbusplus,
327 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600328 ],
329 implicit_include_directories: true,
330 include_directories: '../'
331 )
332 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800333
334 test(
335 'test_scheduled_host_transition',
336 executable('test_scheduled_host_transition',
337 './test/test_scheduled_host_transition.cpp',
338 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800339 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800340 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500341 cereal,
342 gmock,
343 gtest,
344 libgpiod,
345 phosphorlogging,
346 sdbusplus,
347 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800348 ],
349 implicit_include_directories: true,
350 include_directories: '../'
351 )
352 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600353
354 test(
355 'test_hypervisor_state',
356 executable('test_hypervisor_state',
357 './test/hypervisor_state.cpp',
358 'hypervisor_state_manager.cpp',
359 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500360 gtest,
361 phosphorlogging,
362 sdbusplus,
363 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600364 ],
365 implicit_include_directories: true,
366 include_directories: '../'
367 )
368 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600369endif