blob: 945886f54929640565554056e3b41bb708f00398 [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
Patrick Williams87bfacd2023-11-29 06:44:36 -060046if get_option('libpldmresponder').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +053047 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 )
Manojkiran Eda3012b632024-08-22 11:09:01 +053071 conf_data.set('TERMINUS_ID', get_option('terminus-id'))
72 conf_data.set('TERMINUS_HANDLE', get_option('terminus-handle'))
Manojkiran Eda0ff34352024-08-22 19:39:32 +053073 add_project_arguments('-DLIBPLDMRESPONDER', language: 'cpp')
Tom Joseph02b4ee42021-05-02 22:44:36 -070074endif
P Arun Kumar Reddy3b90f7c2025-04-11 11:03:14 +053075conf_data.set('HEARTBEAT_TIMEOUT', get_option('heartbeat-timeout-seconds'))
76conf_data.set('DBUS_TIMEOUT', get_option('dbus-timeout-value'))
Patrick Williams87bfacd2023-11-29 06:44:36 -060077if get_option('softoff').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +053078 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 Liuab865f62020-03-10 09:12:52 +080086endif
Patrick Williams87bfacd2023-11-29 06:44:36 -060087if get_option('oem-ibm').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +053088 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 Eda0ff34352024-08-22 19:39:32 +0530113 add_project_arguments('-DOEM_IBM', language: 'cpp')
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500114endif
Manojkiran Eda3012b632024-08-22 11:09:01 +0530115conf_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)
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530128conf_data.set_quoted('HOST_EID_PATH', join_paths(package_datadir, 'host_eid'))
Tom Josephef90b0d2021-08-17 07:12:49 -0700129conf_data.set('MAXIMUM_TRANSFER_SIZE', get_option('maximum-transfer-size'))
Rashmica Gupta1ed5f7a2023-05-22 13:56:42 +1000130if get_option('transport-implementation') == 'mctp-demux'
Manojkiran Eda3012b632024-08-22 11:09:01 +0530131 conf_data.set('PLDM_TRANSPORT_WITH_MCTP_DEMUX', 1)
Rashmica Gupta1ed5f7a2023-05-22 13:56:42 +1000132elif get_option('transport-implementation') == 'af-mctp'
Manojkiran Eda3012b632024-08-22 11:09:01 +0530133 conf_data.set('PLDM_TRANSPORT_WITH_AF_MCTP', 1)
Rashmica Gupta1ed5f7a2023-05-22 13:56:42 +1000134endif
Manojkiran Eda3012b632024-08-22 11:09:01 +0530135conf_data.set(
136 'DEFAULT_SENSOR_UPDATER_INTERVAL',
137 get_option('default-sensor-update-interval'),
138)
Gilbert Cheneac61a42022-02-23 20:56:19 +0000139conf_data.set('SENSOR_POLLING_TIME', get_option('sensor-polling-time'))
P Arun Kumar Reddy6fa09e92025-04-25 11:24:06 +0530140conf_data.set('UPDATE_TIMEOUT_SECONDS', get_option('update-timeout-seconds'))
Manojkiran Edacfefc152024-02-08 05:35:51 +0530141
Manojkiran Eda3012b632024-08-22 11:09:01 +0530142configure_file(output: 'config.h', configuration: conf_data)
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500143
Manojkiran Eda3012b632024-08-22 11:09:01 +0530144add_project_arguments(
145 '-include',
146 '@0@'.format(meson.current_build_dir() / 'config.h'),
147 language: 'cpp',
148)
Andrew Jeffery47792272023-06-13 17:15:09 +0930149
Manojkiran Edafc81a432023-07-27 05:51:12 +0530150filesystem = import('fs')
Patrick Williams3b1dc012021-04-16 21:51:47 -0500151
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530152phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
153sdbusplus = dependency('sdbusplus')
154sdeventplus = dependency('sdeventplus')
155stdplus = dependency('stdplus')
Riya Dixit49cfb132023-03-02 04:26:53 -0600156phosphor_logging_dep = dependency('phosphor-logging')
Patrick Williams5c7253a2022-03-21 10:52:01 -0500157
Patrick Williamscf772842023-12-07 14:39:52 -0600158nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Patrick Williams5c7253a2022-03-21 10:52:01 -0500159
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530160if cpp.has_header('CLI/CLI.hpp')
Manojkiran Eda3012b632024-08-22 11:09:01 +0530161 CLI11_dep = declare_dependency()
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530162else
Manojkiran Eda3012b632024-08-22 11:09:01 +0530163 CLI11_dep = dependency('CLI11')
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530164endif
Patrick Williams3b1dc012021-04-16 21:51:47 -0500165
Patrick Williams87bfacd2023-11-29 06:44:36 -0600166if get_option('tests').allowed()
Tom Joseph53279882021-04-28 06:29:13 -0700167 gtest = dependency('gtest', main: true, disabler: true, required: false)
168 gmock = dependency('gmock', disabler: true, required: false)
169 if not gtest.found() or not gmock.found()
170 gtest_proj = import('cmake').subproject('googletest', required: false)
171 if gtest_proj.found()
172 gtest = declare_dependency(
173 dependencies: [
174 dependency('threads'),
175 gtest_proj.dependency('gtest'),
176 gtest_proj.dependency('gtest_main'),
Manojkiran Eda3012b632024-08-22 11:09:01 +0530177 ],
Tom Joseph53279882021-04-28 06:29:13 -0700178 )
179 gmock = gtest_proj.dependency('gmock')
180 else
181 assert(
Patrick Williams87bfacd2023-11-29 06:44:36 -0600182 not get_option('tests').allowed(),
Manojkiran Eda3012b632024-08-22 11:09:01 +0530183 'Googletest is required if tests are enabled',
Tom Joseph53279882021-04-28 06:29:13 -0700184 )
185 endif
186 endif
187endif
Patrick Williams3b1dc012021-04-16 21:51:47 -0500188
Manojkiran Eda3012b632024-08-22 11:09:01 +0530189libpldm_dep = dependency(
190 'libpldm',
191 fallback: ['libpldm', 'libpldm_dep'],
192 include_type: 'system',
193)
George Liuab437e52020-01-19 17:12:19 +0800194
Patrick Williamsdc8b0822025-01-30 17:47:44 -0500195if get_option('oem-ampere').allowed()
Patrick Williams9b402602025-02-01 08:37:20 -0500196 add_project_arguments('-DOEM_AMPERE', language: 'cpp')
Dung Cao72c8aa02023-11-22 02:31:41 +0000197endif
Lei YU31fc47e2020-02-27 11:41:45 +0800198
George Liuab437e52020-01-19 17:12:19 +0800199libpldmutils_headers = ['.']
200libpldmutils = library(
Manojkiran Eda3012b632024-08-22 11:09:01 +0530201 'pldmutils',
202 'common/transport.cpp',
203 'common/utils.cpp',
204 version: meson.project_version(),
205 dependencies: [
206 libpldm_dep,
207 phosphor_dbus_interfaces,
208 phosphor_logging_dep,
209 nlohmann_json_dep,
210 sdbusplus,
211 ],
212 install: true,
213 include_directories: include_directories(libpldmutils_headers),
George Liuab437e52020-01-19 17:12:19 +0800214)
215
216libpldmutils = declare_dependency(
Manojkiran Eda3012b632024-08-22 11:09:01 +0530217 include_directories: include_directories(libpldmutils_headers),
218 link_with: libpldmutils,
219)
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500220
221deps = [
Manojkiran Eda3012b632024-08-22 11:09:01 +0530222 libpldm_dep,
223 libpldmutils,
224 nlohmann_json_dep,
225 phosphor_dbus_interfaces,
226 phosphor_logging_dep,
227 sdbusplus,
228 sdeventplus,
229 stdplus,
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500230]
231
Dung Cao72c8aa02023-11-22 02:31:41 +0000232oem_files = []
Patrick Williamsdc8b0822025-01-30 17:47:44 -0500233if get_option('oem-ampere').allowed()
Dung Cao72c8aa02023-11-22 02:31:41 +0000234 subdir('oem/ampere')
235endif
236
Patrick Williams87bfacd2023-11-29 06:44:36 -0600237if get_option('libpldmresponder').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530238 subdir('libpldmresponder')
239 deps += [libpldmresponder_dep]
Tom Joseph02b4ee42021-05-02 22:44:36 -0700240endif
241
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500242executable(
Manojkiran Eda3012b632024-08-22 11:09:01 +0530243 'pldmd',
244 'pldmd/pldmd.cpp',
245 'pldmd/dbus_impl_pdr.cpp',
246 'fw-update/activation.cpp',
247 'fw-update/inventory_manager.cpp',
248 'fw-update/package_parser.cpp',
249 'fw-update/device_updater.cpp',
250 'fw-update/watch.cpp',
251 'fw-update/update_manager.cpp',
Dung Caob6d39432024-06-05 03:46:47 +0000252 'platform-mc/dbus_impl_fru.cpp',
Manojkiran Eda3012b632024-08-22 11:09:01 +0530253 'platform-mc/terminus_manager.cpp',
254 'platform-mc/terminus.cpp',
255 'platform-mc/platform_manager.cpp',
256 'platform-mc/manager.cpp',
257 'platform-mc/sensor_manager.cpp',
258 'platform-mc/numeric_sensor.cpp',
Gilbert Chen77e6fe72024-08-06 09:23:30 +0000259 'platform-mc/event_manager.cpp',
Manojkiran Edadd1f28b2025-03-12 09:55:11 +0530260 'platform-mc/dbus_to_terminus_effecters.cpp',
Chau Lya743e382024-10-26 11:12:22 +0000261 oem_files,
Manojkiran Eda3012b632024-08-22 11:09:01 +0530262 'requester/mctp_endpoint_discovery.cpp',
263 implicit_include_directories: false,
264 dependencies: deps,
265 install: true,
266 install_dir: get_option('bindir'),
267)
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500268
Patrick Williams87bfacd2023-11-29 06:44:36 -0600269if get_option('systemd').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530270 systemd_system_unit_dir = dependency('systemd').get_variable(
271 'systemdsystemunitdir',
272 )
273 filesystem.copyfile(
274 'pldmd/service_files/pldmd.service',
275 'pldmd.service',
276 install: true,
277 install_dir: systemd_system_unit_dir,
278 )
Deepak Kodihalli6935cf62020-06-15 23:38:27 -0500279
Manojkiran Eda3012b632024-08-22 11:09:01 +0530280 if get_option('oem-ibm').allowed()
281 subdir('oem/ibm/service_files')
282 endif
Manojkiran Edafec5d592021-01-21 12:27:34 +0530283endif
284
Deepak Kodihallif7f5da92020-06-17 05:56:10 -0500285subdir('pldmtool')
George Liuab437e52020-01-19 17:12:19 +0800286
Deepak Kodihalli6e51e372020-06-19 03:49:07 -0500287subdir('configurations')
288
Patrick Williams87bfacd2023-11-29 06:44:36 -0600289if get_option('utilities').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530290 subdir('utilities')
Deepak Kodihalli9d494bb2019-11-05 01:28:43 -0600291endif
Lei YU31fc47e2020-02-27 11:41:45 +0800292
Patrick Williams87bfacd2023-11-29 06:44:36 -0600293if get_option('softoff').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530294 subdir('softoff')
George Liu4c1a3fd2020-03-10 08:25:21 +0800295endif
296
Patrick Williams87bfacd2023-11-29 06:44:36 -0600297if get_option('tests').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530298 subdir('common/test')
299 subdir('fw-update/test')
300 subdir('host-bmc/test')
301 subdir('requester/test')
302 subdir('platform-mc/test')
303 subdir('test')
Tom Joseph53279882021-04-28 06:29:13 -0700304endif