blob: da267b670361304d52ed4bb1b91cfd2a6217218c [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(
Andrew Geisslera0d7bb82023-03-01 12:50:14 -060019 'HOST_SCHED_OBJPATH', get_option('host-sched-objpath'))
20conf.set_quoted(
Andrew Geisslerfe270d32021-01-27 14:06:46 -060021 'HYPERVISOR_BUSNAME', get_option('hypervisor-busname'))
22conf.set_quoted(
23 'HYPERVISOR_OBJPATH', get_option('hypervisor-objpath'))
24conf.set_quoted(
Andrew Geisslerf2454102019-12-06 15:14:08 -060025 'HOST_STATE_PERSIST_PATH', get_option('host-state-persist-path'))
26conf.set_quoted(
27 'POH_COUNTER_PERSIST_PATH', get_option('poh-counter-persist-path'))
28conf.set_quoted(
29 'CHASSIS_STATE_CHANGE_PERSIST_PATH', get_option('chassis-state-change-persist-path'))
Carol Wang71230ef2020-02-18 17:39:49 +080030conf.set_quoted(
Carol Wang1dbbef42020-03-09 11:51:23 +080031 'SCHEDULED_HOST_TRANSITION_PERSIST_PATH', get_option('scheduled-host-transition-persist-path'))
Andrew Geisslerf2454102019-12-06 15:14:08 -060032conf.set(
33 'BOOT_COUNT_MAX_ALLOWED', get_option('boot-count-max-allowed'))
34conf.set(
35 'CLASS_VERSION', get_option('class-version'))
Andrew Geissler8d8d7312022-03-04 14:42:26 -060036conf.set_quoted(
37 'SYSFS_SECURE_BOOT_PATH', get_option('sysfs-secure-boot-path'))
38conf.set_quoted(
39 'SYSFS_ABR_IMAGE_PATH', get_option('sysfs-abr-image-path'))
Patrick Williams5cd49f72023-11-29 06:44:17 -060040if build_host_gpios.allowed()
Thang Tranba2241c2021-10-26 17:47:09 +070041 conf.set_quoted(
42 'HOST_GPIOS_BUSNAME', get_option('host-gpios-busname'))
43 conf.set_quoted(
44 'HOST_GPIOS_OBJPATH', get_option('host-gpios-objpath'))
45endif
Andrew Geisslerf2454102019-12-06 15:14:08 -060046
NodeMan97bcbee4a2022-05-27 15:28:45 -050047conf.set10(
48 'ONLY_RUN_APR_ON_POWER_LOSS', get_option('only-run-apr-on-power-loss'))
49
Lakshmi Yadlapatib454d8b2023-03-27 16:11:41 -050050conf.set_quoted(
Lakshmi Yadlapati21d74d82023-07-20 17:37:22 -050051 'SYSFS_TPM_DEVICE_PATH', get_option('sysfs-tpm-device-path'))
52
53conf.set_quoted(
Lakshmi Yadlapatib454d8b2023-03-27 16:11:41 -050054 'SYSFS_TPM_MEASUREMENT_PATH', get_option('sysfs-tpm-measurement-path'))
55
Andrew Geissler629e3c42023-05-25 10:31:13 -040056conf.set10(
57 'ONLY_ALLOW_BOOT_WHEN_BMC_READY', get_option('only-allow-boot-when-bmc-ready'))
58
Andrew Geissler343dbf82021-03-16 16:56:09 -050059# globals shared across applications
60conf.set_quoted(
NodeMan97bcbee4a2022-05-27 15:28:45 -050061 'BASE_FILE_DIR', '/run/openbmc/')
62
63conf.set_quoted(
Patrick Williams78c066f2024-02-13 12:25:58 -060064 'CHASSIS_LOST_POWER_FILE', '/run/openbmc/chassis@{}-lost-power')
NodeMan97bcbee4a2022-05-27 15:28:45 -050065
66conf.set_quoted(
Patrick Williams78c066f2024-02-13 12:25:58 -060067 'HOST_RUNNING_FILE', '/run/openbmc/host@{}-on')
Andrew Geissler343dbf82021-03-16 16:56:09 -050068
Andrew Geissler5259f972021-08-30 15:46:55 -050069conf.set_quoted(
Thang Tran8be7ec42024-03-04 15:08:37 +070070 'CHASSIS_ON_FILE', '/run/openbmc/chassis@{}-on')
Andrew Geissler5259f972021-08-30 15:46:55 -050071
Thang Tran9f381522024-10-18 10:11:01 +070072conf.set(
73 'CHECK_FWUPDATE_BEFORE_DO_TRANSITION', get_option('check-fwupdate-before-do-transition').enabled())
74
Andrew Geisslerf2454102019-12-06 15:14:08 -060075configure_file(output: 'config.h', configuration: conf)
76
Patrick Williams5cd49f72023-11-29 06:44:17 -060077if(get_option('warm-reboot').allowed())
Andrew Geissler7fdad602020-06-22 13:46:16 -050078 add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp')
79endif
80
Andrew Geissler31cddb72024-02-27 14:20:26 -060081if(get_option('force-warm-reboot').allowed())
82 add_project_arguments('-DENABLE_FORCE_WARM_REBOOT',language:'cpp')
83endif
84
Patrick Williamsf0865de2023-12-07 17:16:26 -060085nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Andrew Geisslerf2454102019-12-06 15:14:08 -060086sdbusplus = dependency('sdbusplus')
87sdeventplus = dependency('sdeventplus')
88phosphorlogging = dependency('phosphor-logging')
89phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Peter Delevoryas29c2a1c2024-11-25 14:03:03 -080090libgpiod = dependency('libgpiod', version : '>=1.4.1', default_options: ['bindings=cxx'])
Andrew Geisslerf2454102019-12-06 15:14:08 -060091
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -050092if cpp.has_header('CLI/CLI.hpp')
93 CLI11 = declare_dependency()
94else
95 CLI11 = dependency('CLI11')
96endif
97
98# Get Cereal dependency.
99cereal = dependency('cereal', required: false)
100has_cereal = cpp.has_header_symbol(
101 'cereal/cereal.hpp',
102 'cereal::specialize',
103 dependencies: cereal,
104 required: false)
105if not has_cereal
106 cereal_opts = import('cmake').subproject_options()
Konstantin Aladyshev8a373d52024-04-02 17:38:32 +0300107 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'})
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500108 cereal_proj = import('cmake').subproject(
109 'cereal',
110 options: cereal_opts,
111 required: false)
112 assert(cereal_proj.found(), 'cereal is required')
113 cereal = cereal_proj.dependency('cereal')
114endif
115
Andrew Geisslerf2454102019-12-06 15:14:08 -0600116executable('phosphor-host-state-manager',
117 'host_state_manager.cpp',
118 'host_state_manager_main.cpp',
119 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400120 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600121 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600122 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500123 cereal,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500124 libgpiod,
125 phosphordbusinterfaces,
126 phosphorlogging,
127 sdbusplus,
128 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600129 ],
130 implicit_include_directories: true,
131 install: true
132)
133
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600134executable('phosphor-hypervisor-state-manager',
135 'hypervisor_state_manager.cpp',
136 'hypervisor_state_manager_main.cpp',
137 'settings.cpp',
138 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500139 phosphordbusinterfaces,
140 phosphorlogging,
141 sdbusplus,
142 sdeventplus,
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600143 ],
144 implicit_include_directories: true,
145 install: true
146)
147
Andrew Geisslerf2454102019-12-06 15:14:08 -0600148executable('phosphor-chassis-state-manager',
149 'chassis_state_manager.cpp',
150 'chassis_state_manager_main.cpp',
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -0600151 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600152 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500153 cereal,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500154 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600155 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500156 phosphordbusinterfaces,
157 phosphorlogging,
158 sdbusplus,
159 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600160 ],
161 implicit_include_directories: true,
162 install: true
163)
164
Andrew Geissler378fe112022-02-03 16:39:44 -0600165executable('phosphor-chassis-check-power-status',
166 'chassis_check_power_status.cpp',
167 'utils.cpp',
168 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500169 libgpiod,
170 phosphordbusinterfaces,
171 phosphorlogging,
172 sdbusplus,
Andrew Geissler378fe112022-02-03 16:39:44 -0600173 ],
174 implicit_include_directories: true,
175 install: true
176)
177
Andrew Geisslerf2454102019-12-06 15:14:08 -0600178executable('phosphor-bmc-state-manager',
179 'bmc_state_manager.cpp',
180 'bmc_state_manager_main.cpp',
Andrew Geissler98e64e62022-01-25 16:02:56 -0600181 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600182 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500183 libgpiod,
184 phosphordbusinterfaces,
185 phosphorlogging,
186 sdbusplus,
187 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600188 ],
189 implicit_include_directories: true,
190 install: true
191)
192
193executable('phosphor-discover-system-state',
194 'discover_system_state.cpp',
195 'settings.cpp',
Andrew Geissler49e67132022-01-26 14:27:52 -0600196 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600197 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500198 cereal,
199 libgpiod,
200 phosphorlogging,
201 sdbusplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600202 ],
203 implicit_include_directories: true,
204 install: true
205)
206
Andrew Geisslerf2454102019-12-06 15:14:08 -0600207executable('phosphor-systemd-target-monitor',
Andrew Geissler9e3afdf2022-02-10 15:06:16 -0600208 'systemd_service_parser.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600209 'systemd_target_monitor.cpp',
210 'systemd_target_parser.cpp',
211 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400212 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600213 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500214 CLI11,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400215 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600216 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500217 phosphorlogging,
218 sdbusplus,
219 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600220 ],
221 implicit_include_directories: true,
222 install: true
223)
Andrew Geissler3f125632019-12-11 17:08:19 -0600224
Carol Wang71230ef2020-02-18 17:39:49 +0800225executable('phosphor-scheduled-host-transition',
226 'scheduled_host_transition_main.cpp',
227 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800228 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800229 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500230 cereal,
231 libgpiod,
232 phosphorlogging,
233 sdbusplus,
234 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800235 ],
236 implicit_include_directories: true,
237 install: true
238)
239
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400240executable('phosphor-host-reset-recovery',
241 'host_reset_recovery.cpp',
242 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500243 phosphorlogging,
244 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400245 ],
246 implicit_include_directories: true,
247 install: true
248)
249
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600250executable('phosphor-secure-boot-check',
251 'secure_boot_check.cpp',
252 'utils.cpp',
253 dependencies: [
Patrick Williams78c066f2024-02-13 12:25:58 -0600254 sdbusplus,
NodeMan9727d1e142022-07-27 15:10:07 -0500255 phosphorlogging, libgpiod
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600256 ],
257 implicit_include_directories: true,
258 install: true
259)
260
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600261install_data('obmcutil',
262 install_mode: 'rwxr-xr-x',
263 install_dir: get_option('bindir')
264)
265
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400266install_data('scripts/host-reboot',
267 install_mode: 'rwxr-xr-x',
Patrick Williams306c5ff2024-04-04 14:04:07 -0500268 install_dir: get_option('libexecdir')/'phosphor-state-manager'
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400269)
270
Andrew Geissler179d38c2019-12-10 15:05:23 -0600271systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500272systemd_system_unit_dir = systemd.get_variable(
Patrick Williamsc079c3f2023-04-12 08:01:05 -0500273 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600274subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600275subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600276
Patrick Williams5cd49f72023-11-29 06:44:17 -0600277if build_host_gpios.allowed()
Thang Tranba2241c2021-10-26 17:47:09 +0700278 subdir('host_condition_gpio')
279endif
280
Andrew Geisslerefef9702019-12-10 16:56:57 -0600281datadir = join_paths(
282 get_option('sysconfdir'),
283 'phosphor-systemd-target-monitor'
284)
285subdir('data')
286
Andrew Geissler3f125632019-12-11 17:08:19 -0600287build_tests = get_option('tests')
288
289# If test coverage of source files within the root directory are wanted,
290# need to define and build the tests from here
291if not build_tests.disabled()
292gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800293gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600294 test(
295 'test_systemd_parser',
296 executable('test_systemd_parser',
297 './test/systemd_parser.cpp',
298 'systemd_target_parser.cpp',
299 dependencies: [
300 gtest,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600301 nlohmann_json_dep,
Andrew Geissler3f125632019-12-11 17:08:19 -0600302 ],
303 implicit_include_directories: true,
304 include_directories: '../'
305 )
306 )
307
308 test(
309 'test_systemd_signal',
310 executable('test_systemd_signal',
311 './test/systemd_signal.cpp',
312 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400313 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600314 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500315 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400316 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600317 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500318 phosphorlogging,
319 sdbusplus,
320 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600321 ],
322 implicit_include_directories: true,
323 include_directories: '../'
324 )
325 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800326
327 test(
328 'test_scheduled_host_transition',
329 executable('test_scheduled_host_transition',
330 './test/test_scheduled_host_transition.cpp',
331 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800332 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800333 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500334 cereal,
335 gmock,
336 gtest,
337 libgpiod,
338 phosphorlogging,
339 sdbusplus,
340 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800341 ],
342 implicit_include_directories: true,
343 include_directories: '../'
344 )
345 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600346
347 test(
348 'test_hypervisor_state',
349 executable('test_hypervisor_state',
350 './test/hypervisor_state.cpp',
351 'hypervisor_state_manager.cpp',
352 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500353 gtest,
354 phosphorlogging,
355 sdbusplus,
356 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600357 ],
358 implicit_include_directories: true,
359 include_directories: '../'
360 )
361 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600362endif