blob: c3eed2e768b30f9ba2255e59489ddab7fe2c3b06 [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',
5 meson_version: '>=0.57.0',
6 default_options: [
7 'werror=true',
8 'warning_level=3',
9 'cpp_std=c++20',
10 ])
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'))
19
20# Soft Power off related.
21if not get_option('softoff').disabled()
22 conf_data.set_quoted('SOFTOFF_BUSNAME', get_option('softoff-busname'))
23 conf_data.set_quoted('SOFTOFF_OBJPATH', get_option('softoff-objpath'))
24 conf_data.set('IPMI_SMS_ATN_ACK_TIMEOUT_SECS', get_option('ipmi-sms-atn-ack-timeout-secs'))
25 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'))
35
36conf_h = configure_file(
37 output: 'config.h',
38 configuration: conf_data)
39
40root = meson.current_source_dir()
41root_inc = include_directories('.', 'include')
42
43# Project Arguments
44cpp = meson.get_compiler('cpp')
45add_project_arguments(
46 cpp.get_supported_arguments([
47 '-DBOOST_ERROR_CODE_HEADER_ONLY',
48 '-DBOOST_SYSTEM_NO_DEPRECATED',
49 '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
50 '-DBOOST_ASIO_DISABLE_THREADS',
51 '-DBOOST_ALL_NO_LIB',
52 ]),
53 language : 'cpp')
54
Willy Tub78184e2022-10-27 22:57:38 +000055if not get_option('get-dbus-active-software').disabled()
56 add_project_arguments(
57 cpp.get_supported_arguments([
58 '-DGET_DBUS_ACTIVE_SOFTWARE',
59 ]),
60 language : 'cpp')
61endif
62
Willy Tuc710b972021-08-11 16:33:43 -070063feature_map = {
64 'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT',
65 'i2c-whitelist-check' : '-DENABLE_I2C_WHITELIST_CHECK',
66 'update-functional-on-fail' : '-DUPDATE_FUNCTIONAL_ON_FAIL',
67 'dynamic-sensors' : '-DFEATURE_DYNAMIC_SENSORS',
68 'dynamic-sensors-write' : '-DFEATURE_DYNAMIC_SENSORS_WRITE',
69 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS',
70 'sensors-cache' : '-DFEATURE_SENSORS_CACHE',
71 'sel-logger-clears-sel' : '-DFEATURE_SEL_LOGGER_CLEARS_SEL',
72}
73
74foreach option_key, option_value : feature_map
75 if(get_option(option_key).enabled())
76 summary(option_key,option_value, section : 'Enabled Features')
77 add_project_arguments(option_value,language:'cpp')
78 endif
79endforeach
80
81add_project_arguments(
82 cpp.get_supported_arguments([
83 '-flto',
84 '-Wno-psabi',
85 '-Wno-missing-field-initializers',
86 '-Wno-pedantic',
87 '-Wno-non-virtual-dtor'
88 ]),
89 language: 'cpp')
90
91# Dependencies
92phosphor_logging_dep = dependency('phosphor-logging')
93phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
94sdeventplus_dep = dependency('sdeventplus')
95systemd = dependency('systemd')
96crypto = dependency('libcrypto', version : '>=1.0.2g')
97pam = cpp.find_library('pam', required: true)
Patrick Williams6b4cf432022-06-16 11:31:57 -050098mapper = dependency('libmapper')
Willy Tuc710b972021-08-11 16:33:43 -070099boost_coroutine = cpp.find_library('boost_coroutine', required: true)
Patrick Williams422385d2022-06-16 11:47:40 -0500100sdbusplus_dep = dependency('sdbusplus')
Willy Tuc710b972021-08-11 16:33:43 -0700101
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500102if cpp.has_header_symbol(
103 'nlohmann/json.hpp',
104 'nlohmann::json::string_t',
105 required:false)
106 nlohmann_json_dep = declare_dependency()
107else
108 nlohmann_json_dep = dependency('nlohmann-json')
109endif
110
Patrick Williamsb69b2062022-07-25 09:40:49 -0500111generated_src = []
112
Willy Tuc710b972021-08-11 16:33:43 -0700113# Subfolders
114subdir('libipmid')
Willy Tuc710b972021-08-11 16:33:43 -0700115subdir('include')
116subdir('user_channel')
117subdir('scripts')
118
119if not get_option('softoff').disabled()
120 subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff')
121 subdir('softoff')
122endif
123
124# whitelist
125if not get_option('ipmi-whitelist').disabled()
126 generate_whitelist_script = files('generate_whitelist_create.sh')
127
128 whitelist_conf = get_option('whitelist-conf')
129 ipmiwhitelist = run_command( \
130 'bash', \
131 generate_whitelist_script, \
132 whitelist_conf)
133
134 whitelist_pre = declare_dependency(
135 include_directories: root_inc,
136 dependencies: [
Willy Tuc710b972021-08-11 16:33:43 -0700137 crypto,
138 ipmid_dep,
139 phosphor_dbus_interfaces_dep,
140 phosphor_logging_dep,
141 sdbusplus_dep,
142 ],
143 )
144
Willy Tuba9bbb62022-06-01 03:41:15 -0700145 whitelist_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700146 'whitelist',
147 'whitelist-filter.cpp',
148 'ipmiwhitelist.cpp',
149 implicit_include_directories: false,
150 dependencies: whitelist_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700151 version: meson.project_version(),
152 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700153 install: true,
154 install_dir: get_option('libdir') / 'ipmid-providers')
155endif
156
Willy Tuc710b972021-08-11 16:33:43 -0700157# libsysintfcmds
158sysintfcmds_pre = declare_dependency(
159 include_directories: root_inc,
160 dependencies: [
161 channellayer_dep,
162 crypto,
163 mapper,
164 phosphor_dbus_interfaces_dep,
165 phosphor_logging_dep,
166 sdbusplus_dep,
167 ipmid_dep,
168 ])
169
Willy Tuba9bbb62022-06-01 03:41:15 -0700170sysintfcmds_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700171 'sysintfcmds',
172 'systemintfcmds.cpp',
173 'host-interface.cpp',
174 implicit_include_directories: false,
175 dependencies: sysintfcmds_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700176 version: meson.project_version(),
177 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700178 install: true,
179 install_dir: get_option('libdir') / 'ipmid-providers')
180
Willy Tuc710b972021-08-11 16:33:43 -0700181# ipmid
182ipmid_pre = [
183 sdbusplus_dep,
184 phosphor_logging_dep,
185 phosphor_dbus_interfaces_dep,
186 boost_coroutine,
187 crypto,
188 ipmid_dep,
189 channellayer_dep,
190 mapper,
Willy Tuc710b972021-08-11 16:33:43 -0700191]
192
Willy Tuc710b972021-08-11 16:33:43 -0700193transportoem_src = []
194if not get_option('transport-oem').disabled()
195 transportoem_src = ['transporthandler_oem.cpp']
196endif
197
198entity_map_json_lib = static_library(
199 'entity_map_json',
200 'entity_map_json.cpp',
201 include_directories: root_inc,
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500202 dependencies: [ipmid_dep, nlohmann_json_dep],
Willy Tuc710b972021-08-11 16:33:43 -0700203 implicit_include_directories: false)
204
205entity_map_json_dep = declare_dependency(link_with: entity_map_json_lib)
206
207libipmi20_src = [
208 'app/channel.cpp',
209 'app/watchdog.cpp',
210 'app/watchdog_service.cpp',
211 'apphandler.cpp',
212 'sys_info_param.cpp',
213 'sensorhandler.cpp',
214 'storagehandler.cpp',
215 'chassishandler.cpp',
216 'dcmihandler.cpp',
217 'ipmisensor.cpp',
218 'storageaddsel.cpp',
219 'transporthandler.cpp',
220 'globalhandler.cpp',
221 'groupext.cpp',
222 'selutility.cpp',
223 'ipmi_fru_info_area.cpp',
224 'read_fru_data.cpp',
225 'sensordatahandler.cpp',
Jian Zhangff1b4bf2022-06-28 16:08:26 +0800226 'user_channel/channelcommands.cpp',
Willy Tuc710b972021-08-11 16:33:43 -0700227 generated_src,
228 transportoem_src,
229 conf_h,
230]
231
232ipmi20_lib = library(
233 'ipmi20',
234 libipmi20_src,
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500235 dependencies: [ipmid_pre, entity_map_json_dep, nlohmann_json_dep],
Willy Tuc710b972021-08-11 16:33:43 -0700236 include_directories: root_inc,
237 install: true,
238 install_dir: get_option('libdir') / 'ipmid-providers',
Willy Tuba9bbb62022-06-01 03:41:15 -0700239 version: meson.project_version(),
Willy Tuc710b972021-08-11 16:33:43 -0700240 override_options: ['b_lundef=false'])
241
242libipmi20_dep = declare_dependency(
243 dependencies: ipmid_pre,
244 include_directories: root_inc,
245 link_with: ipmi20_lib)
246
247# ipmid binary
248executable(
249 'ipmid',
250 'ipmid-new.cpp',
251 'host-cmd-manager.cpp',
252 'settings.cpp',
253 implicit_include_directories: false,
254 dependencies: [libipmi20_dep],
255 include_directories: root_inc,
256 export_dynamic: true,
257 install: true,
258 install_dir: get_option('bindir'))
259
260# Dynamic Sensor Stack
261subdir('dbus-sdr')
262
Willy Tu6eab4202022-06-09 11:34:52 -0700263if not get_option('dynamic-sensors').disabled()
264 library(
265 'dynamiccmds',
266 dbus_sdr_src,
267 implicit_include_directories: false,
268 dependencies: dbus_sdr_pre,
269 version: meson.project_version(),
270 override_options: ['b_lundef=false'],
271 install: true,
272 install_dir: get_option('libdir') / 'ipmid-providers')
273endif
Willy Tuba9bbb62022-06-01 03:41:15 -0700274
Willy Tuc710b972021-08-11 16:33:43 -0700275if not get_option('tests').disabled()
276 subdir('test')
277endif
278
279install_subdir(
280 'user_channel',
281 install_dir: get_option('includedir'),
282 strip_directory: false,
283 exclude_files: '*.cpp')