blob: 6ec5dca5da9e8f225ac19bffc45f722e987d04e8 [file] [log] [blame]
Willy Tuc710b972021-08-11 16:33:43 -07001project(
George Liu1a2e1502022-07-08 12:20:19 +08002 'phosphor-host-ipmid',
Willy Tuc710b972021-08-11 16:33:43 -07003 'cpp',
4 version: '0.1',
Patrick Williams6fb31492023-07-12 11:15:11 -05005 meson_version: '>=1.1.1',
Willy Tuc710b972021-08-11 16:33:43 -07006 default_options: [
7 'werror=true',
8 'warning_level=3',
Patrick Williams6fb31492023-07-12 11:15:11 -05009 'cpp_std=c++23',
Konstantin Aladysheve11895f2024-04-04 12:35:33 +030010 'b_lto=true',
Willy Tuc710b972021-08-11 16:33:43 -070011 ])
12
13# Setting up config data
14conf_data = configuration_data()
15
16# The name of the callout's forward association
17conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout')
18conf_data.set_quoted('BOARD_SENSOR', get_option('board-sensor'))
19conf_data.set_quoted('SYSTEM_SENSOR', get_option('system-sensor'))
Lei YU127a24b2023-06-27 17:45:53 +080020conf_data.set('IPMI_SMS_ATN_ACK_TIMEOUT_SECS', get_option('ipmi-sms-atn-ack-timeout-secs'))
Willy Tuc710b972021-08-11 16:33:43 -070021
22# Soft Power off related.
23if not get_option('softoff').disabled()
24 conf_data.set_quoted('SOFTOFF_BUSNAME', get_option('softoff-busname'))
25 conf_data.set_quoted('SOFTOFF_OBJPATH', get_option('softoff-objpath'))
Willy Tuc710b972021-08-11 16:33:43 -070026 conf_data.set('IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS', get_option('ipmi-host-shutdown-complete-timeout-secs'))
27 conf_data.set_quoted('HOST_INBAND_REQUEST_DIR', get_option('host-inband-request-dir'))
28 conf_data.set_quoted('HOST_INBAND_REQUEST_FILE', get_option('host-inband-request-file'))
29endif
30
31conf_data.set_quoted('CONTROL_HOST_BUSNAME', get_option('control-host-busname'))
32conf_data.set_quoted('CONTROL_HOST_OBJ_MGR', get_option('control-host-obj-mgr'))
33conf_data.set_quoted('HOST_NAME', get_option('host-name'))
34conf_data.set_quoted('POWER_READING_SENSOR', get_option('power-reading-sensor'))
35conf_data.set_quoted('HOST_IPMI_LIB_PATH', get_option('host-ipmi-lib-path'))
Potin Lai5d214202023-01-16 18:11:49 +080036conf_data.set_quoted('FW_VER_REGEX', get_option('fw-ver-regex'))
Willy Tuc710b972021-08-11 16:33:43 -070037
Patrick Williams833b7062023-11-29 06:43:54 -060038if get_option('shortname-remove-suffix').allowed()
Alexander Hansenc2c26f92023-07-17 09:38:43 +020039 conf_data.set_quoted('SHORTNAME_REMOVE_SUFFIX', '1')
40endif
Patrick Williams833b7062023-11-29 06:43:54 -060041if get_option('shortname-replace-words').allowed()
Alexander Hansenc2c26f92023-07-17 09:38:43 +020042 conf_data.set_quoted('SHORTNAME_REPLACE_WORDS', '1')
43endif
Patrick Williams768730d2023-09-06 16:27:20 -050044if get_option('open-power').allowed()
45 conf_data.set_quoted('OPEN_POWER_SUPPORT', '1')
46endif
Alexander Hansenc2c26f92023-07-17 09:38:43 +020047
Potin Laic7c55922023-02-16 10:33:55 +080048matches_map = get_option('matches-map')
49conf_data.set('MAJOR_MATCH_INDEX', matches_map[0])
50conf_data.set('MINOR_MATCH_INDEX', matches_map[1])
51conf_data.set('AUX_0_MATCH_INDEX', matches_map[2])
52conf_data.set('AUX_1_MATCH_INDEX', matches_map[3])
53conf_data.set('AUX_2_MATCH_INDEX', matches_map[4])
54conf_data.set('AUX_3_MATCH_INDEX', matches_map[5])
55
Willy Tuc710b972021-08-11 16:33:43 -070056conf_h = configure_file(
57 output: 'config.h',
58 configuration: conf_data)
59
60root = meson.current_source_dir()
61root_inc = include_directories('.', 'include')
62
63# Project Arguments
64cpp = meson.get_compiler('cpp')
65add_project_arguments(
66 cpp.get_supported_arguments([
67 '-DBOOST_ERROR_CODE_HEADER_ONLY',
68 '-DBOOST_SYSTEM_NO_DEPRECATED',
69 '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
70 '-DBOOST_ASIO_DISABLE_THREADS',
71 '-DBOOST_ALL_NO_LIB',
72 ]),
73 language : 'cpp')
74
Willy Tub78184e2022-10-27 22:57:38 +000075if not get_option('get-dbus-active-software').disabled()
76 add_project_arguments(
77 cpp.get_supported_arguments([
78 '-DGET_DBUS_ACTIVE_SOFTWARE',
79 ]),
80 language : 'cpp')
81endif
82
Willy Tuc710b972021-08-11 16:33:43 -070083feature_map = {
84 'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT',
85 'i2c-whitelist-check' : '-DENABLE_I2C_WHITELIST_CHECK',
86 'update-functional-on-fail' : '-DUPDATE_FUNCTIONAL_ON_FAIL',
87 'dynamic-sensors' : '-DFEATURE_DYNAMIC_SENSORS',
88 'dynamic-sensors-write' : '-DFEATURE_DYNAMIC_SENSORS_WRITE',
Johnathan Mantey23a722c2023-05-12 08:18:54 -070089 'entity-manager-decorators' : '-DUSING_ENTITY_MANAGER_DECORATORS',
Willy Tuc710b972021-08-11 16:33:43 -070090 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS',
91 'sensors-cache' : '-DFEATURE_SENSORS_CACHE',
Thang Tran292c9172023-06-26 10:03:04 +070092 'dynamic-storages-only' : '-DFEATURE_DYNAMIC_STORAGES_ONLY',
Willy Tuc710b972021-08-11 16:33:43 -070093}
94
95foreach option_key, option_value : feature_map
Patrick Williams833b7062023-11-29 06:43:54 -060096 if(get_option(option_key).allowed())
Willy Tuc710b972021-08-11 16:33:43 -070097 summary(option_key,option_value, section : 'Enabled Features')
98 add_project_arguments(option_value,language:'cpp')
99 endif
100endforeach
101
102add_project_arguments(
103 cpp.get_supported_arguments([
Willy Tuc710b972021-08-11 16:33:43 -0700104 '-Wno-psabi',
105 '-Wno-missing-field-initializers',
106 '-Wno-pedantic',
107 '-Wno-non-virtual-dtor'
108 ]),
109 language: 'cpp')
110
111# Dependencies
Konstantin Aladysheve11895f2024-04-04 12:35:33 +0300112
113boost = dependency(
114 'boost',
115 modules: [
116 'coroutine',
117 ],
118 required : false,
119)
120
121if not boost.found()
122 cmake = import('cmake')
123 opt = cmake.subproject_options()
124 opt.add_cmake_defines({
125 'BOOST_INCLUDE_LIBRARIES': 'asio;bimap;callable_traits;context;coroutine;interprocess;multiprecision;process',
126 'CMAKE_POSITION_INDEPENDENT_CODE': true
127 })
128 boost_cmake = cmake.subproject('boost', required: true, options: opt)
129 boost_asio = boost_cmake.dependency('boost_asio').as_system()
130 boost_bimap = boost_cmake.dependency('boost_bimap').as_system()
131 boost_callable_traits = boost_cmake.dependency('boost_callable_traits').as_system()
132 boost_context = boost_cmake.dependency('boost_context').as_system()
133 boost_coroutine = boost_cmake.dependency('boost_coroutine').as_system()
134 boost_interprocess = boost_cmake.dependency('boost_interprocess').as_system()
135 boost_multiprecision = boost_cmake.dependency('boost_multiprecision').as_system()
136 boost_process = boost_cmake.dependency('boost_process').as_system()
137 boost = [boost_asio, boost_bimap, boost_callable_traits, boost_context, boost_coroutine, boost_interprocess, boost_multiprecision, boost_process]
138endif
139
Willy Tuc710b972021-08-11 16:33:43 -0700140phosphor_logging_dep = dependency('phosphor-logging')
141phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
142sdeventplus_dep = dependency('sdeventplus')
143systemd = dependency('systemd')
144crypto = dependency('libcrypto', version : '>=1.0.2g')
145pam = cpp.find_library('pam', required: true)
Patrick Williams422385d2022-06-16 11:47:40 -0500146sdbusplus_dep = dependency('sdbusplus')
William A. Kennington III7a3831b2023-06-21 01:10:49 -0700147stdplus_dep = dependency('stdplus')
Willy Tuc710b972021-08-11 16:33:43 -0700148
Patrick Williamse5fa6592023-12-07 14:47:50 -0600149nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500150
Patrick Williamsb69b2062022-07-25 09:40:49 -0500151generated_src = []
152
Willy Tuc710b972021-08-11 16:33:43 -0700153# Subfolders
154subdir('libipmid')
Willy Tuc710b972021-08-11 16:33:43 -0700155subdir('include')
156subdir('user_channel')
157subdir('scripts')
158
159if not get_option('softoff').disabled()
160 subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff')
161 subdir('softoff')
162endif
163
164# whitelist
165if not get_option('ipmi-whitelist').disabled()
166 generate_whitelist_script = files('generate_whitelist_create.sh')
167
168 whitelist_conf = get_option('whitelist-conf')
169 ipmiwhitelist = run_command( \
170 'bash', \
171 generate_whitelist_script, \
172 whitelist_conf)
173
174 whitelist_pre = declare_dependency(
175 include_directories: root_inc,
176 dependencies: [
Willy Tuc710b972021-08-11 16:33:43 -0700177 crypto,
178 ipmid_dep,
179 phosphor_dbus_interfaces_dep,
180 phosphor_logging_dep,
181 sdbusplus_dep,
182 ],
183 )
184
Willy Tuba9bbb62022-06-01 03:41:15 -0700185 whitelist_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700186 'whitelist',
187 'whitelist-filter.cpp',
188 'ipmiwhitelist.cpp',
189 implicit_include_directories: false,
190 dependencies: whitelist_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700191 version: meson.project_version(),
192 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700193 install: true,
194 install_dir: get_option('libdir') / 'ipmid-providers')
195endif
196
Willy Tuc710b972021-08-11 16:33:43 -0700197# libsysintfcmds
198sysintfcmds_pre = declare_dependency(
199 include_directories: root_inc,
200 dependencies: [
201 channellayer_dep,
202 crypto,
Vernon Mauerye4aa6542023-11-01 14:29:21 -0700203 nlohmann_json_dep,
Willy Tuc710b972021-08-11 16:33:43 -0700204 phosphor_dbus_interfaces_dep,
205 phosphor_logging_dep,
206 sdbusplus_dep,
207 ipmid_dep,
208 ])
209
Willy Tuba9bbb62022-06-01 03:41:15 -0700210sysintfcmds_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700211 'sysintfcmds',
212 'systemintfcmds.cpp',
213 'host-interface.cpp',
214 implicit_include_directories: false,
215 dependencies: sysintfcmds_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700216 version: meson.project_version(),
217 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700218 install: true,
219 install_dir: get_option('libdir') / 'ipmid-providers')
220
Willy Tuc710b972021-08-11 16:33:43 -0700221# ipmid
222ipmid_pre = [
223 sdbusplus_dep,
William A. Kennington III7a3831b2023-06-21 01:10:49 -0700224 stdplus_dep,
Willy Tuc710b972021-08-11 16:33:43 -0700225 phosphor_logging_dep,
226 phosphor_dbus_interfaces_dep,
Konstantin Aladysheve11895f2024-04-04 12:35:33 +0300227 boost,
Willy Tuc710b972021-08-11 16:33:43 -0700228 crypto,
229 ipmid_dep,
230 channellayer_dep,
Willy Tuc710b972021-08-11 16:33:43 -0700231]
232
Willy Tuc710b972021-08-11 16:33:43 -0700233transportoem_src = []
234if not get_option('transport-oem').disabled()
235 transportoem_src = ['transporthandler_oem.cpp']
236endif
237
Thang Tran292c9172023-06-26 10:03:04 +0700238storage_cmds_src = []
239if get_option('dynamic-sensors').disabled() and not get_option('dynamic-storages-only').disabled()
240 storage_cmds_src = ['dbus-sdr/storagecommands.cpp', 'dbus-sdr/sdrutils.cpp']
241endif
242
Patrick Williams768730d2023-09-06 16:27:20 -0500243openpower_cmds_src = []
244if get_option('open-power').allowed()
245 openpower_cmds_src = [ 'storageaddsel.cpp' ]
246endif
247
Willy Tuc710b972021-08-11 16:33:43 -0700248libipmi20_src = [
249 'app/channel.cpp',
250 'app/watchdog.cpp',
251 'app/watchdog_service.cpp',
252 'apphandler.cpp',
253 'sys_info_param.cpp',
254 'sensorhandler.cpp',
255 'storagehandler.cpp',
256 'chassishandler.cpp',
257 'dcmihandler.cpp',
258 'ipmisensor.cpp',
Willy Tuc710b972021-08-11 16:33:43 -0700259 'transporthandler.cpp',
260 'globalhandler.cpp',
261 'groupext.cpp',
262 'selutility.cpp',
263 'ipmi_fru_info_area.cpp',
264 'read_fru_data.cpp',
265 'sensordatahandler.cpp',
Jian Zhangff1b4bf2022-06-28 16:08:26 +0800266 'user_channel/channelcommands.cpp',
Willy Tuc710b972021-08-11 16:33:43 -0700267 generated_src,
268 transportoem_src,
Thang Tran292c9172023-06-26 10:03:04 +0700269 storage_cmds_src,
Patrick Williams768730d2023-09-06 16:27:20 -0500270 openpower_cmds_src,
Willy Tuc710b972021-08-11 16:33:43 -0700271 conf_h,
272]
273
274ipmi20_lib = library(
275 'ipmi20',
276 libipmi20_src,
Vernon Mauery9cf08382023-04-28 14:00:11 -0700277 dependencies: [ipmid_pre, nlohmann_json_dep],
Willy Tuc710b972021-08-11 16:33:43 -0700278 include_directories: root_inc,
279 install: true,
280 install_dir: get_option('libdir') / 'ipmid-providers',
Willy Tuba9bbb62022-06-01 03:41:15 -0700281 version: meson.project_version(),
Willy Tuc710b972021-08-11 16:33:43 -0700282 override_options: ['b_lundef=false'])
283
284libipmi20_dep = declare_dependency(
285 dependencies: ipmid_pre,
286 include_directories: root_inc,
287 link_with: ipmi20_lib)
288
289# ipmid binary
290executable(
291 'ipmid',
292 'ipmid-new.cpp',
293 'host-cmd-manager.cpp',
294 'settings.cpp',
295 implicit_include_directories: false,
296 dependencies: [libipmi20_dep],
297 include_directories: root_inc,
298 export_dynamic: true,
299 install: true,
300 install_dir: get_option('bindir'))
301
302# Dynamic Sensor Stack
303subdir('dbus-sdr')
304
Willy Tu0679e4b2022-11-11 14:34:33 -0800305if not get_option('dynamic-sensors').disabled() or not get_option('tests').disabled()
Willy Tu6eab4202022-06-09 11:34:52 -0700306 library(
307 'dynamiccmds',
308 dbus_sdr_src,
309 implicit_include_directories: false,
310 dependencies: dbus_sdr_pre,
311 version: meson.project_version(),
312 override_options: ['b_lundef=false'],
313 install: true,
314 install_dir: get_option('libdir') / 'ipmid-providers')
315endif
Willy Tuba9bbb62022-06-01 03:41:15 -0700316
Willy Tuc710b972021-08-11 16:33:43 -0700317if not get_option('tests').disabled()
318 subdir('test')
319endif
320
321install_subdir(
322 'user_channel',
323 install_dir: get_option('includedir'),
324 strip_directory: false,
325 exclude_files: '*.cpp')