1project( 2 '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) 13 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')) 21conf_data.set( 22 'IPMI_SMS_ATN_ACK_TIMEOUT_SECS', 23 get_option('ipmi-sms-atn-ack-timeout-secs'), 24) 25 26# Soft Power off related. 27if get_option('softoff').allowed() 28 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 ) 42endif 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')) 49conf_data.set_quoted('FW_VER_REGEX', get_option('fw-ver-regex')) 50 51if get_option('shortname-remove-suffix').allowed() 52 conf_data.set_quoted('SHORTNAME_REMOVE_SUFFIX', '1') 53endif 54if get_option('shortname-replace-words').allowed() 55 conf_data.set_quoted('SHORTNAME_REPLACE_WORDS', '1') 56endif 57if get_option('open-power').allowed() 58 conf_data.set_quoted('OPEN_POWER_SUPPORT', '1') 59endif 60 61matches_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 69conf_h = configure_file(output: 'config.h', configuration: conf_data) 70 71root = meson.current_source_dir() 72root_inc = include_directories('.', 'include') 73 74# Project Arguments 75cpp = meson.get_compiler('cpp') 76add_project_arguments( 77 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) 88 89if get_option('get-dbus-active-software').allowed() 90 add_project_arguments( 91 cpp.get_supported_arguments(['-DGET_DBUS_ACTIVE_SOFTWARE']), 92 language: 'cpp', 93 ) 94endif 95 96feature_map = { 97 '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', 106 'arm-sbmr' : '-DARM_SBMR_SUPPORT', 107} 108 109foreach option_key, option_value : feature_map 110 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 114endforeach 115 116add_project_arguments( 117 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) 127 128# Dependencies 129 130boost = dependency('boost', modules: ['context', 'coroutine'], required: false) 131 132if not boost.found() 133 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 ] 160endif 161 162phosphor_logging_dep = dependency('phosphor-logging') 163phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 164sdeventplus_dep = dependency('sdeventplus') 165libsystemd_dep = dependency('libsystemd') 166crypto = dependency('libcrypto', version: '>=1.0.2g') 167pam = cpp.find_library('pam', required: true) 168sdbusplus_dep = dependency('sdbusplus') 169stdplus_dep = dependency('stdplus') 170 171nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 172 173generated_src = [] 174 175# Subfolders 176subdir('libipmid') 177subdir('include') 178subdir('user_channel') 179subdir('scripts') 180 181if get_option('softoff').allowed() 182 subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff') 183 subdir('softoff') 184endif 185 186# whitelist 187if get_option('ipmi-whitelist').allowed() 188 generate_whitelist_script = files('generate_whitelist_create.sh') 189 190 whitelist_conf = get_option('whitelist-conf') 191 ipmiwhitelist = run_command( \ 192 'bash', \ 193 generate_whitelist_script, \ 194 whitelist_conf, 195 check: true, 196 ) 197 198 whitelist_pre = declare_dependency( 199 include_directories: root_inc, 200 dependencies: [ 201 crypto, 202 ipmid_dep, 203 phosphor_dbus_interfaces_dep, 204 phosphor_logging_dep, 205 sdbusplus_dep, 206 ], 207 ) 208 209 whitelist_lib = library( 210 'whitelist', 211 'whitelist-filter.cpp', 212 'ipmiwhitelist.cpp', 213 implicit_include_directories: false, 214 dependencies: whitelist_pre, 215 version: meson.project_version(), 216 override_options: ['b_lundef=false'], 217 install: true, 218 install_dir: get_option('libdir') / 'ipmid-providers', 219 ) 220endif 221 222# libsysintfcmds 223sysintfcmds_pre = declare_dependency( 224 include_directories: root_inc, 225 dependencies: [ 226 channellayer_dep, 227 crypto, 228 nlohmann_json_dep, 229 phosphor_dbus_interfaces_dep, 230 phosphor_logging_dep, 231 sdbusplus_dep, 232 ipmid_dep, 233 ], 234) 235 236sysintfcmds_lib = library( 237 'sysintfcmds', 238 'systemintfcmds.cpp', 239 'host-interface.cpp', 240 implicit_include_directories: false, 241 dependencies: sysintfcmds_pre, 242 version: meson.project_version(), 243 override_options: ['b_lundef=false'], 244 install: true, 245 install_dir: get_option('libdir') / 'ipmid-providers', 246) 247 248# ipmid 249ipmid_pre = [ 250 sdbusplus_dep, 251 stdplus_dep, 252 phosphor_logging_dep, 253 phosphor_dbus_interfaces_dep, 254 boost, 255 crypto, 256 ipmid_dep, 257 channellayer_dep, 258] 259 260transportoem_src = [] 261if get_option('transport-oem').allowed() 262 transportoem_src = ['transporthandler_oem.cpp'] 263endif 264 265storage_cmds_src = [] 266if get_option('dynamic-sensors').disabled() and not get_option( 267 'dynamic-storages-only', 268).disabled() 269 storage_cmds_src = ['dbus-sdr/storagecommands.cpp', 'dbus-sdr/sdrutils.cpp'] 270endif 271 272openpower_cmds_src = [] 273if get_option('open-power').allowed() 274 openpower_cmds_src = ['storageaddsel.cpp'] 275endif 276 277arm_sbmr_cmds_src = [] 278if get_option('arm-sbmr').allowed() 279 arm_sbmr_cmds_src = ['sbmrhandler.cpp'] 280endif 281 282libipmi20_src = [ 283 'app/channel.cpp', 284 'app/watchdog.cpp', 285 'app/watchdog_service.cpp', 286 'apphandler.cpp', 287 'sys_info_param.cpp', 288 'sensorhandler.cpp', 289 'storagehandler.cpp', 290 'chassishandler.cpp', 291 'dcmihandler.cpp', 292 'ipmisensor.cpp', 293 'transporthandler.cpp', 294 'globalhandler.cpp', 295 'groupext.cpp', 296 'selutility.cpp', 297 'ipmi_fru_info_area.cpp', 298 'read_fru_data.cpp', 299 'sensordatahandler.cpp', 300 'user_channel/channelcommands.cpp', 301 generated_src, 302 transportoem_src, 303 storage_cmds_src, 304 openpower_cmds_src, 305 arm_sbmr_cmds_src, 306 conf_h, 307] 308 309ipmi20_lib = library( 310 'ipmi20', 311 libipmi20_src, 312 dependencies: [ipmid_pre, nlohmann_json_dep], 313 include_directories: root_inc, 314 install: true, 315 install_dir: get_option('libdir') / 'ipmid-providers', 316 version: meson.project_version(), 317 override_options: ['b_lundef=false'], 318) 319 320libipmi20_dep = declare_dependency( 321 dependencies: ipmid_pre, 322 include_directories: root_inc, 323 link_with: ipmi20_lib, 324) 325 326# ipmid binary 327executable( 328 'ipmid', 329 'ipmid-new.cpp', 330 'host-cmd-manager.cpp', 331 'settings.cpp', 332 implicit_include_directories: false, 333 dependencies: [libipmi20_dep], 334 include_directories: root_inc, 335 export_dynamic: true, 336 install: true, 337 install_dir: get_option('bindir'), 338) 339 340# Dynamic Sensor Stack 341subdir('dbus-sdr') 342 343if get_option('dynamic-sensors').allowed() or get_option('tests').allowed() 344 library( 345 'dynamiccmds', 346 dbus_sdr_src, 347 implicit_include_directories: false, 348 dependencies: dbus_sdr_pre, 349 version: meson.project_version(), 350 override_options: ['b_lundef=false'], 351 install: true, 352 install_dir: get_option('libdir') / 'ipmid-providers', 353 ) 354endif 355 356if get_option('tests').allowed() 357 subdir('test') 358 subdir('transport/serialbridge') 359endif 360 361install_subdir( 362 'user_channel', 363 install_dir: get_option('includedir'), 364 strip_directory: false, 365 exclude_files: '*.cpp', 366) 367 368# HW Transport 369subdir('transport') 370 371# OEM provider libraries 372subdir('oem') 373