blob: c043d7987b7dc11f22c95e2c307d3bb2589d8125 [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',
Willy Tuc710b972021-08-11 16:33:43 -070010 ])
11
12# Setting up config data
13conf_data = configuration_data()
14
15# The name of the callout's forward association
16conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout')
17conf_data.set_quoted('BOARD_SENSOR', get_option('board-sensor'))
18conf_data.set_quoted('SYSTEM_SENSOR', get_option('system-sensor'))
Lei YU127a24b2023-06-27 17:45:53 +080019conf_data.set('IPMI_SMS_ATN_ACK_TIMEOUT_SECS', get_option('ipmi-sms-atn-ack-timeout-secs'))
Willy Tuc710b972021-08-11 16:33:43 -070020
21# Soft Power off related.
22if not get_option('softoff').disabled()
23 conf_data.set_quoted('SOFTOFF_BUSNAME', get_option('softoff-busname'))
24 conf_data.set_quoted('SOFTOFF_OBJPATH', get_option('softoff-objpath'))
Willy Tuc710b972021-08-11 16:33:43 -070025 conf_data.set('IPMI_HOST_SHUTDOWN_COMPLETE_TIMEOUT_SECS', get_option('ipmi-host-shutdown-complete-timeout-secs'))
26 conf_data.set_quoted('HOST_INBAND_REQUEST_DIR', get_option('host-inband-request-dir'))
27 conf_data.set_quoted('HOST_INBAND_REQUEST_FILE', get_option('host-inband-request-file'))
28endif
29
30conf_data.set_quoted('CONTROL_HOST_BUSNAME', get_option('control-host-busname'))
31conf_data.set_quoted('CONTROL_HOST_OBJ_MGR', get_option('control-host-obj-mgr'))
32conf_data.set_quoted('HOST_NAME', get_option('host-name'))
33conf_data.set_quoted('POWER_READING_SENSOR', get_option('power-reading-sensor'))
34conf_data.set_quoted('HOST_IPMI_LIB_PATH', get_option('host-ipmi-lib-path'))
Potin Lai5d214202023-01-16 18:11:49 +080035conf_data.set_quoted('FW_VER_REGEX', get_option('fw-ver-regex'))
Willy Tuc710b972021-08-11 16:33:43 -070036
Alexander Hansenc2c26f92023-07-17 09:38:43 +020037if get_option('shortname-remove-suffix').enabled()
38 conf_data.set_quoted('SHORTNAME_REMOVE_SUFFIX', '1')
39endif
40if get_option('shortname-replace-words').enabled()
41 conf_data.set_quoted('SHORTNAME_REPLACE_WORDS', '1')
42endif
Patrick Williams768730d2023-09-06 16:27:20 -050043if get_option('open-power').allowed()
44 conf_data.set_quoted('OPEN_POWER_SUPPORT', '1')
45endif
Alexander Hansenc2c26f92023-07-17 09:38:43 +020046
Potin Laic7c55922023-02-16 10:33:55 +080047matches_map = get_option('matches-map')
48conf_data.set('MAJOR_MATCH_INDEX', matches_map[0])
49conf_data.set('MINOR_MATCH_INDEX', matches_map[1])
50conf_data.set('AUX_0_MATCH_INDEX', matches_map[2])
51conf_data.set('AUX_1_MATCH_INDEX', matches_map[3])
52conf_data.set('AUX_2_MATCH_INDEX', matches_map[4])
53conf_data.set('AUX_3_MATCH_INDEX', matches_map[5])
54
Willy Tuc710b972021-08-11 16:33:43 -070055conf_h = configure_file(
56 output: 'config.h',
57 configuration: conf_data)
58
59root = meson.current_source_dir()
60root_inc = include_directories('.', 'include')
61
62# Project Arguments
63cpp = meson.get_compiler('cpp')
64add_project_arguments(
65 cpp.get_supported_arguments([
66 '-DBOOST_ERROR_CODE_HEADER_ONLY',
67 '-DBOOST_SYSTEM_NO_DEPRECATED',
68 '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
69 '-DBOOST_ASIO_DISABLE_THREADS',
70 '-DBOOST_ALL_NO_LIB',
71 ]),
72 language : 'cpp')
73
Willy Tub78184e2022-10-27 22:57:38 +000074if not get_option('get-dbus-active-software').disabled()
75 add_project_arguments(
76 cpp.get_supported_arguments([
77 '-DGET_DBUS_ACTIVE_SOFTWARE',
78 ]),
79 language : 'cpp')
80endif
81
Willy Tuc710b972021-08-11 16:33:43 -070082feature_map = {
83 'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT',
84 'i2c-whitelist-check' : '-DENABLE_I2C_WHITELIST_CHECK',
85 'update-functional-on-fail' : '-DUPDATE_FUNCTIONAL_ON_FAIL',
86 'dynamic-sensors' : '-DFEATURE_DYNAMIC_SENSORS',
87 'dynamic-sensors-write' : '-DFEATURE_DYNAMIC_SENSORS_WRITE',
Johnathan Mantey23a722c2023-05-12 08:18:54 -070088 'entity-manager-decorators' : '-DUSING_ENTITY_MANAGER_DECORATORS',
Willy Tuc710b972021-08-11 16:33:43 -070089 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS',
90 'sensors-cache' : '-DFEATURE_SENSORS_CACHE',
91 'sel-logger-clears-sel' : '-DFEATURE_SEL_LOGGER_CLEARS_SEL',
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
96 if(get_option(option_key).enabled())
97 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
112phosphor_logging_dep = dependency('phosphor-logging')
113phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
114sdeventplus_dep = dependency('sdeventplus')
115systemd = dependency('systemd')
116crypto = dependency('libcrypto', version : '>=1.0.2g')
117pam = cpp.find_library('pam', required: true)
Patrick Williams6b4cf432022-06-16 11:31:57 -0500118mapper = dependency('libmapper')
Willy Tuc710b972021-08-11 16:33:43 -0700119boost_coroutine = cpp.find_library('boost_coroutine', required: true)
Patrick Williams422385d2022-06-16 11:47:40 -0500120sdbusplus_dep = dependency('sdbusplus')
Willy Tuc710b972021-08-11 16:33:43 -0700121
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500122if cpp.has_header_symbol(
123 'nlohmann/json.hpp',
124 'nlohmann::json::string_t',
125 required:false)
126 nlohmann_json_dep = declare_dependency()
127else
128 nlohmann_json_dep = dependency('nlohmann-json')
129endif
130
Patrick Williamsb69b2062022-07-25 09:40:49 -0500131generated_src = []
132
Willy Tuc710b972021-08-11 16:33:43 -0700133# Subfolders
134subdir('libipmid')
Willy Tuc710b972021-08-11 16:33:43 -0700135subdir('include')
136subdir('user_channel')
137subdir('scripts')
138
139if not get_option('softoff').disabled()
140 subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff')
141 subdir('softoff')
142endif
143
144# whitelist
145if not get_option('ipmi-whitelist').disabled()
146 generate_whitelist_script = files('generate_whitelist_create.sh')
147
148 whitelist_conf = get_option('whitelist-conf')
149 ipmiwhitelist = run_command( \
150 'bash', \
151 generate_whitelist_script, \
152 whitelist_conf)
153
154 whitelist_pre = declare_dependency(
155 include_directories: root_inc,
156 dependencies: [
Willy Tuc710b972021-08-11 16:33:43 -0700157 crypto,
158 ipmid_dep,
159 phosphor_dbus_interfaces_dep,
160 phosphor_logging_dep,
161 sdbusplus_dep,
162 ],
163 )
164
Willy Tuba9bbb62022-06-01 03:41:15 -0700165 whitelist_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700166 'whitelist',
167 'whitelist-filter.cpp',
168 'ipmiwhitelist.cpp',
169 implicit_include_directories: false,
170 dependencies: whitelist_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700171 version: meson.project_version(),
172 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700173 install: true,
174 install_dir: get_option('libdir') / 'ipmid-providers')
175endif
176
Willy Tuc710b972021-08-11 16:33:43 -0700177# libsysintfcmds
178sysintfcmds_pre = declare_dependency(
179 include_directories: root_inc,
180 dependencies: [
181 channellayer_dep,
182 crypto,
183 mapper,
184 phosphor_dbus_interfaces_dep,
185 phosphor_logging_dep,
186 sdbusplus_dep,
187 ipmid_dep,
188 ])
189
Willy Tuba9bbb62022-06-01 03:41:15 -0700190sysintfcmds_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700191 'sysintfcmds',
192 'systemintfcmds.cpp',
193 'host-interface.cpp',
194 implicit_include_directories: false,
195 dependencies: sysintfcmds_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700196 version: meson.project_version(),
197 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700198 install: true,
199 install_dir: get_option('libdir') / 'ipmid-providers')
200
Willy Tuc710b972021-08-11 16:33:43 -0700201# ipmid
202ipmid_pre = [
203 sdbusplus_dep,
204 phosphor_logging_dep,
205 phosphor_dbus_interfaces_dep,
206 boost_coroutine,
207 crypto,
208 ipmid_dep,
209 channellayer_dep,
210 mapper,
Willy Tuc710b972021-08-11 16:33:43 -0700211]
212
Willy Tuc710b972021-08-11 16:33:43 -0700213transportoem_src = []
214if not get_option('transport-oem').disabled()
215 transportoem_src = ['transporthandler_oem.cpp']
216endif
217
Thang Tran292c9172023-06-26 10:03:04 +0700218storage_cmds_src = []
219if get_option('dynamic-sensors').disabled() and not get_option('dynamic-storages-only').disabled()
220 storage_cmds_src = ['dbus-sdr/storagecommands.cpp', 'dbus-sdr/sdrutils.cpp']
221endif
222
Patrick Williams768730d2023-09-06 16:27:20 -0500223openpower_cmds_src = []
224if get_option('open-power').allowed()
225 openpower_cmds_src = [ 'storageaddsel.cpp' ]
226endif
227
Willy Tuc710b972021-08-11 16:33:43 -0700228libipmi20_src = [
229 'app/channel.cpp',
230 'app/watchdog.cpp',
231 'app/watchdog_service.cpp',
232 'apphandler.cpp',
233 'sys_info_param.cpp',
234 'sensorhandler.cpp',
235 'storagehandler.cpp',
236 'chassishandler.cpp',
237 'dcmihandler.cpp',
238 'ipmisensor.cpp',
Willy Tuc710b972021-08-11 16:33:43 -0700239 'transporthandler.cpp',
240 'globalhandler.cpp',
241 'groupext.cpp',
242 'selutility.cpp',
243 'ipmi_fru_info_area.cpp',
244 'read_fru_data.cpp',
245 'sensordatahandler.cpp',
Jian Zhangff1b4bf2022-06-28 16:08:26 +0800246 'user_channel/channelcommands.cpp',
Willy Tuc710b972021-08-11 16:33:43 -0700247 generated_src,
248 transportoem_src,
Thang Tran292c9172023-06-26 10:03:04 +0700249 storage_cmds_src,
Patrick Williams768730d2023-09-06 16:27:20 -0500250 openpower_cmds_src,
Willy Tuc710b972021-08-11 16:33:43 -0700251 conf_h,
252]
253
254ipmi20_lib = library(
255 'ipmi20',
256 libipmi20_src,
Vernon Mauery9cf08382023-04-28 14:00:11 -0700257 dependencies: [ipmid_pre, nlohmann_json_dep],
Willy Tuc710b972021-08-11 16:33:43 -0700258 include_directories: root_inc,
259 install: true,
260 install_dir: get_option('libdir') / 'ipmid-providers',
Willy Tuba9bbb62022-06-01 03:41:15 -0700261 version: meson.project_version(),
Willy Tuc710b972021-08-11 16:33:43 -0700262 override_options: ['b_lundef=false'])
263
264libipmi20_dep = declare_dependency(
265 dependencies: ipmid_pre,
266 include_directories: root_inc,
267 link_with: ipmi20_lib)
268
269# ipmid binary
270executable(
271 'ipmid',
272 'ipmid-new.cpp',
273 'host-cmd-manager.cpp',
274 'settings.cpp',
275 implicit_include_directories: false,
276 dependencies: [libipmi20_dep],
277 include_directories: root_inc,
278 export_dynamic: true,
279 install: true,
280 install_dir: get_option('bindir'))
281
282# Dynamic Sensor Stack
283subdir('dbus-sdr')
284
Willy Tu0679e4b2022-11-11 14:34:33 -0800285if not get_option('dynamic-sensors').disabled() or not get_option('tests').disabled()
Willy Tu6eab4202022-06-09 11:34:52 -0700286 library(
287 'dynamiccmds',
288 dbus_sdr_src,
289 implicit_include_directories: false,
290 dependencies: dbus_sdr_pre,
291 version: meson.project_version(),
292 override_options: ['b_lundef=false'],
293 install: true,
294 install_dir: get_option('libdir') / 'ipmid-providers')
295endif
Willy Tuba9bbb62022-06-01 03:41:15 -0700296
Willy Tuc710b972021-08-11 16:33:43 -0700297if not get_option('tests').disabled()
298 subdir('test')
299endif
300
301install_subdir(
302 'user_channel',
303 install_dir: get_option('includedir'),
304 strip_directory: false,
305 exclude_files: '*.cpp')