blob: 245439eb82d99ff059e799c81841bbcfeece192e [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'))
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(
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
Andrew Geissler7fdad602020-06-22 13:46:16 -050088if(get_option('warm-reboot').enabled())
89 add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp')
90endif
91
Andrew Geisslerf2454102019-12-06 15:14:08 -060092sdbusplus = dependency('sdbusplus')
93sdeventplus = dependency('sdeventplus')
94phosphorlogging = dependency('phosphor-logging')
95phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Ben Tyner2c36e5a2021-07-12 14:56:49 -050096libgpiod = dependency('libgpiod', version : '>=1.4.1')
Allen.Wang79b45002022-02-10 17:59:20 +080097fmt = dependency('fmt')
Andrew Geisslerf2454102019-12-06 15:14:08 -060098
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -050099if cpp.has_header('nlohmann/json.hpp')
100 nlohmann_json = declare_dependency()
101else
102 subproject('nlohmann-json')
103 nlohmann_json = declare_dependency(
104 include_directories: [
105 'subprojects/nlohmann-json/single_include',
106 'subprojects/nlohmann-json/single_include/nlohmann',
107 ]
108 )
109endif
110
111if cpp.has_header('CLI/CLI.hpp')
112 CLI11 = declare_dependency()
113else
114 CLI11 = dependency('CLI11')
115endif
116
117# Get Cereal dependency.
118cereal = dependency('cereal', required: false)
119has_cereal = cpp.has_header_symbol(
120 'cereal/cereal.hpp',
121 'cereal::specialize',
122 dependencies: cereal,
123 required: false)
124if not has_cereal
125 cereal_opts = import('cmake').subproject_options()
126 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
127 cereal_proj = import('cmake').subproject(
128 'cereal',
129 options: cereal_opts,
130 required: false)
131 assert(cereal_proj.found(), 'cereal is required')
132 cereal = cereal_proj.dependency('cereal')
133endif
134
Andrew Geisslerf2454102019-12-06 15:14:08 -0600135executable('phosphor-host-state-manager',
136 'host_state_manager.cpp',
137 'host_state_manager_main.cpp',
138 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400139 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600140 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600141 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500142 cereal,
143 fmt,
144 libgpiod,
145 phosphordbusinterfaces,
146 phosphorlogging,
147 sdbusplus,
148 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600149 ],
150 implicit_include_directories: true,
151 install: true
152)
153
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600154executable('phosphor-hypervisor-state-manager',
155 'hypervisor_state_manager.cpp',
156 'hypervisor_state_manager_main.cpp',
157 'settings.cpp',
158 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500159 phosphordbusinterfaces,
160 phosphorlogging,
161 sdbusplus,
162 sdeventplus,
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600163 ],
164 implicit_include_directories: true,
165 install: true
166)
167
Andrew Geisslerf2454102019-12-06 15:14:08 -0600168executable('phosphor-chassis-state-manager',
169 'chassis_state_manager.cpp',
170 'chassis_state_manager_main.cpp',
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -0600171 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600172 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500173 cereal,
174 fmt,
175 libgpiod,
176 nlohmann_json,
177 phosphordbusinterfaces,
178 phosphorlogging,
179 sdbusplus,
180 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600181 ],
182 implicit_include_directories: true,
183 install: true
184)
185
Andrew Geissler378fe112022-02-03 16:39:44 -0600186executable('phosphor-chassis-check-power-status',
187 'chassis_check_power_status.cpp',
188 'utils.cpp',
189 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500190 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500191 libgpiod,
192 phosphordbusinterfaces,
193 phosphorlogging,
194 sdbusplus,
Andrew Geissler378fe112022-02-03 16:39:44 -0600195 ],
196 implicit_include_directories: true,
197 install: true
198)
199
Andrew Geisslerf2454102019-12-06 15:14:08 -0600200executable('phosphor-bmc-state-manager',
201 'bmc_state_manager.cpp',
202 'bmc_state_manager_main.cpp',
Andrew Geissler98e64e62022-01-25 16:02:56 -0600203 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600204 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500205 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500206 libgpiod,
207 phosphordbusinterfaces,
208 phosphorlogging,
209 sdbusplus,
210 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600211 ],
212 implicit_include_directories: true,
213 install: true
214)
215
216executable('phosphor-discover-system-state',
217 'discover_system_state.cpp',
218 'settings.cpp',
Andrew Geissler49e67132022-01-26 14:27:52 -0600219 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600220 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500221 cereal,
NodeMan97bcbee4a2022-05-27 15:28:45 -0500222 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500223 libgpiod,
224 phosphorlogging,
225 sdbusplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600226 ],
227 implicit_include_directories: true,
228 install: true
229)
230
Andrew Geisslerf2454102019-12-06 15:14:08 -0600231executable('phosphor-systemd-target-monitor',
Andrew Geissler9e3afdf2022-02-10 15:06:16 -0600232 'systemd_service_parser.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600233 'systemd_target_monitor.cpp',
234 'systemd_target_parser.cpp',
235 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400236 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600237 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500238 CLI11,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400239 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500240 nlohmann_json,
241 phosphorlogging,
242 sdbusplus,
243 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600244 ],
245 implicit_include_directories: true,
246 install: true
247)
Andrew Geissler3f125632019-12-11 17:08:19 -0600248
Carol Wang71230ef2020-02-18 17:39:49 +0800249executable('phosphor-scheduled-host-transition',
250 'scheduled_host_transition_main.cpp',
251 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800252 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800253 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500254 cereal,
255 libgpiod,
256 phosphorlogging,
257 sdbusplus,
258 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800259 ],
260 implicit_include_directories: true,
261 install: true
262)
263
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400264executable('phosphor-host-reset-recovery',
265 'host_reset_recovery.cpp',
266 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500267 phosphorlogging,
268 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400269 ],
270 implicit_include_directories: true,
271 install: true
272)
273
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600274executable('phosphor-secure-boot-check',
275 'secure_boot_check.cpp',
276 'utils.cpp',
277 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500278 fmt, sdbusplus,
279 phosphorlogging, libgpiod
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600280 ],
281 implicit_include_directories: true,
282 install: true
283)
284
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600285install_data('obmcutil',
286 install_mode: 'rwxr-xr-x',
287 install_dir: get_option('bindir')
288)
289
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400290install_data('scripts/host-reboot',
291 install_mode: 'rwxr-xr-x',
292 install_dir: get_option('libexecdir')
293)
294
Andrew Geissler179d38c2019-12-10 15:05:23 -0600295systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500296systemd_system_unit_dir = systemd.get_variable(
Patrick Williamsc079c3f2023-04-12 08:01:05 -0500297 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600298subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600299subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600300
Thang Tranba2241c2021-10-26 17:47:09 +0700301if build_host_gpios.enabled()
302 subdir('host_condition_gpio')
303endif
304
Andrew Geisslerefef9702019-12-10 16:56:57 -0600305datadir = join_paths(
306 get_option('sysconfdir'),
307 'phosphor-systemd-target-monitor'
308)
309subdir('data')
310
Andrew Geissler3f125632019-12-11 17:08:19 -0600311build_tests = get_option('tests')
312
313# If test coverage of source files within the root directory are wanted,
314# need to define and build the tests from here
315if not build_tests.disabled()
316gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800317gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600318 test(
319 'test_systemd_parser',
320 executable('test_systemd_parser',
321 './test/systemd_parser.cpp',
322 'systemd_target_parser.cpp',
323 dependencies: [
324 gtest,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500325 nlohmann_json,
Andrew Geissler3f125632019-12-11 17:08:19 -0600326 ],
327 implicit_include_directories: true,
328 include_directories: '../'
329 )
330 )
331
332 test(
333 'test_systemd_signal',
334 executable('test_systemd_signal',
335 './test/systemd_signal.cpp',
336 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400337 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600338 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500339 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400340 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500341 nlohmann_json,
342 phosphorlogging,
343 sdbusplus,
344 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600345 ],
346 implicit_include_directories: true,
347 include_directories: '../'
348 )
349 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800350
351 test(
352 'test_scheduled_host_transition',
353 executable('test_scheduled_host_transition',
354 './test/test_scheduled_host_transition.cpp',
355 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800356 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800357 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500358 cereal,
359 gmock,
360 gtest,
361 libgpiod,
362 phosphorlogging,
363 sdbusplus,
364 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800365 ],
366 implicit_include_directories: true,
367 include_directories: '../'
368 )
369 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600370
371 test(
372 'test_hypervisor_state',
373 executable('test_hypervisor_state',
374 './test/hypervisor_state.cpp',
375 'hypervisor_state_manager.cpp',
376 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500377 gtest,
378 phosphorlogging,
379 sdbusplus,
380 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600381 ],
382 implicit_include_directories: true,
383 include_directories: '../'
384 )
385 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600386endif