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', |
Patrick Williams | 6fb3149 | 2023-07-12 11:15:11 -0500 | [diff] [blame] | 5 | meson_version: '>=1.1.1', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 6 | default_options: [ |
| 7 | 'werror=true', |
| 8 | 'warning_level=3', |
Patrick Williams | 6fb3149 | 2023-07-12 11:15:11 -0500 | [diff] [blame] | 9 | 'cpp_std=c++23', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 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')) |
Lei YU | 127a24b | 2023-06-27 17:45:53 +0800 | [diff] [blame] | 19 | conf_data.set('IPMI_SMS_ATN_ACK_TIMEOUT_SECS', get_option('ipmi-sms-atn-ack-timeout-secs')) |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 20 | |
| 21 | # Soft Power off related. |
| 22 | if not get_option('softoff').disabled() |
| 23 | conf_data.set_quoted('SOFTOFF_BUSNAME', get_option('softoff-busname')) |
| 24 | conf_data.set_quoted('SOFTOFF_OBJPATH', get_option('softoff-objpath')) |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 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', |
Johnathan Mantey | 23a722c | 2023-05-12 08:18:54 -0700 | [diff] [blame] | 78 | 'entity-manager-decorators' : '-DUSING_ENTITY_MANAGER_DECORATORS', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 79 | 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS', |
| 80 | 'sensors-cache' : '-DFEATURE_SENSORS_CACHE', |
| 81 | 'sel-logger-clears-sel' : '-DFEATURE_SEL_LOGGER_CLEARS_SEL', |
Thang Tran | 292c917 | 2023-06-26 10:03:04 +0700 | [diff] [blame] | 82 | 'dynamic-storages-only' : '-DFEATURE_DYNAMIC_STORAGES_ONLY', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | foreach option_key, option_value : feature_map |
| 86 | if(get_option(option_key).enabled()) |
| 87 | summary(option_key,option_value, section : 'Enabled Features') |
| 88 | add_project_arguments(option_value,language:'cpp') |
| 89 | endif |
| 90 | endforeach |
| 91 | |
| 92 | add_project_arguments( |
| 93 | cpp.get_supported_arguments([ |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 94 | '-Wno-psabi', |
| 95 | '-Wno-missing-field-initializers', |
| 96 | '-Wno-pedantic', |
| 97 | '-Wno-non-virtual-dtor' |
| 98 | ]), |
| 99 | language: 'cpp') |
| 100 | |
| 101 | # Dependencies |
| 102 | phosphor_logging_dep = dependency('phosphor-logging') |
| 103 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 104 | sdeventplus_dep = dependency('sdeventplus') |
| 105 | systemd = dependency('systemd') |
| 106 | crypto = dependency('libcrypto', version : '>=1.0.2g') |
| 107 | pam = cpp.find_library('pam', required: true) |
Patrick Williams | 6b4cf43 | 2022-06-16 11:31:57 -0500 | [diff] [blame] | 108 | mapper = dependency('libmapper') |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 109 | boost_coroutine = cpp.find_library('boost_coroutine', required: true) |
Patrick Williams | 422385d | 2022-06-16 11:47:40 -0500 | [diff] [blame] | 110 | sdbusplus_dep = dependency('sdbusplus') |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 111 | |
Patrick Williams | c8fc728 | 2022-06-16 11:58:53 -0500 | [diff] [blame] | 112 | if cpp.has_header_symbol( |
| 113 | 'nlohmann/json.hpp', |
| 114 | 'nlohmann::json::string_t', |
| 115 | required:false) |
| 116 | nlohmann_json_dep = declare_dependency() |
| 117 | else |
| 118 | nlohmann_json_dep = dependency('nlohmann-json') |
| 119 | endif |
| 120 | |
Patrick Williams | b69b206 | 2022-07-25 09:40:49 -0500 | [diff] [blame] | 121 | generated_src = [] |
| 122 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 123 | # Subfolders |
| 124 | subdir('libipmid') |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 125 | subdir('include') |
| 126 | subdir('user_channel') |
| 127 | subdir('scripts') |
| 128 | |
| 129 | if not get_option('softoff').disabled() |
| 130 | subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff') |
| 131 | subdir('softoff') |
| 132 | endif |
| 133 | |
| 134 | # whitelist |
| 135 | if not get_option('ipmi-whitelist').disabled() |
| 136 | generate_whitelist_script = files('generate_whitelist_create.sh') |
| 137 | |
| 138 | whitelist_conf = get_option('whitelist-conf') |
| 139 | ipmiwhitelist = run_command( \ |
| 140 | 'bash', \ |
| 141 | generate_whitelist_script, \ |
| 142 | whitelist_conf) |
| 143 | |
| 144 | whitelist_pre = declare_dependency( |
| 145 | include_directories: root_inc, |
| 146 | dependencies: [ |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 147 | crypto, |
| 148 | ipmid_dep, |
| 149 | phosphor_dbus_interfaces_dep, |
| 150 | phosphor_logging_dep, |
| 151 | sdbusplus_dep, |
| 152 | ], |
| 153 | ) |
| 154 | |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 155 | whitelist_lib = library( |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 156 | 'whitelist', |
| 157 | 'whitelist-filter.cpp', |
| 158 | 'ipmiwhitelist.cpp', |
| 159 | implicit_include_directories: false, |
| 160 | dependencies: whitelist_pre, |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 161 | version: meson.project_version(), |
| 162 | override_options: ['b_lundef=false'], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 163 | install: true, |
| 164 | install_dir: get_option('libdir') / 'ipmid-providers') |
| 165 | endif |
| 166 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 167 | # libsysintfcmds |
| 168 | sysintfcmds_pre = declare_dependency( |
| 169 | include_directories: root_inc, |
| 170 | dependencies: [ |
| 171 | channellayer_dep, |
| 172 | crypto, |
| 173 | mapper, |
| 174 | phosphor_dbus_interfaces_dep, |
| 175 | phosphor_logging_dep, |
| 176 | sdbusplus_dep, |
| 177 | ipmid_dep, |
| 178 | ]) |
| 179 | |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 180 | sysintfcmds_lib = library( |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 181 | 'sysintfcmds', |
| 182 | 'systemintfcmds.cpp', |
| 183 | 'host-interface.cpp', |
| 184 | implicit_include_directories: false, |
| 185 | dependencies: sysintfcmds_pre, |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 186 | version: meson.project_version(), |
| 187 | override_options: ['b_lundef=false'], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 188 | install: true, |
| 189 | install_dir: get_option('libdir') / 'ipmid-providers') |
| 190 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 191 | # ipmid |
| 192 | ipmid_pre = [ |
| 193 | sdbusplus_dep, |
| 194 | phosphor_logging_dep, |
| 195 | phosphor_dbus_interfaces_dep, |
| 196 | boost_coroutine, |
| 197 | crypto, |
| 198 | ipmid_dep, |
| 199 | channellayer_dep, |
| 200 | mapper, |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 201 | ] |
| 202 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 203 | transportoem_src = [] |
| 204 | if not get_option('transport-oem').disabled() |
| 205 | transportoem_src = ['transporthandler_oem.cpp'] |
| 206 | endif |
| 207 | |
Thang Tran | 292c917 | 2023-06-26 10:03:04 +0700 | [diff] [blame] | 208 | storage_cmds_src = [] |
| 209 | if get_option('dynamic-sensors').disabled() and not get_option('dynamic-storages-only').disabled() |
| 210 | storage_cmds_src = ['dbus-sdr/storagecommands.cpp', 'dbus-sdr/sdrutils.cpp'] |
| 211 | endif |
| 212 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 213 | libipmi20_src = [ |
| 214 | 'app/channel.cpp', |
| 215 | 'app/watchdog.cpp', |
| 216 | 'app/watchdog_service.cpp', |
| 217 | 'apphandler.cpp', |
| 218 | 'sys_info_param.cpp', |
| 219 | 'sensorhandler.cpp', |
| 220 | 'storagehandler.cpp', |
| 221 | 'chassishandler.cpp', |
| 222 | 'dcmihandler.cpp', |
| 223 | 'ipmisensor.cpp', |
| 224 | 'storageaddsel.cpp', |
| 225 | 'transporthandler.cpp', |
| 226 | 'globalhandler.cpp', |
| 227 | 'groupext.cpp', |
| 228 | 'selutility.cpp', |
| 229 | 'ipmi_fru_info_area.cpp', |
| 230 | 'read_fru_data.cpp', |
| 231 | 'sensordatahandler.cpp', |
Jian Zhang | ff1b4bf | 2022-06-28 16:08:26 +0800 | [diff] [blame] | 232 | 'user_channel/channelcommands.cpp', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 233 | generated_src, |
| 234 | transportoem_src, |
Thang Tran | 292c917 | 2023-06-26 10:03:04 +0700 | [diff] [blame] | 235 | storage_cmds_src, |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 236 | conf_h, |
| 237 | ] |
| 238 | |
| 239 | ipmi20_lib = library( |
| 240 | 'ipmi20', |
| 241 | libipmi20_src, |
Vernon Mauery | 9cf0838 | 2023-04-28 14:00:11 -0700 | [diff] [blame] | 242 | dependencies: [ipmid_pre, nlohmann_json_dep], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 243 | include_directories: root_inc, |
| 244 | install: true, |
| 245 | install_dir: get_option('libdir') / 'ipmid-providers', |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 246 | version: meson.project_version(), |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 247 | override_options: ['b_lundef=false']) |
| 248 | |
| 249 | libipmi20_dep = declare_dependency( |
| 250 | dependencies: ipmid_pre, |
| 251 | include_directories: root_inc, |
| 252 | link_with: ipmi20_lib) |
| 253 | |
| 254 | # ipmid binary |
| 255 | executable( |
| 256 | 'ipmid', |
| 257 | 'ipmid-new.cpp', |
| 258 | 'host-cmd-manager.cpp', |
| 259 | 'settings.cpp', |
| 260 | implicit_include_directories: false, |
| 261 | dependencies: [libipmi20_dep], |
| 262 | include_directories: root_inc, |
| 263 | export_dynamic: true, |
| 264 | install: true, |
| 265 | install_dir: get_option('bindir')) |
| 266 | |
| 267 | # Dynamic Sensor Stack |
| 268 | subdir('dbus-sdr') |
| 269 | |
Willy Tu | 0679e4b | 2022-11-11 14:34:33 -0800 | [diff] [blame] | 270 | 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] | 271 | library( |
| 272 | 'dynamiccmds', |
| 273 | dbus_sdr_src, |
| 274 | implicit_include_directories: false, |
| 275 | dependencies: dbus_sdr_pre, |
| 276 | version: meson.project_version(), |
| 277 | override_options: ['b_lundef=false'], |
| 278 | install: true, |
| 279 | install_dir: get_option('libdir') / 'ipmid-providers') |
| 280 | endif |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 281 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 282 | if not get_option('tests').disabled() |
| 283 | subdir('test') |
| 284 | endif |
| 285 | |
| 286 | install_subdir( |
| 287 | 'user_channel', |
| 288 | install_dir: get_option('includedir'), |
| 289 | strip_directory: false, |
| 290 | exclude_files: '*.cpp') |