blob: 26ffb74f6c5eb855bf3f5404019bc74c513ac478 [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(
78 'CHASSIS_LOST_POWER_FILE', '/run/openbmc/chassis@%d-lost-power')
79
80conf.set_quoted(
Andrew Geissler343dbf82021-03-16 16:56:09 -050081 'HOST_RUNNING_FILE', '/run/openbmc/host@%d-on')
82
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')
Allen.Wang79b45002022-02-10 17:59:20 +080098fmt = dependency('fmt')
Andrew Geisslerf2454102019-12-06 15:14:08 -060099
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500100if cpp.has_header('CLI/CLI.hpp')
101 CLI11 = declare_dependency()
102else
103 CLI11 = dependency('CLI11')
104endif
105
106# Get Cereal dependency.
107cereal = dependency('cereal', required: false)
108has_cereal = cpp.has_header_symbol(
109 'cereal/cereal.hpp',
110 'cereal::specialize',
111 dependencies: cereal,
112 required: false)
113if not has_cereal
114 cereal_opts = import('cmake').subproject_options()
115 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
116 cereal_proj = import('cmake').subproject(
117 'cereal',
118 options: cereal_opts,
119 required: false)
120 assert(cereal_proj.found(), 'cereal is required')
121 cereal = cereal_proj.dependency('cereal')
122endif
123
Andrew Geisslerf2454102019-12-06 15:14:08 -0600124executable('phosphor-host-state-manager',
125 'host_state_manager.cpp',
126 'host_state_manager_main.cpp',
127 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400128 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600129 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600130 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500131 cereal,
132 fmt,
133 libgpiod,
134 phosphordbusinterfaces,
135 phosphorlogging,
136 sdbusplus,
137 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600138 ],
139 implicit_include_directories: true,
140 install: true
141)
142
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600143executable('phosphor-hypervisor-state-manager',
144 'hypervisor_state_manager.cpp',
145 'hypervisor_state_manager_main.cpp',
146 'settings.cpp',
147 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500148 phosphordbusinterfaces,
149 phosphorlogging,
150 sdbusplus,
151 sdeventplus,
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600152 ],
153 implicit_include_directories: true,
154 install: true
155)
156
Andrew Geisslerf2454102019-12-06 15:14:08 -0600157executable('phosphor-chassis-state-manager',
158 'chassis_state_manager.cpp',
159 'chassis_state_manager_main.cpp',
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -0600160 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600161 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500162 cereal,
163 fmt,
164 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600165 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500166 phosphordbusinterfaces,
167 phosphorlogging,
168 sdbusplus,
169 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600170 ],
171 implicit_include_directories: true,
172 install: true
173)
174
Andrew Geissler378fe112022-02-03 16:39:44 -0600175executable('phosphor-chassis-check-power-status',
176 'chassis_check_power_status.cpp',
177 'utils.cpp',
178 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500179 fmt,
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: [
NodeMan9727d1e142022-07-27 15:10:07 -0500194 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500195 libgpiod,
196 phosphordbusinterfaces,
197 phosphorlogging,
198 sdbusplus,
199 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600200 ],
201 implicit_include_directories: true,
202 install: true
203)
204
205executable('phosphor-discover-system-state',
206 'discover_system_state.cpp',
207 'settings.cpp',
Andrew Geissler49e67132022-01-26 14:27:52 -0600208 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600209 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500210 cereal,
NodeMan97bcbee4a2022-05-27 15:28:45 -0500211 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500212 libgpiod,
213 phosphorlogging,
214 sdbusplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600215 ],
216 implicit_include_directories: true,
217 install: true
218)
219
Andrew Geisslerf2454102019-12-06 15:14:08 -0600220executable('phosphor-systemd-target-monitor',
Andrew Geissler9e3afdf2022-02-10 15:06:16 -0600221 'systemd_service_parser.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600222 'systemd_target_monitor.cpp',
223 'systemd_target_parser.cpp',
224 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400225 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600226 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500227 CLI11,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400228 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600229 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500230 phosphorlogging,
231 sdbusplus,
232 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600233 ],
234 implicit_include_directories: true,
235 install: true
236)
Andrew Geissler3f125632019-12-11 17:08:19 -0600237
Carol Wang71230ef2020-02-18 17:39:49 +0800238executable('phosphor-scheduled-host-transition',
239 'scheduled_host_transition_main.cpp',
240 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800241 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800242 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500243 cereal,
244 libgpiod,
245 phosphorlogging,
246 sdbusplus,
247 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800248 ],
249 implicit_include_directories: true,
250 install: true
251)
252
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400253executable('phosphor-host-reset-recovery',
254 'host_reset_recovery.cpp',
255 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500256 phosphorlogging,
257 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400258 ],
259 implicit_include_directories: true,
260 install: true
261)
262
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600263executable('phosphor-secure-boot-check',
264 'secure_boot_check.cpp',
265 'utils.cpp',
266 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500267 fmt, sdbusplus,
268 phosphorlogging, libgpiod
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600269 ],
270 implicit_include_directories: true,
271 install: true
272)
273
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600274install_data('obmcutil',
275 install_mode: 'rwxr-xr-x',
276 install_dir: get_option('bindir')
277)
278
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400279install_data('scripts/host-reboot',
280 install_mode: 'rwxr-xr-x',
281 install_dir: get_option('libexecdir')
282)
283
Andrew Geissler179d38c2019-12-10 15:05:23 -0600284systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500285systemd_system_unit_dir = systemd.get_variable(
Patrick Williamsc079c3f2023-04-12 08:01:05 -0500286 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600287subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600288subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600289
Patrick Williams5cd49f72023-11-29 06:44:17 -0600290if build_host_gpios.allowed()
Thang Tranba2241c2021-10-26 17:47:09 +0700291 subdir('host_condition_gpio')
292endif
293
Andrew Geisslerefef9702019-12-10 16:56:57 -0600294datadir = join_paths(
295 get_option('sysconfdir'),
296 'phosphor-systemd-target-monitor'
297)
298subdir('data')
299
Andrew Geissler3f125632019-12-11 17:08:19 -0600300build_tests = get_option('tests')
301
302# If test coverage of source files within the root directory are wanted,
303# need to define and build the tests from here
304if not build_tests.disabled()
305gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800306gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600307 test(
308 'test_systemd_parser',
309 executable('test_systemd_parser',
310 './test/systemd_parser.cpp',
311 'systemd_target_parser.cpp',
312 dependencies: [
313 gtest,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600314 nlohmann_json_dep,
Andrew Geissler3f125632019-12-11 17:08:19 -0600315 ],
316 implicit_include_directories: true,
317 include_directories: '../'
318 )
319 )
320
321 test(
322 'test_systemd_signal',
323 executable('test_systemd_signal',
324 './test/systemd_signal.cpp',
325 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400326 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600327 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500328 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400329 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600330 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500331 phosphorlogging,
332 sdbusplus,
333 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600334 ],
335 implicit_include_directories: true,
336 include_directories: '../'
337 )
338 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800339
340 test(
341 'test_scheduled_host_transition',
342 executable('test_scheduled_host_transition',
343 './test/test_scheduled_host_transition.cpp',
344 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800345 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800346 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500347 cereal,
348 gmock,
349 gtest,
350 libgpiod,
351 phosphorlogging,
352 sdbusplus,
353 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800354 ],
355 implicit_include_directories: true,
356 include_directories: '../'
357 )
358 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600359
360 test(
361 'test_hypervisor_state',
362 executable('test_hypervisor_state',
363 './test/hypervisor_state.cpp',
364 'hypervisor_state_manager.cpp',
365 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500366 gtest,
367 phosphorlogging,
368 sdbusplus,
369 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600370 ],
371 implicit_include_directories: true,
372 include_directories: '../'
373 )
374 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600375endif