blob: b267f403d0a454066e0dab7b2476c3b0315292d2 [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'))
Thang Tranba2241c2021-10-26 17:47:09 +070048if build_host_gpios.enabled()
49 conf.set_quoted(
50 'HOST_GPIOS_BUSNAME', get_option('host-gpios-busname'))
51 conf.set_quoted(
52 'HOST_GPIOS_OBJPATH', get_option('host-gpios-objpath'))
53endif
Andrew Geisslerf2454102019-12-06 15:14:08 -060054
Andrew Geissler343dbf82021-03-16 16:56:09 -050055# globals shared across applications
56conf.set_quoted(
57 'HOST_RUNNING_FILE', '/run/openbmc/host@%d-on')
58
Andrew Geissler5259f972021-08-30 15:46:55 -050059conf.set_quoted(
60 'CHASSIS_ON_FILE', '/run/openbmc/chassis@%d-on')
61
Andrew Geisslerf2454102019-12-06 15:14:08 -060062configure_file(output: 'config.h', configuration: conf)
63
Andrew Geissler7fdad602020-06-22 13:46:16 -050064if(get_option('warm-reboot').enabled())
65 add_project_arguments('-DENABLE_WARM_REBOOT',language:'cpp')
66endif
67
Andrew Geisslerf2454102019-12-06 15:14:08 -060068sdbusplus = dependency('sdbusplus')
69sdeventplus = dependency('sdeventplus')
70phosphorlogging = dependency('phosphor-logging')
71phosphordbusinterfaces = dependency('phosphor-dbus-interfaces')
Ben Tyner2c36e5a2021-07-12 14:56:49 -050072libgpiod = dependency('libgpiod', version : '>=1.4.1')
Allen.Wang79b45002022-02-10 17:59:20 +080073fmt = dependency('fmt')
Andrew Geisslerf2454102019-12-06 15:14:08 -060074
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -050075if cpp.has_header('nlohmann/json.hpp')
76 nlohmann_json = declare_dependency()
77else
78 subproject('nlohmann-json')
79 nlohmann_json = declare_dependency(
80 include_directories: [
81 'subprojects/nlohmann-json/single_include',
82 'subprojects/nlohmann-json/single_include/nlohmann',
83 ]
84 )
85endif
86
87if cpp.has_header('CLI/CLI.hpp')
88 CLI11 = declare_dependency()
89else
90 CLI11 = dependency('CLI11')
91endif
92
93# Get Cereal dependency.
94cereal = dependency('cereal', required: false)
95has_cereal = cpp.has_header_symbol(
96 'cereal/cereal.hpp',
97 'cereal::specialize',
98 dependencies: cereal,
99 required: false)
100if not has_cereal
101 cereal_opts = import('cmake').subproject_options()
102 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
103 cereal_proj = import('cmake').subproject(
104 'cereal',
105 options: cereal_opts,
106 required: false)
107 assert(cereal_proj.found(), 'cereal is required')
108 cereal = cereal_proj.dependency('cereal')
109endif
110
Andrew Geisslerf2454102019-12-06 15:14:08 -0600111executable('phosphor-host-state-manager',
112 'host_state_manager.cpp',
113 'host_state_manager_main.cpp',
114 'settings.cpp',
Andrew Geissler0d1c3f12021-07-27 16:21:01 -0400115 'host_check.cpp',
Andrew Geissler1ab2b6c2022-03-10 16:16:15 -0600116 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600117 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500118 cereal,
119 fmt,
120 libgpiod,
121 phosphordbusinterfaces,
122 phosphorlogging,
123 sdbusplus,
124 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600125 ],
126 implicit_include_directories: true,
127 install: true
128)
129
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600130executable('phosphor-hypervisor-state-manager',
131 'hypervisor_state_manager.cpp',
132 'hypervisor_state_manager_main.cpp',
133 'settings.cpp',
134 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500135 phosphordbusinterfaces,
136 phosphorlogging,
137 sdbusplus,
138 sdeventplus,
Andrew Geisslerfe270d32021-01-27 14:06:46 -0600139 ],
140 implicit_include_directories: true,
141 install: true
142)
143
Andrew Geisslerf2454102019-12-06 15:14:08 -0600144executable('phosphor-chassis-state-manager',
145 'chassis_state_manager.cpp',
146 'chassis_state_manager_main.cpp',
Andrew Geisslerf8ae6a02022-01-21 17:00:20 -0600147 'utils.cpp',
Andrew Geisslerf2454102019-12-06 15:14:08 -0600148 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500149 cereal,
150 fmt,
151 libgpiod,
152 nlohmann_json,
153 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 Williamsf8d5f3e2022-04-05 15:51:15 -0500213 nlohmann_json,
214 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: [
251 sdbusplus, phosphorlogging, libgpiod
252 ],
253 implicit_include_directories: true,
254 install: true
255)
256
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600257install_data('obmcutil',
258 install_mode: 'rwxr-xr-x',
259 install_dir: get_option('bindir')
260)
261
Andrew Geissler179d38c2019-12-10 15:05:23 -0600262systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500263systemd_system_unit_dir = systemd.get_variable(
264 pkgconfig : 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600265subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600266subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600267
Thang Tranba2241c2021-10-26 17:47:09 +0700268if build_host_gpios.enabled()
269 subdir('host_condition_gpio')
270endif
271
Andrew Geisslerefef9702019-12-10 16:56:57 -0600272datadir = join_paths(
273 get_option('sysconfdir'),
274 'phosphor-systemd-target-monitor'
275)
276subdir('data')
277
Andrew Geissler3f125632019-12-11 17:08:19 -0600278build_tests = get_option('tests')
279
280# If test coverage of source files within the root directory are wanted,
281# need to define and build the tests from here
282if not build_tests.disabled()
283gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800284gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600285 test(
286 'test_systemd_parser',
287 executable('test_systemd_parser',
288 './test/systemd_parser.cpp',
289 'systemd_target_parser.cpp',
290 dependencies: [
291 gtest,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500292 nlohmann_json,
Andrew Geissler3f125632019-12-11 17:08:19 -0600293 ],
294 implicit_include_directories: true,
295 include_directories: '../'
296 )
297 )
298
299 test(
300 'test_systemd_signal',
301 executable('test_systemd_signal',
302 './test/systemd_signal.cpp',
303 'systemd_target_signal.cpp',
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400304 'utils.cpp',
Andrew Geissler3f125632019-12-11 17:08:19 -0600305 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500306 gtest,
Andrew Geissler55e96ac2022-04-19 11:44:53 -0400307 libgpiod,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500308 nlohmann_json,
309 phosphorlogging,
310 sdbusplus,
311 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600312 ],
313 implicit_include_directories: true,
314 include_directories: '../'
315 )
316 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800317
318 test(
319 'test_scheduled_host_transition',
320 executable('test_scheduled_host_transition',
321 './test/test_scheduled_host_transition.cpp',
322 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800323 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800324 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500325 cereal,
326 gmock,
327 gtest,
328 libgpiod,
329 phosphorlogging,
330 sdbusplus,
331 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800332 ],
333 implicit_include_directories: true,
334 include_directories: '../'
335 )
336 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600337
338 test(
339 'test_hypervisor_state',
340 executable('test_hypervisor_state',
341 './test/hypervisor_state.cpp',
342 'hypervisor_state_manager.cpp',
343 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500344 gtest,
345 phosphorlogging,
346 sdbusplus,
347 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600348 ],
349 implicit_include_directories: true,
350 include_directories: '../'
351 )
352 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600353endif