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