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