blob: 0fbadc375c959b84f5ed585de678d4f5fbcc2a8d [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
55feature_map = {
56 'boot-flag-safe-mode-support': '-DENABLE_BOOT_FLAG_SAFE_MODE_SUPPORT',
57 'i2c-whitelist-check' : '-DENABLE_I2C_WHITELIST_CHECK',
58 'update-functional-on-fail' : '-DUPDATE_FUNCTIONAL_ON_FAIL',
59 'dynamic-sensors' : '-DFEATURE_DYNAMIC_SENSORS',
60 'dynamic-sensors-write' : '-DFEATURE_DYNAMIC_SENSORS_WRITE',
61 'hybrid-sensors' : '-DFEATURE_HYBRID_SENSORS',
62 'sensors-cache' : '-DFEATURE_SENSORS_CACHE',
63 'sel-logger-clears-sel' : '-DFEATURE_SEL_LOGGER_CLEARS_SEL',
64}
65
66foreach option_key, option_value : feature_map
67 if(get_option(option_key).enabled())
68 summary(option_key,option_value, section : 'Enabled Features')
69 add_project_arguments(option_value,language:'cpp')
70 endif
71endforeach
72
73add_project_arguments(
74 cpp.get_supported_arguments([
75 '-flto',
76 '-Wno-psabi',
77 '-Wno-missing-field-initializers',
78 '-Wno-pedantic',
79 '-Wno-non-virtual-dtor'
80 ]),
81 language: 'cpp')
82
83# Dependencies
84phosphor_logging_dep = dependency('phosphor-logging')
85phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
86sdeventplus_dep = dependency('sdeventplus')
87systemd = dependency('systemd')
88crypto = dependency('libcrypto', version : '>=1.0.2g')
89pam = cpp.find_library('pam', required: true)
Patrick Williams6b4cf432022-06-16 11:31:57 -050090mapper = dependency('libmapper')
Willy Tuc710b972021-08-11 16:33:43 -070091boost_coroutine = cpp.find_library('boost_coroutine', required: true)
Patrick Williams422385d2022-06-16 11:47:40 -050092sdbusplus_dep = dependency('sdbusplus')
Willy Tuc710b972021-08-11 16:33:43 -070093
Patrick Williamsc8fc7282022-06-16 11:58:53 -050094if cpp.has_header_symbol(
95 'nlohmann/json.hpp',
96 'nlohmann::json::string_t',
97 required:false)
98 nlohmann_json_dep = declare_dependency()
99else
100 nlohmann_json_dep = dependency('nlohmann-json')
101endif
102
Patrick Williamsb69b2062022-07-25 09:40:49 -0500103generated_src = []
104
Willy Tuc710b972021-08-11 16:33:43 -0700105# Subfolders
106subdir('libipmid')
Willy Tuc710b972021-08-11 16:33:43 -0700107subdir('include')
108subdir('user_channel')
109subdir('scripts')
110
111if not get_option('softoff').disabled()
112 subdir('xyz/openbmc_project/Ipmi/Internal/SoftPowerOff')
113 subdir('softoff')
114endif
115
116# whitelist
117if not get_option('ipmi-whitelist').disabled()
118 generate_whitelist_script = files('generate_whitelist_create.sh')
119
120 whitelist_conf = get_option('whitelist-conf')
121 ipmiwhitelist = run_command( \
122 'bash', \
123 generate_whitelist_script, \
124 whitelist_conf)
125
126 whitelist_pre = declare_dependency(
127 include_directories: root_inc,
128 dependencies: [
Willy Tuc710b972021-08-11 16:33:43 -0700129 crypto,
130 ipmid_dep,
131 phosphor_dbus_interfaces_dep,
132 phosphor_logging_dep,
133 sdbusplus_dep,
134 ],
135 )
136
Willy Tuba9bbb62022-06-01 03:41:15 -0700137 whitelist_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700138 'whitelist',
139 'whitelist-filter.cpp',
140 'ipmiwhitelist.cpp',
141 implicit_include_directories: false,
142 dependencies: whitelist_pre,
Willy Tuba9bbb62022-06-01 03:41:15 -0700143 version: meson.project_version(),
144 override_options: ['b_lundef=false'],
Willy Tuc710b972021-08-11 16:33:43 -0700145 install: true,
146 install_dir: get_option('libdir') / 'ipmid-providers')
147endif
148
Willy Tuc710b972021-08-11 16:33:43 -0700149# libsysintfcmds
150sysintfcmds_pre = declare_dependency(
151 include_directories: root_inc,
152 dependencies: [
153 channellayer_dep,
154 crypto,
155 mapper,
156 phosphor_dbus_interfaces_dep,
157 phosphor_logging_dep,
158 sdbusplus_dep,
159 ipmid_dep,
160 ])
161
Willy Tuba9bbb62022-06-01 03:41:15 -0700162sysintfcmds_lib = library(
Willy Tuc710b972021-08-11 16:33:43 -0700163 'sysintfcmds',
164 'systemintfcmds.cpp',
165 'host-interface.cpp',
166 implicit_include_directories: false,
167 dependencies: sysintfcmds_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')
172
Willy Tuc710b972021-08-11 16:33:43 -0700173# ipmid
174ipmid_pre = [
175 sdbusplus_dep,
176 phosphor_logging_dep,
177 phosphor_dbus_interfaces_dep,
178 boost_coroutine,
179 crypto,
180 ipmid_dep,
181 channellayer_dep,
182 mapper,
Willy Tuc710b972021-08-11 16:33:43 -0700183]
184
Willy Tuc710b972021-08-11 16:33:43 -0700185transportoem_src = []
186if not get_option('transport-oem').disabled()
187 transportoem_src = ['transporthandler_oem.cpp']
188endif
189
190entity_map_json_lib = static_library(
191 'entity_map_json',
192 'entity_map_json.cpp',
193 include_directories: root_inc,
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500194 dependencies: [ipmid_dep, nlohmann_json_dep],
Willy Tuc710b972021-08-11 16:33:43 -0700195 implicit_include_directories: false)
196
197entity_map_json_dep = declare_dependency(link_with: entity_map_json_lib)
198
199libipmi20_src = [
200 'app/channel.cpp',
201 'app/watchdog.cpp',
202 'app/watchdog_service.cpp',
203 'apphandler.cpp',
204 'sys_info_param.cpp',
205 'sensorhandler.cpp',
206 'storagehandler.cpp',
207 'chassishandler.cpp',
208 'dcmihandler.cpp',
209 'ipmisensor.cpp',
210 'storageaddsel.cpp',
211 'transporthandler.cpp',
212 'globalhandler.cpp',
213 'groupext.cpp',
214 'selutility.cpp',
215 'ipmi_fru_info_area.cpp',
216 'read_fru_data.cpp',
217 'sensordatahandler.cpp',
Jian Zhangff1b4bf2022-06-28 16:08:26 +0800218 'user_channel/channelcommands.cpp',
Willy Tuc710b972021-08-11 16:33:43 -0700219 generated_src,
220 transportoem_src,
221 conf_h,
222]
223
224ipmi20_lib = library(
225 'ipmi20',
226 libipmi20_src,
Patrick Williamsc8fc7282022-06-16 11:58:53 -0500227 dependencies: [ipmid_pre, entity_map_json_dep, nlohmann_json_dep],
Willy Tuc710b972021-08-11 16:33:43 -0700228 include_directories: root_inc,
229 install: true,
230 install_dir: get_option('libdir') / 'ipmid-providers',
Willy Tuba9bbb62022-06-01 03:41:15 -0700231 version: meson.project_version(),
Willy Tuc710b972021-08-11 16:33:43 -0700232 override_options: ['b_lundef=false'])
233
234libipmi20_dep = declare_dependency(
235 dependencies: ipmid_pre,
236 include_directories: root_inc,
237 link_with: ipmi20_lib)
238
239# ipmid binary
240executable(
241 'ipmid',
242 'ipmid-new.cpp',
243 'host-cmd-manager.cpp',
244 'settings.cpp',
245 implicit_include_directories: false,
246 dependencies: [libipmi20_dep],
247 include_directories: root_inc,
248 export_dynamic: true,
249 install: true,
250 install_dir: get_option('bindir'))
251
252# Dynamic Sensor Stack
253subdir('dbus-sdr')
254
Willy Tu6eab4202022-06-09 11:34:52 -0700255if not get_option('dynamic-sensors').disabled()
256 library(
257 'dynamiccmds',
258 dbus_sdr_src,
259 implicit_include_directories: false,
260 dependencies: dbus_sdr_pre,
261 version: meson.project_version(),
262 override_options: ['b_lundef=false'],
263 install: true,
264 install_dir: get_option('libdir') / 'ipmid-providers')
265endif
Willy Tuba9bbb62022-06-01 03:41:15 -0700266
Willy Tuc710b972021-08-11 16:33:43 -0700267if not get_option('tests').disabled()
268 subdir('test')
269endif
270
271install_subdir(
272 'user_channel',
273 install_dir: get_option('includedir'),
274 strip_directory: false,
275 exclude_files: '*.cpp')