blob: a8e94beb928afd00581a3f9a0c53775d34a2837b [file] [log] [blame]
Andrew Geisslerf2454102019-12-06 15:14:08 -06001project(
2 'phosphor-state-manager',
3 'cpp',
Patrick Williams71e399d2025-02-01 08:36:54 -05004 default_options: ['warning_level=3', 'werror=true', 'cpp_std=c++23'],
Patrick Williams9beba5a2023-07-12 11:15:24 -05005 meson_version: '>=1.1.1',
Andrew Geisslerf2454102019-12-06 15:14:08 -06006 license: 'Apache-2.0',
7 version: '0.1',
8)
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -05009cpp = meson.get_compiler('cpp')
Andrew Geisslerf2454102019-12-06 15:14:08 -060010
Thang Tranba2241c2021-10-26 17:47:09 +070011build_host_gpios = get_option('host-gpios')
12
Andrew Geisslerf2454102019-12-06 15:14:08 -060013conf = configuration_data()
Patrick Williams71e399d2025-02-01 08:36:54 -050014conf.set_quoted('HOST_SCHED_OBJPATH', get_option('host-sched-objpath'))
15conf.set_quoted('HYPERVISOR_BUSNAME', get_option('hypervisor-busname'))
16conf.set_quoted('HYPERVISOR_OBJPATH', get_option('hypervisor-objpath'))
17conf.set_quoted('HOST_STATE_PERSIST_PATH', get_option('host-state-persist-path'))
Andrew Geisslerf2454102019-12-06 15:14:08 -060018conf.set_quoted(
Patrick Williams71e399d2025-02-01 08:36:54 -050019 'POH_COUNTER_PERSIST_PATH',
20 get_option('poh-counter-persist-path'),
21)
Andrew Geisslera0d7bb82023-03-01 12:50:14 -060022conf.set_quoted(
Patrick Williams71e399d2025-02-01 08:36:54 -050023 'CHASSIS_STATE_CHANGE_PERSIST_PATH',
24 get_option('chassis-state-change-persist-path'),
25)
Andrew Geisslerfe270d32021-01-27 14:06:46 -060026conf.set_quoted(
Patrick Williams71e399d2025-02-01 08:36:54 -050027 'SCHEDULED_HOST_TRANSITION_PERSIST_PATH',
28 get_option('scheduled-host-transition-persist-path'),
29)
30conf.set('BOOT_COUNT_MAX_ALLOWED', get_option('boot-count-max-allowed'))
31conf.set('CLASS_VERSION', get_option('class-version'))
32conf.set_quoted('SYSFS_SECURE_BOOT_PATH', get_option('sysfs-secure-boot-path'))
33conf.set_quoted('SYSFS_ABR_IMAGE_PATH', get_option('sysfs-abr-image-path'))
Patrick Williams5cd49f72023-11-29 06:44:17 -060034if build_host_gpios.allowed()
Patrick Williams71e399d2025-02-01 08:36:54 -050035 conf.set_quoted('HOST_GPIOS_BUSNAME', get_option('host-gpios-busname'))
36 conf.set_quoted('HOST_GPIOS_OBJPATH', get_option('host-gpios-objpath'))
Thang Tranba2241c2021-10-26 17:47:09 +070037endif
Andrew Geisslerf2454102019-12-06 15:14:08 -060038
NodeMan97bcbee4a2022-05-27 15:28:45 -050039conf.set10(
Patrick Williams71e399d2025-02-01 08:36:54 -050040 'ONLY_RUN_APR_ON_POWER_LOSS',
41 get_option('only-run-apr-on-power-loss'),
42)
43
Thang Tranff85df62025-05-07 13:40:43 +070044conf.set10('RUN_APR_ON_PINHOLE_RESET', get_option('run-apr-on-pinhole-reset'))
45
46conf.set10('RUN_APR_ON_WATCHDOG_RESET', get_option('run-apr-on-watchdog-reset'))
47
48conf.set10('RUN_APR_ON_SOFTWARE_RESET', get_option('run-apr-on-software-reset'))
49
Patrick Williams71e399d2025-02-01 08:36:54 -050050conf.set_quoted('SYSFS_TPM_DEVICE_PATH', get_option('sysfs-tpm-device-path'))
NodeMan97bcbee4a2022-05-27 15:28:45 -050051
Lakshmi Yadlapatib454d8b2023-03-27 16:11:41 -050052conf.set_quoted(
Patrick Williams71e399d2025-02-01 08:36:54 -050053 'SYSFS_TPM_MEASUREMENT_PATH',
54 get_option('sysfs-tpm-measurement-path'),
55)
Lakshmi Yadlapatib454d8b2023-03-27 16:11:41 -050056
Andrew Geissler629e3c42023-05-25 10:31:13 -040057conf.set10(
Patrick Williams71e399d2025-02-01 08:36:54 -050058 'ONLY_ALLOW_BOOT_WHEN_BMC_READY',
59 get_option('only-allow-boot-when-bmc-ready'),
60)
Andrew Geissler629e3c42023-05-25 10:31:13 -040061
Andrew Geissler343dbf82021-03-16 16:56:09 -050062# globals shared across applications
Patrick Williams71e399d2025-02-01 08:36:54 -050063conf.set_quoted('BASE_FILE_DIR', '/run/openbmc/')
NodeMan97bcbee4a2022-05-27 15:28:45 -050064
Patrick Williams71e399d2025-02-01 08:36:54 -050065conf.set_quoted('CHASSIS_LOST_POWER_FILE', '/run/openbmc/chassis@{}-lost-power')
NodeMan97bcbee4a2022-05-27 15:28:45 -050066
Patrick Williams71e399d2025-02-01 08:36:54 -050067conf.set_quoted('HOST_RUNNING_FILE', '/run/openbmc/host@{}-on')
Andrew Geissler343dbf82021-03-16 16:56:09 -050068
Patrick Williams71e399d2025-02-01 08:36:54 -050069conf.set_quoted('CHASSIS_ON_FILE', '/run/openbmc/chassis@{}-on')
Andrew Geissler5259f972021-08-30 15:46:55 -050070
Thang Tran9f381522024-10-18 10:11:01 +070071conf.set(
Patrick Williams71e399d2025-02-01 08:36:54 -050072 'CHECK_FWUPDATE_BEFORE_DO_TRANSITION',
73 get_option('check-fwupdate-before-do-transition').allowed(),
74)
Thang Tran9f381522024-10-18 10:11:01 +070075
Andrew Geisslerf2454102019-12-06 15:14:08 -060076configure_file(output: 'config.h', configuration: conf)
77
Patrick Williams71e399d2025-02-01 08:36:54 -050078if (get_option('warm-reboot').allowed())
79 add_project_arguments('-DENABLE_WARM_REBOOT', language: 'cpp')
Andrew Geissler7fdad602020-06-22 13:46:16 -050080endif
81
Patrick Williams71e399d2025-02-01 08:36:54 -050082if (get_option('force-warm-reboot').allowed())
83 add_project_arguments('-DENABLE_FORCE_WARM_REBOOT', language: 'cpp')
Andrew Geissler31cddb72024-02-27 14:20:26 -060084endif
85
Prithvi Pai3d506282025-02-01 12:31:01 +053086if (get_option('apply-power-policy-bmc-ready').allowed())
87 add_project_arguments('-DAPPLY_POWER_POLICY_WHEN_BMC_READY', language: 'cpp')
88endif
89
Patrick Williamsf0865de2023-12-07 17:16:26 -060090nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Andrew Geisslerf2454102019-12-06 15:14:08 -060091sdbusplus = dependency('sdbusplus')
92sdeventplus = dependency('sdeventplus')
93phosphorlogging = dependency('phosphor-logging')
94phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Patrick Williams71e399d2025-02-01 08:36:54 -050095libgpiod = dependency(
96 'libgpiod',
97 version: '>=1.4.1',
98 default_options: ['bindings=cxx'],
99)
Andrew Geisslerf2454102019-12-06 15:14:08 -0600100
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500101if cpp.has_header('CLI/CLI.hpp')
102 CLI11 = declare_dependency()
103else
104 CLI11 = dependency('CLI11')
105endif
106
107# Get Cereal dependency.
108cereal = dependency('cereal', required: false)
109has_cereal = cpp.has_header_symbol(
110 'cereal/cereal.hpp',
111 'cereal::specialize',
112 dependencies: cereal,
Patrick Williams71e399d2025-02-01 08:36:54 -0500113 required: false,
114)
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500115if not has_cereal
116 cereal_opts = import('cmake').subproject_options()
Patrick Williams71e399d2025-02-01 08:36:54 -0500117 cereal_opts.add_cmake_defines(
118 {'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'},
119 )
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500120 cereal_proj = import('cmake').subproject(
121 'cereal',
122 options: cereal_opts,
Patrick Williams71e399d2025-02-01 08:36:54 -0500123 required: false,
124 )
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500125 assert(cereal_proj.found(), 'cereal is required')
126 cereal = cereal_proj.dependency('cereal')
127endif
128
Alexander Hansen409c4492025-10-16 17:33:32 +0200129settings_lib = static_library(
130 'settings',
131 'settings.cpp',
132 dependencies: [sdbusplus, phosphorlogging, phosphordbusinterfaces],
133)
134
135utils_lib = static_library(
136 'utils',
137 'utils.cpp',
138 dependencies: [sdbusplus, phosphorlogging, phosphordbusinterfaces, libgpiod],
139)
140
Patrick Williams71e399d2025-02-01 08:36:54 -0500141executable(
142 'phosphor-host-state-manager',
143 'host_state_manager.cpp',
144 'host_state_manager_main.cpp',
Patrick Williams71e399d2025-02-01 08:36:54 -0500145 'host_check.cpp',
Patrick Williams71e399d2025-02-01 08:36:54 -0500146 dependencies: [
147 cereal,
148 libgpiod,
149 phosphordbusinterfaces,
150 phosphorlogging,
151 sdbusplus,
152 sdeventplus,
153 ],
Alexander Hansen409c4492025-10-16 17:33:32 +0200154 link_with: [settings_lib, utils_lib],
Andrew Geisslerf2454102019-12-06 15:14:08 -0600155 implicit_include_directories: true,
Patrick Williams71e399d2025-02-01 08:36:54 -0500156 install: true,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600157)
158
Patrick Williams71e399d2025-02-01 08:36:54 -0500159executable(
160 'phosphor-hypervisor-state-manager',
161 'hypervisor_state_manager.cpp',
162 'hypervisor_state_manager_main.cpp',
Patrick Williams71e399d2025-02-01 08:36:54 -0500163 dependencies: [
164 phosphordbusinterfaces,
165 phosphorlogging,
166 sdbusplus,
167 sdeventplus,
168 ],
Alexander Hansen409c4492025-10-16 17:33:32 +0200169 link_with: [settings_lib],
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600170 implicit_include_directories: true,
Patrick Williams71e399d2025-02-01 08:36:54 -0500171 install: true,
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600172)
173
Patrick Williams71e399d2025-02-01 08:36:54 -0500174executable(
175 'phosphor-chassis-state-manager',
176 'chassis_state_manager.cpp',
177 'chassis_state_manager_main.cpp',
Patrick Williams71e399d2025-02-01 08:36:54 -0500178 dependencies: [
179 cereal,
180 libgpiod,
181 nlohmann_json_dep,
182 phosphordbusinterfaces,
183 phosphorlogging,
184 sdbusplus,
185 sdeventplus,
186 ],
Alexander Hansen409c4492025-10-16 17:33:32 +0200187 link_with: [utils_lib],
Andrew Geisslerf2454102019-12-06 15:14:08 -0600188 implicit_include_directories: true,
Patrick Williams71e399d2025-02-01 08:36:54 -0500189 install: true,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600190)
191
Patrick Williams71e399d2025-02-01 08:36:54 -0500192executable(
193 'phosphor-chassis-check-power-status',
194 'chassis_check_power_status.cpp',
Patrick Williams71e399d2025-02-01 08:36:54 -0500195 dependencies: [libgpiod, phosphordbusinterfaces, phosphorlogging, sdbusplus],
Alexander Hansen409c4492025-10-16 17:33:32 +0200196 link_with: [utils_lib],
Andrew Geissler378fe112022-02-03 16:39:44 -0600197 implicit_include_directories: true,
Patrick Williams71e399d2025-02-01 08:36:54 -0500198 install: true,
Andrew Geissler378fe112022-02-03 16:39:44 -0600199)
200
Patrick Williams71e399d2025-02-01 08:36:54 -0500201executable(
202 'phosphor-bmc-state-manager',
203 'bmc_state_manager.cpp',
204 'bmc_state_manager_main.cpp',
Patrick Williams71e399d2025-02-01 08:36:54 -0500205 dependencies: [
206 libgpiod,
207 phosphordbusinterfaces,
208 phosphorlogging,
209 sdbusplus,
210 sdeventplus,
211 ],
Alexander Hansen409c4492025-10-16 17:33:32 +0200212 link_with: [utils_lib],
Andrew Geisslerf2454102019-12-06 15:14:08 -0600213 implicit_include_directories: true,
Patrick Williams71e399d2025-02-01 08:36:54 -0500214 install: true,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600215)
216
Patrick Williams71e399d2025-02-01 08:36:54 -0500217executable(
218 'phosphor-discover-system-state',
219 'discover_system_state.cpp',
Patrick Williams71e399d2025-02-01 08:36:54 -0500220 dependencies: [cereal, libgpiod, phosphorlogging, sdbusplus],
Alexander Hansen409c4492025-10-16 17:33:32 +0200221 link_with: [settings_lib, utils_lib],
Andrew Geisslerf2454102019-12-06 15:14:08 -0600222 implicit_include_directories: true,
Patrick Williams71e399d2025-02-01 08:36:54 -0500223 install: true,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600224)
225
Patrick Williams71e399d2025-02-01 08:36:54 -0500226executable(
227 'phosphor-systemd-target-monitor',
228 'systemd_service_parser.cpp',
229 'systemd_target_monitor.cpp',
230 'systemd_target_parser.cpp',
231 'systemd_target_signal.cpp',
Patrick Williams71e399d2025-02-01 08:36:54 -0500232 dependencies: [
233 CLI11,
234 libgpiod,
235 nlohmann_json_dep,
236 phosphorlogging,
237 sdbusplus,
238 sdeventplus,
239 ],
Alexander Hansen409c4492025-10-16 17:33:32 +0200240 link_with: [utils_lib],
Andrew Geisslerf2454102019-12-06 15:14:08 -0600241 implicit_include_directories: true,
Patrick Williams71e399d2025-02-01 08:36:54 -0500242 install: true,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600243)
Andrew Geissler3f125632019-12-11 17:08:19 -0600244
Patrick Williams71e399d2025-02-01 08:36:54 -0500245executable(
246 'phosphor-scheduled-host-transition',
247 'scheduled_host_transition_main.cpp',
248 'scheduled_host_transition.cpp',
Patrick Williams71e399d2025-02-01 08:36:54 -0500249 dependencies: [cereal, libgpiod, phosphorlogging, sdbusplus, sdeventplus],
Alexander Hansen409c4492025-10-16 17:33:32 +0200250 link_with: [utils_lib],
Carol Wang71230ef2020-02-18 17:39:49 +0800251 implicit_include_directories: true,
Patrick Williams71e399d2025-02-01 08:36:54 -0500252 install: true,
Carol Wang71230ef2020-02-18 17:39:49 +0800253)
254
Patrick Williams71e399d2025-02-01 08:36:54 -0500255executable(
256 'phosphor-host-reset-recovery',
257 'host_reset_recovery.cpp',
258 dependencies: [phosphorlogging, sdbusplus],
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400259 implicit_include_directories: true,
Patrick Williams71e399d2025-02-01 08:36:54 -0500260 install: true,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400261)
262
Patrick Williams71e399d2025-02-01 08:36:54 -0500263executable(
264 'phosphor-secure-boot-check',
265 'secure_boot_check.cpp',
Patrick Williams71e399d2025-02-01 08:36:54 -0500266 dependencies: [sdbusplus, phosphorlogging, libgpiod],
Alexander Hansen409c4492025-10-16 17:33:32 +0200267 link_with: [utils_lib],
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600268 implicit_include_directories: true,
Patrick Williams71e399d2025-02-01 08:36:54 -0500269 install: true,
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600270)
271
Patrick Williams (aider)ee7bb9e2025-04-19 14:13:12 -0400272if get_option('install-utils').allowed()
273 install_data(
274 'obmcutil',
275 install_mode: 'rwxr-xr-x',
276 install_dir: get_option('bindir'),
277 )
278endif
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600279
Patrick Williams71e399d2025-02-01 08:36:54 -0500280install_data(
281 'scripts/host-reboot',
282 install_mode: 'rwxr-xr-x',
283 install_dir: get_option('libexecdir') / 'phosphor-state-manager',
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400284)
285
Andrew Geissler179d38c2019-12-10 15:05:23 -0600286systemd = dependency('systemd')
Patrick Williamsebaa5092025-07-09 11:26:55 -0400287systemd_system_unit_dir = systemd.get_variable('systemd_system_unit_dir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600288subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600289subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600290
Patrick Williams5cd49f72023-11-29 06:44:17 -0600291if build_host_gpios.allowed()
Thang Tranba2241c2021-10-26 17:47:09 +0700292 subdir('host_condition_gpio')
293endif
294
Patrick Williams71e399d2025-02-01 08:36:54 -0500295datadir = join_paths(get_option('sysconfdir'), 'phosphor-systemd-target-monitor')
Andrew Geisslerefef9702019-12-10 16:56:57 -0600296subdir('data')
297
Andrew Geissler3f125632019-12-11 17:08:19 -0600298build_tests = get_option('tests')
299
300# If test coverage of source files within the root directory are wanted,
301# need to define and build the tests from here
Patrick Williamsf88281d2025-01-30 17:47:36 -0500302if build_tests.allowed()
Matt Spinlera279f872025-03-05 14:59:42 -0600303 gtest = dependency('gtest', main: true, disabler: true, required: false)
304 gmock = dependency('gmock', disabler: true, required: false)
305
306 if not gtest.found() or not gmock.found()
307 gtest_proj = import('cmake').subproject('googletest', required: false)
308 if gtest_proj.found()
309 gtest = declare_dependency(
310 dependencies: [
311 dependency('threads'),
312 gtest_proj.dependency('gtest'),
313 gtest_proj.dependency('gtest_main'),
314 ],
315 )
316 gmock = gtest_proj.dependency('gmock')
317 else
318 assert(
319 not get_option('tests').enabled(),
320 'Googletest is required if tests are enabled',
321 )
322 endif
323 endif
324
Alexander Hansen22a1e162025-10-02 15:03:43 +0200325 subdir('test')
Andrew Geissler3f125632019-12-11 17:08:19 -0600326endif