blob: a492697041c293ee76adf54d98034b4f07586742 [file] [log] [blame]
Willy Tuc710b972021-08-11 16:33:43 -07001project(
Patrick Williams62ce1592025-02-03 14:12:56 -05002 'phosphor-host-ipmid',
3 'cpp',
4 version: '0.1',
5 meson_version: '>=1.1.1',
6 default_options: [
7 'werror=true',
8 'warning_level=3',
9 'cpp_std=c++23',
10 'b_lto=true',
11 ],
12)
Willy Tuc710b972021-08-11 16:33:43 -070013
14# Setting up config data
15conf_data = configuration_data()
16
17# The name of the callout's forward association
18conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout')
19conf_data.set_quoted('BOARD_SENSOR', get_option('board-sensor'))
20conf_data.set_quoted('SYSTEM_SENSOR', get_option('system-sensor'))
Patrick Williams62ce1592025-02-03 14:12:56 -050021conf_data.set(
22 'IPMI_SMS_ATN_ACK_TIMEOUT_SECS',
23 get_option('ipmi-sms-atn-ack-timeout-secs'),
24)
Willy Tuc710b972021-08-11 16:33:43 -070025
26# Soft Power off related.
Patrick Williamsed7dbef2025-02-07 10:54:37 -050027if get_option('softoff').allowed()
Patrick Williams62ce1592025-02-03 14:12:56 -050028 conf_data.set_quoted('SOFTOFF_BUSNAME', get_option('softoff-busname'))
29 conf_data.set_quoted('SOFTOFF_OBJPATH', get_option('softoff-objpath'))
30 conf_data.set(
31 'IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS',
32 get_option('ipmi-host-shutdown-complete-timeout-secs'),
33 )
34 conf_data.set_quoted(
35 'HOST_INBAND_REQUEST_DIR',
36 get_option('host-inband-request-dir'),
37 )
38 conf_data.set_quoted(
39 'HOST_INBAND_REQUEST_FILE',
40 get_option('host-inband-request-file'),
41 )
Willy Tuc710b972021-08-11 16:33:43 -070042endif
43
44conf_data.set_quoted('CONTROL_HOST_BUSNAME', get_option('control-host-busname'))
45conf_data.set_quoted('CONTROL_HOST_OBJ_MGR', get_option('control-host-obj-mgr'))
46conf_data.set_quoted('HOST_NAME', get_option('host-name'))
47conf_data.set_quoted('POWER_READING_SENSOR', get_option('power-reading-sensor'))
48conf_data.set_quoted('HOST_IPMI_LIB_PATH', get_option('host-ipmi-lib-path'))
Potin Lai5d214202023-01-16 18:11:49 +080049conf_data.set_quoted('FW_VER_REGEX', get_option('fw-ver-regex'))
Willy Tuc710b972021-08-11 16:33:43 -070050
Patrick Williams833b7062023-11-29 06:43:54 -060051if get_option('shortname-remove-suffix').allowed()
Patrick Williams62ce1592025-02-03 14:12:56 -050052 conf_data.set_quoted('SHORTNAME_REMOVE_SUFFIX', '1')
Alexander Hansenc2c26f92023-07-17 09:38:43 +020053endif
Patrick Williams833b7062023-11-29 06:43:54 -060054if get_option('shortname-replace-words').allowed()
Patrick Williams62ce1592025-02-03 14:12:56 -050055 conf_data.set_quoted('SHORTNAME_REPLACE_WORDS', '1')
Alexander Hansenc2c26f92023-07-17 09:38:43 +020056endif
Patrick Williams768730d2023-09-06 16:27:20 -050057if get_option('open-power').allowed()
Patrick Williams62ce1592025-02-03 14:12:56 -050058 conf_data.set_quoted('OPEN_POWER_SUPPORT', '1')
Patrick Williams768730d2023-09-06 16:27:20 -050059endif
Alexander Hansenc2c26f92023-07-17 09:38:43 +020060
Potin Laic7c55922023-02-16 10:33:55 +080061matches_map = get_option('matches-map')
62conf_data.set('MAJOR_MATCH_INDEX', matches_map[0])
63conf_data.set('MINOR_MATCH_INDEX', matches_map[1])
64conf_data.set('AUX_0_MATCH_INDEX', matches_map[2])
65conf_data.set('AUX_1_MATCH_INDEX', matches_map[3])
66conf_data.set('AUX_2_MATCH_INDEX', matches_map[4])
67conf_data.set('AUX_3_MATCH_INDEX', matches_map[5])
68
Patrick Williams62ce1592025-02-03 14:12:56 -050069conf_h = configure_file(output: 'config.h', configuration: conf_data)
Willy Tuc710b972021-08-11 16:33:43 -070070
71root = meson.current_source_dir()
72root_inc = include_directories('.', 'include')
73
74# Project Arguments
75cpp = meson.get_compiler('cpp')
76add_project_arguments(
Patrick Williams62ce1592025-02-03 14:12:56 -050077 cpp.get_supported_arguments(
78 [
79 '-DBOOST_ERROR_CODE_HEADER_ONLY',
80 '-DBOOST_SYSTEM_NO_DEPRECATED',
81 '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
82 '-DBOOST_ASIO_DISABLE_THREADS',
83 '-DBOOST_ALL_NO_LIB',
84 ],
85 ),
86 language: 'cpp',
87)
Willy Tuc710b972021-08-11 16:33:43 -070088
Patrick Williamsed7dbef2025-02-07 10:54:37 -050089if get_option('get-dbus-active-software').allowed()
Patrick Williams62ce1592025-02-03 14:12:56 -050090 add_project_arguments(
91 cpp.get_supported_arguments(['-DGET_DBUS_ACTIVE_SOFTWARE']),
92 language: 'cpp',
93 )
Willy Tub78184e2022-10-27 22:57:38 +000094endif
95
Willy Tuc710b972021-08-11 16:33:43 -070096feature_map = {
Patrick Williams62ce1592025-02-03 14:12:56 -050097 'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT',
98 'i2c-whitelist-check' : '-DENABLE_I2C_WHITELIST_CHECK',
99 'update-functional-on-fail' : '-DUPDATE_FUNCTIONAL_ON_FAIL',
100 'dynamic-sensors' : '-DFEATURE_DYNAMIC_SENSORS',
101 'dynamic-sensors-write' : '-DFEATURE_DYNAMIC_SENSORS_WRITE',
102 'entity-manager-decorators' : '-DUSING_ENTITY_MANAGER_DECORATORS',
103 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS',
104 'sensors-cache' : '-DFEATURE_SENSORS_CACHE',
105 'dynamic-storages-only' : '-DFEATURE_DYNAMIC_STORAGES_ONLY',
John Chung0a3f40b2025-01-22 18:07:52 -0600106 'arm-sbmr' : '-DARM_SBMR_SUPPORT',
Willy Tuc710b972021-08-11 16:33:43 -0700107}
108
109foreach option_key, option_value : feature_map
Patrick Williams62ce1592025-02-03 14:12:56 -0500110 if (get_option(option_key).allowed())
111 summary(option_key, option_value, section: 'Enabled Features')
112 add_project_arguments(option_value, language: 'cpp')
113 endif
Willy Tuc710b972021-08-11 16:33:43 -0700114endforeach
115
116add_project_arguments(
Patrick Williams62ce1592025-02-03 14:12:56 -0500117 cpp.get_supported_arguments(
118 [
119 '-Wno-psabi',
120 '-Wno-missing-field-initializers',
121 '-Wno-pedantic',
122 '-Wno-non-virtual-dtor',
123 ],
124 ),
125 language: 'cpp',
126)
Willy Tuc710b972021-08-11 16:33:43 -0700127
128# Dependencies
Konstantin Aladysheve11895f2024-04-04 12:35:33 +0300129
Ed Tanous98605052025-02-13 16:57:13 -0800130boost = dependency('boost', modules: ['context', 'coroutine'], required: false)
Konstantin Aladysheve11895f2024-04-04 12:35:33 +0300131
132if not boost.found()
Patrick Williams62ce1592025-02-03 14:12:56 -0500133 cmake = import('cmake')
134 opt = cmake.subproject_options()
135 opt.add_cmake_defines(
136 {
137 'BOOST_INCLUDE_LIBRARIES': 'asio;bimap;callable_traits;context;coroutine;interprocess;multiprecision;process',
138 'CMAKE_POSITION_INDEPENDENT_CODE': true,
139 },
140 )
141 boost_cmake = cmake.subproject('boost', required: true, options: opt)
142 boost_asio = boost_cmake.dependency('boost_asio').as_system()
143 boost_bimap = boost_cmake.dependency('boost_bimap').as_system()
144 boost_callable_traits = boost_cmake.dependency('boost_callable_traits').as_system()
145 boost_context = boost_cmake.dependency('boost_context').as_system()
146 boost_coroutine = boost_cmake.dependency('boost_coroutine').as_system()
147 boost_interprocess = boost_cmake.dependency('boost_interprocess').as_system()
148 boost_multiprecision = boost_cmake.dependency('boost_multiprecision').as_system()
149 boost_process = boost_cmake.dependency('boost_process').as_system()
150 boost = [
151 boost_asio,
152 boost_bimap,
153 boost_callable_traits,
154 boost_context,
155 boost_coroutine,
156 boost_interprocess,
157 boost_multiprecision,
158 boost_process,
159 ]
Konstantin Aladysheve11895f2024-04-04 12:35:33 +0300160endif
161
Willy Tuc710b972021-08-11 16:33:43 -0700162phosphor_logging_dep = dependency('phosphor-logging')
163phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
164sdeventplus_dep = dependency('sdeventplus')
Patrick Williamsf62ad6f2024-09-03 16:15:14 -0400165libsystemd_dep = dependency('libsystemd')
Patrick Williams62ce1592025-02-03 14:12:56 -0500166crypto = dependency('libcrypto', version: '>=1.0.2g')
Willy Tuc710b972021-08-11 16:33:43 -0700167pam = cpp.find_library('pam', required: true)
Patrick Williams422385d2022-06-16 11:47:40 -0500168sdbusplus_dep = dependency('sdbusplus')
William A. Kennington III7a3831b2023-06-21 01:10:49 -0700169stdplus_dep = dependency('stdplus')
Willy Tuc710b972021-08-11 16:33:43 -0700170
Patrick Williamse5fa6592023-12-07 14:47:50 -0600171nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500172
Patrick Williamsb69b2062022-07-25 09:40:49 -0500173generated_src = []
174
Willy Tuc710b972021-08-11 16:33:43 -0700175# Subfolders
176subdir('libipmid')
Willy Tuc710b972021-08-11 16:33:43 -0700177subdir('include')
178subdir('user_channel')
179subdir('scripts')
180
Patrick Williamsed7dbef2025-02-07 10:54:37 -0500181if get_option('softoff').allowed()
Patrick Williams62ce1592025-02-03 14:12:56 -0500182 subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff')
183 subdir('softoff')
Willy Tuc710b972021-08-11 16:33:43 -0700184endif
185
186# whitelist
Patrick Williamsed7dbef2025-02-07 10:54:37 -0500187if get_option('ipmi-whitelist').allowed()
Patrick Williams62ce1592025-02-03 14:12:56 -0500188 generate_whitelist_script = files('generate_whitelist_create.sh')
Willy Tuc710b972021-08-11 16:33:43 -0700189
Patrick Williams62ce1592025-02-03 14:12:56 -0500190 whitelist_conf = get_option('whitelist-conf')
191 ipmiwhitelist = run_command( \
192 'bash', \
193 generate_whitelist_script, \
194 whitelist_conf,
195 )
Willy Tuc710b972021-08-11 16:33:43 -0700196
Patrick Williams62ce1592025-02-03 14:12:56 -0500197 whitelist_pre = declare_dependency(
198 include_directories: root_inc,
199 dependencies: [
200 crypto,
201 ipmid_dep,
202 phosphor_dbus_interfaces_dep,
203 phosphor_logging_dep,
204 sdbusplus_dep,
205 ],
206 )
Willy Tuc710b972021-08-11 16:33:43 -0700207
Patrick Williams62ce1592025-02-03 14:12:56 -0500208 whitelist_lib = library(
209 'whitelist',
210 'whitelist-filter.cpp',
211 'ipmiwhitelist.cpp',
212 implicit_include_directories: false,
213 dependencies: whitelist_pre,
214 version: meson.project_version(),
215 override_options: ['b_lundef=false'],
216 install: true,
217 install_dir: get_option('libdir') / 'ipmid-providers',
218 )
Willy Tuc710b972021-08-11 16:33:43 -0700219endif
220
Willy Tuc710b972021-08-11 16:33:43 -0700221# libsysintfcmds
222sysintfcmds_pre = declare_dependency(
Patrick Williams62ce1592025-02-03 14:12:56 -0500223 include_directories: root_inc,
224 dependencies: [
225 channellayer_dep,
226 crypto,
227 nlohmann_json_dep,
228 phosphor_dbus_interfaces_dep,
229 phosphor_logging_dep,
230 sdbusplus_dep,
231 ipmid_dep,
232 ],
233)
Willy Tuc710b972021-08-11 16:33:43 -0700234
Willy Tuba9bbb62022-06-01 03:41:15 -0700235sysintfcmds_lib = library(
Patrick Williams62ce1592025-02-03 14:12:56 -0500236 'sysintfcmds',
237 'systemintfcmds.cpp',
238 'host-interface.cpp',
239 implicit_include_directories: false,
240 dependencies: sysintfcmds_pre,
241 version: meson.project_version(),
242 override_options: ['b_lundef=false'],
243 install: true,
244 install_dir: get_option('libdir') / 'ipmid-providers',
245)
Willy Tuc710b972021-08-11 16:33:43 -0700246
Willy Tuc710b972021-08-11 16:33:43 -0700247# ipmid
248ipmid_pre = [
Patrick Williams62ce1592025-02-03 14:12:56 -0500249 sdbusplus_dep,
250 stdplus_dep,
251 phosphor_logging_dep,
252 phosphor_dbus_interfaces_dep,
253 boost,
254 crypto,
255 ipmid_dep,
256 channellayer_dep,
Willy Tuc710b972021-08-11 16:33:43 -0700257]
258
Willy Tuc710b972021-08-11 16:33:43 -0700259transportoem_src = []
Patrick Williamsed7dbef2025-02-07 10:54:37 -0500260if get_option('transport-oem').allowed()
Patrick Williams62ce1592025-02-03 14:12:56 -0500261 transportoem_src = ['transporthandler_oem.cpp']
Willy Tuc710b972021-08-11 16:33:43 -0700262endif
263
Thang Tran292c9172023-06-26 10:03:04 +0700264storage_cmds_src = []
Patrick Williams62ce1592025-02-03 14:12:56 -0500265if get_option('dynamic-sensors').disabled() and not get_option(
266 'dynamic-storages-only',
267).disabled()
268 storage_cmds_src = ['dbus-sdr/storagecommands.cpp', 'dbus-sdr/sdrutils.cpp']
Thang Tran292c9172023-06-26 10:03:04 +0700269endif
270
Patrick Williams768730d2023-09-06 16:27:20 -0500271openpower_cmds_src = []
272if get_option('open-power').allowed()
Patrick Williams62ce1592025-02-03 14:12:56 -0500273 openpower_cmds_src = ['storageaddsel.cpp']
Patrick Williams768730d2023-09-06 16:27:20 -0500274endif
275
John Chung0a3f40b2025-01-22 18:07:52 -0600276arm_sbmr_cmds_src = []
277if get_option('arm-sbmr').allowed()
278 arm_sbmr_cmds_src = ['sbmrhandler.cpp']
279endif
280
Willy Tuc710b972021-08-11 16:33:43 -0700281libipmi20_src = [
Patrick Williams62ce1592025-02-03 14:12:56 -0500282 'app/channel.cpp',
283 'app/watchdog.cpp',
284 'app/watchdog_service.cpp',
285 'apphandler.cpp',
286 'sys_info_param.cpp',
287 'sensorhandler.cpp',
288 'storagehandler.cpp',
289 'chassishandler.cpp',
290 'dcmihandler.cpp',
291 'ipmisensor.cpp',
292 'transporthandler.cpp',
293 'globalhandler.cpp',
294 'groupext.cpp',
295 'selutility.cpp',
296 'ipmi_fru_info_area.cpp',
297 'read_fru_data.cpp',
298 'sensordatahandler.cpp',
299 'user_channel/channelcommands.cpp',
300 generated_src,
301 transportoem_src,
302 storage_cmds_src,
303 openpower_cmds_src,
John Chung0a3f40b2025-01-22 18:07:52 -0600304 arm_sbmr_cmds_src,
Patrick Williams62ce1592025-02-03 14:12:56 -0500305 conf_h,
Willy Tuc710b972021-08-11 16:33:43 -0700306]
307
308ipmi20_lib = library(
Patrick Williams62ce1592025-02-03 14:12:56 -0500309 'ipmi20',
310 libipmi20_src,
311 dependencies: [ipmid_pre, nlohmann_json_dep],
312 include_directories: root_inc,
313 install: true,
314 install_dir: get_option('libdir') / 'ipmid-providers',
315 version: meson.project_version(),
316 override_options: ['b_lundef=false'],
317)
Willy Tuc710b972021-08-11 16:33:43 -0700318
319libipmi20_dep = declare_dependency(
Patrick Williams62ce1592025-02-03 14:12:56 -0500320 dependencies: ipmid_pre,
321 include_directories: root_inc,
322 link_with: ipmi20_lib,
323)
Willy Tuc710b972021-08-11 16:33:43 -0700324
325# ipmid binary
326executable(
Patrick Williams62ce1592025-02-03 14:12:56 -0500327 'ipmid',
328 'ipmid-new.cpp',
329 'host-cmd-manager.cpp',
330 'settings.cpp',
331 implicit_include_directories: false,
332 dependencies: [libipmi20_dep],
333 include_directories: root_inc,
334 export_dynamic: true,
335 install: true,
336 install_dir: get_option('bindir'),
337)
Willy Tuc710b972021-08-11 16:33:43 -0700338
339# Dynamic Sensor Stack
340subdir('dbus-sdr')
341
Patrick Williamsed7dbef2025-02-07 10:54:37 -0500342if get_option('dynamic-sensors').disabled() or not get_option('tests').allowed()
Patrick Williams62ce1592025-02-03 14:12:56 -0500343 library(
344 'dynamiccmds',
345 dbus_sdr_src,
346 implicit_include_directories: false,
347 dependencies: dbus_sdr_pre,
348 version: meson.project_version(),
349 override_options: ['b_lundef=false'],
350 install: true,
351 install_dir: get_option('libdir') / 'ipmid-providers',
352 )
Willy Tu6eab4202022-06-09 11:34:52 -0700353endif
Willy Tuba9bbb62022-06-01 03:41:15 -0700354
Patrick Williamsed7dbef2025-02-07 10:54:37 -0500355if get_option('tests').allowed()
Patrick Williams62ce1592025-02-03 14:12:56 -0500356 subdir('test')
John Chunge2fae4b2024-11-13 18:10:31 -0600357 subdir('transport/serialbridge')
Willy Tuc710b972021-08-11 16:33:43 -0700358endif
359
360install_subdir(
Patrick Williams62ce1592025-02-03 14:12:56 -0500361 'user_channel',
362 install_dir: get_option('includedir'),
363 strip_directory: false,
364 exclude_files: '*.cpp',
365)
John Chunge2fae4b2024-11-13 18:10:31 -0600366
367# HW Transport
368subdir('transport')