blob: de40c9397adc5dd5524b99e89790ea2141fc0045 [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 Geissler179d38c2019-12-10 15:05:23 -0600266systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500267systemd_system_unit_dir = systemd.get_variable(
268 pkgconfig : 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600269subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600270subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600271
Thang Tranba2241c2021-10-26 17:47:09 +0700272if build_host_gpios.enabled()
273 subdir('host_condition_gpio')
274endif
275
Andrew Geisslerefef9702019-12-10 16:56:57 -0600276datadir = join_paths(
277 get_option('sysconfdir'),
278 'phosphor-systemd-target-monitor'
279)
280subdir('data')
281
Andrew Geissler3f125632019-12-11 17:08:19 -0600282build_tests = get_option('tests')
283
284# If test coverage of source files within the root directory are wanted,
285# need to define and build the tests from here
286if not build_tests.disabled()
287gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800288gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600289 test(
290 'test_systemd_parser',
291 executable('test_systemd_parser',
292 './test/systemd_parser.cpp',
293 'systemd_target_parser.cpp',
294 dependencies: [
295 gtest,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500296 nlohmann_json,
Andrew Geissler3f125632019-12-11 17:08:19 -0600297 ],
298 implicit_include_directories: true,
299 include_directories: '../'
300 )
301 )
302
303 test(
304 'test_systemd_signal',
305 executable('test_systemd_signal',
306 './test/systemd_signal.cpp',
307 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400308 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600309 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500310 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400311 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500312 nlohmann_json,
313 phosphorlogging,
314 sdbusplus,
315 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600316 ],
317 implicit_include_directories: true,
318 include_directories: '../'
319 )
320 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800321
322 test(
323 'test_scheduled_host_transition',
324 executable('test_scheduled_host_transition',
325 './test/test_scheduled_host_transition.cpp',
326 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800327 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800328 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500329 cereal,
330 gmock,
331 gtest,
332 libgpiod,
333 phosphorlogging,
334 sdbusplus,
335 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800336 ],
337 implicit_include_directories: true,
338 include_directories: '../'
339 )
340 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600341
342 test(
343 'test_hypervisor_state',
344 executable('test_hypervisor_state',
345 './test/hypervisor_state.cpp',
346 'hypervisor_state_manager.cpp',
347 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500348 gtest,
349 phosphorlogging,
350 sdbusplus,
351 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600352 ],
353 implicit_include_directories: true,
354 include_directories: '../'
355 )
356 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600357endif