blob: f734b4664297ca9b7cddadb7732321080a88b8e3 [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',
Andrew Geissler429100a2021-09-09 12:50:24 -05007 'cpp_std=c++20'
Andrew Geisslerf2454102019-12-06 15:14:08 -06008 ],
Andrew Geissler429100a2021-09-09 12:50:24 -05009 meson_version: '>= 0.57.0',
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'))
Thang Tranba2241c2021-10-26 17:47:09 +070054if build_host_gpios.enabled()
55 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
Andrew Geissler343dbf82021-03-16 16:56:09 -050064# globals shared across applications
65conf.set_quoted(
NodeMan97bcbee4a2022-05-27 15:28:45 -050066 'BASE_FILE_DIR', '/run/openbmc/')
67
68conf.set_quoted(
69 'CHASSIS_LOST_POWER_FILE', '/run/openbmc/chassis@%d-lost-power')
70
71conf.set_quoted(
Andrew Geissler343dbf82021-03-16 16:56:09 -050072 'HOST_RUNNING_FILE', '/run/openbmc/host@%d-on')
73
Andrew Geissler5259f972021-08-30 15:46:55 -050074conf.set_quoted(
75 'CHASSIS_ON_FILE', '/run/openbmc/chassis@%d-on')
76
Andrew Geisslerf2454102019-12-06 15:14:08 -060077configure_file(output: 'config.h', configuration: conf)
78
Andrew Geissler7fdad602020-06-22 13:46:16 -050079if(get_option('warm-reboot').enabled())
80 add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp')
81endif
82
Andrew Geisslerf2454102019-12-06 15:14:08 -060083sdbusplus = dependency('sdbusplus')
84sdeventplus = dependency('sdeventplus')
85phosphorlogging = dependency('phosphor-logging')
86phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Ben Tyner2c36e5a2021-07-12 14:56:49 -050087libgpiod = dependency('libgpiod', version : '>=1.4.1')
Allen.Wang79b45002022-02-10 17:59:20 +080088fmt = dependency('fmt')
Andrew Geisslerf2454102019-12-06 15:14:08 -060089
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -050090if cpp.has_header('nlohmann/json.hpp')
91 nlohmann_json = declare_dependency()
92else
93 subproject('nlohmann-json')
94 nlohmann_json = declare_dependency(
95 include_directories: [
96 'subprojects/nlohmann-json/single_include',
97 'subprojects/nlohmann-json/single_include/nlohmann',
98 ]
99 )
100endif
101
102if cpp.has_header('CLI/CLI.hpp')
103 CLI11 = declare_dependency()
104else
105 CLI11 = dependency('CLI11')
106endif
107
108# Get Cereal dependency.
109cereal = dependency('cereal', required: false)
110has_cereal = cpp.has_header_symbol(
111 'cereal/cereal.hpp',
112 'cereal::specialize',
113 dependencies: cereal,
114 required: false)
115if not has_cereal
116 cereal_opts = import('cmake').subproject_options()
117 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
118 cereal_proj = import('cmake').subproject(
119 'cereal',
120 options: cereal_opts,
121 required: false)
122 assert(cereal_proj.found(), 'cereal is required')
123 cereal = cereal_proj.dependency('cereal')
124endif
125
Andrew Geisslerf2454102019-12-06 15:14:08 -0600126executable('phosphor-host-state-manager',
127 'host_state_manager.cpp',
128 'host_state_manager_main.cpp',
129 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400130 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600131 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600132 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500133 cereal,
134 fmt,
135 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,
165 fmt,
166 libgpiod,
167 nlohmann_json,
168 phosphordbusinterfaces,
169 phosphorlogging,
170 sdbusplus,
171 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600172 ],
173 implicit_include_directories: true,
174 install: true
175)
176
Andrew Geissler378fe112022-02-03 16:39:44 -0600177executable('phosphor-chassis-check-power-status',
178 'chassis_check_power_status.cpp',
179 'utils.cpp',
180 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500181 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500182 libgpiod,
183 phosphordbusinterfaces,
184 phosphorlogging,
185 sdbusplus,
Andrew Geissler378fe112022-02-03 16:39:44 -0600186 ],
187 implicit_include_directories: true,
188 install: true
189)
190
Andrew Geisslerf2454102019-12-06 15:14:08 -0600191executable('phosphor-bmc-state-manager',
192 'bmc_state_manager.cpp',
193 'bmc_state_manager_main.cpp',
Andrew Geissler98e64e62022-01-25 16:02:56 -0600194 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600195 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500196 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500197 libgpiod,
198 phosphordbusinterfaces,
199 phosphorlogging,
200 sdbusplus,
201 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600202 ],
203 implicit_include_directories: true,
204 install: true
205)
206
207executable('phosphor-discover-system-state',
208 'discover_system_state.cpp',
209 'settings.cpp',
Andrew Geissler49e67132022-01-26 14:27:52 -0600210 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600211 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500212 cereal,
NodeMan97bcbee4a2022-05-27 15:28:45 -0500213 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500214 libgpiod,
215 phosphorlogging,
216 sdbusplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600217 ],
218 implicit_include_directories: true,
219 install: true
220)
221
Andrew Geisslerf2454102019-12-06 15:14:08 -0600222executable('phosphor-systemd-target-monitor',
Andrew Geissler9e3afdf2022-02-10 15:06:16 -0600223 'systemd_service_parser.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600224 'systemd_target_monitor.cpp',
225 'systemd_target_parser.cpp',
226 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400227 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600228 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500229 CLI11,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400230 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500231 nlohmann_json,
232 phosphorlogging,
233 sdbusplus,
234 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600235 ],
236 implicit_include_directories: true,
237 install: true
238)
Andrew Geissler3f125632019-12-11 17:08:19 -0600239
Carol Wang71230ef2020-02-18 17:39:49 +0800240executable('phosphor-scheduled-host-transition',
241 'scheduled_host_transition_main.cpp',
242 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800243 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800244 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500245 cereal,
246 libgpiod,
247 phosphorlogging,
248 sdbusplus,
249 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800250 ],
251 implicit_include_directories: true,
252 install: true
253)
254
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400255executable('phosphor-host-reset-recovery',
256 'host_reset_recovery.cpp',
257 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500258 phosphorlogging,
259 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400260 ],
261 implicit_include_directories: true,
262 install: true
263)
264
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600265executable('phosphor-secure-boot-check',
266 'secure_boot_check.cpp',
267 'utils.cpp',
268 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500269 fmt, sdbusplus,
270 phosphorlogging, libgpiod
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600271 ],
272 implicit_include_directories: true,
273 install: true
274)
275
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600276install_data('obmcutil',
277 install_mode: 'rwxr-xr-x',
278 install_dir: get_option('bindir')
279)
280
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400281install_data('scripts/host-reboot',
282 install_mode: 'rwxr-xr-x',
283 install_dir: get_option('libexecdir')
284)
285
Andrew Geissler179d38c2019-12-10 15:05:23 -0600286systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500287systemd_system_unit_dir = systemd.get_variable(
288 pkgconfig : 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600289subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600290subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600291
Thang Tranba2241c2021-10-26 17:47:09 +0700292if build_host_gpios.enabled()
293 subdir('host_condition_gpio')
294endif
295
Andrew Geisslerefef9702019-12-10 16:56:57 -0600296datadir = join_paths(
297 get_option('sysconfdir'),
298 'phosphor-systemd-target-monitor'
299)
300subdir('data')
301
Andrew Geissler3f125632019-12-11 17:08:19 -0600302build_tests = get_option('tests')
303
304# If test coverage of source files within the root directory are wanted,
305# need to define and build the tests from here
306if not build_tests.disabled()
307gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800308gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600309 test(
310 'test_systemd_parser',
311 executable('test_systemd_parser',
312 './test/systemd_parser.cpp',
313 'systemd_target_parser.cpp',
314 dependencies: [
315 gtest,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500316 nlohmann_json,
Andrew Geissler3f125632019-12-11 17:08:19 -0600317 ],
318 implicit_include_directories: true,
319 include_directories: '../'
320 )
321 )
322
323 test(
324 'test_systemd_signal',
325 executable('test_systemd_signal',
326 './test/systemd_signal.cpp',
327 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400328 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600329 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500330 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400331 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500332 nlohmann_json,
333 phosphorlogging,
334 sdbusplus,
335 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600336 ],
337 implicit_include_directories: true,
338 include_directories: '../'
339 )
340 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800341
342 test(
343 'test_scheduled_host_transition',
344 executable('test_scheduled_host_transition',
345 './test/test_scheduled_host_transition.cpp',
346 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800347 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800348 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500349 cereal,
350 gmock,
351 gtest,
352 libgpiod,
353 phosphorlogging,
354 sdbusplus,
355 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800356 ],
357 implicit_include_directories: true,
358 include_directories: '../'
359 )
360 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600361
362 test(
363 'test_hypervisor_state',
364 executable('test_hypervisor_state',
365 './test/hypervisor_state.cpp',
366 'hypervisor_state_manager.cpp',
367 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500368 gtest,
369 phosphorlogging,
370 sdbusplus,
371 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600372 ],
373 implicit_include_directories: true,
374 include_directories: '../'
375 )
376 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600377endif