blob: 05b3963fc363aa785e0cf56a502a6150deb53712 [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
Andrew Geissler343dbf82021-03-16 16:56:09 -050059# globals shared across applications
60conf.set_quoted(
61 'HOST_RUNNING_FILE', '/run/openbmc/host@%d-on')
62
Andrew Geissler5259f972021-08-30 15:46:55 -050063conf.set_quoted(
64 'CHASSIS_ON_FILE', '/run/openbmc/chassis@%d-on')
65
Andrew Geisslerf2454102019-12-06 15:14:08 -060066configure_file(output: 'config.h', configuration: conf)
67
Andrew Geissler7fdad602020-06-22 13:46:16 -050068if(get_option('warm-reboot').enabled())
69 add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp')
70endif
71
Andrew Geisslerf2454102019-12-06 15:14:08 -060072sdbusplus = dependency('sdbusplus')
73sdeventplus = dependency('sdeventplus')
74phosphorlogging = dependency('phosphor-logging')
75phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Ben Tyner2c36e5a2021-07-12 14:56:49 -050076libgpiod = dependency('libgpiod', version : '>=1.4.1')
Allen.Wang79b45002022-02-10 17:59:20 +080077fmt = dependency('fmt')
Andrew Geisslerf2454102019-12-06 15:14:08 -060078
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -050079if cpp.has_header('nlohmann/json.hpp')
80 nlohmann_json = declare_dependency()
81else
82 subproject('nlohmann-json')
83 nlohmann_json = declare_dependency(
84 include_directories: [
85 'subprojects/nlohmann-json/single_include',
86 'subprojects/nlohmann-json/single_include/nlohmann',
87 ]
88 )
89endif
90
91if cpp.has_header('CLI/CLI.hpp')
92 CLI11 = declare_dependency()
93else
94 CLI11 = dependency('CLI11')
95endif
96
97# Get Cereal dependency.
98cereal = dependency('cereal', required: false)
99has_cereal = cpp.has_header_symbol(
100 'cereal/cereal.hpp',
101 'cereal::specialize',
102 dependencies: cereal,
103 required: false)
104if not has_cereal
105 cereal_opts = import('cmake').subproject_options()
106 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
107 cereal_proj = import('cmake').subproject(
108 'cereal',
109 options: cereal_opts,
110 required: false)
111 assert(cereal_proj.found(), 'cereal is required')
112 cereal = cereal_proj.dependency('cereal')
113endif
114
Andrew Geisslerf2454102019-12-06 15:14:08 -0600115executable('phosphor-host-state-manager',
116 'host_state_manager.cpp',
117 'host_state_manager_main.cpp',
118 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400119 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600120 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600121 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500122 cereal,
123 fmt,
124 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,
154 fmt,
155 libgpiod,
156 nlohmann_json,
157 phosphordbusinterfaces,
158 phosphorlogging,
159 sdbusplus,
160 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600161 ],
162 implicit_include_directories: true,
163 install: true
164)
165
Andrew Geissler378fe112022-02-03 16:39:44 -0600166executable('phosphor-chassis-check-power-status',
167 'chassis_check_power_status.cpp',
168 'utils.cpp',
169 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500170 libgpiod,
171 phosphordbusinterfaces,
172 phosphorlogging,
173 sdbusplus,
Andrew Geissler378fe112022-02-03 16:39:44 -0600174 ],
175 implicit_include_directories: true,
176 install: true
177)
178
Andrew Geisslerf2454102019-12-06 15:14:08 -0600179executable('phosphor-bmc-state-manager',
180 'bmc_state_manager.cpp',
181 'bmc_state_manager_main.cpp',
Andrew Geissler98e64e62022-01-25 16:02:56 -0600182 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600183 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500184 libgpiod,
185 phosphordbusinterfaces,
186 phosphorlogging,
187 sdbusplus,
188 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600189 ],
190 implicit_include_directories: true,
191 install: true
192)
193
194executable('phosphor-discover-system-state',
195 'discover_system_state.cpp',
196 'settings.cpp',
Andrew Geissler49e67132022-01-26 14:27:52 -0600197 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600198 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500199 cereal,
200 libgpiod,
201 phosphorlogging,
202 sdbusplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600203 ],
204 implicit_include_directories: true,
205 install: true
206)
207
Andrew Geisslerf2454102019-12-06 15:14:08 -0600208executable('phosphor-systemd-target-monitor',
Andrew Geissler9e3afdf2022-02-10 15:06:16 -0600209 'systemd_service_parser.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600210 'systemd_target_monitor.cpp',
211 'systemd_target_parser.cpp',
212 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400213 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600214 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500215 CLI11,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400216 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500217 nlohmann_json,
218 phosphorlogging,
219 sdbusplus,
220 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600221 ],
222 implicit_include_directories: true,
223 install: true
224)
Andrew Geissler3f125632019-12-11 17:08:19 -0600225
Carol Wang71230ef2020-02-18 17:39:49 +0800226executable('phosphor-scheduled-host-transition',
227 'scheduled_host_transition_main.cpp',
228 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800229 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800230 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500231 cereal,
232 libgpiod,
233 phosphorlogging,
234 sdbusplus,
235 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800236 ],
237 implicit_include_directories: true,
238 install: true
239)
240
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400241executable('phosphor-host-reset-recovery',
242 'host_reset_recovery.cpp',
243 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500244 phosphorlogging,
245 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400246 ],
247 implicit_include_directories: true,
248 install: true
249)
250
Andrew Geissler6b9421b2022-02-24 17:01:55 -0600251executable('phosphor-secure-boot-check',
252 'secure_boot_check.cpp',
253 'utils.cpp',
254 dependencies: [
255 sdbusplus, phosphorlogging, libgpiod
256 ],
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',
268 install_dir: get_option('libexecdir')
269)
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(
273 pkgconfig : '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
Thang Tranba2241c2021-10-26 17:47:09 +0700277if build_host_gpios.enabled()
278 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 Williamsf8d5f3e2022-04-05 15:51:15 -0500301 nlohmann_json,
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 Williamsf8d5f3e2022-04-05 15:51:15 -0500317 nlohmann_json,
318 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