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# Setting up config data 14conf_data = configuration_data() 15 16# The name of the callout's forward association 17conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout') 18conf_data.set_quoted('BOARD_SENSOR', get_option('board-sensor')) 19conf_data.set_quoted('SYSTEM_SENSOR', get_option('system-sensor')) 20conf_data.set('IPMI_SMS_ATN_ACK_TIMEOUT_SECS', get_option('ipmi-sms-atn-ack-timeout-secs')) 21 22# Soft Power off related. 23if not get_option('softoff').disabled() 24 conf_data.set_quoted('SOFTOFF_BUSNAME', get_option('softoff-busname')) 25 conf_data.set_quoted('SOFTOFF_OBJPATH', get_option('softoff-objpath')) 26 conf_data.set('IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS', get_option('ipmi-host-shutdown-complete-timeout-secs')) 27 conf_data.set_quoted('HOST_INBAND_REQUEST_DIR', get_option('host-inband-request-dir')) 28 conf_data.set_quoted('HOST_INBAND_REQUEST_FILE', get_option('host-inband-request-file')) 29endif 30 31conf_data.set_quoted('CONTROL_HOST_BUSNAME', get_option('control-host-busname')) 32conf_data.set_quoted('CONTROL_HOST_OBJ_MGR', get_option('control-host-obj-mgr')) 33conf_data.set_quoted('HOST_NAME', get_option('host-name')) 34conf_data.set_quoted('POWER_READING_SENSOR', get_option('power-reading-sensor')) 35conf_data.set_quoted('HOST_IPMI_LIB_PATH', get_option('host-ipmi-lib-path')) 36conf_data.set_quoted('FW_VER_REGEX', get_option('fw-ver-regex')) 37 38if get_option('shortname-remove-suffix').allowed() 39 conf_data.set_quoted('SHORTNAME_REMOVE_SUFFIX', '1') 40endif 41if get_option('shortname-replace-words').allowed() 42 conf_data.set_quoted('SHORTNAME_REPLACE_WORDS', '1') 43endif 44if get_option('open-power').allowed() 45 conf_data.set_quoted('OPEN_POWER_SUPPORT', '1') 46endif 47 48matches_map = get_option('matches-map') 49conf_data.set('MAJOR_MATCH_INDEX', matches_map[0]) 50conf_data.set('MINOR_MATCH_INDEX', matches_map[1]) 51conf_data.set('AUX_0_MATCH_INDEX', matches_map[2]) 52conf_data.set('AUX_1_MATCH_INDEX', matches_map[3]) 53conf_data.set('AUX_2_MATCH_INDEX', matches_map[4]) 54conf_data.set('AUX_3_MATCH_INDEX', matches_map[5]) 55 56conf_h = configure_file( 57 output: 'config.h', 58 configuration: conf_data) 59 60root = meson.current_source_dir() 61root_inc = include_directories('.', 'include') 62 63# Project Arguments 64cpp = meson.get_compiler('cpp') 65add_project_arguments( 66 cpp.get_supported_arguments([ 67 '-DBOOST_ERROR_CODE_HEADER_ONLY', 68 '-DBOOST_SYSTEM_NO_DEPRECATED', 69 '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING', 70 '-DBOOST_ASIO_DISABLE_THREADS', 71 '-DBOOST_ALL_NO_LIB', 72 ]), 73 language : 'cpp') 74 75if not get_option('get-dbus-active-software').disabled() 76 add_project_arguments( 77 cpp.get_supported_arguments([ 78 '-DGET_DBUS_ACTIVE_SOFTWARE', 79 ]), 80 language : 'cpp') 81endif 82 83feature_map = { 84 'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT', 85 'i2c-whitelist-check' : '-DENABLE_I2C_WHITELIST_CHECK', 86 'update-functional-on-fail' : '-DUPDATE_FUNCTIONAL_ON_FAIL', 87 'dynamic-sensors' : '-DFEATURE_DYNAMIC_SENSORS', 88 'dynamic-sensors-write' : '-DFEATURE_DYNAMIC_SENSORS_WRITE', 89 'entity-manager-decorators' : '-DUSING_ENTITY_MANAGER_DECORATORS', 90 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS', 91 'sensors-cache' : '-DFEATURE_SENSORS_CACHE', 92 'dynamic-storages-only' : '-DFEATURE_DYNAMIC_STORAGES_ONLY', 93} 94 95foreach option_key, option_value : feature_map 96 if(get_option(option_key).allowed()) 97 summary(option_key,option_value, section : 'Enabled Features') 98 add_project_arguments(option_value,language:'cpp') 99 endif 100endforeach 101 102add_project_arguments( 103 cpp.get_supported_arguments([ 104 '-Wno-psabi', 105 '-Wno-missing-field-initializers', 106 '-Wno-pedantic', 107 '-Wno-non-virtual-dtor' 108 ]), 109 language: 'cpp') 110 111# Dependencies 112 113boost = dependency( 114 'boost', 115 modules: [ 116 'coroutine', 117 ], 118 required : false, 119) 120 121if not boost.found() 122 cmake = import('cmake') 123 opt = cmake.subproject_options() 124 opt.add_cmake_defines({ 125 'BOOST_INCLUDE_LIBRARIES': 'asio;bimap;callable_traits;context;coroutine;interprocess;multiprecision;process', 126 'CMAKE_POSITION_INDEPENDENT_CODE': true 127 }) 128 boost_cmake = cmake.subproject('boost', required: true, options: opt) 129 boost_asio = boost_cmake.dependency('boost_asio').as_system() 130 boost_bimap = boost_cmake.dependency('boost_bimap').as_system() 131 boost_callable_traits = boost_cmake.dependency('boost_callable_traits').as_system() 132 boost_context = boost_cmake.dependency('boost_context').as_system() 133 boost_coroutine = boost_cmake.dependency('boost_coroutine').as_system() 134 boost_interprocess = boost_cmake.dependency('boost_interprocess').as_system() 135 boost_multiprecision = boost_cmake.dependency('boost_multiprecision').as_system() 136 boost_process = boost_cmake.dependency('boost_process').as_system() 137 boost = [boost_asio, boost_bimap, boost_callable_traits, boost_context, boost_coroutine, boost_interprocess, boost_multiprecision, boost_process] 138endif 139 140phosphor_logging_dep = dependency('phosphor-logging') 141phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 142sdeventplus_dep = dependency('sdeventplus') 143systemd = dependency('systemd') 144crypto = dependency('libcrypto', version : '>=1.0.2g') 145pam = cpp.find_library('pam', required: true) 146sdbusplus_dep = dependency('sdbusplus') 147stdplus_dep = dependency('stdplus') 148 149nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 150 151generated_src = [] 152 153# Subfolders 154subdir('libipmid') 155subdir('include') 156subdir('user_channel') 157subdir('scripts') 158 159if not get_option('softoff').disabled() 160 subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff') 161 subdir('softoff') 162endif 163 164# whitelist 165if not get_option('ipmi-whitelist').disabled() 166 generate_whitelist_script = files('generate_whitelist_create.sh') 167 168 whitelist_conf = get_option('whitelist-conf') 169 ipmiwhitelist = run_command( \ 170 'bash', \ 171 generate_whitelist_script, \ 172 whitelist_conf) 173 174 whitelist_pre = declare_dependency( 175 include_directories: root_inc, 176 dependencies: [ 177 crypto, 178 ipmid_dep, 179 phosphor_dbus_interfaces_dep, 180 phosphor_logging_dep, 181 sdbusplus_dep, 182 ], 183 ) 184 185 whitelist_lib = library( 186 'whitelist', 187 'whitelist-filter.cpp', 188 'ipmiwhitelist.cpp', 189 implicit_include_directories: false, 190 dependencies: whitelist_pre, 191 version: meson.project_version(), 192 override_options: ['b_lundef=false'], 193 install: true, 194 install_dir: get_option('libdir') / 'ipmid-providers') 195endif 196 197# libsysintfcmds 198sysintfcmds_pre = declare_dependency( 199 include_directories: root_inc, 200 dependencies: [ 201 channellayer_dep, 202 crypto, 203 nlohmann_json_dep, 204 phosphor_dbus_interfaces_dep, 205 phosphor_logging_dep, 206 sdbusplus_dep, 207 ipmid_dep, 208 ]) 209 210sysintfcmds_lib = library( 211 'sysintfcmds', 212 'systemintfcmds.cpp', 213 'host-interface.cpp', 214 implicit_include_directories: false, 215 dependencies: sysintfcmds_pre, 216 version: meson.project_version(), 217 override_options: ['b_lundef=false'], 218 install: true, 219 install_dir: get_option('libdir') / 'ipmid-providers') 220 221# ipmid 222ipmid_pre = [ 223 sdbusplus_dep, 224 stdplus_dep, 225 phosphor_logging_dep, 226 phosphor_dbus_interfaces_dep, 227 boost, 228 crypto, 229 ipmid_dep, 230 channellayer_dep, 231] 232 233transportoem_src = [] 234if not get_option('transport-oem').disabled() 235 transportoem_src = ['transporthandler_oem.cpp'] 236endif 237 238storage_cmds_src = [] 239if get_option('dynamic-sensors').disabled() and not get_option('dynamic-storages-only').disabled() 240 storage_cmds_src = ['dbus-sdr/storagecommands.cpp', 'dbus-sdr/sdrutils.cpp'] 241endif 242 243openpower_cmds_src = [] 244if get_option('open-power').allowed() 245 openpower_cmds_src = [ 'storageaddsel.cpp' ] 246endif 247 248libipmi20_src = [ 249 'app/channel.cpp', 250 'app/watchdog.cpp', 251 'app/watchdog_service.cpp', 252 'apphandler.cpp', 253 'sys_info_param.cpp', 254 'sensorhandler.cpp', 255 'storagehandler.cpp', 256 'chassishandler.cpp', 257 'dcmihandler.cpp', 258 'ipmisensor.cpp', 259 'transporthandler.cpp', 260 'globalhandler.cpp', 261 'groupext.cpp', 262 'selutility.cpp', 263 'ipmi_fru_info_area.cpp', 264 'read_fru_data.cpp', 265 'sensordatahandler.cpp', 266 'user_channel/channelcommands.cpp', 267 generated_src, 268 transportoem_src, 269 storage_cmds_src, 270 openpower_cmds_src, 271 conf_h, 272] 273 274ipmi20_lib = library( 275 'ipmi20', 276 libipmi20_src, 277 dependencies: [ipmid_pre, nlohmann_json_dep], 278 include_directories: root_inc, 279 install: true, 280 install_dir: get_option('libdir') / 'ipmid-providers', 281 version: meson.project_version(), 282 override_options: ['b_lundef=false']) 283 284libipmi20_dep = declare_dependency( 285 dependencies: ipmid_pre, 286 include_directories: root_inc, 287 link_with: ipmi20_lib) 288 289# ipmid binary 290executable( 291 'ipmid', 292 'ipmid-new.cpp', 293 'host-cmd-manager.cpp', 294 'settings.cpp', 295 implicit_include_directories: false, 296 dependencies: [libipmi20_dep], 297 include_directories: root_inc, 298 export_dynamic: true, 299 install: true, 300 install_dir: get_option('bindir')) 301 302# Dynamic Sensor Stack 303subdir('dbus-sdr') 304 305if not get_option('dynamic-sensors').disabled() or not get_option('tests').disabled() 306 library( 307 'dynamiccmds', 308 dbus_sdr_src, 309 implicit_include_directories: false, 310 dependencies: dbus_sdr_pre, 311 version: meson.project_version(), 312 override_options: ['b_lundef=false'], 313 install: true, 314 install_dir: get_option('libdir') / 'ipmid-providers') 315endif 316 317if not get_option('tests').disabled() 318 subdir('test') 319endif 320 321install_subdir( 322 'user_channel', 323 install_dir: get_option('includedir'), 324 strip_directory: false, 325 exclude_files: '*.cpp') 326