blob: 17a5a118d81b159335335956947c7176584eee95 [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 ],
Andrew Geissler429100a2021-09-09 12:50:24 -05009 meson_version: '>= 0.57.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 Geisslerfe270d32021-01-27 14:06:46 -060023 'HYPERVISOR_BUSNAME', get_option('hypervisor-busname'))
24conf.set_quoted(
25 'HYPERVISOR_OBJPATH', get_option('hypervisor-objpath'))
26conf.set_quoted(
Andrew Geisslerf2454102019-12-06 15:14:08 -060027 'CHASSIS_BUSNAME', get_option('chassis-busname'))
28conf.set_quoted(
29 'CHASSIS_OBJPATH', get_option('chassis-objpath'))
30conf.set_quoted(
31 'BMC_BUSNAME', get_option('bmc-busname'))
32conf.set_quoted(
33 'BMC_OBJPATH', get_option('bmc-objpath'))
34conf.set_quoted(
Andrew Geisslerf2454102019-12-06 15:14:08 -060035 'HOST_STATE_PERSIST_PATH', get_option('host-state-persist-path'))
36conf.set_quoted(
37 'POH_COUNTER_PERSIST_PATH', get_option('poh-counter-persist-path'))
38conf.set_quoted(
39 'CHASSIS_STATE_CHANGE_PERSIST_PATH', get_option('chassis-state-change-persist-path'))
Carol Wang71230ef2020-02-18 17:39:49 +080040conf.set_quoted(
Carol Wang1dbbef42020-03-09 11:51:23 +080041 'SCHEDULED_HOST_TRANSITION_PERSIST_PATH', get_option('scheduled-host-transition-persist-path'))
42conf.set_quoted(
Carol Wang71230ef2020-02-18 17:39:49 +080043 'SCHEDULED_HOST_TRANSITION_BUSNAME', get_option('scheduled-host-transition-busname'))
Andrew Geisslerf2454102019-12-06 15:14:08 -060044conf.set(
45 'BOOT_COUNT_MAX_ALLOWED', get_option('boot-count-max-allowed'))
46conf.set(
47 'CLASS_VERSION', get_option('class-version'))
Andrew Geissler8d8d7312022-03-04 14:42:26 -060048conf.set_quoted(
49 'SYSFS_SECURE_BOOT_PATH', get_option('sysfs-secure-boot-path'))
50conf.set_quoted(
51 'SYSFS_ABR_IMAGE_PATH', get_option('sysfs-abr-image-path'))
Thang Tranba2241c2021-10-26 17:47:09 +070052if build_host_gpios.enabled()
53 conf.set_quoted(
54 'HOST_GPIOS_BUSNAME', get_option('host-gpios-busname'))
55 conf.set_quoted(
56 'HOST_GPIOS_OBJPATH', get_option('host-gpios-objpath'))
57endif
Andrew Geisslerf2454102019-12-06 15:14:08 -060058
NodeMan97bcbee4a2022-05-27 15:28:45 -050059conf.set10(
60 'ONLY_RUN_APR_ON_POWER_LOSS', get_option('only-run-apr-on-power-loss'))
61
Andrew Geissler343dbf82021-03-16 16:56:09 -050062# globals shared across applications
63conf.set_quoted(
NodeMan97bcbee4a2022-05-27 15:28:45 -050064 'BASE_FILE_DIR', '/run/openbmc/')
65
66conf.set_quoted(
67 'CHASSIS_LOST_POWER_FILE', '/run/openbmc/chassis@%d-lost-power')
68
69conf.set_quoted(
Andrew Geissler343dbf82021-03-16 16:56:09 -050070 'HOST_RUNNING_FILE', '/run/openbmc/host@%d-on')
71
Andrew Geissler5259f972021-08-30 15:46:55 -050072conf.set_quoted(
73 'CHASSIS_ON_FILE', '/run/openbmc/chassis@%d-on')
74
Andrew Geisslerf2454102019-12-06 15:14:08 -060075configure_file(output: 'config.h', configuration: conf)
76
Andrew Geissler7fdad602020-06-22 13:46:16 -050077if(get_option('warm-reboot').enabled())
78 add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp')
79endif
80
Andrew Geisslerf2454102019-12-06 15:14:08 -060081sdbusplus = dependency('sdbusplus')
82sdeventplus = dependency('sdeventplus')
83phosphorlogging = dependency('phosphor-logging')
84phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Ben Tyner2c36e5a2021-07-12 14:56:49 -050085libgpiod = dependency('libgpiod', version : '>=1.4.1')
Allen.Wang79b45002022-02-10 17:59:20 +080086fmt = dependency('fmt')
Andrew Geisslerf2454102019-12-06 15:14:08 -060087
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -050088if cpp.has_header('nlohmann/json.hpp')
89 nlohmann_json = declare_dependency()
90else
91 subproject('nlohmann-json')
92 nlohmann_json = declare_dependency(
93 include_directories: [
94 'subprojects/nlohmann-json/single_include',
95 'subprojects/nlohmann-json/single_include/nlohmann',
96 ]
97 )
98endif
99
100if cpp.has_header('CLI/CLI.hpp')
101 CLI11 = declare_dependency()
102else
103 CLI11 = dependency('CLI11')
104endif
105
106# Get Cereal dependency.
107cereal = dependency('cereal', required: false)
108has_cereal = cpp.has_header_symbol(
109 'cereal/cereal.hpp',
110 'cereal::specialize',
111 dependencies: cereal,
112 required: false)
113if not has_cereal
114 cereal_opts = import('cmake').subproject_options()
115 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
116 cereal_proj = import('cmake').subproject(
117 'cereal',
118 options: cereal_opts,
119 required: false)
120 assert(cereal_proj.found(), 'cereal is required')
121 cereal = cereal_proj.dependency('cereal')
122endif
123
Andrew Geisslerf2454102019-12-06 15:14:08 -0600124executable('phosphor-host-state-manager',
125 'host_state_manager.cpp',
126 'host_state_manager_main.cpp',
127 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400128 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600129 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600130 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500131 cereal,
132 fmt,
133 libgpiod,
134 phosphordbusinterfaces,
135 phosphorlogging,
136 sdbusplus,
137 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600138 ],
139 implicit_include_directories: true,
140 install: true
141)
142
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600143executable('phosphor-hypervisor-state-manager',
144 'hypervisor_state_manager.cpp',
145 'hypervisor_state_manager_main.cpp',
146 'settings.cpp',
147 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500148 phosphordbusinterfaces,
149 phosphorlogging,
150 sdbusplus,
151 sdeventplus,
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600152 ],
153 implicit_include_directories: true,
154 install: true
155)
156
Andrew Geisslerf2454102019-12-06 15:14:08 -0600157executable('phosphor-chassis-state-manager',
158 'chassis_state_manager.cpp',
159 'chassis_state_manager_main.cpp',
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -0600160 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600161 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500162 cereal,
163 fmt,
164 libgpiod,
165 nlohmann_json,
166 phosphordbusinterfaces,
167 phosphorlogging,
168 sdbusplus,
169 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600170 ],
171 implicit_include_directories: true,
172 install: true
173)
174
Andrew Geissler378fe112022-02-03 16:39:44 -0600175executable('phosphor-chassis-check-power-status',
176 'chassis_check_power_status.cpp',
177 'utils.cpp',
178 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500179 libgpiod,
180 phosphordbusinterfaces,
181 phosphorlogging,
182 sdbusplus,
Andrew Geissler378fe112022-02-03 16:39:44 -0600183 ],
184 implicit_include_directories: true,
185 install: true
186)
187
Andrew Geisslerf2454102019-12-06 15:14:08 -0600188executable('phosphor-bmc-state-manager',
189 'bmc_state_manager.cpp',
190 'bmc_state_manager_main.cpp',
Andrew Geissler98e64e62022-01-25 16:02:56 -0600191 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600192 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500193 libgpiod,
194 phosphordbusinterfaces,
195 phosphorlogging,
196 sdbusplus,
197 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600198 ],
199 implicit_include_directories: true,
200 install: true
201)
202
203executable('phosphor-discover-system-state',
204 'discover_system_state.cpp',
205 'settings.cpp',
Andrew Geissler49e67132022-01-26 14:27:52 -0600206 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600207 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500208 cereal,
NodeMan97bcbee4a2022-05-27 15:28:45 -0500209 fmt,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500210 libgpiod,
211 phosphorlogging,
212 sdbusplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600213 ],
214 implicit_include_directories: true,
215 install: true
216)
217
Andrew Geisslerf2454102019-12-06 15:14:08 -0600218executable('phosphor-systemd-target-monitor',
Andrew Geissler9e3afdf2022-02-10 15:06:16 -0600219 'systemd_service_parser.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600220 'systemd_target_monitor.cpp',
221 'systemd_target_parser.cpp',
222 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400223 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600224 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500225 CLI11,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400226 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500227 nlohmann_json,
228 phosphorlogging,
229 sdbusplus,
230 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600231 ],
232 implicit_include_directories: true,
233 install: true
234)
Andrew Geissler3f125632019-12-11 17:08:19 -0600235
Carol Wang71230ef2020-02-18 17:39:49 +0800236executable('phosphor-scheduled-host-transition',
237 'scheduled_host_transition_main.cpp',
238 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800239 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800240 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500241 cereal,
242 libgpiod,
243 phosphorlogging,
244 sdbusplus,
245 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800246 ],
247 implicit_include_directories: true,
248 install: true
249)
250
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400251executable('phosphor-host-reset-recovery',
252 'host_reset_recovery.cpp',
253 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500254 phosphorlogging,
255 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400256 ],
257 implicit_include_directories: true,
258 install: true
259)
260
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600261executable('phosphor-secure-boot-check',
262 'secure_boot_check.cpp',
263 'utils.cpp',
264 dependencies: [
265 sdbusplus, phosphorlogging, libgpiod
266 ],
267 implicit_include_directories: true,
268 install: true
269)
270
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600271install_data('obmcutil',
272 install_mode: 'rwxr-xr-x',
273 install_dir: get_option('bindir')
274)
275
Andrew Geissler128ea8e2022-06-22 12:28:15 -0400276install_data('scripts/host-reboot',
277 install_mode: 'rwxr-xr-x',
278 install_dir: get_option('libexecdir')
279)
280
Andrew Geissler179d38c2019-12-10 15:05:23 -0600281systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500282systemd_system_unit_dir = systemd.get_variable(
283 pkgconfig : 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600284subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600285subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600286
Thang Tranba2241c2021-10-26 17:47:09 +0700287if build_host_gpios.enabled()
288 subdir('host_condition_gpio')
289endif
290
Andrew Geisslerefef9702019-12-10 16:56:57 -0600291datadir = join_paths(
292 get_option('sysconfdir'),
293 'phosphor-systemd-target-monitor'
294)
295subdir('data')
296
Andrew Geissler3f125632019-12-11 17:08:19 -0600297build_tests = get_option('tests')
298
299# If test coverage of source files within the root directory are wanted,
300# need to define and build the tests from here
301if not build_tests.disabled()
302gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800303gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600304 test(
305 'test_systemd_parser',
306 executable('test_systemd_parser',
307 './test/systemd_parser.cpp',
308 'systemd_target_parser.cpp',
309 dependencies: [
310 gtest,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500311 nlohmann_json,
Andrew Geissler3f125632019-12-11 17:08:19 -0600312 ],
313 implicit_include_directories: true,
314 include_directories: '../'
315 )
316 )
317
318 test(
319 'test_systemd_signal',
320 executable('test_systemd_signal',
321 './test/systemd_signal.cpp',
322 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400323 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600324 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500325 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400326 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500327 nlohmann_json,
328 phosphorlogging,
329 sdbusplus,
330 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600331 ],
332 implicit_include_directories: true,
333 include_directories: '../'
334 )
335 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800336
337 test(
338 'test_scheduled_host_transition',
339 executable('test_scheduled_host_transition',
340 './test/test_scheduled_host_transition.cpp',
341 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800342 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800343 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500344 cereal,
345 gmock,
346 gtest,
347 libgpiod,
348 phosphorlogging,
349 sdbusplus,
350 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800351 ],
352 implicit_include_directories: true,
353 include_directories: '../'
354 )
355 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600356
357 test(
358 'test_hypervisor_state',
359 executable('test_hypervisor_state',
360 './test/hypervisor_state.cpp',
361 'hypervisor_state_manager.cpp',
362 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500363 gtest,
364 phosphorlogging,
365 sdbusplus,
366 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600367 ],
368 implicit_include_directories: true,
369 include_directories: '../'
370 )
371 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600372endif