Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 1 | project( |
George Liu | 1a2e150 | 2022-07-08 12:20:19 +0800 | [diff] [blame] | 2 | 'phosphor-host-ipmid', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 3 | 'cpp', |
| 4 | version: '0.1', |
| 5 | meson_version: '>=0.57.0', |
| 6 | default_options: [ |
| 7 | 'werror=true', |
| 8 | 'warning_level=3', |
| 9 | 'cpp_std=c++20', |
| 10 | ]) |
| 11 | |
| 12 | # Setting up config data |
| 13 | conf_data = configuration_data() |
| 14 | |
| 15 | # The name of the callout's forward association |
| 16 | conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout') |
| 17 | conf_data.set_quoted('BOARD_SENSOR', get_option('board-sensor')) |
| 18 | conf_data.set_quoted('SYSTEM_SENSOR', get_option('system-sensor')) |
| 19 | |
| 20 | # Soft Power off related. |
| 21 | if not get_option('softoff').disabled() |
| 22 | conf_data.set_quoted('SOFTOFF_BUSNAME', get_option('softoff-busname')) |
| 23 | conf_data.set_quoted('SOFTOFF_OBJPATH', get_option('softoff-objpath')) |
| 24 | conf_data.set('IPMI_SMS_ATN_ACK_TIMEOUT_SECS', get_option('ipmi-sms-atn-ack-timeout-secs')) |
| 25 | conf_data.set('IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS', get_option('ipmi-host-shutdown-complete-timeout-secs')) |
| 26 | conf_data.set_quoted('HOST_INBAND_REQUEST_DIR', get_option('host-inband-request-dir')) |
| 27 | conf_data.set_quoted('HOST_INBAND_REQUEST_FILE', get_option('host-inband-request-file')) |
| 28 | endif |
| 29 | |
| 30 | conf_data.set_quoted('CONTROL_HOST_BUSNAME', get_option('control-host-busname')) |
| 31 | conf_data.set_quoted('CONTROL_HOST_OBJ_MGR', get_option('control-host-obj-mgr')) |
| 32 | conf_data.set_quoted('HOST_NAME', get_option('host-name')) |
| 33 | conf_data.set_quoted('POWER_READING_SENSOR', get_option('power-reading-sensor')) |
| 34 | conf_data.set_quoted('HOST_IPMI_LIB_PATH', get_option('host-ipmi-lib-path')) |
Potin Lai | 5d21420 | 2023-01-16 18:11:49 +0800 | [diff] [blame] | 35 | conf_data.set_quoted('FW_VER_REGEX', get_option('fw-ver-regex')) |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 36 | |
Potin Lai | c7c5592 | 2023-02-16 10:33:55 +0800 | [diff] [blame] | 37 | matches_map = get_option('matches-map') |
| 38 | conf_data.set('MAJOR_MATCH_INDEX', matches_map[0]) |
| 39 | conf_data.set('MINOR_MATCH_INDEX', matches_map[1]) |
| 40 | conf_data.set('AUX_0_MATCH_INDEX', matches_map[2]) |
| 41 | conf_data.set('AUX_1_MATCH_INDEX', matches_map[3]) |
| 42 | conf_data.set('AUX_2_MATCH_INDEX', matches_map[4]) |
| 43 | conf_data.set('AUX_3_MATCH_INDEX', matches_map[5]) |
| 44 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 45 | conf_h = configure_file( |
| 46 | output: 'config.h', |
| 47 | configuration: conf_data) |
| 48 | |
| 49 | root = meson.current_source_dir() |
| 50 | root_inc = include_directories('.', 'include') |
| 51 | |
| 52 | # Project Arguments |
| 53 | cpp = meson.get_compiler('cpp') |
| 54 | add_project_arguments( |
| 55 | cpp.get_supported_arguments([ |
| 56 | '-DBOOST_ERROR_CODE_HEADER_ONLY', |
| 57 | '-DBOOST_SYSTEM_NO_DEPRECATED', |
| 58 | '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING', |
| 59 | '-DBOOST_ASIO_DISABLE_THREADS', |
| 60 | '-DBOOST_ALL_NO_LIB', |
| 61 | ]), |
| 62 | language : 'cpp') |
| 63 | |
Willy Tu | b78184e | 2022-10-27 22:57:38 +0000 | [diff] [blame] | 64 | if not get_option('get-dbus-active-software').disabled() |
| 65 | add_project_arguments( |
| 66 | cpp.get_supported_arguments([ |
| 67 | '-DGET_DBUS_ACTIVE_SOFTWARE', |
| 68 | ]), |
| 69 | language : 'cpp') |
| 70 | endif |
| 71 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 72 | feature_map = { |
| 73 | 'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT', |
| 74 | 'i2c-whitelist-check' : '-DENABLE_I2C_WHITELIST_CHECK', |
| 75 | 'update-functional-on-fail' : '-DUPDATE_FUNCTIONAL_ON_FAIL', |
| 76 | 'dynamic-sensors' : '-DFEATURE_DYNAMIC_SENSORS', |
| 77 | 'dynamic-sensors-write' : '-DFEATURE_DYNAMIC_SENSORS_WRITE', |
| 78 | 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS', |
| 79 | 'sensors-cache' : '-DFEATURE_SENSORS_CACHE', |
| 80 | 'sel-logger-clears-sel' : '-DFEATURE_SEL_LOGGER_CLEARS_SEL', |
| 81 | } |
| 82 | |
| 83 | foreach option_key, option_value : feature_map |
| 84 | if(get_option(option_key).enabled()) |
| 85 | summary(option_key,option_value, section : 'Enabled Features') |
| 86 | add_project_arguments(option_value,language:'cpp') |
| 87 | endif |
| 88 | endforeach |
| 89 | |
| 90 | add_project_arguments( |
| 91 | cpp.get_supported_arguments([ |
| 92 | '-flto', |
| 93 | '-Wno-psabi', |
| 94 | '-Wno-missing-field-initializers', |
| 95 | '-Wno-pedantic', |
| 96 | '-Wno-non-virtual-dtor' |
| 97 | ]), |
| 98 | language: 'cpp') |
| 99 | |
| 100 | # Dependencies |
| 101 | phosphor_logging_dep = dependency('phosphor-logging') |
| 102 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 103 | sdeventplus_dep = dependency('sdeventplus') |
| 104 | systemd = dependency('systemd') |
| 105 | crypto = dependency('libcrypto', version : '>=1.0.2g') |
| 106 | pam = cpp.find_library('pam', required: true) |
Patrick Williams | 6b4cf43 | 2022-06-16 11:31:57 -0500 | [diff] [blame] | 107 | mapper = dependency('libmapper') |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 108 | boost_coroutine = cpp.find_library('boost_coroutine', required: true) |
Patrick Williams | 422385d | 2022-06-16 11:47:40 -0500 | [diff] [blame] | 109 | sdbusplus_dep = dependency('sdbusplus') |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 110 | |
Patrick Williams | c8fc728 | 2022-06-16 11:58:53 -0500 | [diff] [blame] | 111 | if cpp.has_header_symbol( |
| 112 | 'nlohmann/json.hpp', |
| 113 | 'nlohmann::json::string_t', |
| 114 | required:false) |
| 115 | nlohmann_json_dep = declare_dependency() |
| 116 | else |
| 117 | nlohmann_json_dep = dependency('nlohmann-json') |
| 118 | endif |
| 119 | |
Patrick Williams | b69b206 | 2022-07-25 09:40:49 -0500 | [diff] [blame] | 120 | generated_src = [] |
| 121 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 122 | # Subfolders |
| 123 | subdir('libipmid') |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 124 | subdir('include') |
| 125 | subdir('user_channel') |
| 126 | subdir('scripts') |
| 127 | |
| 128 | if not get_option('softoff').disabled() |
| 129 | subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff') |
| 130 | subdir('softoff') |
| 131 | endif |
| 132 | |
| 133 | # whitelist |
| 134 | if not get_option('ipmi-whitelist').disabled() |
| 135 | generate_whitelist_script = files('generate_whitelist_create.sh') |
| 136 | |
| 137 | whitelist_conf = get_option('whitelist-conf') |
| 138 | ipmiwhitelist = run_command( \ |
| 139 | 'bash', \ |
| 140 | generate_whitelist_script, \ |
| 141 | whitelist_conf) |
| 142 | |
| 143 | whitelist_pre = declare_dependency( |
| 144 | include_directories: root_inc, |
| 145 | dependencies: [ |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 146 | crypto, |
| 147 | ipmid_dep, |
| 148 | phosphor_dbus_interfaces_dep, |
| 149 | phosphor_logging_dep, |
| 150 | sdbusplus_dep, |
| 151 | ], |
| 152 | ) |
| 153 | |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 154 | whitelist_lib = library( |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 155 | 'whitelist', |
| 156 | 'whitelist-filter.cpp', |
| 157 | 'ipmiwhitelist.cpp', |
| 158 | implicit_include_directories: false, |
| 159 | dependencies: whitelist_pre, |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 160 | version: meson.project_version(), |
| 161 | override_options: ['b_lundef=false'], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 162 | install: true, |
| 163 | install_dir: get_option('libdir') / 'ipmid-providers') |
| 164 | endif |
| 165 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 166 | # libsysintfcmds |
| 167 | sysintfcmds_pre = declare_dependency( |
| 168 | include_directories: root_inc, |
| 169 | dependencies: [ |
| 170 | channellayer_dep, |
| 171 | crypto, |
| 172 | mapper, |
| 173 | phosphor_dbus_interfaces_dep, |
| 174 | phosphor_logging_dep, |
| 175 | sdbusplus_dep, |
| 176 | ipmid_dep, |
| 177 | ]) |
| 178 | |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 179 | sysintfcmds_lib = library( |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 180 | 'sysintfcmds', |
| 181 | 'systemintfcmds.cpp', |
| 182 | 'host-interface.cpp', |
| 183 | implicit_include_directories: false, |
| 184 | dependencies: sysintfcmds_pre, |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 185 | version: meson.project_version(), |
| 186 | override_options: ['b_lundef=false'], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 187 | install: true, |
| 188 | install_dir: get_option('libdir') / 'ipmid-providers') |
| 189 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 190 | # ipmid |
| 191 | ipmid_pre = [ |
| 192 | sdbusplus_dep, |
| 193 | phosphor_logging_dep, |
| 194 | phosphor_dbus_interfaces_dep, |
| 195 | boost_coroutine, |
| 196 | crypto, |
| 197 | ipmid_dep, |
| 198 | channellayer_dep, |
| 199 | mapper, |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 200 | ] |
| 201 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 202 | transportoem_src = [] |
| 203 | if not get_option('transport-oem').disabled() |
| 204 | transportoem_src = ['transporthandler_oem.cpp'] |
| 205 | endif |
| 206 | |
| 207 | entity_map_json_lib = static_library( |
| 208 | 'entity_map_json', |
| 209 | 'entity_map_json.cpp', |
| 210 | include_directories: root_inc, |
Patrick Williams | c8fc728 | 2022-06-16 11:58:53 -0500 | [diff] [blame] | 211 | dependencies: [ipmid_dep, nlohmann_json_dep], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 212 | implicit_include_directories: false) |
| 213 | |
| 214 | entity_map_json_dep = declare_dependency(link_with: entity_map_json_lib) |
| 215 | |
| 216 | libipmi20_src = [ |
| 217 | 'app/channel.cpp', |
| 218 | 'app/watchdog.cpp', |
| 219 | 'app/watchdog_service.cpp', |
| 220 | 'apphandler.cpp', |
| 221 | 'sys_info_param.cpp', |
| 222 | 'sensorhandler.cpp', |
| 223 | 'storagehandler.cpp', |
| 224 | 'chassishandler.cpp', |
| 225 | 'dcmihandler.cpp', |
| 226 | 'ipmisensor.cpp', |
| 227 | 'storageaddsel.cpp', |
| 228 | 'transporthandler.cpp', |
| 229 | 'globalhandler.cpp', |
| 230 | 'groupext.cpp', |
| 231 | 'selutility.cpp', |
| 232 | 'ipmi_fru_info_area.cpp', |
| 233 | 'read_fru_data.cpp', |
| 234 | 'sensordatahandler.cpp', |
Jian Zhang | ff1b4bf | 2022-06-28 16:08:26 +0800 | [diff] [blame] | 235 | 'user_channel/channelcommands.cpp', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 236 | generated_src, |
| 237 | transportoem_src, |
| 238 | conf_h, |
| 239 | ] |
| 240 | |
| 241 | ipmi20_lib = library( |
| 242 | 'ipmi20', |
| 243 | libipmi20_src, |
Patrick Williams | c8fc728 | 2022-06-16 11:58:53 -0500 | [diff] [blame] | 244 | dependencies: [ipmid_pre, entity_map_json_dep, nlohmann_json_dep], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 245 | include_directories: root_inc, |
| 246 | install: true, |
| 247 | install_dir: get_option('libdir') / 'ipmid-providers', |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 248 | version: meson.project_version(), |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 249 | override_options: ['b_lundef=false']) |
| 250 | |
| 251 | libipmi20_dep = declare_dependency( |
| 252 | dependencies: ipmid_pre, |
| 253 | include_directories: root_inc, |
| 254 | link_with: ipmi20_lib) |
| 255 | |
| 256 | # ipmid binary |
| 257 | executable( |
| 258 | 'ipmid', |
| 259 | 'ipmid-new.cpp', |
| 260 | 'host-cmd-manager.cpp', |
| 261 | 'settings.cpp', |
| 262 | implicit_include_directories: false, |
| 263 | dependencies: [libipmi20_dep], |
| 264 | include_directories: root_inc, |
| 265 | export_dynamic: true, |
| 266 | install: true, |
| 267 | install_dir: get_option('bindir')) |
| 268 | |
| 269 | # Dynamic Sensor Stack |
| 270 | subdir('dbus-sdr') |
| 271 | |
Willy Tu | 0679e4b | 2022-11-11 14:34:33 -0800 | [diff] [blame] | 272 | if not get_option('dynamic-sensors').disabled() or not get_option('tests').disabled() |
Willy Tu | 6eab420 | 2022-06-09 11:34:52 -0700 | [diff] [blame] | 273 | library( |
| 274 | 'dynamiccmds', |
| 275 | dbus_sdr_src, |
| 276 | implicit_include_directories: false, |
| 277 | dependencies: dbus_sdr_pre, |
| 278 | version: meson.project_version(), |
| 279 | override_options: ['b_lundef=false'], |
| 280 | install: true, |
| 281 | install_dir: get_option('libdir') / 'ipmid-providers') |
| 282 | endif |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 283 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 284 | if not get_option('tests').disabled() |
| 285 | subdir('test') |
| 286 | endif |
| 287 | |
| 288 | install_subdir( |
| 289 | 'user_channel', |
| 290 | install_dir: get_option('includedir'), |
| 291 | strip_directory: false, |
| 292 | exclude_files: '*.cpp') |