blob: 6991667b8e3825c3a0bd09aa68d1606821f88e25 [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
Andrew Geisslerf2454102019-12-06 15:14:08 -060072configure_file(output: 'config.h', configuration: conf)
73
Patrick Williams5cd49f72023-11-29 06:44:17 -060074if(get_option('warm-reboot').allowed())
Andrew Geissler7fdad602020-06-22 13:46:16 -050075 add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp')
76endif
77
Andrew Geissler31cddb72024-02-27 14:20:26 -060078if(get_option('force-warm-reboot').allowed())
79 add_project_arguments('-DENABLE_FORCE_WARM_REBOOT',language:'cpp')
80endif
81
Patrick Williamsf0865de2023-12-07 17:16:26 -060082nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Andrew Geisslerf2454102019-12-06 15:14:08 -060083sdbusplus = dependency('sdbusplus')
84sdeventplus = dependency('sdeventplus')
85phosphorlogging = dependency('phosphor-logging')
86phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Peter Delevoryas29c2a1c2024-11-25 14:03:03 -080087libgpiod = dependency('libgpiod', version : '>=1.4.1', default_options: ['bindings=cxx'])
Andrew Geisslerf2454102019-12-06 15:14:08 -060088
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -050089if cpp.has_header('CLI/CLI.hpp')
90 CLI11 = declare_dependency()
91else
92 CLI11 = dependency('CLI11')
93endif
94
95# Get Cereal dependency.
96cereal = dependency('cereal', required: false)
97has_cereal = cpp.has_header_symbol(
98 'cereal/cereal.hpp',
99 'cereal::specialize',
100 dependencies: cereal,
101 required: false)
102if not has_cereal
103 cereal_opts = import('cmake').subproject_options()
Konstantin Aladyshev8a373d52024-04-02 17:38:32 +0300104 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'})
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500105 cereal_proj = import('cmake').subproject(
106 'cereal',
107 options: cereal_opts,
108 required: false)
109 assert(cereal_proj.found(), 'cereal is required')
110 cereal = cereal_proj.dependency('cereal')
111endif
112
Andrew Geisslerf2454102019-12-06 15:14:08 -0600113executable('phosphor-host-state-manager',
114 'host_state_manager.cpp',
115 'host_state_manager_main.cpp',
116 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400117 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600118 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600119 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500120 cereal,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500121 libgpiod,
122 phosphordbusinterfaces,
123 phosphorlogging,
124 sdbusplus,
125 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600126 ],
127 implicit_include_directories: true,
128 install: true
129)
130
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600131executable('phosphor-hypervisor-state-manager',
132 'hypervisor_state_manager.cpp',
133 'hypervisor_state_manager_main.cpp',
134 'settings.cpp',
135 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500136 phosphordbusinterfaces,
137 phosphorlogging,
138 sdbusplus,
139 sdeventplus,
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600140 ],
141 implicit_include_directories: true,
142 install: true
143)
144
Andrew Geisslerf2454102019-12-06 15:14:08 -0600145executable('phosphor-chassis-state-manager',
146 'chassis_state_manager.cpp',
147 'chassis_state_manager_main.cpp',
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -0600148 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600149 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500150 cereal,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500151 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600152 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500153 phosphordbusinterfaces,
154 phosphorlogging,
155 sdbusplus,
156 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600157 ],
158 implicit_include_directories: true,
159 install: true
160)
161
Andrew Geissler378fe112022-02-03 16:39:44 -0600162executable('phosphor-chassis-check-power-status',
163 'chassis_check_power_status.cpp',
164 'utils.cpp',
165 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500166 libgpiod,
167 phosphordbusinterfaces,
168 phosphorlogging,
169 sdbusplus,
Andrew Geissler378fe112022-02-03 16:39:44 -0600170 ],
171 implicit_include_directories: true,
172 install: true
173)
174
Andrew Geisslerf2454102019-12-06 15:14:08 -0600175executable('phosphor-bmc-state-manager',
176 'bmc_state_manager.cpp',
177 'bmc_state_manager_main.cpp',
Andrew Geissler98e64e62022-01-25 16:02:56 -0600178 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600179 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500180 libgpiod,
181 phosphordbusinterfaces,
182 phosphorlogging,
183 sdbusplus,
184 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600185 ],
186 implicit_include_directories: true,
187 install: true
188)
189
190executable('phosphor-discover-system-state',
191 'discover_system_state.cpp',
192 'settings.cpp',
Andrew Geissler49e67132022-01-26 14:27:52 -0600193 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600194 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500195 cereal,
196 libgpiod,
197 phosphorlogging,
198 sdbusplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600199 ],
200 implicit_include_directories: true,
201 install: true
202)
203
Andrew Geisslerf2454102019-12-06 15:14:08 -0600204executable('phosphor-systemd-target-monitor',
Andrew Geissler9e3afdf2022-02-10 15:06:16 -0600205 'systemd_service_parser.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600206 'systemd_target_monitor.cpp',
207 'systemd_target_parser.cpp',
208 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400209 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600210 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500211 CLI11,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400212 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600213 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500214 phosphorlogging,
215 sdbusplus,
216 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600217 ],
218 implicit_include_directories: true,
219 install: true
220)
Andrew Geissler3f125632019-12-11 17:08:19 -0600221
Carol Wang71230ef2020-02-18 17:39:49 +0800222executable('phosphor-scheduled-host-transition',
223 'scheduled_host_transition_main.cpp',
224 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800225 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800226 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500227 cereal,
228 libgpiod,
229 phosphorlogging,
230 sdbusplus,
231 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800232 ],
233 implicit_include_directories: true,
234 install: true
235)
236
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400237executable('phosphor-host-reset-recovery',
238 'host_reset_recovery.cpp',
239 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500240 phosphorlogging,
241 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400242 ],
243 implicit_include_directories: true,
244 install: true
245)
246
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600247executable('phosphor-secure-boot-check',
248 'secure_boot_check.cpp',
249 'utils.cpp',
250 dependencies: [
Patrick Williams78c066f2024-02-13 12:25:58 -0600251 sdbusplus,
NodeMan9727d1e142022-07-27 15:10:07 -0500252 phosphorlogging, libgpiod
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600253 ],
254 implicit_include_directories: true,
255 install: true
256)
257
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600258install_data('obmcutil',
259 install_mode: 'rwxr-xr-x',
260 install_dir: get_option('bindir')
261)
262
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400263install_data('scripts/host-reboot',
264 install_mode: 'rwxr-xr-x',
Patrick Williams306c5ff2024-04-04 14:04:07 -0500265 install_dir: get_option('libexecdir')/'phosphor-state-manager'
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400266)
267
Andrew Geissler179d38c2019-12-10 15:05:23 -0600268systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500269systemd_system_unit_dir = systemd.get_variable(
Patrick Williamsc079c3f2023-04-12 08:01:05 -0500270 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600271subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600272subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600273
Patrick Williams5cd49f72023-11-29 06:44:17 -0600274if build_host_gpios.allowed()
Thang Tranba2241c2021-10-26 17:47:09 +0700275 subdir('host_condition_gpio')
276endif
277
Andrew Geisslerefef9702019-12-10 16:56:57 -0600278datadir = join_paths(
279 get_option('sysconfdir'),
280 'phosphor-systemd-target-monitor'
281)
282subdir('data')
283
Andrew Geissler3f125632019-12-11 17:08:19 -0600284build_tests = get_option('tests')
285
286# If test coverage of source files within the root directory are wanted,
287# need to define and build the tests from here
288if not build_tests.disabled()
289gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800290gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600291 test(
292 'test_systemd_parser',
293 executable('test_systemd_parser',
294 './test/systemd_parser.cpp',
295 'systemd_target_parser.cpp',
296 dependencies: [
297 gtest,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600298 nlohmann_json_dep,
Andrew Geissler3f125632019-12-11 17:08:19 -0600299 ],
300 implicit_include_directories: true,
301 include_directories: '../'
302 )
303 )
304
305 test(
306 'test_systemd_signal',
307 executable('test_systemd_signal',
308 './test/systemd_signal.cpp',
309 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400310 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600311 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500312 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400313 libgpiod,
Patrick Williamsf0865de2023-12-07 17:16:26 -0600314 nlohmann_json_dep,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500315 phosphorlogging,
316 sdbusplus,
317 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600318 ],
319 implicit_include_directories: true,
320 include_directories: '../'
321 )
322 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800323
324 test(
325 'test_scheduled_host_transition',
326 executable('test_scheduled_host_transition',
327 './test/test_scheduled_host_transition.cpp',
328 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800329 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800330 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500331 cereal,
332 gmock,
333 gtest,
334 libgpiod,
335 phosphorlogging,
336 sdbusplus,
337 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800338 ],
339 implicit_include_directories: true,
340 include_directories: '../'
341 )
342 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600343
344 test(
345 'test_hypervisor_state',
346 executable('test_hypervisor_state',
347 './test/hypervisor_state.cpp',
348 'hypervisor_state_manager.cpp',
349 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500350 gtest,
351 phosphorlogging,
352 sdbusplus,
353 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600354 ],
355 implicit_include_directories: true,
356 include_directories: '../'
357 )
358 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600359endif