blob: 08e0feb59bf1c490000038ea2c6154500a7675e4 [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 ],
Patrick Williamsc079c3f2023-04-12 08:01:05 -05009 meson_version: '>= 0.58.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
Lakshmi Yadlapatib454d8b2023-03-27 16:11:41 -050064conf.set_quoted(
65 'SYSFS_TPM_MEASUREMENT_PATH', get_option('sysfs-tpm-measurement-path'))
66
Andrew Geissler343dbf82021-03-16 16:56:09 -050067# globals shared across applications
68conf.set_quoted(
NodeMan97bcbee4a2022-05-27 15:28:45 -050069 'BASE_FILE_DIR', '/run/openbmc/')
70
71conf.set_quoted(
72 'CHASSIS_LOST_POWER_FILE', '/run/openbmc/chassis@%d-lost-power')
73
74conf.set_quoted(
Andrew Geissler343dbf82021-03-16 16:56:09 -050075 'HOST_RUNNING_FILE', '/run/openbmc/host@%d-on')
76
Andrew Geissler5259f972021-08-30 15:46:55 -050077conf.set_quoted(
78 'CHASSIS_ON_FILE', '/run/openbmc/chassis@%d-on')
79
Andrew Geisslerf2454102019-12-06 15:14:08 -060080configure_file(output: 'config.h', configuration: conf)
81
Andrew Geissler7fdad602020-06-22 13:46:16 -050082if(get_option('warm-reboot').enabled())
83 add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp')
84endif
85
Andrew Geisslerf2454102019-12-06 15:14:08 -060086sdbusplus = dependency('sdbusplus')
87sdeventplus = dependency('sdeventplus')
88phosphorlogging = dependency('phosphor-logging')
89phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Ben Tyner2c36e5a2021-07-12 14:56:49 -050090libgpiod = dependency('libgpiod', version : '>=1.4.1')
Allen.Wang79b45002022-02-10 17:59:20 +080091fmt = dependency('fmt')
Andrew Geisslerf2454102019-12-06 15:14:08 -060092
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -050093if cpp.has_header('nlohmann/json.hpp')
94 nlohmann_json = declare_dependency()
95else
96 subproject('nlohmann-json')
97 nlohmann_json = declare_dependency(
98 include_directories: [
99 'subprojects/nlohmann-json/single_include',
100 'subprojects/nlohmann-json/single_include/nlohmann',
101 ]
102 )
103endif
104
105if cpp.has_header('CLI/CLI.hpp')
106 CLI11 = declare_dependency()
107else
108 CLI11 = dependency('CLI11')
109endif
110
111# Get Cereal dependency.
112cereal = dependency('cereal', required: false)
113has_cereal = cpp.has_header_symbol(
114 'cereal/cereal.hpp',
115 'cereal::specialize',
116 dependencies: cereal,
117 required: false)
118if not has_cereal
119 cereal_opts = import('cmake').subproject_options()
120 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
121 cereal_proj = import('cmake').subproject(
122 'cereal',
123 options: cereal_opts,
124 required: false)
125 assert(cereal_proj.found(), 'cereal is required')
126 cereal = cereal_proj.dependency('cereal')
127endif
128
Andrew Geisslerf2454102019-12-06 15:14:08 -0600129executable('phosphor-host-state-manager',
130 'host_state_manager.cpp',
131 'host_state_manager_main.cpp',
132 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400133 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600134 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600135 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500136 cereal,
137 fmt,
138 libgpiod,
139 phosphordbusinterfaces,
140 phosphorlogging,
141 sdbusplus,
142 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600143 ],
144 implicit_include_directories: true,
145 install: true
146)
147
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600148executable('phosphor-hypervisor-state-manager',
149 'hypervisor_state_manager.cpp',
150 'hypervisor_state_manager_main.cpp',
151 'settings.cpp',
152 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500153 phosphordbusinterfaces,
154 phosphorlogging,
155 sdbusplus,
156 sdeventplus,
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600157 ],
158 implicit_include_directories: true,
159 install: true
160)
161
Andrew Geisslerf2454102019-12-06 15:14:08 -0600162executable('phosphor-chassis-state-manager',
163 'chassis_state_manager.cpp',
164 'chassis_state_manager_main.cpp',
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -0600165 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600166 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500167 cereal,
168 fmt,
169 libgpiod,
170 nlohmann_json,
171 phosphordbusinterfaces,
172 phosphorlogging,
173 sdbusplus,
174 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600175 ],
176 implicit_include_directories: true,
177 install: true
178)
179
Andrew Geissler378fe112022-02-03 16:39:44 -0600180executable('phosphor-chassis-check-power-status',
181 'chassis_check_power_status.cpp',
182 'utils.cpp',
183 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500184 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500185 libgpiod,
186 phosphordbusinterfaces,
187 phosphorlogging,
188 sdbusplus,
Andrew Geissler378fe112022-02-03 16:39:44 -0600189 ],
190 implicit_include_directories: true,
191 install: true
192)
193
Andrew Geisslerf2454102019-12-06 15:14:08 -0600194executable('phosphor-bmc-state-manager',
195 'bmc_state_manager.cpp',
196 'bmc_state_manager_main.cpp',
Andrew Geissler98e64e62022-01-25 16:02:56 -0600197 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600198 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500199 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500200 libgpiod,
201 phosphordbusinterfaces,
202 phosphorlogging,
203 sdbusplus,
204 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600205 ],
206 implicit_include_directories: true,
207 install: true
208)
209
210executable('phosphor-discover-system-state',
211 'discover_system_state.cpp',
212 'settings.cpp',
Andrew Geissler49e67132022-01-26 14:27:52 -0600213 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600214 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500215 cereal,
NodeMan97bcbee4a2022-05-27 15:28:45 -0500216 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500217 libgpiod,
218 phosphorlogging,
219 sdbusplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600220 ],
221 implicit_include_directories: true,
222 install: true
223)
224
Andrew Geisslerf2454102019-12-06 15:14:08 -0600225executable('phosphor-systemd-target-monitor',
Andrew Geissler9e3afdf2022-02-10 15:06:16 -0600226 'systemd_service_parser.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600227 'systemd_target_monitor.cpp',
228 'systemd_target_parser.cpp',
229 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400230 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600231 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500232 CLI11,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400233 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500234 nlohmann_json,
235 phosphorlogging,
236 sdbusplus,
237 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600238 ],
239 implicit_include_directories: true,
240 install: true
241)
Andrew Geissler3f125632019-12-11 17:08:19 -0600242
Carol Wang71230ef2020-02-18 17:39:49 +0800243executable('phosphor-scheduled-host-transition',
244 'scheduled_host_transition_main.cpp',
245 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800246 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800247 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500248 cereal,
249 libgpiod,
250 phosphorlogging,
251 sdbusplus,
252 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800253 ],
254 implicit_include_directories: true,
255 install: true
256)
257
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400258executable('phosphor-host-reset-recovery',
259 'host_reset_recovery.cpp',
260 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500261 phosphorlogging,
262 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400263 ],
264 implicit_include_directories: true,
265 install: true
266)
267
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600268executable('phosphor-secure-boot-check',
269 'secure_boot_check.cpp',
270 'utils.cpp',
271 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500272 fmt, sdbusplus,
273 phosphorlogging, libgpiod
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600274 ],
275 implicit_include_directories: true,
276 install: true
277)
278
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600279install_data('obmcutil',
280 install_mode: 'rwxr-xr-x',
281 install_dir: get_option('bindir')
282)
283
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400284install_data('scripts/host-reboot',
285 install_mode: 'rwxr-xr-x',
286 install_dir: get_option('libexecdir')
287)
288
Andrew Geissler179d38c2019-12-10 15:05:23 -0600289systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500290systemd_system_unit_dir = systemd.get_variable(
Patrick Williamsc079c3f2023-04-12 08:01:05 -0500291 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600292subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600293subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600294
Thang Tranba2241c2021-10-26 17:47:09 +0700295if build_host_gpios.enabled()
296 subdir('host_condition_gpio')
297endif
298
Andrew Geisslerefef9702019-12-10 16:56:57 -0600299datadir = join_paths(
300 get_option('sysconfdir'),
301 'phosphor-systemd-target-monitor'
302)
303subdir('data')
304
Andrew Geissler3f125632019-12-11 17:08:19 -0600305build_tests = get_option('tests')
306
307# If test coverage of source files within the root directory are wanted,
308# need to define and build the tests from here
309if not build_tests.disabled()
310gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800311gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600312 test(
313 'test_systemd_parser',
314 executable('test_systemd_parser',
315 './test/systemd_parser.cpp',
316 'systemd_target_parser.cpp',
317 dependencies: [
318 gtest,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500319 nlohmann_json,
Andrew Geissler3f125632019-12-11 17:08:19 -0600320 ],
321 implicit_include_directories: true,
322 include_directories: '../'
323 )
324 )
325
326 test(
327 'test_systemd_signal',
328 executable('test_systemd_signal',
329 './test/systemd_signal.cpp',
330 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400331 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600332 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500333 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400334 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500335 nlohmann_json,
336 phosphorlogging,
337 sdbusplus,
338 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600339 ],
340 implicit_include_directories: true,
341 include_directories: '../'
342 )
343 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800344
345 test(
346 'test_scheduled_host_transition',
347 executable('test_scheduled_host_transition',
348 './test/test_scheduled_host_transition.cpp',
349 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800350 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800351 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500352 cereal,
353 gmock,
354 gtest,
355 libgpiod,
356 phosphorlogging,
357 sdbusplus,
358 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800359 ],
360 implicit_include_directories: true,
361 include_directories: '../'
362 )
363 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600364
365 test(
366 'test_hypervisor_state',
367 executable('test_hypervisor_state',
368 './test/hypervisor_state.cpp',
369 'hypervisor_state_manager.cpp',
370 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500371 gtest,
372 phosphorlogging,
373 sdbusplus,
374 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600375 ],
376 implicit_include_directories: true,
377 include_directories: '../'
378 )
379 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600380endif