1project( 2 'pldm', 3 'cpp', 4 version: '0.1', 5 meson_version: '>=1.1.1', 6 default_options: [ 7 'warning_level=3', 8 'default_library=shared', 9 'werror=true', 10 'cpp_std=c++23', 11 'buildtype=debugoptimized', 12 ], 13) 14 15# Wno-psabi reduces the number of "Note:" messages when cross-compiling some STL 16# stuff for ARM. See https://stackoverflow.com/questions/48149323/strange-gcc-warning-when-compiling-qt-project 17# Basically, gcc 6 and gcc 7 are not ABI compatible, but since the whole OpenBMC 18# project uses the same compiler, we can safely ignmore these info notes. 19add_project_arguments('-Wno-psabi', language: 'cpp') 20 21 22# Disable FORTIFY_SOURCE when compiling with no optimization 23if (get_option('optimization') == '0') 24 add_project_arguments('-U_FORTIFY_SOURCE', language: 'cpp') 25 message('Disabling FORTIFY_SOURCE as optimization is set to 0') 26endif 27 28package_datadir = join_paths( 29 get_option('prefix'), 30 get_option('datadir'), 31 meson.project_name(), 32) 33package_localstatedir = join_paths( 34 get_option('prefix'), 35 get_option('localstatedir'), 36 meson.project_name(), 37) 38 39conf_data = configuration_data() 40cpp = meson.get_compiler('cpp') 41 42# Enable POSIX poll APIs in libpldm 43if cpp.has_header('poll.h') 44 conf_data.set('PLDM_HAS_POLL', 1) 45endif 46if get_option('libpldmresponder').allowed() 47 conf_data.set_quoted('BIOS_JSONS_DIR', join_paths(package_datadir, 'bios')) 48 conf_data.set( 49 'SYSTEM_SPECIFIC_BIOS_JSON', 50 get_option('system-specific-bios-json').allowed(), 51 ) 52 conf_data.set_quoted( 53 'BIOS_TABLES_DIR', 54 join_paths(package_localstatedir, 'bios'), 55 ) 56 conf_data.set_quoted('PDR_JSONS_DIR', join_paths(package_datadir, 'pdr')) 57 conf_data.set_quoted('FRU_JSONS_DIR', join_paths(package_datadir, 'fru')) 58 conf_data.set_quoted( 59 'FRU_MASTER_JSON', 60 join_paths(package_datadir, 'fru_master.json'), 61 ) 62 conf_data.set_quoted( 63 'ENTITY_MAP_JSON', 64 join_paths(package_datadir, 'entityMap.json'), 65 ) 66 conf_data.set_quoted('HOST_JSONS_DIR', join_paths(package_datadir, 'host')) 67 conf_data.set_quoted( 68 'EVENTS_JSONS_DIR', 69 join_paths(package_datadir, 'events'), 70 ) 71 conf_data.set('HEARTBEAT_TIMEOUT', get_option('heartbeat-timeout-seconds')) 72 conf_data.set('TERMINUS_ID', get_option('terminus-id')) 73 conf_data.set('TERMINUS_HANDLE', get_option('terminus-handle')) 74 conf_data.set('DBUS_TIMEOUT', get_option('dbus-timeout-value')) 75 add_project_arguments('-DLIBPLDMRESPONDER', language: 'cpp') 76endif 77if get_option('softoff').allowed() 78 conf_data.set( 79 'SOFTOFF_TIMEOUT_SECONDS', 80 get_option('softoff-timeout-seconds'), 81 ) 82 conf_data.set_quoted( 83 'SOFTOFF_CONFIG_JSON', 84 join_paths(package_datadir, 'softoff'), 85 ) 86endif 87if get_option('oem-ibm').allowed() 88 conf_data.set_quoted( 89 'FILE_TABLE_JSON', 90 join_paths(package_datadir, 'fileTable.json'), 91 ) 92 conf_data.set_quoted( 93 'LID_RUNNING_DIR', 94 '/var/lib/phosphor-software-manager/hostfw/running', 95 ) 96 conf_data.set_quoted( 97 'LID_ALTERNATE_DIR', 98 '/var/lib/phosphor-software-manager/hostfw/alternate', 99 ) 100 conf_data.set_quoted( 101 'LID_STAGING_DIR', 102 '/var/lib/phosphor-software-manager/hostfw/staging', 103 ) 104 conf_data.set_quoted( 105 'LID_RUNNING_PATCH_DIR', 106 '/usr/local/share/hostfw/running', 107 ) 108 conf_data.set_quoted( 109 'LID_ALTERNATE_PATCH_DIR', 110 '/usr/local/share/hostfw/alternate', 111 ) 112 conf_data.set('DMA_MAXSIZE', get_option('oem-ibm-dma-maxsize')) 113 add_project_arguments('-DOEM_IBM', language: 'cpp') 114endif 115conf_data.set( 116 'NUMBER_OF_REQUEST_RETRIES', 117 get_option('number-of-request-retries'), 118) 119conf_data.set( 120 'INSTANCE_ID_EXPIRATION_INTERVAL', 121 get_option('instance-id-expiration-interval'), 122) 123conf_data.set('RESPONSE_TIME_OUT', get_option('response-time-out')) 124conf_data.set( 125 'FLIGHT_RECORDER_MAX_ENTRIES', 126 get_option('flightrecorder-max-entries'), 127) 128conf_data.set_quoted('HOST_EID_PATH', join_paths(package_datadir, 'host_eid')) 129conf_data.set('MAXIMUM_TRANSFER_SIZE', get_option('maximum-transfer-size')) 130if get_option('transport-implementation') == 'mctp-demux' 131 conf_data.set('PLDM_TRANSPORT_WITH_MCTP_DEMUX', 1) 132elif get_option('transport-implementation') == 'af-mctp' 133 conf_data.set('PLDM_TRANSPORT_WITH_AF_MCTP', 1) 134endif 135conf_data.set( 136 'DEFAULT_SENSOR_UPDATER_INTERVAL', 137 get_option('default-sensor-update-interval'), 138) 139conf_data.set('SENSOR_POLLING_TIME', get_option('sensor-polling-time')) 140 141oem_files = [] 142if get_option('oem-ampere').enabled() 143 add_project_arguments('-DOEM_AMPERE', language : 'cpp') 144 subdir('oem/ampere') 145endif 146 147configure_file(output: 'config.h', configuration: conf_data) 148 149add_project_arguments( 150 '-include', 151 '@0@'.format(meson.current_build_dir() / 'config.h'), 152 language: 'cpp', 153) 154 155filesystem = import('fs') 156 157phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces') 158sdbusplus = dependency('sdbusplus') 159sdeventplus = dependency('sdeventplus') 160stdplus = dependency('stdplus') 161phosphor_logging_dep = dependency('phosphor-logging') 162 163nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 164 165if cpp.has_header('CLI/CLI.hpp') 166 CLI11_dep = declare_dependency() 167else 168 CLI11_dep = dependency('CLI11') 169endif 170 171if get_option('tests').allowed() 172 gtest = dependency('gtest', main: true, disabler: true, required: false) 173 gmock = dependency('gmock', disabler: true, required: false) 174 if not gtest.found() or not gmock.found() 175 gtest_proj = import('cmake').subproject('googletest', required: false) 176 if gtest_proj.found() 177 gtest = declare_dependency( 178 dependencies: [ 179 dependency('threads'), 180 gtest_proj.dependency('gtest'), 181 gtest_proj.dependency('gtest_main'), 182 ], 183 ) 184 gmock = gtest_proj.dependency('gmock') 185 else 186 assert( 187 not get_option('tests').allowed(), 188 'Googletest is required if tests are enabled', 189 ) 190 endif 191 endif 192endif 193 194libpldm_dep = dependency( 195 'libpldm', 196 fallback: ['libpldm', 'libpldm_dep'], 197 include_type: 'system', 198) 199 200 201libpldmutils_headers = ['.'] 202libpldmutils = library( 203 'pldmutils', 204 'common/transport.cpp', 205 'common/utils.cpp', 206 version: meson.project_version(), 207 dependencies: [ 208 libpldm_dep, 209 phosphor_dbus_interfaces, 210 phosphor_logging_dep, 211 nlohmann_json_dep, 212 sdbusplus, 213 ], 214 install: true, 215 include_directories: include_directories(libpldmutils_headers), 216) 217 218libpldmutils = declare_dependency( 219 include_directories: include_directories(libpldmutils_headers), 220 link_with: libpldmutils, 221) 222 223deps = [ 224 libpldm_dep, 225 libpldmutils, 226 nlohmann_json_dep, 227 phosphor_dbus_interfaces, 228 phosphor_logging_dep, 229 sdbusplus, 230 sdeventplus, 231 stdplus, 232] 233 234if get_option('libpldmresponder').allowed() 235 subdir('libpldmresponder') 236 deps += [libpldmresponder_dep] 237endif 238 239executable( 240 'pldmd', 241 'pldmd/pldmd.cpp', 242 'pldmd/dbus_impl_pdr.cpp', 243 'fw-update/activation.cpp', 244 'fw-update/inventory_manager.cpp', 245 'fw-update/package_parser.cpp', 246 'fw-update/device_updater.cpp', 247 'fw-update/watch.cpp', 248 'fw-update/update_manager.cpp', 249 'platform-mc/terminus_manager.cpp', 250 'platform-mc/terminus.cpp', 251 'platform-mc/platform_manager.cpp', 252 'platform-mc/manager.cpp', 253 'platform-mc/sensor_manager.cpp', 254 'platform-mc/numeric_sensor.cpp', 255 'platform-mc/event_manager.cpp', 256 oem_files, 257 'requester/mctp_endpoint_discovery.cpp', 258 implicit_include_directories: false, 259 dependencies: deps, 260 install: true, 261 install_dir: get_option('bindir'), 262) 263 264if get_option('systemd').allowed() 265 systemd_system_unit_dir = dependency('systemd').get_variable( 266 'systemdsystemunitdir', 267 ) 268 filesystem.copyfile( 269 'pldmd/service_files/pldmd.service', 270 'pldmd.service', 271 install: true, 272 install_dir: systemd_system_unit_dir, 273 ) 274 275 if get_option('oem-ibm').allowed() 276 subdir('oem/ibm/service_files') 277 endif 278endif 279 280subdir('pldmtool') 281 282subdir('configurations') 283 284if get_option('utilities').allowed() 285 subdir('utilities') 286endif 287 288if get_option('softoff').allowed() 289 subdir('softoff') 290endif 291 292if get_option('tests').allowed() 293 subdir('common/test') 294 subdir('fw-update/test') 295 subdir('host-bmc/test') 296 subdir('requester/test') 297 subdir('platform-mc/test') 298 subdir('test') 299endif 300