blob: ddf9efcb1f0710f72ccda686b5404fc04472b577 [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
Manojkiran Eda3012b632024-08-22 11:09:01 +0530145configure_file(output: 'config.h', configuration: conf_data)
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500146
Manojkiran Eda3012b632024-08-22 11:09:01 +0530147add_project_arguments(
148 '-include',
149 '@0@'.format(meson.current_build_dir() / 'config.h'),
150 language: 'cpp',
151)
Andrew Jeffery47792272023-06-13 17:15:09 +0930152
Manojkiran Edafc81a432023-07-27 05:51:12 +0530153filesystem = import('fs')
Patrick Williams3b1dc012021-04-16 21:51:47 -0500154
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530155phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
156sdbusplus = dependency('sdbusplus')
157sdeventplus = dependency('sdeventplus')
158stdplus = dependency('stdplus')
Riya Dixit49cfb132023-03-02 04:26:53 -0600159phosphor_logging_dep = dependency('phosphor-logging')
Patrick Williams5c7253a2022-03-21 10:52:01 -0500160
Patrick Williamscf772842023-12-07 14:39:52 -0600161nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Patrick Williams5c7253a2022-03-21 10:52:01 -0500162
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530163if cpp.has_header('CLI/CLI.hpp')
Manojkiran Eda3012b632024-08-22 11:09:01 +0530164 CLI11_dep = declare_dependency()
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530165else
Manojkiran Eda3012b632024-08-22 11:09:01 +0530166 CLI11_dep = dependency('CLI11')
Manojkiran Edab69d8bf2022-09-28 01:11:31 +0530167endif
Patrick Williams3b1dc012021-04-16 21:51:47 -0500168
Patrick Williams87bfacd2023-11-29 06:44:36 -0600169if get_option('tests').allowed()
Tom Joseph53279882021-04-28 06:29:13 -0700170 gtest = dependency('gtest', main: true, disabler: true, required: false)
171 gmock = dependency('gmock', disabler: true, required: false)
172 if not gtest.found() or not gmock.found()
173 gtest_proj = import('cmake').subproject('googletest', required: false)
174 if gtest_proj.found()
175 gtest = declare_dependency(
176 dependencies: [
177 dependency('threads'),
178 gtest_proj.dependency('gtest'),
179 gtest_proj.dependency('gtest_main'),
Manojkiran Eda3012b632024-08-22 11:09:01 +0530180 ],
Tom Joseph53279882021-04-28 06:29:13 -0700181 )
182 gmock = gtest_proj.dependency('gmock')
183 else
184 assert(
Patrick Williams87bfacd2023-11-29 06:44:36 -0600185 not get_option('tests').allowed(),
Manojkiran Eda3012b632024-08-22 11:09:01 +0530186 'Googletest is required if tests are enabled',
Tom Joseph53279882021-04-28 06:29:13 -0700187 )
188 endif
189 endif
190endif
Patrick Williams3b1dc012021-04-16 21:51:47 -0500191
Manojkiran Eda3012b632024-08-22 11:09:01 +0530192libpldm_dep = dependency(
193 'libpldm',
194 fallback: ['libpldm', 'libpldm_dep'],
195 include_type: 'system',
196)
George Liuab437e52020-01-19 17:12:19 +0800197
Patrick Williamsdc8b0822025-01-30 17:47:44 -0500198if get_option('oem-ampere').allowed()
Patrick Williams9b402602025-02-01 08:37:20 -0500199 add_project_arguments('-DOEM_AMPERE', language: 'cpp')
Dung Cao72c8aa02023-11-22 02:31:41 +0000200endif
Lei YU31fc47e2020-02-27 11:41:45 +0800201
George Liuab437e52020-01-19 17:12:19 +0800202libpldmutils_headers = ['.']
203libpldmutils = library(
Manojkiran Eda3012b632024-08-22 11:09:01 +0530204 'pldmutils',
205 'common/transport.cpp',
206 'common/utils.cpp',
207 version: meson.project_version(),
208 dependencies: [
209 libpldm_dep,
210 phosphor_dbus_interfaces,
211 phosphor_logging_dep,
212 nlohmann_json_dep,
213 sdbusplus,
214 ],
215 install: true,
216 include_directories: include_directories(libpldmutils_headers),
George Liuab437e52020-01-19 17:12:19 +0800217)
218
219libpldmutils = declare_dependency(
Manojkiran Eda3012b632024-08-22 11:09:01 +0530220 include_directories: include_directories(libpldmutils_headers),
221 link_with: libpldmutils,
222)
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500223
224deps = [
Manojkiran Eda3012b632024-08-22 11:09:01 +0530225 libpldm_dep,
226 libpldmutils,
227 nlohmann_json_dep,
228 phosphor_dbus_interfaces,
229 phosphor_logging_dep,
230 sdbusplus,
231 sdeventplus,
232 stdplus,
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500233]
234
Dung Cao72c8aa02023-11-22 02:31:41 +0000235oem_files = []
Patrick Williamsdc8b0822025-01-30 17:47:44 -0500236if get_option('oem-ampere').allowed()
Dung Cao72c8aa02023-11-22 02:31:41 +0000237 subdir('oem/ampere')
238endif
239
Patrick Williams87bfacd2023-11-29 06:44:36 -0600240if get_option('libpldmresponder').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530241 subdir('libpldmresponder')
242 deps += [libpldmresponder_dep]
Tom Joseph02b4ee42021-05-02 22:44:36 -0700243endif
244
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500245executable(
Manojkiran Eda3012b632024-08-22 11:09:01 +0530246 'pldmd',
247 'pldmd/pldmd.cpp',
248 'pldmd/dbus_impl_pdr.cpp',
249 'fw-update/activation.cpp',
250 'fw-update/inventory_manager.cpp',
251 'fw-update/package_parser.cpp',
252 'fw-update/device_updater.cpp',
253 'fw-update/watch.cpp',
254 'fw-update/update_manager.cpp',
Dung Caob6d39432024-06-05 03:46:47 +0000255 'platform-mc/dbus_impl_fru.cpp',
Manojkiran Eda3012b632024-08-22 11:09:01 +0530256 'platform-mc/terminus_manager.cpp',
257 'platform-mc/terminus.cpp',
258 'platform-mc/platform_manager.cpp',
259 'platform-mc/manager.cpp',
260 'platform-mc/sensor_manager.cpp',
261 'platform-mc/numeric_sensor.cpp',
Gilbert Chen77e6fe72024-08-06 09:23:30 +0000262 'platform-mc/event_manager.cpp',
Manojkiran Edadd1f28b2025-03-12 09:55:11 +0530263 'platform-mc/dbus_to_terminus_effecters.cpp',
Chau Lya743e382024-10-26 11:12:22 +0000264 oem_files,
Manojkiran Eda3012b632024-08-22 11:09:01 +0530265 'requester/mctp_endpoint_discovery.cpp',
266 implicit_include_directories: false,
267 dependencies: deps,
268 install: true,
269 install_dir: get_option('bindir'),
270)
Deepak Kodihalli3c275e12019-09-21 06:39:39 -0500271
Patrick Williams87bfacd2023-11-29 06:44:36 -0600272if get_option('systemd').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530273 systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williams42053e62025-07-09 11:27:14 -0400274 'systemd_system_unit_dir',
Manojkiran Eda3012b632024-08-22 11:09:01 +0530275 )
276 filesystem.copyfile(
277 'pldmd/service_files/pldmd.service',
278 'pldmd.service',
279 install: true,
280 install_dir: systemd_system_unit_dir,
281 )
Deepak Kodihalli6935cf62020-06-15 23:38:27 -0500282
Manojkiran Eda3012b632024-08-22 11:09:01 +0530283 if get_option('oem-ibm').allowed()
284 subdir('oem/ibm/service_files')
285 endif
Manojkiran Edafec5d592021-01-21 12:27:34 +0530286endif
287
Deepak Kodihallif7f5da92020-06-17 05:56:10 -0500288subdir('pldmtool')
George Liuab437e52020-01-19 17:12:19 +0800289
Deepak Kodihalli6e51e372020-06-19 03:49:07 -0500290subdir('configurations')
291
Patrick Williams87bfacd2023-11-29 06:44:36 -0600292if get_option('utilities').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530293 subdir('utilities')
Deepak Kodihalli9d494bb2019-11-05 01:28:43 -0600294endif
Lei YU31fc47e2020-02-27 11:41:45 +0800295
Patrick Williams87bfacd2023-11-29 06:44:36 -0600296if get_option('softoff').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530297 subdir('softoff')
George Liu4c1a3fd2020-03-10 08:25:21 +0800298endif
299
Patrick Williams87bfacd2023-11-29 06:44:36 -0600300if get_option('tests').allowed()
Manojkiran Eda3012b632024-08-22 11:09:01 +0530301 subdir('common/test')
302 subdir('fw-update/test')
303 subdir('host-bmc/test')
304 subdir('requester/test')
305 subdir('platform-mc/test')
306 subdir('test')
Tom Joseph53279882021-04-28 06:29:13 -0700307endif