blob: 821be9b50b496e939309517e6c2e4b18f9f72d9a [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 Geissler629e3c42023-05-25 10:31:13 -040067conf.set10(
68 'ONLY_ALLOW_BOOT_WHEN_BMC_READY', get_option('only-allow-boot-when-bmc-ready'))
69
Andrew Geissler343dbf82021-03-16 16:56:09 -050070# globals shared across applications
71conf.set_quoted(
NodeMan97bcbee4a2022-05-27 15:28:45 -050072 'BASE_FILE_DIR', '/run/openbmc/')
73
74conf.set_quoted(
75 'CHASSIS_LOST_POWER_FILE', '/run/openbmc/chassis@%d-lost-power')
76
77conf.set_quoted(
Andrew Geissler343dbf82021-03-16 16:56:09 -050078 'HOST_RUNNING_FILE', '/run/openbmc/host@%d-on')
79
Andrew Geissler5259f972021-08-30 15:46:55 -050080conf.set_quoted(
81 'CHASSIS_ON_FILE', '/run/openbmc/chassis@%d-on')
82
Andrew Geisslerf2454102019-12-06 15:14:08 -060083configure_file(output: 'config.h', configuration: conf)
84
Andrew Geissler7fdad602020-06-22 13:46:16 -050085if(get_option('warm-reboot').enabled())
86 add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp')
87endif
88
Andrew Geisslerf2454102019-12-06 15:14:08 -060089sdbusplus = dependency('sdbusplus')
90sdeventplus = dependency('sdeventplus')
91phosphorlogging = dependency('phosphor-logging')
92phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Ben Tyner2c36e5a2021-07-12 14:56:49 -050093libgpiod = dependency('libgpiod', version : '>=1.4.1')
Allen.Wang79b45002022-02-10 17:59:20 +080094fmt = dependency('fmt')
Andrew Geisslerf2454102019-12-06 15:14:08 -060095
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -050096if cpp.has_header('nlohmann/json.hpp')
97 nlohmann_json = declare_dependency()
98else
99 subproject('nlohmann-json')
100 nlohmann_json = declare_dependency(
101 include_directories: [
102 'subprojects/nlohmann-json/single_include',
103 'subprojects/nlohmann-json/single_include/nlohmann',
104 ]
105 )
106endif
107
108if cpp.has_header('CLI/CLI.hpp')
109 CLI11 = declare_dependency()
110else
111 CLI11 = dependency('CLI11')
112endif
113
114# Get Cereal dependency.
115cereal = dependency('cereal', required: false)
116has_cereal = cpp.has_header_symbol(
117 'cereal/cereal.hpp',
118 'cereal::specialize',
119 dependencies: cereal,
120 required: false)
121if not has_cereal
122 cereal_opts = import('cmake').subproject_options()
123 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
124 cereal_proj = import('cmake').subproject(
125 'cereal',
126 options: cereal_opts,
127 required: false)
128 assert(cereal_proj.found(), 'cereal is required')
129 cereal = cereal_proj.dependency('cereal')
130endif
131
Andrew Geisslerf2454102019-12-06 15:14:08 -0600132executable('phosphor-host-state-manager',
133 'host_state_manager.cpp',
134 'host_state_manager_main.cpp',
135 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400136 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600137 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600138 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500139 cereal,
140 fmt,
141 libgpiod,
142 phosphordbusinterfaces,
143 phosphorlogging,
144 sdbusplus,
145 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600146 ],
147 implicit_include_directories: true,
148 install: true
149)
150
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600151executable('phosphor-hypervisor-state-manager',
152 'hypervisor_state_manager.cpp',
153 'hypervisor_state_manager_main.cpp',
154 'settings.cpp',
155 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500156 phosphordbusinterfaces,
157 phosphorlogging,
158 sdbusplus,
159 sdeventplus,
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600160 ],
161 implicit_include_directories: true,
162 install: true
163)
164
Andrew Geisslerf2454102019-12-06 15:14:08 -0600165executable('phosphor-chassis-state-manager',
166 'chassis_state_manager.cpp',
167 'chassis_state_manager_main.cpp',
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -0600168 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600169 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500170 cereal,
171 fmt,
172 libgpiod,
173 nlohmann_json,
174 phosphordbusinterfaces,
175 phosphorlogging,
176 sdbusplus,
177 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600178 ],
179 implicit_include_directories: true,
180 install: true
181)
182
Andrew Geissler378fe112022-02-03 16:39:44 -0600183executable('phosphor-chassis-check-power-status',
184 'chassis_check_power_status.cpp',
185 'utils.cpp',
186 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500187 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500188 libgpiod,
189 phosphordbusinterfaces,
190 phosphorlogging,
191 sdbusplus,
Andrew Geissler378fe112022-02-03 16:39:44 -0600192 ],
193 implicit_include_directories: true,
194 install: true
195)
196
Andrew Geisslerf2454102019-12-06 15:14:08 -0600197executable('phosphor-bmc-state-manager',
198 'bmc_state_manager.cpp',
199 'bmc_state_manager_main.cpp',
Andrew Geissler98e64e62022-01-25 16:02:56 -0600200 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600201 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500202 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500203 libgpiod,
204 phosphordbusinterfaces,
205 phosphorlogging,
206 sdbusplus,
207 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600208 ],
209 implicit_include_directories: true,
210 install: true
211)
212
213executable('phosphor-discover-system-state',
214 'discover_system_state.cpp',
215 'settings.cpp',
Andrew Geissler49e67132022-01-26 14:27:52 -0600216 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600217 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500218 cereal,
NodeMan97bcbee4a2022-05-27 15:28:45 -0500219 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500220 libgpiod,
221 phosphorlogging,
222 sdbusplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600223 ],
224 implicit_include_directories: true,
225 install: true
226)
227
Andrew Geisslerf2454102019-12-06 15:14:08 -0600228executable('phosphor-systemd-target-monitor',
Andrew Geissler9e3afdf2022-02-10 15:06:16 -0600229 'systemd_service_parser.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600230 'systemd_target_monitor.cpp',
231 'systemd_target_parser.cpp',
232 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400233 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600234 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500235 CLI11,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400236 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500237 nlohmann_json,
238 phosphorlogging,
239 sdbusplus,
240 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600241 ],
242 implicit_include_directories: true,
243 install: true
244)
Andrew Geissler3f125632019-12-11 17:08:19 -0600245
Carol Wang71230ef2020-02-18 17:39:49 +0800246executable('phosphor-scheduled-host-transition',
247 'scheduled_host_transition_main.cpp',
248 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800249 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800250 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500251 cereal,
252 libgpiod,
253 phosphorlogging,
254 sdbusplus,
255 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800256 ],
257 implicit_include_directories: true,
258 install: true
259)
260
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400261executable('phosphor-host-reset-recovery',
262 'host_reset_recovery.cpp',
263 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500264 phosphorlogging,
265 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400266 ],
267 implicit_include_directories: true,
268 install: true
269)
270
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600271executable('phosphor-secure-boot-check',
272 'secure_boot_check.cpp',
273 'utils.cpp',
274 dependencies: [
NodeMan9727d1e142022-07-27 15:10:07 -0500275 fmt, sdbusplus,
276 phosphorlogging, libgpiod
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600277 ],
278 implicit_include_directories: true,
279 install: true
280)
281
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600282install_data('obmcutil',
283 install_mode: 'rwxr-xr-x',
284 install_dir: get_option('bindir')
285)
286
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400287install_data('scripts/host-reboot',
288 install_mode: 'rwxr-xr-x',
289 install_dir: get_option('libexecdir')
290)
291
Andrew Geissler179d38c2019-12-10 15:05:23 -0600292systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500293systemd_system_unit_dir = systemd.get_variable(
Patrick Williamsc079c3f2023-04-12 08:01:05 -0500294 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600295subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600296subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600297
Thang Tranba2241c2021-10-26 17:47:09 +0700298if build_host_gpios.enabled()
299 subdir('host_condition_gpio')
300endif
301
Andrew Geisslerefef9702019-12-10 16:56:57 -0600302datadir = join_paths(
303 get_option('sysconfdir'),
304 'phosphor-systemd-target-monitor'
305)
306subdir('data')
307
Andrew Geissler3f125632019-12-11 17:08:19 -0600308build_tests = get_option('tests')
309
310# If test coverage of source files within the root directory are wanted,
311# need to define and build the tests from here
312if not build_tests.disabled()
313gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800314gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600315 test(
316 'test_systemd_parser',
317 executable('test_systemd_parser',
318 './test/systemd_parser.cpp',
319 'systemd_target_parser.cpp',
320 dependencies: [
321 gtest,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500322 nlohmann_json,
Andrew Geissler3f125632019-12-11 17:08:19 -0600323 ],
324 implicit_include_directories: true,
325 include_directories: '../'
326 )
327 )
328
329 test(
330 'test_systemd_signal',
331 executable('test_systemd_signal',
332 './test/systemd_signal.cpp',
333 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400334 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600335 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500336 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400337 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500338 nlohmann_json,
339 phosphorlogging,
340 sdbusplus,
341 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600342 ],
343 implicit_include_directories: true,
344 include_directories: '../'
345 )
346 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800347
348 test(
349 'test_scheduled_host_transition',
350 executable('test_scheduled_host_transition',
351 './test/test_scheduled_host_transition.cpp',
352 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800353 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800354 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500355 cereal,
356 gmock,
357 gtest,
358 libgpiod,
359 phosphorlogging,
360 sdbusplus,
361 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800362 ],
363 implicit_include_directories: true,
364 include_directories: '../'
365 )
366 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600367
368 test(
369 'test_hypervisor_state',
370 executable('test_hypervisor_state',
371 './test/hypervisor_state.cpp',
372 'hypervisor_state_manager.cpp',
373 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500374 gtest,
375 phosphorlogging,
376 sdbusplus,
377 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600378 ],
379 implicit_include_directories: true,
380 include_directories: '../'
381 )
382 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600383endif