blob: 4a4d01e78e4ffed3a696b04bdaa692e0beb061ca [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
43
Potin Laic7c55922023-02-16 10:33:55 +080044matches_map = get_option('matches-map')
45conf_data.set('MAJOR_MATCH_INDEX', matches_map[0])
46conf_data.set('MINOR_MATCH_INDEX', matches_map[1])
47conf_data.set('AUX_0_MATCH_INDEX', matches_map[2])
48conf_data.set('AUX_1_MATCH_INDEX', matches_map[3])
49conf_data.set('AUX_2_MATCH_INDEX', matches_map[4])
50conf_data.set('AUX_3_MATCH_INDEX', matches_map[5])
51
Willy Tuc710b972021-08-11 16:33:43 -070052conf_h = configure_file(
53 output: 'config.h',
54 configuration: conf_data)
55
56root = meson.current_source_dir()
57root_inc = include_directories('.', 'include')
58
59# Project Arguments
60cpp = meson.get_compiler('cpp')
61add_project_arguments(
62 cpp.get_supported_arguments([
63 '-DBOOST_ERROR_CODE_HEADER_ONLY',
64 '-DBOOST_SYSTEM_NO_DEPRECATED',
65 '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
66 '-DBOOST_ASIO_DISABLE_THREADS',
67 '-DBOOST_ALL_NO_LIB',
68 ]),
69 language : 'cpp')
70
Willy Tub78184e2022-10-27 22:57:38 +000071if not get_option('get-dbus-active-software').disabled()
72 add_project_arguments(
73 cpp.get_supported_arguments([
74 '-DGET_DBUS_ACTIVE_SOFTWARE',
75 ]),
76 language : 'cpp')
77endif
78
Willy Tuc710b972021-08-11 16:33:43 -070079feature_map = {
80 'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT',
81 'i2c-whitelist-check' : '-DENABLE_I2C_WHITELIST_CHECK',
82 'update-functional-on-fail' : '-DUPDATE_FUNCTIONAL_ON_FAIL',
83 'dynamic-sensors' : '-DFEATURE_DYNAMIC_SENSORS',
84 'dynamic-sensors-write' : '-DFEATURE_DYNAMIC_SENSORS_WRITE',
Johnathan Mantey23a722c2023-05-12 08:18:54 -070085 'entity-manager-decorators' : '-DUSING_ENTITY_MANAGER_DECORATORS',
Willy Tuc710b972021-08-11 16:33:43 -070086 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS',
87 'sensors-cache' : '-DFEATURE_SENSORS_CACHE',
88 'sel-logger-clears-sel' : '-DFEATURE_SEL_LOGGER_CLEARS_SEL',
Thang Tran292c9172023-06-26 10:03:04 +070089 'dynamic-storages-only' : '-DFEATURE_DYNAMIC_STORAGES_ONLY',
Willy Tuc710b972021-08-11 16:33:43 -070090}
91
92foreach option_key, option_value : feature_map
93 if(get_option(option_key).enabled())
94 summary(option_key,option_value, section : 'Enabled Features')
95 add_project_arguments(option_value,language:'cpp')
96 endif
97endforeach
98
99add_project_arguments(
100 cpp.get_supported_arguments([
Willy Tuc710b972021-08-11 16:33:43 -0700101 '-Wno-psabi',
102 '-Wno-missing-field-initializers',
103 '-Wno-pedantic',
104 '-Wno-non-virtual-dtor'
105 ]),
106 language: 'cpp')
107
108# Dependencies
109phosphor_logging_dep = dependency('phosphor-logging')
110phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
111sdeventplus_dep = dependency('sdeventplus')
112systemd = dependency('systemd')
113crypto = dependency('libcrypto', version : '>=1.0.2g')
114pam = cpp.find_library('pam', required: true)
Patrick Williams6b4cf432022-06-16 11:31:57 -0500115mapper = dependency('libmapper')
Willy Tuc710b972021-08-11 16:33:43 -0700116boost_coroutine = cpp.find_library('boost_coroutine', required: true)
Patrick Williams422385d2022-06-16 11:47:40 -0500117sdbusplus_dep = dependency('sdbusplus')
Willy Tuc710b972021-08-11 16:33:43 -0700118
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500119if cpp.has_header_symbol(
120 'nlohmann/json.hpp',
121 'nlohmann::json::string_t',
122 required:false)
123 nlohmann_json_dep = declare_dependency()
124else
125 nlohmann_json_dep = dependency('nlohmann-json')
126endif
127
Patrick Williamsb69b2062022-07-25 09:40:49 -0500128generated_src = []
129
Willy Tuc710b972021-08-11 16:33:43 -0700130# Subfolders
131subdir('libipmid')
Willy Tuc710b972021-08-11 16:33:43 -0700132subdir('include')
133subdir('user_channel')
134subdir('scripts')
135
136if not get_option('softoff').disabled()
137 subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff')
138 subdir('softoff')
139endif
140
141# whitelist
142if not get_option('ipmi-whitelist').disabled()
143 generate_whitelist_script = files('generate_whitelist_create.sh')
144
145 whitelist_conf = get_option('whitelist-conf')
146 ipmiwhitelist = run_command( \
147 'bash', \
148 generate_whitelist_script, \
149 whitelist_conf)
150
151 whitelist_pre = declare_dependency(
152 include_directories: root_inc,
153 dependencies: [
Willy Tuc710b972021-08-11 16:33:43 -0700154 crypto,
155 ipmid_dep,
156 phosphor_dbus_interfaces_dep,
157 phosphor_logging_dep,
158 sdbusplus_dep,
159 ],
160 )
161
Willy Tuba9bbb62022-06-01 03:41:15 -0700162 whitelist_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700163 'whitelist',
164 'whitelist-filter.cpp',
165 'ipmiwhitelist.cpp',
166 implicit_include_directories: false,
167 dependencies: whitelist_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700168 version: meson.project_version(),
169 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700170 install: true,
171 install_dir: get_option('libdir') / 'ipmid-providers')
172endif
173
Willy Tuc710b972021-08-11 16:33:43 -0700174# libsysintfcmds
175sysintfcmds_pre = declare_dependency(
176 include_directories: root_inc,
177 dependencies: [
178 channellayer_dep,
179 crypto,
180 mapper,
181 phosphor_dbus_interfaces_dep,
182 phosphor_logging_dep,
183 sdbusplus_dep,
184 ipmid_dep,
185 ])
186
Willy Tuba9bbb62022-06-01 03:41:15 -0700187sysintfcmds_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700188 'sysintfcmds',
189 'systemintfcmds.cpp',
190 'host-interface.cpp',
191 implicit_include_directories: false,
192 dependencies: sysintfcmds_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700193 version: meson.project_version(),
194 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700195 install: true,
196 install_dir: get_option('libdir') / 'ipmid-providers')
197
Willy Tuc710b972021-08-11 16:33:43 -0700198# ipmid
199ipmid_pre = [
200 sdbusplus_dep,
201 phosphor_logging_dep,
202 phosphor_dbus_interfaces_dep,
203 boost_coroutine,
204 crypto,
205 ipmid_dep,
206 channellayer_dep,
207 mapper,
Willy Tuc710b972021-08-11 16:33:43 -0700208]
209
Willy Tuc710b972021-08-11 16:33:43 -0700210transportoem_src = []
211if not get_option('transport-oem').disabled()
212 transportoem_src = ['transporthandler_oem.cpp']
213endif
214
Thang Tran292c9172023-06-26 10:03:04 +0700215storage_cmds_src = []
216if get_option('dynamic-sensors').disabled() and not get_option('dynamic-storages-only').disabled()
217 storage_cmds_src = ['dbus-sdr/storagecommands.cpp', 'dbus-sdr/sdrutils.cpp']
218endif
219
Willy Tuc710b972021-08-11 16:33:43 -0700220libipmi20_src = [
221 'app/channel.cpp',
222 'app/watchdog.cpp',
223 'app/watchdog_service.cpp',
224 'apphandler.cpp',
225 'sys_info_param.cpp',
226 'sensorhandler.cpp',
227 'storagehandler.cpp',
228 'chassishandler.cpp',
229 'dcmihandler.cpp',
230 'ipmisensor.cpp',
231 'storageaddsel.cpp',
232 'transporthandler.cpp',
233 'globalhandler.cpp',
234 'groupext.cpp',
235 'selutility.cpp',
236 'ipmi_fru_info_area.cpp',
237 'read_fru_data.cpp',
238 'sensordatahandler.cpp',
Jian Zhangff1b4bf2022-06-28 16:08:26 +0800239 'user_channel/channelcommands.cpp',
Willy Tuc710b972021-08-11 16:33:43 -0700240 generated_src,
241 transportoem_src,
Thang Tran292c9172023-06-26 10:03:04 +0700242 storage_cmds_src,
Willy Tuc710b972021-08-11 16:33:43 -0700243 conf_h,
244]
245
246ipmi20_lib = library(
247 'ipmi20',
248 libipmi20_src,
Vernon Mauery9cf08382023-04-28 14:00:11 -0700249 dependencies: [ipmid_pre, nlohmann_json_dep],
Willy Tuc710b972021-08-11 16:33:43 -0700250 include_directories: root_inc,
251 install: true,
252 install_dir: get_option('libdir') / 'ipmid-providers',
Willy Tuba9bbb62022-06-01 03:41:15 -0700253 version: meson.project_version(),
Willy Tuc710b972021-08-11 16:33:43 -0700254 override_options: ['b_lundef=false'])
255
256libipmi20_dep = declare_dependency(
257 dependencies: ipmid_pre,
258 include_directories: root_inc,
259 link_with: ipmi20_lib)
260
261# ipmid binary
262executable(
263 'ipmid',
264 'ipmid-new.cpp',
265 'host-cmd-manager.cpp',
266 'settings.cpp',
267 implicit_include_directories: false,
268 dependencies: [libipmi20_dep],
269 include_directories: root_inc,
270 export_dynamic: true,
271 install: true,
272 install_dir: get_option('bindir'))
273
274# Dynamic Sensor Stack
275subdir('dbus-sdr')
276
Willy Tu0679e4b2022-11-11 14:34:33 -0800277if not get_option('dynamic-sensors').disabled() or not get_option('tests').disabled()
Willy Tu6eab4202022-06-09 11:34:52 -0700278 library(
279 'dynamiccmds',
280 dbus_sdr_src,
281 implicit_include_directories: false,
282 dependencies: dbus_sdr_pre,
283 version: meson.project_version(),
284 override_options: ['b_lundef=false'],
285 install: true,
286 install_dir: get_option('libdir') / 'ipmid-providers')
287endif
Willy Tuba9bbb62022-06-01 03:41:15 -0700288
Willy Tuc710b972021-08-11 16:33:43 -0700289if not get_option('tests').disabled()
290 subdir('test')
291endif
292
293install_subdir(
294 'user_channel',
295 install_dir: get_option('includedir'),
296 strip_directory: false,
297 exclude_files: '*.cpp')