blob: 9b5b00be17640e64b2ed9523dde0c264bc00702e [file] [log] [blame]
Manojkiran Eda3012b632024-08-22 11:09:01 +05301project(
2 'pldm',
Manojkiran Eda0ff34352024-08-22 19:39:32 +05303 'cpp',
Manojkiran Eda3012b632024-08-22 11:09:01 +05304 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 Kodihalli3c275e12019-09-21 06:39:39 -050014
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
Manojkiran Eda38ce97c2021-02-14 12:15:17 +053021
22# Disable FORTIFY_SOURCE when compiling with no optimization
Manojkiran Eda3012b632024-08-22 11:09:01 +053023if (get_option('optimization') == '0')
Manojkiran Eda0ff34352024-08-22 19:39:32 +053024 add_project_arguments('-U_FORTIFY_SOURCE', language: 'cpp')
Manojkiran Eda3012b632024-08-22 11:09:01 +053025 message('Disabling FORTIFY_SOURCE as optimization is set to 0')
Manojkiran Eda38ce97c2021-02-14 12:15:17 +053026endif
27
Manojkiran Eda3012b632024-08-22 11:09:01 +053028package_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)
Brad Bishop06052cc2021-08-16 15:17:16 -040038
Deepak Kodihalli3c275e12019-09-21 06:39:39 -050039conf_data = configuration_data()
Rashmica Gupta1ed5f7a2023-05-22 13:56:42 +100040cpp = 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
Thu Nguyen6d0d9c72025-08-26 10:18:04 +000046
47conf_data.set_quoted('HOST_JSONS_DIR', join_paths(package_datadir, 'host'))
48
Patrick Williams87bfacd2023-11-29 06:44:36 -060049if get_option('libpldmresponder').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +053050 conf_data.set_quoted('BIOS_JSONS_DIR', join_paths(package_datadir, 'bios'))
51 conf_data.set(
52 'SYSTEM_SPECIFIC_BIOS_JSON',
53 get_option('system-specific-bios-json').allowed(),
54 )
55 conf_data.set_quoted(
56 'BIOS_TABLES_DIR',
57 join_paths(package_localstatedir, 'bios'),
58 )
59 conf_data.set_quoted('PDR_JSONS_DIR', join_paths(package_datadir, 'pdr'))
60 conf_data.set_quoted('FRU_JSONS_DIR', join_paths(package_datadir, 'fru'))
61 conf_data.set_quoted(
62 'FRU_MASTER_JSON',
63 join_paths(package_datadir, 'fru_master.json'),
64 )
65 conf_data.set_quoted(
66 'ENTITY_MAP_JSON',
67 join_paths(package_datadir, 'entityMap.json'),
68 )
Thu Nguyen6d0d9c72025-08-26 10:18:04 +000069
Manojkiran Eda3012b632024-08-22 11:09:01 +053070 conf_data.set_quoted(
71 'EVENTS_JSONS_DIR',
72 join_paths(package_datadir, 'events'),
73 )
Manojkiran Eda3012b632024-08-22 11:09:01 +053074 conf_data.set('TERMINUS_ID', get_option('terminus-id'))
75 conf_data.set('TERMINUS_HANDLE', get_option('terminus-handle'))
Manojkiran Eda0ff34352024-08-22 19:39:32 +053076 add_project_arguments('-DLIBPLDMRESPONDER', language: 'cpp')
Tom Joseph02b4ee42021-05-02 22:44:36 -070077endif
P Arun Kumar Reddy3b90f7c2025-04-11 11:03:14 +053078conf_data.set('HEARTBEAT_TIMEOUT', get_option('heartbeat-timeout-seconds'))
79conf_data.set('DBUS_TIMEOUT', get_option('dbus-timeout-value'))
Patrick Williams87bfacd2023-11-29 06:44:36 -060080if get_option('softoff').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +053081 conf_data.set(
82 'SOFTOFF_TIMEOUT_SECONDS',
83 get_option('softoff-timeout-seconds'),
84 )
85 conf_data.set_quoted(
86 'SOFTOFF_CONFIG_JSON',
87 join_paths(package_datadir, 'softoff'),
88 )
George Liuab865f62020-03-10 09:12:52 +080089endif
Patrick Williams87bfacd2023-11-29 06:44:36 -060090if get_option('oem-ibm').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +053091 conf_data.set_quoted(
92 'FILE_TABLE_JSON',
93 join_paths(package_datadir, 'fileTable.json'),
94 )
95 conf_data.set_quoted(
96 'LID_RUNNING_DIR',
97 '/var/lib/phosphor-software-manager/hostfw/running',
98 )
99 conf_data.set_quoted(
100 'LID_ALTERNATE_DIR',
101 '/var/lib/phosphor-software-manager/hostfw/alternate',
102 )
103 conf_data.set_quoted(
104 'LID_STAGING_DIR',
105 '/var/lib/phosphor-software-manager/hostfw/staging',
106 )
107 conf_data.set_quoted(
108 'LID_RUNNING_PATCH_DIR',
109 '/usr/local/share/hostfw/running',
110 )
111 conf_data.set_quoted(
112 'LID_ALTERNATE_PATCH_DIR',
113 '/usr/local/share/hostfw/alternate',
114 )
115 conf_data.set('DMA_MAXSIZE', get_option('oem-ibm-dma-maxsize'))
Manojkiran Eda0ff34352024-08-22 19:39:32 +0530116 add_project_arguments('-DOEM_IBM', language: 'cpp')
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500117endif
Manojkiran Eda3012b632024-08-22 11:09:01 +0530118conf_data.set(
119 'NUMBER_OF_REQUEST_RETRIES',
120 get_option('number-of-request-retries'),
121)
122conf_data.set(
123 'INSTANCE_ID_EXPIRATION_INTERVAL',
124 get_option('instance-id-expiration-interval'),
125)
126conf_data.set('RESPONSE_TIME_OUT', get_option('response-time-out'))
127conf_data.set(
128 'FLIGHT_RECORDER_MAX_ENTRIES',
129 get_option('flightrecorder-max-entries'),
130)
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530131conf_data.set_quoted('HOST_EID_PATH', join_paths(package_datadir, 'host_eid'))
Tom Josephef90b0d2021-08-17 07:12:49 -0700132conf_data.set('MAXIMUM_TRANSFER_SIZE', get_option('maximum-transfer-size'))
Rashmica Gupta1ed5f7a2023-05-22 13:56:42 +1000133if get_option('transport-implementation') == 'mctp-demux'
Manojkiran Eda3012b632024-08-22 11:09:01 +0530134 conf_data.set('PLDM_TRANSPORT_WITH_MCTP_DEMUX', 1)
Rashmica Gupta1ed5f7a2023-05-22 13:56:42 +1000135elif get_option('transport-implementation') == 'af-mctp'
Manojkiran Eda3012b632024-08-22 11:09:01 +0530136 conf_data.set('PLDM_TRANSPORT_WITH_AF_MCTP', 1)
Rashmica Gupta1ed5f7a2023-05-22 13:56:42 +1000137endif
Manojkiran Eda3012b632024-08-22 11:09:01 +0530138conf_data.set(
139 'DEFAULT_SENSOR_UPDATER_INTERVAL',
140 get_option('default-sensor-update-interval'),
141)
Gilbert Cheneac61a42022-02-23 20:56:19 +0000142conf_data.set('SENSOR_POLLING_TIME', get_option('sensor-polling-time'))
P Arun Kumar Reddy6fa09e92025-04-25 11:24:06 +0530143conf_data.set('UPDATE_TIMEOUT_SECONDS', get_option('update-timeout-seconds'))
Manojkiran Edacfefc152024-02-08 05:35:51 +0530144
P Arun Kumar Reddy6a3f9902025-03-26 10:23:06 +0530145# Firmware update inotify option
146if get_option('fw-update-pkg-inotify').allowed()
147 conf_data.set('FW_UPDATE_INOTIFY_ENABLED', 1)
148endif
149
Manojkiran Eda3012b632024-08-22 11:09:01 +0530150configure_file(output: 'config.h', configuration: conf_data)
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500151
Manojkiran Eda3012b632024-08-22 11:09:01 +0530152add_project_arguments(
153 '-include',
154 '@0@'.format(meson.current_build_dir() / 'config.h'),
155 language: 'cpp',
156)
Andrew Jeffery47792272023-06-13 17:15:09 +0930157
Manojkiran Edafc81a432023-07-27 05:51:12 +0530158filesystem = import('fs')
Patrick Williams3b1dc012021-04-16 21:51:47 -0500159
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530160phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
161sdbusplus = dependency('sdbusplus')
162sdeventplus = dependency('sdeventplus')
163stdplus = dependency('stdplus')
Riya Dixit49cfb132023-03-02 04:26:53 -0600164phosphor_logging_dep = dependency('phosphor-logging')
Patrick Williams5c7253a2022-03-21 10:52:01 -0500165
Patrick Williamscf772842023-12-07 14:39:52 -0600166nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Patrick Williams5c7253a2022-03-21 10:52:01 -0500167
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530168if cpp.has_header('CLI/CLI.hpp')
Manojkiran Eda3012b632024-08-22 11:09:01 +0530169 CLI11_dep = declare_dependency()
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530170else
Manojkiran Eda3012b632024-08-22 11:09:01 +0530171 CLI11_dep = dependency('CLI11')
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530172endif
Patrick Williams3b1dc012021-04-16 21:51:47 -0500173
Patrick Williams87bfacd2023-11-29 06:44:36 -0600174if get_option('tests').allowed()
Tom Joseph53279882021-04-28 06:29:13 -0700175 gtest = dependency('gtest', main: true, disabler: true, required: false)
176 gmock = dependency('gmock', disabler: true, required: false)
177 if not gtest.found() or not gmock.found()
178 gtest_proj = import('cmake').subproject('googletest', required: false)
179 if gtest_proj.found()
180 gtest = declare_dependency(
181 dependencies: [
182 dependency('threads'),
183 gtest_proj.dependency('gtest'),
184 gtest_proj.dependency('gtest_main'),
Manojkiran Eda3012b632024-08-22 11:09:01 +0530185 ],
Tom Joseph53279882021-04-28 06:29:13 -0700186 )
187 gmock = gtest_proj.dependency('gmock')
188 else
189 assert(
Patrick Williams87bfacd2023-11-29 06:44:36 -0600190 not get_option('tests').allowed(),
Manojkiran Eda3012b632024-08-22 11:09:01 +0530191 'Googletest is required if tests are enabled',
Tom Joseph53279882021-04-28 06:29:13 -0700192 )
193 endif
194 endif
195endif
Patrick Williams3b1dc012021-04-16 21:51:47 -0500196
Manojkiran Eda3012b632024-08-22 11:09:01 +0530197libpldm_dep = dependency(
198 'libpldm',
199 fallback: ['libpldm', 'libpldm_dep'],
200 include_type: 'system',
201)
George Liuab437e52020-01-19 17:12:19 +0800202
Patrick Williamsdc8b0822025-01-30 17:47:44 -0500203if get_option('oem-ampere').allowed()
Patrick Williams9b402602025-02-01 08:37:20 -0500204 add_project_arguments('-DOEM_AMPERE', language: 'cpp')
Dung Cao72c8aa02023-11-22 02:31:41 +0000205endif
Lei YU31fc47e2020-02-27 11:41:45 +0800206
George Liuab437e52020-01-19 17:12:19 +0800207libpldmutils_headers = ['.']
208libpldmutils = library(
Manojkiran Eda3012b632024-08-22 11:09:01 +0530209 'pldmutils',
210 'common/transport.cpp',
211 'common/utils.cpp',
212 version: meson.project_version(),
213 dependencies: [
214 libpldm_dep,
215 phosphor_dbus_interfaces,
216 phosphor_logging_dep,
217 nlohmann_json_dep,
218 sdbusplus,
219 ],
220 install: true,
221 include_directories: include_directories(libpldmutils_headers),
George Liuab437e52020-01-19 17:12:19 +0800222)
223
224libpldmutils = declare_dependency(
Manojkiran Eda3012b632024-08-22 11:09:01 +0530225 include_directories: include_directories(libpldmutils_headers),
226 link_with: libpldmutils,
227)
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500228
229deps = [
Manojkiran Eda3012b632024-08-22 11:09:01 +0530230 libpldm_dep,
231 libpldmutils,
232 nlohmann_json_dep,
233 phosphor_dbus_interfaces,
234 phosphor_logging_dep,
235 sdbusplus,
236 sdeventplus,
237 stdplus,
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500238]
239
Dung Cao72c8aa02023-11-22 02:31:41 +0000240oem_files = []
Patrick Williamsdc8b0822025-01-30 17:47:44 -0500241if get_option('oem-ampere').allowed()
Dung Cao72c8aa02023-11-22 02:31:41 +0000242 subdir('oem/ampere')
243endif
244
Patrick Williams87bfacd2023-11-29 06:44:36 -0600245if get_option('libpldmresponder').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530246 subdir('libpldmresponder')
247 deps += [libpldmresponder_dep]
Tom Joseph02b4ee42021-05-02 22:44:36 -0700248endif
249
P Arun Kumar Reddy6a3f9902025-03-26 10:23:06 +0530250fw_update_sources = [
Manojkiran Eda3012b632024-08-22 11:09:01 +0530251 'fw-update/activation.cpp',
252 'fw-update/inventory_manager.cpp',
Unive Tien7ad45b42025-08-18 06:04:53 +0000253 'fw-update/firmware_inventory_manager.cpp',
254 'fw-update/firmware_inventory.cpp',
Manojkiran Eda3012b632024-08-22 11:09:01 +0530255 'fw-update/package_parser.cpp',
256 'fw-update/device_updater.cpp',
Manojkiran Eda3012b632024-08-22 11:09:01 +0530257 'fw-update/update_manager.cpp',
P Arun Kumar Reddy6a3f9902025-03-26 10:23:06 +0530258 'fw-update/update.cpp',
259]
260
261if get_option('fw-update-pkg-inotify').allowed()
262 fw_update_sources += 'fw-update/watch.cpp'
263endif
264
265executable(
266 'pldmd',
267 'pldmd/pldmd.cpp',
268 'pldmd/dbus_impl_pdr.cpp',
269 fw_update_sources,
Dung Caob6d39432024-06-05 03:46:47 +0000270 'platform-mc/dbus_impl_fru.cpp',
Manojkiran Eda3012b632024-08-22 11:09:01 +0530271 'platform-mc/terminus_manager.cpp',
272 'platform-mc/terminus.cpp',
273 'platform-mc/platform_manager.cpp',
274 'platform-mc/manager.cpp',
275 'platform-mc/sensor_manager.cpp',
276 'platform-mc/numeric_sensor.cpp',
Gilbert Chen77e6fe72024-08-06 09:23:30 +0000277 'platform-mc/event_manager.cpp',
Manojkiran Edadd1f28b2025-03-12 09:55:11 +0530278 'platform-mc/dbus_to_terminus_effecters.cpp',
Chau Lya743e382024-10-26 11:12:22 +0000279 oem_files,
Manojkiran Eda3012b632024-08-22 11:09:01 +0530280 'requester/mctp_endpoint_discovery.cpp',
281 implicit_include_directories: false,
282 dependencies: deps,
283 install: true,
284 install_dir: get_option('bindir'),
285)
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500286
Patrick Williams87bfacd2023-11-29 06:44:36 -0600287if get_option('systemd').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530288 systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williams42053e62025-07-09 11:27:14 -0400289 'systemd_system_unit_dir',
Manojkiran Eda3012b632024-08-22 11:09:01 +0530290 )
291 filesystem.copyfile(
292 'pldmd/service_files/pldmd.service',
293 'pldmd.service',
294 install: true,
295 install_dir: systemd_system_unit_dir,
296 )
Deepak Kodihalli6935cf62020-06-15 23:38:27 -0500297
Manojkiran Eda3012b632024-08-22 11:09:01 +0530298 if get_option('oem-ibm').allowed()
299 subdir('oem/ibm/service_files')
300 endif
Manojkiran Edafec5d592021-01-21 12:27:34 +0530301endif
302
Deepak Kodihallif7f5da92020-06-17 05:56:10 -0500303subdir('pldmtool')
George Liuab437e52020-01-19 17:12:19 +0800304
Deepak Kodihalli6e51e372020-06-19 03:49:07 -0500305subdir('configurations')
306
Patrick Williams87bfacd2023-11-29 06:44:36 -0600307if get_option('utilities').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530308 subdir('utilities')
Deepak Kodihalli9d494bb2019-11-05 01:28:43 -0600309endif
Lei YU31fc47e2020-02-27 11:41:45 +0800310
Patrick Williams87bfacd2023-11-29 06:44:36 -0600311if get_option('softoff').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530312 subdir('softoff')
George Liu4c1a3fd2020-03-10 08:25:21 +0800313endif
314
Patrick Williams87bfacd2023-11-29 06:44:36 -0600315if get_option('tests').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530316 subdir('common/test')
317 subdir('fw-update/test')
318 subdir('host-bmc/test')
319 subdir('requester/test')
320 subdir('platform-mc/test')
321 subdir('test')
Tom Joseph53279882021-04-28 06:29:13 -0700322endif