Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 1 | project( |
| 2 | 'pldm', |
Manojkiran Eda | 0ff3435 | 2024-08-22 19:39:32 +0530 | [diff] [blame] | 3 | 'cpp', |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 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 | ) |
Deepak Kodihalli | 3c275e1 | 2019-09-21 06:39:39 -0500 | [diff] [blame] | 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. |
| 19 | add_project_arguments('-Wno-psabi', language: 'cpp') |
| 20 | |
Manojkiran Eda | 38ce97c | 2021-02-14 12:15:17 +0530 | [diff] [blame] | 21 | |
| 22 | # Disable FORTIFY_SOURCE when compiling with no optimization |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 23 | if (get_option('optimization') == '0') |
Manojkiran Eda | 0ff3435 | 2024-08-22 19:39:32 +0530 | [diff] [blame] | 24 | add_project_arguments('-U_FORTIFY_SOURCE', language: 'cpp') |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 25 | message('Disabling FORTIFY_SOURCE as optimization is set to 0') |
Manojkiran Eda | 38ce97c | 2021-02-14 12:15:17 +0530 | [diff] [blame] | 26 | endif |
| 27 | |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 28 | package_datadir = join_paths( |
| 29 | get_option('prefix'), |
| 30 | get_option('datadir'), |
| 31 | meson.project_name(), |
| 32 | ) |
| 33 | package_localstatedir = join_paths( |
| 34 | get_option('prefix'), |
| 35 | get_option('localstatedir'), |
| 36 | meson.project_name(), |
| 37 | ) |
Brad Bishop | 06052cc | 2021-08-16 15:17:16 -0400 | [diff] [blame] | 38 | |
Deepak Kodihalli | 3c275e1 | 2019-09-21 06:39:39 -0500 | [diff] [blame] | 39 | conf_data = configuration_data() |
Rashmica Gupta | 1ed5f7a | 2023-05-22 13:56:42 +1000 | [diff] [blame] | 40 | cpp = meson.get_compiler('cpp') |
| 41 | |
| 42 | # Enable POSIX poll APIs in libpldm |
| 43 | if cpp.has_header('poll.h') |
| 44 | conf_data.set('PLDM_HAS_POLL', 1) |
| 45 | endif |
Patrick Williams | 87bfacd | 2023-11-29 06:44:36 -0600 | [diff] [blame] | 46 | if get_option('libpldmresponder').allowed() |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 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')) |
Manojkiran Eda | 0ff3435 | 2024-08-22 19:39:32 +0530 | [diff] [blame] | 75 | add_project_arguments('-DLIBPLDMRESPONDER', language: 'cpp') |
Tom Joseph | 02b4ee4 | 2021-05-02 22:44:36 -0700 | [diff] [blame] | 76 | endif |
Patrick Williams | 87bfacd | 2023-11-29 06:44:36 -0600 | [diff] [blame] | 77 | if get_option('softoff').allowed() |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 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 | ) |
George Liu | ab865f6 | 2020-03-10 09:12:52 +0800 | [diff] [blame] | 86 | endif |
Patrick Williams | 87bfacd | 2023-11-29 06:44:36 -0600 | [diff] [blame] | 87 | if get_option('oem-ibm').allowed() |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 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')) |
Manojkiran Eda | 0ff3435 | 2024-08-22 19:39:32 +0530 | [diff] [blame] | 113 | add_project_arguments('-DOEM_IBM', language: 'cpp') |
Deepak Kodihalli | 3c275e1 | 2019-09-21 06:39:39 -0500 | [diff] [blame] | 114 | endif |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 115 | conf_data.set( |
| 116 | 'NUMBER_OF_REQUEST_RETRIES', |
| 117 | get_option('number-of-request-retries'), |
| 118 | ) |
| 119 | conf_data.set( |
| 120 | 'INSTANCE_ID_EXPIRATION_INTERVAL', |
| 121 | get_option('instance-id-expiration-interval'), |
| 122 | ) |
| 123 | conf_data.set('RESPONSE_TIME_OUT', get_option('response-time-out')) |
| 124 | conf_data.set( |
| 125 | 'FLIGHT_RECORDER_MAX_ENTRIES', |
| 126 | get_option('flightrecorder-max-entries'), |
| 127 | ) |
Manojkiran Eda | b69d8bf | 2022-09-28 01:11:31 +0530 | [diff] [blame] | 128 | conf_data.set_quoted('HOST_EID_PATH', join_paths(package_datadir, 'host_eid')) |
Tom Joseph | ef90b0d | 2021-08-17 07:12:49 -0700 | [diff] [blame] | 129 | conf_data.set('MAXIMUM_TRANSFER_SIZE', get_option('maximum-transfer-size')) |
Rashmica Gupta | 1ed5f7a | 2023-05-22 13:56:42 +1000 | [diff] [blame] | 130 | if get_option('transport-implementation') == 'mctp-demux' |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 131 | conf_data.set('PLDM_TRANSPORT_WITH_MCTP_DEMUX', 1) |
Rashmica Gupta | 1ed5f7a | 2023-05-22 13:56:42 +1000 | [diff] [blame] | 132 | elif get_option('transport-implementation') == 'af-mctp' |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 133 | conf_data.set('PLDM_TRANSPORT_WITH_AF_MCTP', 1) |
Rashmica Gupta | 1ed5f7a | 2023-05-22 13:56:42 +1000 | [diff] [blame] | 134 | endif |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 135 | conf_data.set( |
| 136 | 'DEFAULT_SENSOR_UPDATER_INTERVAL', |
| 137 | get_option('default-sensor-update-interval'), |
| 138 | ) |
Gilbert Chen | eac61a4 | 2022-02-23 20:56:19 +0000 | [diff] [blame] | 139 | conf_data.set('SENSOR_POLLING_TIME', get_option('sensor-polling-time')) |
Manojkiran Eda | cfefc15 | 2024-02-08 05:35:51 +0530 | [diff] [blame] | 140 | |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 141 | configure_file(output: 'config.h', configuration: conf_data) |
Deepak Kodihalli | 3c275e1 | 2019-09-21 06:39:39 -0500 | [diff] [blame] | 142 | |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 143 | add_project_arguments( |
| 144 | '-include', |
| 145 | '@0@'.format(meson.current_build_dir() / 'config.h'), |
| 146 | language: 'cpp', |
| 147 | ) |
Andrew Jeffery | 4779227 | 2023-06-13 17:15:09 +0930 | [diff] [blame] | 148 | |
Manojkiran Eda | fc81a43 | 2023-07-27 05:51:12 +0530 | [diff] [blame] | 149 | filesystem = import('fs') |
Patrick Williams | 3b1dc01 | 2021-04-16 21:51:47 -0500 | [diff] [blame] | 150 | |
Manojkiran Eda | b69d8bf | 2022-09-28 01:11:31 +0530 | [diff] [blame] | 151 | phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces') |
| 152 | sdbusplus = dependency('sdbusplus') |
| 153 | sdeventplus = dependency('sdeventplus') |
| 154 | stdplus = dependency('stdplus') |
Riya Dixit | 49cfb13 | 2023-03-02 04:26:53 -0600 | [diff] [blame] | 155 | phosphor_logging_dep = dependency('phosphor-logging') |
Patrick Williams | 5c7253a | 2022-03-21 10:52:01 -0500 | [diff] [blame] | 156 | |
Patrick Williams | cf77284 | 2023-12-07 14:39:52 -0600 | [diff] [blame] | 157 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
Patrick Williams | 5c7253a | 2022-03-21 10:52:01 -0500 | [diff] [blame] | 158 | |
Manojkiran Eda | b69d8bf | 2022-09-28 01:11:31 +0530 | [diff] [blame] | 159 | if cpp.has_header('CLI/CLI.hpp') |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 160 | CLI11_dep = declare_dependency() |
Manojkiran Eda | b69d8bf | 2022-09-28 01:11:31 +0530 | [diff] [blame] | 161 | else |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 162 | CLI11_dep = dependency('CLI11') |
Manojkiran Eda | b69d8bf | 2022-09-28 01:11:31 +0530 | [diff] [blame] | 163 | endif |
Patrick Williams | 3b1dc01 | 2021-04-16 21:51:47 -0500 | [diff] [blame] | 164 | |
Patrick Williams | 87bfacd | 2023-11-29 06:44:36 -0600 | [diff] [blame] | 165 | if get_option('tests').allowed() |
Tom Joseph | 5327988 | 2021-04-28 06:29:13 -0700 | [diff] [blame] | 166 | gtest = dependency('gtest', main: true, disabler: true, required: false) |
| 167 | gmock = dependency('gmock', disabler: true, required: false) |
| 168 | if not gtest.found() or not gmock.found() |
| 169 | gtest_proj = import('cmake').subproject('googletest', required: false) |
| 170 | if gtest_proj.found() |
| 171 | gtest = declare_dependency( |
| 172 | dependencies: [ |
| 173 | dependency('threads'), |
| 174 | gtest_proj.dependency('gtest'), |
| 175 | gtest_proj.dependency('gtest_main'), |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 176 | ], |
Tom Joseph | 5327988 | 2021-04-28 06:29:13 -0700 | [diff] [blame] | 177 | ) |
| 178 | gmock = gtest_proj.dependency('gmock') |
| 179 | else |
| 180 | assert( |
Patrick Williams | 87bfacd | 2023-11-29 06:44:36 -0600 | [diff] [blame] | 181 | not get_option('tests').allowed(), |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 182 | 'Googletest is required if tests are enabled', |
Tom Joseph | 5327988 | 2021-04-28 06:29:13 -0700 | [diff] [blame] | 183 | ) |
| 184 | endif |
| 185 | endif |
| 186 | endif |
Patrick Williams | 3b1dc01 | 2021-04-16 21:51:47 -0500 | [diff] [blame] | 187 | |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 188 | libpldm_dep = dependency( |
| 189 | 'libpldm', |
| 190 | fallback: ['libpldm', 'libpldm_dep'], |
| 191 | include_type: 'system', |
| 192 | ) |
George Liu | ab437e5 | 2020-01-19 17:12:19 +0800 | [diff] [blame] | 193 | |
Lei YU | 31fc47e | 2020-02-27 11:41:45 +0800 | [diff] [blame] | 194 | |
George Liu | ab437e5 | 2020-01-19 17:12:19 +0800 | [diff] [blame] | 195 | libpldmutils_headers = ['.'] |
| 196 | libpldmutils = library( |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 197 | 'pldmutils', |
| 198 | 'common/transport.cpp', |
| 199 | 'common/utils.cpp', |
| 200 | version: meson.project_version(), |
| 201 | dependencies: [ |
| 202 | libpldm_dep, |
| 203 | phosphor_dbus_interfaces, |
| 204 | phosphor_logging_dep, |
| 205 | nlohmann_json_dep, |
| 206 | sdbusplus, |
| 207 | ], |
| 208 | install: true, |
| 209 | include_directories: include_directories(libpldmutils_headers), |
George Liu | ab437e5 | 2020-01-19 17:12:19 +0800 | [diff] [blame] | 210 | ) |
| 211 | |
| 212 | libpldmutils = declare_dependency( |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 213 | include_directories: include_directories(libpldmutils_headers), |
| 214 | link_with: libpldmutils, |
| 215 | ) |
Deepak Kodihalli | 3c275e1 | 2019-09-21 06:39:39 -0500 | [diff] [blame] | 216 | |
| 217 | deps = [ |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 218 | libpldm_dep, |
| 219 | libpldmutils, |
| 220 | nlohmann_json_dep, |
| 221 | phosphor_dbus_interfaces, |
| 222 | phosphor_logging_dep, |
| 223 | sdbusplus, |
| 224 | sdeventplus, |
| 225 | stdplus, |
Deepak Kodihalli | 3c275e1 | 2019-09-21 06:39:39 -0500 | [diff] [blame] | 226 | ] |
| 227 | |
Patrick Williams | 87bfacd | 2023-11-29 06:44:36 -0600 | [diff] [blame] | 228 | if get_option('libpldmresponder').allowed() |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 229 | subdir('libpldmresponder') |
| 230 | deps += [libpldmresponder_dep] |
Tom Joseph | 02b4ee4 | 2021-05-02 22:44:36 -0700 | [diff] [blame] | 231 | endif |
| 232 | |
Deepak Kodihalli | 3c275e1 | 2019-09-21 06:39:39 -0500 | [diff] [blame] | 233 | executable( |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 234 | 'pldmd', |
| 235 | 'pldmd/pldmd.cpp', |
| 236 | 'pldmd/dbus_impl_pdr.cpp', |
| 237 | 'fw-update/activation.cpp', |
| 238 | 'fw-update/inventory_manager.cpp', |
| 239 | 'fw-update/package_parser.cpp', |
| 240 | 'fw-update/device_updater.cpp', |
| 241 | 'fw-update/watch.cpp', |
| 242 | 'fw-update/update_manager.cpp', |
| 243 | 'platform-mc/terminus_manager.cpp', |
| 244 | 'platform-mc/terminus.cpp', |
| 245 | 'platform-mc/platform_manager.cpp', |
| 246 | 'platform-mc/manager.cpp', |
| 247 | 'platform-mc/sensor_manager.cpp', |
| 248 | 'platform-mc/numeric_sensor.cpp', |
| 249 | 'requester/mctp_endpoint_discovery.cpp', |
| 250 | implicit_include_directories: false, |
| 251 | dependencies: deps, |
| 252 | install: true, |
| 253 | install_dir: get_option('bindir'), |
| 254 | ) |
Deepak Kodihalli | 3c275e1 | 2019-09-21 06:39:39 -0500 | [diff] [blame] | 255 | |
Patrick Williams | 87bfacd | 2023-11-29 06:44:36 -0600 | [diff] [blame] | 256 | if get_option('systemd').allowed() |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 257 | systemd_system_unit_dir = dependency('systemd').get_variable( |
| 258 | 'systemdsystemunitdir', |
| 259 | ) |
| 260 | filesystem.copyfile( |
| 261 | 'pldmd/service_files/pldmd.service', |
| 262 | 'pldmd.service', |
| 263 | install: true, |
| 264 | install_dir: systemd_system_unit_dir, |
| 265 | ) |
Deepak Kodihalli | 6935cf6 | 2020-06-15 23:38:27 -0500 | [diff] [blame] | 266 | |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 267 | if get_option('oem-ibm').allowed() |
| 268 | subdir('oem/ibm/service_files') |
| 269 | endif |
Manojkiran Eda | fec5d59 | 2021-01-21 12:27:34 +0530 | [diff] [blame] | 270 | endif |
| 271 | |
Deepak Kodihalli | f7f5da9 | 2020-06-17 05:56:10 -0500 | [diff] [blame] | 272 | subdir('pldmtool') |
George Liu | ab437e5 | 2020-01-19 17:12:19 +0800 | [diff] [blame] | 273 | |
Deepak Kodihalli | 6e51e37 | 2020-06-19 03:49:07 -0500 | [diff] [blame] | 274 | subdir('configurations') |
| 275 | |
Patrick Williams | 87bfacd | 2023-11-29 06:44:36 -0600 | [diff] [blame] | 276 | if get_option('utilities').allowed() |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 277 | subdir('utilities') |
Deepak Kodihalli | 9d494bb | 2019-11-05 01:28:43 -0600 | [diff] [blame] | 278 | endif |
Lei YU | 31fc47e | 2020-02-27 11:41:45 +0800 | [diff] [blame] | 279 | |
Patrick Williams | 87bfacd | 2023-11-29 06:44:36 -0600 | [diff] [blame] | 280 | if get_option('softoff').allowed() |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 281 | subdir('softoff') |
George Liu | 4c1a3fd | 2020-03-10 08:25:21 +0800 | [diff] [blame] | 282 | endif |
| 283 | |
Patrick Williams | 87bfacd | 2023-11-29 06:44:36 -0600 | [diff] [blame] | 284 | if get_option('tests').allowed() |
Manojkiran Eda | 3012b63 | 2024-08-22 11:09:01 +0530 | [diff] [blame] | 285 | subdir('common/test') |
| 286 | subdir('fw-update/test') |
| 287 | subdir('host-bmc/test') |
| 288 | subdir('requester/test') |
| 289 | subdir('platform-mc/test') |
| 290 | subdir('test') |
Tom Joseph | 5327988 | 2021-04-28 06:29:13 -0700 | [diff] [blame] | 291 | endif |