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 | |
Alexander Hansen | c2c26f9 | 2023-07-17 09:38:43 +0200 | [diff] [blame] | 37 | if get_option('shortname-remove-suffix').enabled() |
| 38 | conf_data.set_quoted('SHORTNAME_REMOVE_SUFFIX', '1') |
| 39 | endif |
| 40 | if get_option('shortname-replace-words').enabled() |
| 41 | conf_data.set_quoted('SHORTNAME_REPLACE_WORDS', '1') |
| 42 | endif |
Patrick Williams | 768730d | 2023-09-06 16:27:20 -0500 | [diff] [blame] | 43 | if get_option('open-power').allowed() |
| 44 | conf_data.set_quoted('OPEN_POWER_SUPPORT', '1') |
| 45 | endif |
Alexander Hansen | c2c26f9 | 2023-07-17 09:38:43 +0200 | [diff] [blame] | 46 | |
Potin Lai | c7c5592 | 2023-02-16 10:33:55 +0800 | [diff] [blame] | 47 | matches_map = get_option('matches-map') |
| 48 | conf_data.set('MAJOR_MATCH_INDEX', matches_map[0]) |
| 49 | conf_data.set('MINOR_MATCH_INDEX', matches_map[1]) |
| 50 | conf_data.set('AUX_0_MATCH_INDEX', matches_map[2]) |
| 51 | conf_data.set('AUX_1_MATCH_INDEX', matches_map[3]) |
| 52 | conf_data.set('AUX_2_MATCH_INDEX', matches_map[4]) |
| 53 | conf_data.set('AUX_3_MATCH_INDEX', matches_map[5]) |
| 54 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 55 | conf_h = configure_file( |
| 56 | output: 'config.h', |
| 57 | configuration: conf_data) |
| 58 | |
| 59 | root = meson.current_source_dir() |
| 60 | root_inc = include_directories('.', 'include') |
| 61 | |
| 62 | # Project Arguments |
| 63 | cpp = meson.get_compiler('cpp') |
| 64 | add_project_arguments( |
| 65 | cpp.get_supported_arguments([ |
| 66 | '-DBOOST_ERROR_CODE_HEADER_ONLY', |
| 67 | '-DBOOST_SYSTEM_NO_DEPRECATED', |
| 68 | '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING', |
| 69 | '-DBOOST_ASIO_DISABLE_THREADS', |
| 70 | '-DBOOST_ALL_NO_LIB', |
| 71 | ]), |
| 72 | language : 'cpp') |
| 73 | |
Willy Tu | b78184e | 2022-10-27 22:57:38 +0000 | [diff] [blame] | 74 | if not get_option('get-dbus-active-software').disabled() |
| 75 | add_project_arguments( |
| 76 | cpp.get_supported_arguments([ |
| 77 | '-DGET_DBUS_ACTIVE_SOFTWARE', |
| 78 | ]), |
| 79 | language : 'cpp') |
| 80 | endif |
| 81 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 82 | feature_map = { |
| 83 | 'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT', |
| 84 | 'i2c-whitelist-check' : '-DENABLE_I2C_WHITELIST_CHECK', |
| 85 | 'update-functional-on-fail' : '-DUPDATE_FUNCTIONAL_ON_FAIL', |
| 86 | 'dynamic-sensors' : '-DFEATURE_DYNAMIC_SENSORS', |
| 87 | 'dynamic-sensors-write' : '-DFEATURE_DYNAMIC_SENSORS_WRITE', |
Johnathan Mantey | 23a722c | 2023-05-12 08:18:54 -0700 | [diff] [blame] | 88 | 'entity-manager-decorators' : '-DUSING_ENTITY_MANAGER_DECORATORS', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 89 | 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS', |
| 90 | 'sensors-cache' : '-DFEATURE_SENSORS_CACHE', |
Thang Tran | 292c917 | 2023-06-26 10:03:04 +0700 | [diff] [blame] | 91 | 'dynamic-storages-only' : '-DFEATURE_DYNAMIC_STORAGES_ONLY', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | foreach option_key, option_value : feature_map |
| 95 | if(get_option(option_key).enabled()) |
| 96 | summary(option_key,option_value, section : 'Enabled Features') |
| 97 | add_project_arguments(option_value,language:'cpp') |
| 98 | endif |
| 99 | endforeach |
| 100 | |
| 101 | add_project_arguments( |
| 102 | cpp.get_supported_arguments([ |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 103 | '-Wno-psabi', |
| 104 | '-Wno-missing-field-initializers', |
| 105 | '-Wno-pedantic', |
| 106 | '-Wno-non-virtual-dtor' |
| 107 | ]), |
| 108 | language: 'cpp') |
| 109 | |
| 110 | # Dependencies |
| 111 | phosphor_logging_dep = dependency('phosphor-logging') |
| 112 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 113 | sdeventplus_dep = dependency('sdeventplus') |
| 114 | systemd = dependency('systemd') |
| 115 | crypto = dependency('libcrypto', version : '>=1.0.2g') |
| 116 | pam = cpp.find_library('pam', required: true) |
Patrick Williams | 6b4cf43 | 2022-06-16 11:31:57 -0500 | [diff] [blame] | 117 | mapper = dependency('libmapper') |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 118 | boost_coroutine = cpp.find_library('boost_coroutine', required: true) |
Patrick Williams | 422385d | 2022-06-16 11:47:40 -0500 | [diff] [blame] | 119 | sdbusplus_dep = dependency('sdbusplus') |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 120 | stdplus_dep = dependency('stdplus') |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 121 | |
Patrick Williams | c8fc728 | 2022-06-16 11:58:53 -0500 | [diff] [blame] | 122 | if cpp.has_header_symbol( |
| 123 | 'nlohmann/json.hpp', |
| 124 | 'nlohmann::json::string_t', |
| 125 | required:false) |
| 126 | nlohmann_json_dep = declare_dependency() |
| 127 | else |
| 128 | nlohmann_json_dep = dependency('nlohmann-json') |
| 129 | endif |
| 130 | |
Patrick Williams | b69b206 | 2022-07-25 09:40:49 -0500 | [diff] [blame] | 131 | generated_src = [] |
| 132 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 133 | # Subfolders |
| 134 | subdir('libipmid') |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 135 | subdir('include') |
| 136 | subdir('user_channel') |
| 137 | subdir('scripts') |
| 138 | |
| 139 | if not get_option('softoff').disabled() |
| 140 | subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff') |
| 141 | subdir('softoff') |
| 142 | endif |
| 143 | |
| 144 | # whitelist |
| 145 | if not get_option('ipmi-whitelist').disabled() |
| 146 | generate_whitelist_script = files('generate_whitelist_create.sh') |
| 147 | |
| 148 | whitelist_conf = get_option('whitelist-conf') |
| 149 | ipmiwhitelist = run_command( \ |
| 150 | 'bash', \ |
| 151 | generate_whitelist_script, \ |
| 152 | whitelist_conf) |
| 153 | |
| 154 | whitelist_pre = declare_dependency( |
| 155 | include_directories: root_inc, |
| 156 | dependencies: [ |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 157 | crypto, |
| 158 | ipmid_dep, |
| 159 | phosphor_dbus_interfaces_dep, |
| 160 | phosphor_logging_dep, |
| 161 | sdbusplus_dep, |
| 162 | ], |
| 163 | ) |
| 164 | |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 165 | whitelist_lib = library( |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 166 | 'whitelist', |
| 167 | 'whitelist-filter.cpp', |
| 168 | 'ipmiwhitelist.cpp', |
| 169 | implicit_include_directories: false, |
| 170 | dependencies: whitelist_pre, |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 171 | version: meson.project_version(), |
| 172 | override_options: ['b_lundef=false'], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 173 | install: true, |
| 174 | install_dir: get_option('libdir') / 'ipmid-providers') |
| 175 | endif |
| 176 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 177 | # libsysintfcmds |
| 178 | sysintfcmds_pre = declare_dependency( |
| 179 | include_directories: root_inc, |
| 180 | dependencies: [ |
| 181 | channellayer_dep, |
| 182 | crypto, |
| 183 | mapper, |
| 184 | phosphor_dbus_interfaces_dep, |
| 185 | phosphor_logging_dep, |
| 186 | sdbusplus_dep, |
| 187 | ipmid_dep, |
| 188 | ]) |
| 189 | |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 190 | sysintfcmds_lib = library( |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 191 | 'sysintfcmds', |
| 192 | 'systemintfcmds.cpp', |
| 193 | 'host-interface.cpp', |
| 194 | implicit_include_directories: false, |
| 195 | dependencies: sysintfcmds_pre, |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 196 | version: meson.project_version(), |
| 197 | override_options: ['b_lundef=false'], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 198 | install: true, |
| 199 | install_dir: get_option('libdir') / 'ipmid-providers') |
| 200 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 201 | # ipmid |
| 202 | ipmid_pre = [ |
| 203 | sdbusplus_dep, |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 204 | stdplus_dep, |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 205 | phosphor_logging_dep, |
| 206 | phosphor_dbus_interfaces_dep, |
| 207 | boost_coroutine, |
| 208 | crypto, |
| 209 | ipmid_dep, |
| 210 | channellayer_dep, |
| 211 | mapper, |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 212 | ] |
| 213 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 214 | transportoem_src = [] |
| 215 | if not get_option('transport-oem').disabled() |
| 216 | transportoem_src = ['transporthandler_oem.cpp'] |
| 217 | endif |
| 218 | |
Thang Tran | 292c917 | 2023-06-26 10:03:04 +0700 | [diff] [blame] | 219 | storage_cmds_src = [] |
| 220 | if get_option('dynamic-sensors').disabled() and not get_option('dynamic-storages-only').disabled() |
| 221 | storage_cmds_src = ['dbus-sdr/storagecommands.cpp', 'dbus-sdr/sdrutils.cpp'] |
| 222 | endif |
| 223 | |
Patrick Williams | 768730d | 2023-09-06 16:27:20 -0500 | [diff] [blame] | 224 | openpower_cmds_src = [] |
| 225 | if get_option('open-power').allowed() |
| 226 | openpower_cmds_src = [ 'storageaddsel.cpp' ] |
| 227 | endif |
| 228 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 229 | libipmi20_src = [ |
| 230 | 'app/channel.cpp', |
| 231 | 'app/watchdog.cpp', |
| 232 | 'app/watchdog_service.cpp', |
| 233 | 'apphandler.cpp', |
| 234 | 'sys_info_param.cpp', |
| 235 | 'sensorhandler.cpp', |
| 236 | 'storagehandler.cpp', |
| 237 | 'chassishandler.cpp', |
| 238 | 'dcmihandler.cpp', |
| 239 | 'ipmisensor.cpp', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 240 | 'transporthandler.cpp', |
| 241 | 'globalhandler.cpp', |
| 242 | 'groupext.cpp', |
| 243 | 'selutility.cpp', |
| 244 | 'ipmi_fru_info_area.cpp', |
| 245 | 'read_fru_data.cpp', |
| 246 | 'sensordatahandler.cpp', |
Jian Zhang | ff1b4bf | 2022-06-28 16:08:26 +0800 | [diff] [blame] | 247 | 'user_channel/channelcommands.cpp', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 248 | generated_src, |
| 249 | transportoem_src, |
Thang Tran | 292c917 | 2023-06-26 10:03:04 +0700 | [diff] [blame] | 250 | storage_cmds_src, |
Patrick Williams | 768730d | 2023-09-06 16:27:20 -0500 | [diff] [blame] | 251 | openpower_cmds_src, |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 252 | conf_h, |
| 253 | ] |
| 254 | |
| 255 | ipmi20_lib = library( |
| 256 | 'ipmi20', |
| 257 | libipmi20_src, |
Vernon Mauery | 9cf0838 | 2023-04-28 14:00:11 -0700 | [diff] [blame] | 258 | dependencies: [ipmid_pre, nlohmann_json_dep], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 259 | include_directories: root_inc, |
| 260 | install: true, |
| 261 | install_dir: get_option('libdir') / 'ipmid-providers', |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 262 | version: meson.project_version(), |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 263 | override_options: ['b_lundef=false']) |
| 264 | |
| 265 | libipmi20_dep = declare_dependency( |
| 266 | dependencies: ipmid_pre, |
| 267 | include_directories: root_inc, |
| 268 | link_with: ipmi20_lib) |
| 269 | |
| 270 | # ipmid binary |
| 271 | executable( |
| 272 | 'ipmid', |
| 273 | 'ipmid-new.cpp', |
| 274 | 'host-cmd-manager.cpp', |
| 275 | 'settings.cpp', |
| 276 | implicit_include_directories: false, |
| 277 | dependencies: [libipmi20_dep], |
| 278 | include_directories: root_inc, |
| 279 | export_dynamic: true, |
| 280 | install: true, |
| 281 | install_dir: get_option('bindir')) |
| 282 | |
| 283 | # Dynamic Sensor Stack |
| 284 | subdir('dbus-sdr') |
| 285 | |
Willy Tu | 0679e4b | 2022-11-11 14:34:33 -0800 | [diff] [blame] | 286 | 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] | 287 | library( |
| 288 | 'dynamiccmds', |
| 289 | dbus_sdr_src, |
| 290 | implicit_include_directories: false, |
| 291 | dependencies: dbus_sdr_pre, |
| 292 | version: meson.project_version(), |
| 293 | override_options: ['b_lundef=false'], |
| 294 | install: true, |
| 295 | install_dir: get_option('libdir') / 'ipmid-providers') |
| 296 | endif |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 297 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 298 | if not get_option('tests').disabled() |
| 299 | subdir('test') |
| 300 | endif |
| 301 | |
| 302 | install_subdir( |
| 303 | 'user_channel', |
| 304 | install_dir: get_option('includedir'), |
| 305 | strip_directory: false, |
| 306 | exclude_files: '*.cpp') |