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', |
Konstantin Aladyshev | e11895f | 2024-04-04 12:35:33 +0300 | [diff] [blame] | 10 | 'b_lto=true', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 11 | ]) |
| 12 | |
| 13 | # Setting up config data |
| 14 | conf_data = configuration_data() |
| 15 | |
| 16 | # The name of the callout's forward association |
| 17 | conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout') |
| 18 | conf_data.set_quoted('BOARD_SENSOR', get_option('board-sensor')) |
| 19 | conf_data.set_quoted('SYSTEM_SENSOR', get_option('system-sensor')) |
Lei YU | 127a24b | 2023-06-27 17:45:53 +0800 | [diff] [blame] | 20 | 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] | 21 | |
| 22 | # Soft Power off related. |
| 23 | if 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')) |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 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')) |
| 29 | endif |
| 30 | |
| 31 | conf_data.set_quoted('CONTROL_HOST_BUSNAME', get_option('control-host-busname')) |
| 32 | conf_data.set_quoted('CONTROL_HOST_OBJ_MGR', get_option('control-host-obj-mgr')) |
| 33 | conf_data.set_quoted('HOST_NAME', get_option('host-name')) |
| 34 | conf_data.set_quoted('POWER_READING_SENSOR', get_option('power-reading-sensor')) |
| 35 | 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] | 36 | conf_data.set_quoted('FW_VER_REGEX', get_option('fw-ver-regex')) |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 37 | |
Patrick Williams | 833b706 | 2023-11-29 06:43:54 -0600 | [diff] [blame] | 38 | if get_option('shortname-remove-suffix').allowed() |
Alexander Hansen | c2c26f9 | 2023-07-17 09:38:43 +0200 | [diff] [blame] | 39 | conf_data.set_quoted('SHORTNAME_REMOVE_SUFFIX', '1') |
| 40 | endif |
Patrick Williams | 833b706 | 2023-11-29 06:43:54 -0600 | [diff] [blame] | 41 | if get_option('shortname-replace-words').allowed() |
Alexander Hansen | c2c26f9 | 2023-07-17 09:38:43 +0200 | [diff] [blame] | 42 | conf_data.set_quoted('SHORTNAME_REPLACE_WORDS', '1') |
| 43 | endif |
Patrick Williams | 768730d | 2023-09-06 16:27:20 -0500 | [diff] [blame] | 44 | if get_option('open-power').allowed() |
| 45 | conf_data.set_quoted('OPEN_POWER_SUPPORT', '1') |
| 46 | endif |
Alexander Hansen | c2c26f9 | 2023-07-17 09:38:43 +0200 | [diff] [blame] | 47 | |
Potin Lai | c7c5592 | 2023-02-16 10:33:55 +0800 | [diff] [blame] | 48 | matches_map = get_option('matches-map') |
| 49 | conf_data.set('MAJOR_MATCH_INDEX', matches_map[0]) |
| 50 | conf_data.set('MINOR_MATCH_INDEX', matches_map[1]) |
| 51 | conf_data.set('AUX_0_MATCH_INDEX', matches_map[2]) |
| 52 | conf_data.set('AUX_1_MATCH_INDEX', matches_map[3]) |
| 53 | conf_data.set('AUX_2_MATCH_INDEX', matches_map[4]) |
| 54 | conf_data.set('AUX_3_MATCH_INDEX', matches_map[5]) |
| 55 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 56 | conf_h = configure_file( |
| 57 | output: 'config.h', |
| 58 | configuration: conf_data) |
| 59 | |
| 60 | root = meson.current_source_dir() |
| 61 | root_inc = include_directories('.', 'include') |
| 62 | |
| 63 | # Project Arguments |
| 64 | cpp = meson.get_compiler('cpp') |
| 65 | add_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 | |
Willy Tu | b78184e | 2022-10-27 22:57:38 +0000 | [diff] [blame] | 75 | if 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') |
| 81 | endif |
| 82 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 83 | feature_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', |
Johnathan Mantey | 23a722c | 2023-05-12 08:18:54 -0700 | [diff] [blame] | 89 | 'entity-manager-decorators' : '-DUSING_ENTITY_MANAGER_DECORATORS', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 90 | 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS', |
| 91 | 'sensors-cache' : '-DFEATURE_SENSORS_CACHE', |
Thang Tran | 292c917 | 2023-06-26 10:03:04 +0700 | [diff] [blame] | 92 | 'dynamic-storages-only' : '-DFEATURE_DYNAMIC_STORAGES_ONLY', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | foreach option_key, option_value : feature_map |
Patrick Williams | 833b706 | 2023-11-29 06:43:54 -0600 | [diff] [blame] | 96 | if(get_option(option_key).allowed()) |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 97 | summary(option_key,option_value, section : 'Enabled Features') |
| 98 | add_project_arguments(option_value,language:'cpp') |
| 99 | endif |
| 100 | endforeach |
| 101 | |
| 102 | add_project_arguments( |
| 103 | cpp.get_supported_arguments([ |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 104 | '-Wno-psabi', |
| 105 | '-Wno-missing-field-initializers', |
| 106 | '-Wno-pedantic', |
| 107 | '-Wno-non-virtual-dtor' |
| 108 | ]), |
| 109 | language: 'cpp') |
| 110 | |
| 111 | # Dependencies |
Konstantin Aladyshev | e11895f | 2024-04-04 12:35:33 +0300 | [diff] [blame] | 112 | |
| 113 | boost = dependency( |
| 114 | 'boost', |
| 115 | modules: [ |
| 116 | 'coroutine', |
| 117 | ], |
| 118 | required : false, |
| 119 | ) |
| 120 | |
| 121 | if 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] |
| 138 | endif |
| 139 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 140 | phosphor_logging_dep = dependency('phosphor-logging') |
| 141 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 142 | sdeventplus_dep = dependency('sdeventplus') |
| 143 | systemd = dependency('systemd') |
| 144 | crypto = dependency('libcrypto', version : '>=1.0.2g') |
| 145 | pam = cpp.find_library('pam', required: true) |
Patrick Williams | 422385d | 2022-06-16 11:47:40 -0500 | [diff] [blame] | 146 | sdbusplus_dep = dependency('sdbusplus') |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 147 | stdplus_dep = dependency('stdplus') |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 148 | |
Patrick Williams | e5fa659 | 2023-12-07 14:47:50 -0600 | [diff] [blame] | 149 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
Patrick Williams | c8fc728 | 2022-06-16 11:58:53 -0500 | [diff] [blame] | 150 | |
Patrick Williams | b69b206 | 2022-07-25 09:40:49 -0500 | [diff] [blame] | 151 | generated_src = [] |
| 152 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 153 | # Subfolders |
| 154 | subdir('libipmid') |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 155 | subdir('include') |
| 156 | subdir('user_channel') |
| 157 | subdir('scripts') |
| 158 | |
| 159 | if not get_option('softoff').disabled() |
| 160 | subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff') |
| 161 | subdir('softoff') |
| 162 | endif |
| 163 | |
| 164 | # whitelist |
| 165 | if 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: [ |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 177 | crypto, |
| 178 | ipmid_dep, |
| 179 | phosphor_dbus_interfaces_dep, |
| 180 | phosphor_logging_dep, |
| 181 | sdbusplus_dep, |
| 182 | ], |
| 183 | ) |
| 184 | |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 185 | whitelist_lib = library( |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 186 | 'whitelist', |
| 187 | 'whitelist-filter.cpp', |
| 188 | 'ipmiwhitelist.cpp', |
| 189 | implicit_include_directories: false, |
| 190 | dependencies: whitelist_pre, |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 191 | version: meson.project_version(), |
| 192 | override_options: ['b_lundef=false'], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 193 | install: true, |
| 194 | install_dir: get_option('libdir') / 'ipmid-providers') |
| 195 | endif |
| 196 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 197 | # libsysintfcmds |
| 198 | sysintfcmds_pre = declare_dependency( |
| 199 | include_directories: root_inc, |
| 200 | dependencies: [ |
| 201 | channellayer_dep, |
| 202 | crypto, |
Vernon Mauery | e4aa654 | 2023-11-01 14:29:21 -0700 | [diff] [blame] | 203 | nlohmann_json_dep, |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 204 | phosphor_dbus_interfaces_dep, |
| 205 | phosphor_logging_dep, |
| 206 | sdbusplus_dep, |
| 207 | ipmid_dep, |
| 208 | ]) |
| 209 | |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 210 | sysintfcmds_lib = library( |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 211 | 'sysintfcmds', |
| 212 | 'systemintfcmds.cpp', |
| 213 | 'host-interface.cpp', |
| 214 | implicit_include_directories: false, |
| 215 | dependencies: sysintfcmds_pre, |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 216 | version: meson.project_version(), |
| 217 | override_options: ['b_lundef=false'], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 218 | install: true, |
| 219 | install_dir: get_option('libdir') / 'ipmid-providers') |
| 220 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 221 | # ipmid |
| 222 | ipmid_pre = [ |
| 223 | sdbusplus_dep, |
William A. Kennington III | 7a3831b | 2023-06-21 01:10:49 -0700 | [diff] [blame] | 224 | stdplus_dep, |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 225 | phosphor_logging_dep, |
| 226 | phosphor_dbus_interfaces_dep, |
Konstantin Aladyshev | e11895f | 2024-04-04 12:35:33 +0300 | [diff] [blame] | 227 | boost, |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 228 | crypto, |
| 229 | ipmid_dep, |
| 230 | channellayer_dep, |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 231 | ] |
| 232 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 233 | transportoem_src = [] |
| 234 | if not get_option('transport-oem').disabled() |
| 235 | transportoem_src = ['transporthandler_oem.cpp'] |
| 236 | endif |
| 237 | |
Thang Tran | 292c917 | 2023-06-26 10:03:04 +0700 | [diff] [blame] | 238 | storage_cmds_src = [] |
| 239 | if 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'] |
| 241 | endif |
| 242 | |
Patrick Williams | 768730d | 2023-09-06 16:27:20 -0500 | [diff] [blame] | 243 | openpower_cmds_src = [] |
| 244 | if get_option('open-power').allowed() |
| 245 | openpower_cmds_src = [ 'storageaddsel.cpp' ] |
| 246 | endif |
| 247 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 248 | libipmi20_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', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 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', |
Jian Zhang | ff1b4bf | 2022-06-28 16:08:26 +0800 | [diff] [blame] | 266 | 'user_channel/channelcommands.cpp', |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 267 | generated_src, |
| 268 | transportoem_src, |
Thang Tran | 292c917 | 2023-06-26 10:03:04 +0700 | [diff] [blame] | 269 | storage_cmds_src, |
Patrick Williams | 768730d | 2023-09-06 16:27:20 -0500 | [diff] [blame] | 270 | openpower_cmds_src, |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 271 | conf_h, |
| 272 | ] |
| 273 | |
| 274 | ipmi20_lib = library( |
| 275 | 'ipmi20', |
| 276 | libipmi20_src, |
Vernon Mauery | 9cf0838 | 2023-04-28 14:00:11 -0700 | [diff] [blame] | 277 | dependencies: [ipmid_pre, nlohmann_json_dep], |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 278 | include_directories: root_inc, |
| 279 | install: true, |
| 280 | install_dir: get_option('libdir') / 'ipmid-providers', |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 281 | version: meson.project_version(), |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 282 | override_options: ['b_lundef=false']) |
| 283 | |
| 284 | libipmi20_dep = declare_dependency( |
| 285 | dependencies: ipmid_pre, |
| 286 | include_directories: root_inc, |
| 287 | link_with: ipmi20_lib) |
| 288 | |
| 289 | # ipmid binary |
| 290 | executable( |
| 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 |
| 303 | subdir('dbus-sdr') |
| 304 | |
Willy Tu | 0679e4b | 2022-11-11 14:34:33 -0800 | [diff] [blame] | 305 | 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] | 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') |
| 315 | endif |
Willy Tu | ba9bbb6 | 2022-06-01 03:41:15 -0700 | [diff] [blame] | 316 | |
Willy Tu | c710b97 | 2021-08-11 16:33:43 -0700 | [diff] [blame] | 317 | if not get_option('tests').disabled() |
| 318 | subdir('test') |
| 319 | endif |
| 320 | |
| 321 | install_subdir( |
| 322 | 'user_channel', |
| 323 | install_dir: get_option('includedir'), |
| 324 | strip_directory: false, |
| 325 | exclude_files: '*.cpp') |