blob: 87fd97be2dbf51b786c6b35185f870d3ea449017 [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',
209 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500210 CLI11,
211 nlohmann_json,
212 phosphorlogging,
213 sdbusplus,
214 sdeventplus,
Andrew Geisslerf2454102019-12-06 15:14:08 -0600215 ],
216 implicit_include_directories: true,
217 install: true
218)
Andrew Geissler3f125632019-12-11 17:08:19 -0600219
Carol Wang71230ef2020-02-18 17:39:49 +0800220executable('phosphor-scheduled-host-transition',
221 'scheduled_host_transition_main.cpp',
222 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800223 'utils.cpp',
Carol Wang71230ef2020-02-18 17:39:49 +0800224 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500225 cereal,
226 libgpiod,
227 phosphorlogging,
228 sdbusplus,
229 sdeventplus,
Carol Wang71230ef2020-02-18 17:39:49 +0800230 ],
231 implicit_include_directories: true,
232 install: true
233)
234
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400235executable('phosphor-host-reset-recovery',
236 'host_reset_recovery.cpp',
237 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500238 phosphorlogging,
239 sdbusplus,
Andrew Geisslerba0163a2021-08-11 15:09:50 -0400240 ],
241 implicit_include_directories: true,
242 install: true
243)
244
Andrew Geisslerdfa75fc2019-12-11 17:26:42 -0600245install_data('obmcutil',
246 install_mode: 'rwxr-xr-x',
247 install_dir: get_option('bindir')
248)
249
Andrew Geissler179d38c2019-12-10 15:05:23 -0600250systemd = dependency('systemd')
Andrew Geissler429100a2021-09-09 12:50:24 -0500251systemd_system_unit_dir = systemd.get_variable(
252 pkgconfig : 'systemdsystemunitdir')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600253subdir('service_files')
Andrew Geisslerc1011572020-01-27 15:09:50 -0600254subdir('target_files')
Andrew Geissler179d38c2019-12-10 15:05:23 -0600255
Thang Tranba2241c2021-10-26 17:47:09 +0700256if build_host_gpios.enabled()
257 subdir('host_condition_gpio')
258endif
259
Andrew Geisslerefef9702019-12-10 16:56:57 -0600260datadir = join_paths(
261 get_option('sysconfdir'),
262 'phosphor-systemd-target-monitor'
263)
264subdir('data')
265
Andrew Geissler3f125632019-12-11 17:08:19 -0600266build_tests = get_option('tests')
267
268# If test coverage of source files within the root directory are wanted,
269# need to define and build the tests from here
270if not build_tests.disabled()
271gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800272gmock = dependency('gmock', disabler: true, required: build_tests)
Andrew Geissler3f125632019-12-11 17:08:19 -0600273 test(
274 'test_systemd_parser',
275 executable('test_systemd_parser',
276 './test/systemd_parser.cpp',
277 'systemd_target_parser.cpp',
278 dependencies: [
279 gtest,
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500280 nlohmann_json,
Andrew Geissler3f125632019-12-11 17:08:19 -0600281 ],
282 implicit_include_directories: true,
283 include_directories: '../'
284 )
285 )
286
287 test(
288 'test_systemd_signal',
289 executable('test_systemd_signal',
290 './test/systemd_signal.cpp',
291 'systemd_target_signal.cpp',
292 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500293 gtest,
294 nlohmann_json,
295 phosphorlogging,
296 sdbusplus,
297 sdeventplus,
Andrew Geissler3f125632019-12-11 17:08:19 -0600298 ],
299 implicit_include_directories: true,
300 include_directories: '../'
301 )
302 )
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800303
304 test(
305 'test_scheduled_host_transition',
306 executable('test_scheduled_host_transition',
307 './test/test_scheduled_host_transition.cpp',
308 'scheduled_host_transition.cpp',
Carol Wangdc059392020-03-13 17:39:17 +0800309 'utils.cpp',
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800310 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500311 cereal,
312 gmock,
313 gtest,
314 libgpiod,
315 phosphorlogging,
316 sdbusplus,
317 sdeventplus,
Carol Wang4ca6f3f2020-02-19 16:28:59 +0800318 ],
319 implicit_include_directories: true,
320 include_directories: '../'
321 )
322 )
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600323
324 test(
325 'test_hypervisor_state',
326 executable('test_hypervisor_state',
327 './test/hypervisor_state.cpp',
328 'hypervisor_state_manager.cpp',
329 dependencies: [
Patrick Williamsf8d5f3e2022-04-05 15:51:15 -0500330 gtest,
331 phosphorlogging,
332 sdbusplus,
333 sdeventplus,
Andrew Geisslerc74716e2021-02-09 15:11:10 -0600334 ],
335 implicit_include_directories: true,
336 include_directories: '../'
337 )
338 )
Andrew Geissler3f125632019-12-11 17:08:19 -0600339endif